@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.
@@ -14571,113 +14571,113 @@ var require_pkg_src = __commonJS({
14571
14571
  deployedAt: 1784569687492,
14572
14572
  size: 4140,
14573
14573
  hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
14574
- validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
14574
+ validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
14575
14575
  pkp: {
14576
14576
  publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
14577
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14577
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14578
14578
  }
14579
14579
  },
14580
14580
  btcTransactionSigner: {
14581
- cid: "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf",
14581
+ cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
14582
14582
  authorizedCidHex: cidToHex(
14583
- "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf"
14583
+ "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
14584
14584
  ),
14585
14585
  name: "Btc Transaction Signer",
14586
14586
  description: "Production Btc Transaction Signer",
14587
14587
  version: "1.1.1",
14588
14588
  deployed: true,
14589
- deployedAt: 1787923905597,
14590
- size: 70646,
14591
- hash: "37c3bb72a660c8275d92e1b73f9482742d86b64789480b9246304c0ca1bab47a"
14589
+ deployedAt: 1790246185256,
14590
+ size: 73313,
14591
+ hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
14592
14592
  },
14593
14593
  ucdMintValidator: {
14594
- cid: "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc",
14594
+ cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
14595
14595
  authorizedCidHex: cidToHex(
14596
- "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc"
14596
+ "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
14597
14597
  ),
14598
14598
  name: "Ucd Mint Validator",
14599
14599
  description: "Production Ucd Mint Validator",
14600
- version: "1.2.1",
14600
+ version: "1.3.0",
14601
14601
  deployed: true,
14602
- deployedAt: 1787923919527,
14603
- size: 86197,
14604
- hash: "c2d80939746cc37f65ef2f63c6a3215b929214a63f10c78144e1f5c98320dabf",
14605
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14602
+ deployedAt: 1790246219868,
14603
+ size: 90022,
14604
+ hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
14605
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14606
14606
  pkp: {
14607
14607
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
14608
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14608
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14609
14609
  }
14610
14610
  },
14611
14611
  processPaymentValidator: {
14612
- cid: "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF",
14612
+ cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
14613
14613
  authorizedCidHex: cidToHex(
14614
- "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF"
14614
+ "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
14615
14615
  ),
14616
14616
  name: "Process Payment Validator",
14617
14617
  description: "Production Process Payment Validator",
14618
14618
  version: "1.2.1",
14619
14619
  deployed: true,
14620
- deployedAt: 1787923987153,
14621
- size: 82217,
14622
- hash: "13defa19614215ab3b1fe88955d69e530d13a09475396af932fe0e213637da2f",
14623
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14620
+ deployedAt: 1790246225795,
14621
+ size: 85107,
14622
+ hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
14623
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14624
14624
  pkp: {
14625
14625
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
14626
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14626
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14627
14627
  }
14628
14628
  },
14629
14629
  extendPositionValidator: {
14630
- cid: "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m",
14630
+ cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
14631
14631
  authorizedCidHex: cidToHex(
14632
- "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m"
14632
+ "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
14633
14633
  ),
14634
14634
  name: "Extend Position Validator",
14635
14635
  description: "Production Extend Position Validator",
14636
14636
  version: "1.2.1",
14637
14637
  deployed: true,
14638
- deployedAt: 1787923999294,
14639
- size: 79975,
14640
- hash: "31c1aaf883ef22f37681ddb0a4a949be5c05304b6aef178989475a2da935ef9a",
14641
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14638
+ deployedAt: 1790246231975,
14639
+ size: 82853,
14640
+ hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
14641
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14642
14642
  pkp: {
14643
14643
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
14644
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14644
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14645
14645
  }
14646
14646
  },
14647
14647
  btcWithdrawal: {
14648
- cid: "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY",
14648
+ cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
14649
14649
  authorizedCidHex: cidToHex(
14650
- "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY"
14650
+ "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
14651
14651
  ),
14652
14652
  name: "Btc Withdrawal",
14653
14653
  description: "Production Btc Withdrawal",
14654
14654
  version: "1.2.7",
14655
14655
  deployed: true,
14656
- deployedAt: 1787924017769,
14657
- size: 100069,
14658
- hash: "4f8e27414e4da235e63d6ae1325c63f3d2fb956464515a21aa007a99935f0f13",
14659
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14656
+ deployedAt: 1790246239599,
14657
+ size: 101228,
14658
+ hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
14659
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14660
14660
  pkp: {
14661
14661
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
14662
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14662
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14663
14663
  }
14664
14664
  },
14665
14665
  liquidationValidator: {
14666
- cid: "Qme6aGADhiszkQbZL977E6nmBacd2PEB7K9Hs8puVrscNx",
14666
+ cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
14667
14667
  authorizedCidHex: cidToHex(
14668
- "Qme6aGADhiszkQbZL977E6nmBacd2PEB7K9Hs8puVrscNx"
14668
+ "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
14669
14669
  ),
14670
14670
  name: "Liquidation Validator",
14671
14671
  description: "Production Liquidation Validator",
14672
14672
  version: "1.2.1",
14673
14673
  deployed: true,
14674
- deployedAt: 1785173262533,
14675
- size: 66846,
14676
- hash: "b35ee7706d733d625faa4dbe37f73c8e20f0c1befa897cd7875e827de52003de",
14677
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14674
+ deployedAt: 1790246247904,
14675
+ size: 70308,
14676
+ hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
14677
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14678
14678
  pkp: {
14679
14679
  publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
14680
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14680
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14681
14681
  }
14682
14682
  },
14683
14683
  priceOracle: {
@@ -14692,28 +14692,28 @@ var require_pkg_src = __commonJS({
14692
14692
  deployedAt: 1781116663270,
14693
14693
  size: 8695,
14694
14694
  hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
14695
- validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
14695
+ validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
14696
14696
  pkp: {
14697
14697
  publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
14698
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14698
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14699
14699
  }
14700
14700
  },
14701
14701
  loanVaultBtcBalance: {
14702
- cid: "QmaeQoHYvcMYobNbu9hQavGDudi8AXoW9tg3YHrvy1g2A4",
14702
+ cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
14703
14703
  authorizedCidHex: cidToHex(
14704
- "QmaeQoHYvcMYobNbu9hQavGDudi8AXoW9tg3YHrvy1g2A4"
14704
+ "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
14705
14705
  ),
14706
14706
  name: "Loan Vault Btc Balance",
14707
14707
  description: "Production Loan Vault Btc Balance",
14708
14708
  version: "1.2.1",
14709
14709
  deployed: true,
14710
- deployedAt: 1785173271802,
14711
- size: 56800,
14712
- hash: "a059133214e6ba0a73d655a15600c4b33e361fb340c98f8eecaf8ab7b95aaf83",
14713
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14710
+ deployedAt: 1790179961079,
14711
+ size: 60046,
14712
+ hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
14713
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14714
14714
  pkp: {
14715
14715
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
14716
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14716
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14717
14717
  }
14718
14718
  },
14719
14719
  // btc-address-balance (Option B) — address-only signed total balance via
@@ -14723,21 +14723,21 @@ var require_pkg_src = __commonJS({
14723
14723
  // Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
14724
14724
  // on each target chain (the action decrypts registry slots). No OAR entry.
14725
14725
  btcAddressBalance: {
14726
- cid: "QmUXUtU9r1HhQVYgkXPN5s19SKXanhn4pMsCtFEP3GK4Kj",
14726
+ cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
14727
14727
  authorizedCidHex: cidToHex(
14728
- "QmUXUtU9r1HhQVYgkXPN5s19SKXanhn4pMsCtFEP3GK4Kj"
14728
+ "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
14729
14729
  ),
14730
14730
  name: "Btc Address Balance",
14731
14731
  description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
14732
14732
  version: "0.2.1",
14733
14733
  deployed: true,
14734
- deployedAt: 1785173280221,
14735
- size: 27309,
14736
- hash: "f0d08938713d9d89a56a3a386cacbc2b57afd5ad367ea82d827d40e1bfc70989",
14737
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14734
+ deployedAt: 1790179971315,
14735
+ size: 30295,
14736
+ hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
14737
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14738
14738
  pkp: {
14739
14739
  publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
14740
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14740
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14741
14741
  }
14742
14742
  },
14743
14743
  alwaysSigner: {
@@ -14767,48 +14767,48 @@ var require_pkg_src = __commonJS({
14767
14767
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
14768
14768
  },
14769
14769
  agentModuleExecutor: {
14770
- cid: "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf",
14770
+ cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
14771
14771
  authorizedCidHex: cidToHex(
14772
- "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf"
14772
+ "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
14773
14773
  ),
14774
14774
  name: "Agent Module Executor",
14775
14775
  description: "Production Agent Module Executor",
14776
14776
  version: "1.1.1",
14777
14777
  deployed: true,
14778
- deployedAt: 1787924032013,
14779
- size: 13878,
14780
- hash: "a7f0204700912e26e5a354bee13a1242a2baa218643b3bb22d28481f67f9baf4"
14778
+ deployedAt: 1790179978959,
14779
+ size: 14688,
14780
+ hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
14781
14781
  },
14782
14782
  staleSpendRecoveryValidator: {
14783
- cid: "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8",
14783
+ cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
14784
14784
  authorizedCidHex: cidToHex(
14785
- "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8"
14785
+ "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
14786
14786
  ),
14787
14787
  name: "Stale Spend Recovery Validator",
14788
14788
  description: "Production Stale Spend Recovery Validator",
14789
14789
  version: "1.1.2",
14790
14790
  deployed: true,
14791
- deployedAt: 1787924048772,
14792
- size: 41424,
14793
- hash: "3c5f028d2bef4344768462993616d45e30d9d44ef126e04d6eb579821d57d99c",
14794
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14791
+ deployedAt: 1790246256280,
14792
+ size: 48143,
14793
+ hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
14794
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14795
14795
  pkp: {
14796
14796
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
14797
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14797
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14798
14798
  }
14799
14799
  },
14800
14800
  btcUtxoInvalidator: {
14801
- cid: "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf",
14801
+ cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
14802
14802
  authorizedCidHex: cidToHex(
14803
- "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf"
14803
+ "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
14804
14804
  ),
14805
14805
  name: "Btc Utxo Invalidator",
14806
14806
  description: "Production Btc Utxo Invalidator",
14807
14807
  version: "1.0.0",
14808
14808
  deployed: true,
14809
- deployedAt: 1787924133241,
14810
- size: 66026,
14811
- hash: "603bc50920d7f1dee77086f2c518d9e2922ab3858a419d3fbea8221ea3a6d9e9"
14809
+ deployedAt: 1790246264563,
14810
+ size: 69219,
14811
+ hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
14812
14812
  }
14813
14813
  };
14814
14814
  function getDeploymentsForNetwork(network) {
@@ -15552,7 +15552,7 @@ ${errorReport}`);
15552
15552
  }
15553
15553
  init_debug_logger();
15554
15554
  init_session_signature_cache();
15555
- var import_ethers53 = require("ethers");
15555
+ var import_ethers54 = require("ethers");
15556
15556
  var EXPIRED_LOAN_MIN_LIQUIDATION_THRESHOLD_BPS = 11e3;
15557
15557
  var GRACE_PERIOD_DAYS = 30;
15558
15558
  var SATOSHIS_PER_BITCOIN = 100000000n;
@@ -15574,7 +15574,10 @@ ${errorReport}`);
15574
15574
  BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
15575
15575
  BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
15576
15576
  LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
15577
- PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
15577
+ PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
15578
+ TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
15579
+ UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
15580
+ LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
15578
15581
  },
15579
15582
  11155111: {
15580
15583
  PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
@@ -15582,7 +15585,10 @@ ${errorReport}`);
15582
15585
  BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
15583
15586
  BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
15584
15587
  LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
15585
- PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
15588
+ PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
15589
+ TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
15590
+ UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
15591
+ LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
15586
15592
  }
15587
15593
  };
15588
15594
  function getPinnedContractAddresses(chainId) {
@@ -15768,10 +15774,10 @@ ${errorReport}`);
15768
15774
  };
15769
15775
  }
15770
15776
  const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
15771
- const collateralRatioBps = Number(ratioBigInt);
15777
+ const collateralRatioBps2 = Number(ratioBigInt);
15772
15778
  return {
15773
15779
  collateralValueUsd,
15774
- collateralRatioBps
15780
+ collateralRatioBps: collateralRatioBps2
15775
15781
  };
15776
15782
  }
15777
15783
  function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
@@ -16616,6 +16622,17 @@ ${auth.clientId}`;
16616
16622
  );
16617
16623
  }
16618
16624
  }
16625
+ var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
16626
+ var BitcoinTipUnreadableError = class extends Error {
16627
+ constructor(message) {
16628
+ super(message);
16629
+ this.isBitcoinTipUnreadable = true;
16630
+ this.name = "BitcoinTipUnreadableError";
16631
+ }
16632
+ };
16633
+ function isBitcoinTipUnreadableError(error) {
16634
+ return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
16635
+ }
16619
16636
  var BitcoinDataProvider = class {
16620
16637
  constructor(config) {
16621
16638
  this.config = config;
@@ -17067,27 +17084,12 @@ ${auth.clientId}`;
17067
17084
  if (!data.status.confirmed || !data.status.block_height) {
17068
17085
  return { txid: data.txid ?? txid, confirmations: 0 };
17069
17086
  }
17070
- try {
17071
- const tipResp = await fetch(
17072
- `${this.config.providerUrl}/blocks/tip/height`,
17073
- { signal: controller.signal, headers: await this.withAuth() }
17074
- );
17075
- if (!tipResp.ok) {
17076
- return { txid: data.txid ?? txid, confirmations: 1 };
17077
- }
17078
- const tipBody = (await tipResp.text()).trim();
17079
- const tipHeight = Number.parseInt(tipBody, 10);
17080
- if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
17081
- return { txid: data.txid ?? txid, confirmations: 1 };
17082
- }
17083
- const depth = tipHeight - data.status.block_height + 1;
17084
- return {
17085
- txid: data.txid ?? txid,
17086
- confirmations: depth > 0 ? depth : 0
17087
- };
17088
- } catch {
17089
- return { txid: data.txid ?? txid, confirmations: 1 };
17090
- }
17087
+ const tipHeight = await this.fetchTipHeight(controller.signal);
17088
+ const depth = tipHeight - data.status.block_height + 1;
17089
+ return {
17090
+ txid: data.txid ?? txid,
17091
+ confirmations: depth > 0 ? depth : 0
17092
+ };
17091
17093
  }
17092
17094
  return null;
17093
17095
  } catch (error) {
@@ -17095,12 +17097,55 @@ ${auth.clientId}`;
17095
17097
  if (isAbortError(error)) {
17096
17098
  throw new Error(`Request timeout after ${this.timeout}ms`);
17097
17099
  }
17100
+ if (isBitcoinTipUnreadableError(error)) {
17101
+ throw error;
17102
+ }
17098
17103
  if (getUnknownErrorMessage(error).includes("404")) {
17099
17104
  return null;
17100
17105
  }
17101
17106
  throw error;
17102
17107
  }
17103
17108
  }
17109
+ /**
17110
+ * Current chain tip height from THIS provider — or throw.
17111
+ *
17112
+ * Every exit is a throw naming the provider and the precise failure, because
17113
+ * the only alternative is inventing a confirmation depth (see the call site).
17114
+ * The single `try` exists solely to attach that name to a transport-level
17115
+ * rejection (DNS, TLS, connection reset, abort); it re-throws the cause
17116
+ * verbatim inside the message and never substitutes a value — authorized for
17117
+ * this case by the Batch 2 plan, §C2.
17118
+ *
17119
+ * @param signal - The caller's AbortSignal, so this read shares the same
17120
+ * timeout budget as the transaction fetch it serves.
17121
+ */
17122
+ async fetchTipHeight(signal) {
17123
+ const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
17124
+ let tipResp;
17125
+ try {
17126
+ tipResp = await fetch(endpoint, {
17127
+ signal,
17128
+ headers: await this.withAuth()
17129
+ });
17130
+ } catch (error) {
17131
+ throw new BitcoinTipUnreadableError(
17132
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
17133
+ );
17134
+ }
17135
+ if (!tipResp.ok) {
17136
+ throw new BitcoinTipUnreadableError(
17137
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
17138
+ );
17139
+ }
17140
+ const tipBody = (await tipResp.text()).trim();
17141
+ const tipHeight = Number.parseInt(tipBody, 10);
17142
+ if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
17143
+ throw new BitcoinTipUnreadableError(
17144
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
17145
+ );
17146
+ }
17147
+ return tipHeight;
17148
+ }
17104
17149
  /**
17105
17150
  * Get outputs (vouts) of a Bitcoin transaction
17106
17151
  *
@@ -17735,10 +17780,13 @@ ${auth.clientId}`;
17735
17780
  * only on unanimity. The confirmed-balance consensus the validators run
17736
17781
  * covers `chain_stats` only, so without this the primary provider alone
17737
17782
  * could fabricate an unconfirmed UTXO plus a self-consistent parent proof
17738
- * and inflate the signed balance. Any provider failure or verdict
17739
- * disagreement THROWS (fail-closed) — exclusion on a suppressed proof
17740
- * would deflate the balance and open a wrongful-liquidation window, so
17741
- * neither direction may proceed without agreement.
17783
+ * and inflate the signed balance. Any verdict disagreement THROWS
17784
+ * (fail-closed) — exclusion on a suppressed proof would deflate the balance
17785
+ * and open a wrongful-liquidation window, so neither direction may proceed
17786
+ * without agreement. A provider that cannot state the chain tip — and only
17787
+ * that failure — is dropped from the quorum rather than aborting the read (it
17788
+ * never counts as agreeing), and falling below `minConsensusProviders`
17789
+ * survivors throws — see `verifyParentIsSelfSpendConsensus`.
17742
17790
  *
17743
17791
  * The same per-provider `/tx` fetch also returns the parent's outputs, and
17744
17792
  * every provider must corroborate each claimed UTXO (index, vault address,
@@ -17833,10 +17881,26 @@ ${auth.clientId}`;
17833
17881
  }
17834
17882
  /**
17835
17883
  * Run the self-spend proof against every configured provider and require
17836
- * unanimity. Fail-closed: a provider request failure or a verdict
17837
- * disagreement throws and aborts the balance calculation — see
17884
+ * unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
17885
+ * a verdict mismatch throws and aborts the balance calculation — see
17838
17886
  * classifySelfChange for why exclusion is not a safe fallback here.
17839
17887
  *
17888
+ * Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
17889
+ * provider that could not state the chain tip (`BitcoinTipUnreadableError`).
17890
+ * It is ABSENT from the quorum — never counted as agreeing, never allowed to
17891
+ * decide the verdict — and the policy floor, not "at least one", decides when
17892
+ * that absence is fatal: below `minConsensusProviders` surviving readings
17893
+ * there is no cross-check left to trust, and the read fails loudly naming
17894
+ * every provider that dropped out.
17895
+ *
17896
+ * Why only that class. `getTransaction` now throws on an unreadable tip
17897
+ * instead of fabricating `confirmations: 1`; without this carve-out one flaky
17898
+ * `/blocks/tip/height` endpoint would take every balance and spend path down
17899
+ * with it. Every OTHER failure remains fatal, as before: a provider that
17900
+ * answers "I have never seen that transaction" is making a claim about the
17901
+ * chain rather than suffering an outage, and that shape is precisely the
17902
+ * fabricated-UTXO signature the fail-closed rule exists to catch.
17903
+ *
17840
17904
  * When the parent IS a unanimous self-spend, every provider's view of the
17841
17905
  * parent's OUTPUTS must additionally corroborate the primary's claimed
17842
17906
  * UTXOs (index exists, pays the vault, exact value). Without this, a
@@ -17861,32 +17925,52 @@ ${auth.clientId}`;
17861
17925
  )
17862
17926
  )
17863
17927
  );
17864
- const failures = settled.map((r, i) => ({ r, name: providerName(i) })).filter(
17865
- (x) => x.r.status === "rejected"
17866
- ).map(
17867
- ({ r, name }) => `${name} \u2192 ${r.reason?.message ?? String(r.reason)}`
17868
- );
17928
+ const answered = [];
17929
+ const absences = [];
17930
+ const failures = [];
17931
+ settled.forEach((result, i) => {
17932
+ if (result.status === "fulfilled") {
17933
+ answered.push({ index: i, evaluation: result.value });
17934
+ return;
17935
+ }
17936
+ const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
17937
+ if (isBitcoinTipUnreadableError(result.reason)) {
17938
+ absences.push(described);
17939
+ return;
17940
+ }
17941
+ failures.push(described);
17942
+ });
17869
17943
  if (failures.length > 0) {
17870
17944
  throw new Error(
17871
17945
  `Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
17872
17946
  );
17873
17947
  }
17874
- const evaluations = settled.map(
17875
- (r) => r.value
17876
- );
17877
- const votes = evaluations.map((e) => e.selfSpend);
17878
- const disagreements = votes.map((vote, i) => ({ vote, name: providerName(i) })).filter((x) => x.vote !== votes[0]).map(
17879
- (x) => `${providerName(0)}=${votes[0]} vs ${x.name}=${x.vote}`
17948
+ const floor = Math.max(1, this.minConsensusProviders);
17949
+ if (answered.length < floor) {
17950
+ throw new Error(
17951
+ `Self-change classification for tx ${parentTxid}: only ${answered.length}/${providerConfigs.length} provider(s) could state a confirmation depth, below this chain's floor of ${floor}. Unreadable tips: ${absences.join("; ")}`
17952
+ );
17953
+ }
17954
+ if (absences.length > 0) {
17955
+ litDebugLog(
17956
+ `[VaultBalance] self-change: tx ${parentTxid} classified on a reduced quorum \u2014 ${answered.length}/${providerConfigs.length} provider(s) answered (floor ${floor}); dropped for an unreadable chain tip: ${absences.join("; ")}`
17957
+ );
17958
+ }
17959
+ const first = answered[0];
17960
+ const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
17961
+ (a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
17880
17962
  );
17881
17963
  if (disagreements.length > 0) {
17882
17964
  throw new Error(
17883
17965
  `Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
17884
17966
  );
17885
17967
  }
17886
- if (!votes[0]) {
17968
+ if (!first.evaluation.selfSpend) {
17887
17969
  return false;
17888
17970
  }
17889
- const outputMismatches = evaluations.map((e, i) => e.outputMismatch ? `${providerName(i)} \u2192 ${e.outputMismatch}` : null).filter((m) => m !== null);
17971
+ const outputMismatches = answered.map(
17972
+ (a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
17973
+ ).filter((m) => m !== null);
17890
17974
  if (outputMismatches.length > 0) {
17891
17975
  throw new Error(
17892
17976
  `Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
@@ -18129,16 +18213,6 @@ ${auth.clientId}`;
18129
18213
  minConfirmations
18130
18214
  );
18131
18215
  const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
18132
- for (const spend of authorizedSpends) {
18133
- const utxoStillExists = utxoSet.utxos.some(
18134
- (utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
18135
- );
18136
- if (utxoStillExists) {
18137
- throw new Error(
18138
- `Authorized UTXO ${spend.txid}:${spend.vout} not yet spent. Transaction was authorized in smart contract but not signed and broadcasted to Bitcoin network. Complete the transaction by signing and broadcasting it.`
18139
- );
18140
- }
18141
- }
18142
18216
  const authorizedBalance = authorizedSpends.reduce(
18143
18217
  (sum, spend) => sum + spend.satoshis,
18144
18218
  0n
@@ -18434,7 +18508,13 @@ ${auth.clientId}`;
18434
18508
  allowDevSinglePriceProvider: false,
18435
18509
  minBitcoinBalanceConfirmations: 1,
18436
18510
  minBitcoinSpendConfirmations: 1,
18437
- minConsensusProviders: 1
18511
+ // 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
18512
+ // "by design", so the consensus floor was documented as a mainnet-only
18513
+ // guarantee. The registry now holds two, and leaving the floor at 1 meant
18514
+ // Sepolia could never exercise the multi-provider agreement the stale-spend
18515
+ // and balance paths rely on — the one environment where that logic is
18516
+ // supposed to be proved before mainnet.
18517
+ minConsensusProviders: 2
18438
18518
  },
18439
18519
  [
18440
18520
  "ethereum"
@@ -18468,12 +18548,12 @@ ${auth.clientId}`;
18468
18548
  }
18469
18549
  async function executeVaultSnapshot(params) {
18470
18550
  global.ethers = {
18471
- ...import_ethers53.ethers,
18551
+ ...import_ethers54.ethers,
18472
18552
  providers: {
18473
- StaticJsonRpcProvider: import_ethers53.ethers.JsonRpcProvider
18553
+ StaticJsonRpcProvider: import_ethers54.ethers.JsonRpcProvider
18474
18554
  },
18475
- Contract: import_ethers53.ethers.Contract,
18476
- utils: import_ethers53.ethers
18555
+ Contract: import_ethers54.ethers.Contract,
18556
+ utils: import_ethers54.ethers
18477
18557
  // v6 moved utils to top level
18478
18558
  };
18479
18559
  global.Lit = {
@@ -24043,9 +24123,35 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
24043
24123
  return mod && mod.__esModule ? mod : { "default": mod };
24044
24124
  };
24045
24125
  Object.defineProperty(exports2, "__esModule", { value: true });
24126
+ exports2.computeCidV0 = computeCidV0;
24046
24127
  exports2.fetchLitActionCodeFromIpfs = fetchLitActionCodeFromIpfs;
24047
24128
  var axios_1 = __importDefault(require_axios());
24129
+ var ethers_1 = require("ethers");
24048
24130
  var ipfsCodeCache = /* @__PURE__ */ new Map();
24131
+ var CIDV0 = /^Qm[1-9A-HJ-NP-Za-km-z]{44}$/;
24132
+ var SINGLE_BLOCK_MAX_BYTES = 262144;
24133
+ function varint(n) {
24134
+ const out = [];
24135
+ while (n >= 128) {
24136
+ out.push(n & 127 | 128);
24137
+ n >>>= 7;
24138
+ }
24139
+ out.push(n);
24140
+ return out;
24141
+ }
24142
+ function computeCidV0(content) {
24143
+ const n = varint(content.length);
24144
+ const unixfs = new Uint8Array([8, 2, 18, ...n, ...content, 24, ...n]);
24145
+ const node = new Uint8Array([10, ...varint(unixfs.length), ...unixfs]);
24146
+ return (0, ethers_1.encodeBase58)(new Uint8Array([18, 32, ...(0, ethers_1.getBytes)((0, ethers_1.sha256)(node))]));
24147
+ }
24148
+ function responseBytes(data) {
24149
+ if (data instanceof Uint8Array)
24150
+ return data;
24151
+ if (data instanceof ArrayBuffer)
24152
+ return new Uint8Array(data);
24153
+ return null;
24154
+ }
24049
24155
  var GATEWAY_TIMEOUT_MS = 2e4;
24050
24156
  var buildGatewayList = (cid, pinataJwt) => {
24051
24157
  const gateways = [];
@@ -24066,6 +24172,9 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
24066
24172
  }
24067
24173
  return cached;
24068
24174
  }
24175
+ if (!CIDV0.test(cid)) {
24176
+ throw new Error(`Refusing to fetch LIT Action for ${cid}: only CIDv0 (Qm\u2026) content can be verified`);
24177
+ }
24069
24178
  const pinataJwt = options.pinataJwt ?? process.env.PINATA_JWT;
24070
24179
  const extraGateways = options.extraGateways?.map((t) => ({ url: t.replace("{cid}", cid) })) ?? [];
24071
24180
  const gateways = [...extraGateways, ...buildGatewayList(cid, pinataJwt)];
@@ -24077,19 +24186,32 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
24077
24186
  }
24078
24187
  const response = await axios_1.default.get(gateway.url, {
24079
24188
  timeout: GATEWAY_TIMEOUT_MS,
24189
+ responseType: "arraybuffer",
24080
24190
  headers: {
24081
24191
  Accept: "text/plain, application/javascript, text/javascript",
24082
24192
  ...gateway.headers
24083
24193
  }
24084
24194
  });
24085
- if (response.data && typeof response.data === "string") {
24086
- if (options.debug) {
24087
- console.log(`\u2705 [fetchLitActionCodeFromIpfs] Fetched from ${gateway.url}`);
24088
- }
24089
- ipfsCodeCache.set(cid, response.data);
24090
- return response.data;
24195
+ const bytes = responseBytes(response.data);
24196
+ if (!bytes || bytes.length === 0) {
24197
+ failures.push(`${gateway.url}: HTTP ${response.status} returned ${bytes ? "an empty body" : typeof response.data}, expected bytes`);
24198
+ continue;
24199
+ }
24200
+ if (bytes.length > SINGLE_BLOCK_MAX_BYTES) {
24201
+ failures.push(`${gateway.url}: ${bytes.length} bytes exceeds the single-block CIDv0 limit (${SINGLE_BLOCK_MAX_BYTES}); content cannot be verified`);
24202
+ continue;
24203
+ }
24204
+ const actualCid = computeCidV0(bytes);
24205
+ if (actualCid !== cid) {
24206
+ failures.push(`${gateway.url}: content hashes to ${actualCid}, not the requested CID`);
24207
+ continue;
24091
24208
  }
24092
- failures.push(`${gateway.url}: HTTP ${response.status} returned ${typeof response.data}, expected string`);
24209
+ const code = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
24210
+ if (options.debug) {
24211
+ console.log(`\u2705 [fetchLitActionCodeFromIpfs] Fetched and verified from ${gateway.url}`);
24212
+ }
24213
+ ipfsCodeCache.set(cid, code);
24214
+ return code;
24093
24215
  } catch (error) {
24094
24216
  const message = error instanceof Error ? error.message : String(error);
24095
24217
  failures.push(`${gateway.url}: ${message}`);
@@ -25577,6 +25699,53 @@ var require_pkp_signer_module = __commonJS({
25577
25699
  }
25578
25700
  });
25579
25701
 
25702
+ // node_modules/@gvnrdao/dh-lit-ops/dist/modules/mainnet-validator-wallets.js
25703
+ var require_mainnet_validator_wallets = __commonJS({
25704
+ "node_modules/@gvnrdao/dh-lit-ops/dist/modules/mainnet-validator-wallets.js"(exports2) {
25705
+ "use strict";
25706
+ Object.defineProperty(exports2, "__esModule", { value: true });
25707
+ exports2.MAINNET_OP_VALIDATOR_WALLETS = exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET = exports2.NON_MAINNET_CHAIN_IDS = void 0;
25708
+ exports2.resolveMainnetValidatorWallet = resolveMainnetValidatorWallet;
25709
+ exports2.NON_MAINNET_CHAIN_IDS = /* @__PURE__ */ new Set([
25710
+ 11155111,
25711
+ // Sepolia
25712
+ 1337,
25713
+ // Hardhat (DH local deployment chainId)
25714
+ 31337
25715
+ // Hardhat (default)
25716
+ ]);
25717
+ exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET = "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c";
25718
+ exports2.MAINNET_OP_VALIDATOR_WALLETS = {
25719
+ ucdMintValidator: "0x19C8FeE0f8f4b6F9Aa8e521D4CC62F4697CF85af",
25720
+ processPaymentValidator: "0x01480725c1fA026fd4A6bfA3100c691aeC955135",
25721
+ extendPositionValidator: "0xcE08AF213D8d95ad3dD317276F9e93Ab2eD75030",
25722
+ btcWithdrawal: "0x69dCd1204CDB31437CaF7114f74422390b472d3A",
25723
+ loanVaultBtcBalance: "0xc3d549EEb62721750Ff6518f6730Ab0e8D0Fea97",
25724
+ liquidationValidator: "0x66B30C19173005A51f21e2e4180FD7BC8c1d485b",
25725
+ // Non-OAR: verified on-chain by BTCSpendAuthorizer.staleSpendValidatorAddress (set via
25726
+ // AdminModule to this PKP's derived signer). Self-deriving Safe-owned PKP; seed == signer.
25727
+ staleSpendRecoveryValidator: "0x58F9144cF9781c15C061ba86901905a5a19F7661",
25728
+ // Non-OAR: no on-chain consumer verifies these signatures. The Sepolia seed has no key
25729
+ // derivation registered on the mainnet Lit account, so they reuse the Safe-owned
25730
+ // pkp-validator PKP (live derivation, group 2). See
25731
+ // docs/INCIDENT_2026-09-21_MAINNET_PKP_DERIVATION_DECRYPT.md.
25732
+ btcAddressBalance: "0x19524aE4e514a0f08A542596c2DA0B2262c61f48",
25733
+ priceOracle: "0x19524aE4e514a0f08A542596c2DA0B2262c61f48"
25734
+ };
25735
+ function resolveMainnetValidatorWallet(args) {
25736
+ const { registryKey, chainId, wallet } = args;
25737
+ const isNonMainnetChain = Number.isFinite(chainId) && exports2.NON_MAINNET_CHAIN_IDS.has(chainId);
25738
+ if (isNonMainnetChain || !wallet || wallet.toLowerCase() !== exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET) {
25739
+ return wallet;
25740
+ }
25741
+ if (!registryKey || !Object.prototype.hasOwnProperty.call(exports2.MAINNET_OP_VALIDATOR_WALLETS, registryKey)) {
25742
+ return wallet;
25743
+ }
25744
+ return exports2.MAINNET_OP_VALIDATOR_WALLETS[registryKey];
25745
+ }
25746
+ }
25747
+ });
25748
+
25580
25749
  // node_modules/@gvnrdao/dh-lit-ops/dist/utils/async-request.util.js
25581
25750
  var require_async_request_util = __commonJS({
25582
25751
  "node_modules/@gvnrdao/dh-lit-ops/dist/utils/async-request.util.js"(exports2) {
@@ -25604,7 +25773,9 @@ var require_async_request_util = __commonJS({
25604
25773
  });
25605
25774
  if (!submitResponse.ok) {
25606
25775
  const errorText = await submitResponse.text();
25607
- throw new Error(`Failed to submit request (${submitResponse.status}): ${errorText}`);
25776
+ const retryAfter = submitResponse.status === 429 ? submitResponse.headers.get("retry-after") : null;
25777
+ const retryHint = retryAfter && /^\d+$/.test(retryAfter.trim()) ? ` Retry after ${retryAfter.trim()}s.` : "";
25778
+ throw new Error(`Failed to submit request (${submitResponse.status}): ${errorText}${retryHint}`);
25608
25779
  }
25609
25780
  const submitEnvelope = await submitResponse.json();
25610
25781
  if (!submitEnvelope.success || !submitEnvelope.data?.ticketId) {
@@ -25882,6 +26053,7 @@ var require_lit_ops_module = __commonJS({
25882
26053
  var pkp_manager_module_1 = require_pkp_manager_module();
25883
26054
  var pkp_minter_module_1 = require_pkp_minter_module();
25884
26055
  var pkp_signer_module_1 = require_pkp_signer_module();
26056
+ var mainnet_validator_wallets_1 = require_mainnet_validator_wallets();
25885
26057
  var async_request_util_1 = require_async_request_util();
25886
26058
  var crypto_1 = require("crypto");
25887
26059
  var lit_core_lit_action_client_1 = require_lit_core_lit_action_client();
@@ -25894,26 +26066,6 @@ var require_lit_ops_module = __commonJS({
25894
26066
  { name: "borrower", type: "address" }
25895
26067
  ]
25896
26068
  };
25897
- var NON_MAINNET_CHAIN_IDS = /* @__PURE__ */ new Set([
25898
- 11155111,
25899
- // Sepolia
25900
- 1337,
25901
- // Hardhat (DH local deployment chainId)
25902
- 31337
25903
- // Hardhat (default)
25904
- ]);
25905
- var SEPOLIA_DEFAULT_VALIDATOR_WALLET = "0x82db9f515957aa380b596c6ea2bd30cef181f236";
25906
- var MAINNET_OP_VALIDATOR_WALLETS = {
25907
- ucdMintValidator: "0x19C8FeE0f8f4b6F9Aa8e521D4CC62F4697CF85af",
25908
- processPaymentValidator: "0x01480725c1fA026fd4A6bfA3100c691aeC955135",
25909
- extendPositionValidator: "0xcE08AF213D8d95ad3dD317276F9e93Ab2eD75030",
25910
- btcWithdrawal: "0x69dCd1204CDB31437CaF7114f74422390b472d3A",
25911
- loanVaultBtcBalance: "0xc3d549EEb62721750Ff6518f6730Ab0e8D0Fea97",
25912
- liquidationValidator: "0x66B30C19173005A51f21e2e4180FD7BC8c1d485b",
25913
- // Non-OAR: verified on-chain by BTCSpendAuthorizer.staleSpendValidatorAddress (set via
25914
- // AdminModule to this PKP's derived signer). Self-deriving Safe-owned PKP; seed == signer.
25915
- staleSpendRecoveryValidator: "0x58F9144cF9781c15C061ba86901905a5a19F7661"
25916
- };
25917
26069
  function resolvePkpValidationRegistryAddress(config) {
25918
26070
  const fromConfig = config.pkpValidationRegistryAddress;
25919
26071
  return fromConfig || process.env.PKP_VALIDATION_REGISTRY_ADDRESS || process.env.PKP_VALIDATION_REGISTRY;
@@ -27154,17 +27306,18 @@ var require_lit_ops_module = __commonJS({
27154
27306
  let effectiveValidatorWallet = litActionInfo.validatorWalletAddress;
27155
27307
  const jp = jsParams;
27156
27308
  const resolvedChainId = Number(jp.chainId ?? jp.auth?.chainId ?? jp.authMessage?.chainId ?? this.config.chainId);
27157
- const isNonMainnetChain = Number.isFinite(resolvedChainId) && NON_MAINNET_CHAIN_IDS.has(resolvedChainId);
27158
- if (!isNonMainnetChain && effectiveValidatorWallet && effectiveValidatorWallet.toLowerCase() === SEPOLIA_DEFAULT_VALIDATOR_WALLET) {
27159
- const reg = (0, dh_lit_actions_1.getDeploymentsForNetwork)(this.config.network);
27160
- const registryKey = Object.keys(reg).find((k) => reg[k]?.cid === litActionInfo.cid);
27161
- const mainnetWallet = registryKey ? MAINNET_OP_VALIDATOR_WALLETS[registryKey] : void 0;
27162
- if (mainnetWallet) {
27163
- if (this.config.debug) {
27164
- console.log(`[${label}] mainnet validator remap (${registryKey}, chainId=${Number.isFinite(resolvedChainId) ? resolvedChainId : "unknown\u2192mainnet"}): ${effectiveValidatorWallet} -> ${mainnetWallet}`);
27165
- }
27166
- effectiveValidatorWallet = mainnetWallet;
27309
+ const reg = (0, dh_lit_actions_1.getDeploymentsForNetwork)(this.config.network);
27310
+ const registryKey = Object.keys(reg).find((k) => reg[k]?.cid === litActionInfo.cid);
27311
+ const mainnetWallet = (0, mainnet_validator_wallets_1.resolveMainnetValidatorWallet)({
27312
+ registryKey,
27313
+ chainId: resolvedChainId,
27314
+ wallet: effectiveValidatorWallet
27315
+ });
27316
+ if (mainnetWallet !== effectiveValidatorWallet) {
27317
+ if (this.config.debug) {
27318
+ console.log(`[${label}] mainnet validator remap (${registryKey}, chainId=${Number.isFinite(resolvedChainId) ? resolvedChainId : "unknown\u2192mainnet"}): ${effectiveValidatorWallet} -> ${mainnetWallet}`);
27167
27319
  }
27320
+ effectiveValidatorWallet = mainnetWallet;
27168
27321
  }
27169
27322
  if (process.env.LIT_LANE_VALIDATOR_WALLET_OVERRIDE) {
27170
27323
  if (process.env.LIT_LANE_GUARD !== "1") {
@@ -28331,7 +28484,11 @@ var require_lit_ops_module = __commonJS({
28331
28484
  error: "sign=true requires price oracle PKP in registry (ethAddress/publicKey) or options.pkpId (Lit jsParams pkpId)"
28332
28485
  };
28333
28486
  }
28334
- priceOracleParams.pkpId = resolvedPkpId;
28487
+ priceOracleParams.pkpId = (0, mainnet_validator_wallets_1.resolveMainnetValidatorWallet)({
28488
+ registryKey: "priceOracle",
28489
+ chainId: Number(this.config.chainId),
28490
+ wallet: resolvedPkpId
28491
+ });
28335
28492
  }
28336
28493
  if (this.config.debug) {
28337
28494
  console.log("\u{1F4B0} Calling Price Oracle LIT Action:");
@@ -40556,7 +40713,7 @@ var require_dist3 = __commonJS({
40556
40713
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
40557
40714
  };
40558
40715
  Object.defineProperty(exports2, "__esModule", { value: true });
40559
- exports2.default = exports2.broadcastSignedBitcoinTransaction = exports2.convertEthereumSignatureToBitcoinDER = exports2.CORE_API_TRANSPORT_FAILURE_MARKER = exports2.isCoreApiTransportError = exports2.describeErrorWithCause = exports2.normalizeCoreLitActionResult = exports2.executeLitActionViaCoreApi = exports2.fetchLitActionCodeFromIpfs = exports2.redactPositionIdForLog = exports2.asyncRequest = exports2.TaskQueue = exports2.TicketManager = exports2.PKPSigner = exports2.PKPAuthorizerUtils = exports2.PKPAuthorizer = exports2.PKPMinterUtils = exports2.PKPMinter = exports2.PKPManager = exports2.LitActionExecutor = exports2.LitAuthManager = exports2.LitOps = exports2.cidToHex = exports2.getDeploymentsForNetwork = void 0;
40716
+ exports2.default = exports2.broadcastSignedBitcoinTransaction = exports2.convertEthereumSignatureToBitcoinDER = exports2.CORE_API_TRANSPORT_FAILURE_MARKER = exports2.isCoreApiTransportError = exports2.describeErrorWithCause = exports2.normalizeCoreLitActionResult = exports2.executeLitActionViaCoreApi = exports2.fetchLitActionCodeFromIpfs = exports2.redactPositionIdForLog = exports2.asyncRequest = exports2.TaskQueue = exports2.TicketManager = exports2.PKPSigner = exports2.PKPAuthorizerUtils = exports2.PKPAuthorizer = exports2.PKPMinterUtils = exports2.PKPMinter = exports2.PKPManager = exports2.LitActionExecutor = exports2.LitAuthManager = exports2.resolveMainnetValidatorWallet = exports2.LitOps = exports2.cidToHex = exports2.getDeploymentsForNetwork = void 0;
40560
40717
  __exportStar(require_interfaces(), exports2);
40561
40718
  var dh_lit_actions_1 = require_pkg_src();
40562
40719
  Object.defineProperty(exports2, "getDeploymentsForNetwork", { enumerable: true, get: function() {
@@ -40569,6 +40726,10 @@ var require_dist3 = __commonJS({
40569
40726
  Object.defineProperty(exports2, "LitOps", { enumerable: true, get: function() {
40570
40727
  return lit_ops_module_1.LitOps;
40571
40728
  } });
40729
+ var mainnet_validator_wallets_1 = require_mainnet_validator_wallets();
40730
+ Object.defineProperty(exports2, "resolveMainnetValidatorWallet", { enumerable: true, get: function() {
40731
+ return mainnet_validator_wallets_1.resolveMainnetValidatorWallet;
40732
+ } });
40572
40733
  var auth_manager_module_1 = require_auth_manager_module();
40573
40734
  Object.defineProperty(exports2, "LitAuthManager", { enumerable: true, get: function() {
40574
40735
  return auth_manager_module_1.LitAuthManager;
@@ -40925,6 +41086,7 @@ function renderLandingPage(input) {
40925
41086
 
40926
41087
  // src/util/page-headers.ts
40927
41088
  var import_node_crypto = require("crypto");
41089
+ var STRICT_TRANSPORT_SECURITY = { name: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" };
40928
41090
  function htmlPageSecurityHeaders(extra) {
40929
41091
  const nonce = (0, import_node_crypto.randomBytes)(16).toString("base64");
40930
41092
  const base = [
@@ -40952,7 +41114,7 @@ function htmlPageSecurityHeaders(extra) {
40952
41114
  }
40953
41115
 
40954
41116
  // src/version.ts
40955
- var SERVER_VERSION = "0.5.18";
41117
+ var SERVER_VERSION = "0.5.20";
40956
41118
 
40957
41119
  // src/connector/siwe-oauth.ts
40958
41120
  var import_node_crypto2 = require("crypto");
@@ -41162,6 +41324,7 @@ var SiweOAuthProvider = class {
41162
41324
  this.flows.set(flowId, { clientId: client.client_id, params, createdAt: this.clock() });
41163
41325
  const page = htmlPageSecurityHeaders();
41164
41326
  for (const [name, value] of Object.entries(page.headers)) res.setHeader(name, value);
41327
+ res.setHeader(STRICT_TRANSPORT_SECURITY.name, STRICT_TRANSPORT_SECURITY.value);
41165
41328
  res.status(200).type("html").send(
41166
41329
  renderSiwePage({
41167
41330
  flowId,
@@ -41672,7 +41835,7 @@ function resolveRealConfig(env) {
41672
41835
 
41673
41836
  // src/boot.ts
41674
41837
  var fs6 = __toESM(require("fs"));
41675
- var import_ethers50 = require("ethers");
41838
+ var import_ethers51 = require("ethers");
41676
41839
 
41677
41840
  // src/boundary/index.ts
41678
41841
  var import_node_crypto9 = require("crypto");
@@ -41762,8 +41925,13 @@ function iso(sec) {
41762
41925
  return new Date(sec * 1e3).toISOString();
41763
41926
  }
41764
41927
  var PSM_FLOOR_TOLERANCE_BPS = 100;
41928
+ var CANONICAL_MAINNET_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
41929
+ function stablecoinKindFor(network, stablecoinAddress) {
41930
+ if (network !== "mainnet") return "mock";
41931
+ return stablecoinAddress.toLowerCase() === CANONICAL_MAINNET_USDC.toLowerCase() ? "circle" : "onchain";
41932
+ }
41765
41933
  function failureToError(f) {
41766
- const code = f.kind === "signer-missing" ? "SIGNER_UNAVAILABLE" : f.kind === "unavailable" ? "UPSTREAM_UNAVAILABLE" : f.kind === "not-found" ? "NOT_FOUND" : "UPSTREAM_REJECTED";
41934
+ 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";
41767
41935
  const message = f.kind === "malformed" ? `${f.message} (upstream response failed integrity checks)` : f.message;
41768
41936
  return boundaryError(code, message, {
41769
41937
  source: f.source,
@@ -42239,7 +42407,7 @@ var BoundaryCore = class {
42239
42407
  tokenAddress: a.tokenAddress,
42240
42408
  spenderAddress: a.spenderAddress,
42241
42409
  spenderContract: a.spenderContract,
42242
- 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",
42410
+ 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",
42243
42411
  before: a.before,
42244
42412
  amountUnit: q.amountInUnit,
42245
42413
  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."
@@ -42298,9 +42466,10 @@ var BoundaryCore = class {
42298
42466
  chainId: this.deps.chainId,
42299
42467
  psmAddress: s.psmAddress,
42300
42468
  stablecoinAddress: s.stablecoinAddress,
42301
- // Only mainnet runs real Circle USDC; the mock world and sepolia both run a
42302
- // practice stablecoin with a public self-serve mint.
42303
- stablecoinKind: this.deps.network === "mainnet" ? "circle" : "mock",
42469
+ // Labelled by the ACTUAL coin, not the network (C-49): `circle` only for canonical
42470
+ // mainnet USDC, `mock` for the practice token, `onchain` for any other real coin
42471
+ // (e.g. mainnet USDT) — a USDT swap must never render as "real USDC".
42472
+ stablecoinKind: stablecoinKindFor(this.deps.network, s.stablecoinAddress),
42304
42473
  stablecoinSymbol: s.stablecoinSymbol,
42305
42474
  stablecoinDecimals: s.stablecoinDecimals,
42306
42475
  exchangeRate: s.exchangeRate,
@@ -45291,6 +45460,35 @@ var import_ethers10 = require("ethers");
45291
45460
  // src/boundary/upstream/shared/external-bridge/card.ts
45292
45461
  var import_ethers8 = require("ethers");
45293
45462
  init_tx_validator();
45463
+
45464
+ // src/boundary/upstream/shared/external-bridge/card-escape.ts
45465
+ var MAX_VALUE_CHARS = 200;
45466
+ function mustEscape(code) {
45467
+ if (code <= 31 || code === 127) return true;
45468
+ if (code >= 128 && code <= 159) return true;
45469
+ if (code === 8232 || code === 8233) return true;
45470
+ if (code >= 8234 && code <= 8238) return true;
45471
+ if (code >= 8294 && code <= 8297) return true;
45472
+ return false;
45473
+ }
45474
+ function safeValue(raw) {
45475
+ let out = "";
45476
+ for (const ch of String(raw)) {
45477
+ const code = ch.codePointAt(0);
45478
+ out += mustEscape(code) ? `\\u${code.toString(16).padStart(4, "0")}` : ch;
45479
+ if (out.length > MAX_VALUE_CHARS) return `${out.slice(0, MAX_VALUE_CHARS)}\u2026[truncated]`;
45480
+ }
45481
+ return out;
45482
+ }
45483
+
45484
+ // src/boundary/upstream/shared/external-bridge/card.ts
45485
+ function formatBtc(sats) {
45486
+ const negative = sats < 0n;
45487
+ const abs = negative ? -sats : sats;
45488
+ const whole = abs / 10n ** 8n;
45489
+ const frac = (abs % 10n ** 8n).toString().padStart(8, "0").replace(/0+$/, "");
45490
+ return `${negative ? "-" : ""}${whole}${frac ? "." + frac : ""}`;
45491
+ }
45294
45492
  function formatUcd(wei) {
45295
45493
  const negative = wei < 0n;
45296
45494
  const abs = negative ? -wei : wei;
@@ -45336,15 +45534,15 @@ function cardForTx(tx2) {
45336
45534
  "Operation: create a new borrowing position (your wallet is the borrower)",
45337
45535
  `Term: ${Number(args[4])} months`,
45338
45536
  `Position key (PKP id): ${String(args[0])}`,
45339
- `BTC vault (mainnet form): ${String(args[2])}`,
45340
- `BTC vault (regtest form): ${String(args[3])}`,
45537
+ `BTC vault (mainnet form): ${safeValue(args[2])}`,
45538
+ `BTC vault (regtest form): ${safeValue(args[3])}`,
45341
45539
  `Validator generation: ${Number(args[5])}`,
45342
45540
  ...head
45343
45541
  ];
45344
45542
  case "addAddress":
45345
45543
  return [
45346
45544
  "Operation: allowlist a Bitcoin withdrawal destination for YOUR account",
45347
- `BTC address to allowlist: ${String(args[0])}`,
45545
+ `BTC address to allowlist: ${safeValue(args[0])}`,
45348
45546
  "Withdrawals to this address become possible only after the registry's on-chain delay",
45349
45547
  ...head
45350
45548
  ];
@@ -45372,15 +45570,40 @@ function cardForTx(tx2) {
45372
45570
  `Minimum stablecoin out \u2014 the slippage floor (smallest units): ${String(args[2])}`,
45373
45571
  ...head
45374
45572
  ];
45573
+ case "withdrawBTC": {
45574
+ const p = args[0];
45575
+ return [
45576
+ "Operation: withdraw BTC from your vault \u2014 THIS MOVES BITCOIN OUT",
45577
+ `Position: ${safeValue(p.positionId)}`,
45578
+ // The destination is the whole security question of this card. It is a caller-
45579
+ // supplied string, hence safeValue: see the escaping note above.
45580
+ `BTC sent to: ${safeValue(p.withdrawalAddress)}`,
45581
+ `Leaves the vault (fee included): ${formatBtc(BigInt(p.totalDeduction))} BTC (${BigInt(p.totalDeduction)} sats)`,
45582
+ `Collateral remaining after this: ${formatBtc(BigInt(p.newCollateral))} BTC (${BigInt(p.newCollateral)} sats)`,
45583
+ `Spending vault UTXO: ${safeValue(p.utxoTxid)}:${Number(p.utxoVout)}`,
45584
+ ...head
45585
+ ];
45586
+ }
45587
+ case "setPositionDelegate":
45588
+ return [
45589
+ "Operation: set the DELEGATE for this position \u2014 this address may act on the position on your behalf",
45590
+ `Position: ${safeValue(args[0])}`,
45591
+ `Delegate address: ${safeValue(args[1])}`,
45592
+ "Setting the zero address removes the current delegate",
45593
+ ...head
45594
+ ];
45375
45595
  default:
45376
- return [`Operation: ${name}`, ...args.map((a, i) => `arg[${i}]: ${String(a)}`), ...head];
45596
+ throw new Error(
45597
+ `no approval card is defined for the signable function "${name}" \u2014 add a case to cardForTx before this operation can be approved`
45598
+ );
45377
45599
  }
45378
45600
  }
45379
45601
  function cardForTypedData(action, payload) {
45380
45602
  const m = payload.message;
45381
45603
  return [
45382
45604
  `Operation: ${action} \u2014 this signature AUTHORIZES the operation described below; the protocol executes it after your approval`,
45383
- ...Object.entries(m).map(([k, v]) => `${k}: ${String(v)}`),
45605
+ // `detail` here is a server-composed string — same escaping rule as the tx card.
45606
+ ...Object.entries(m).map(([k, v]) => `${safeValue(k)}: ${safeValue(v)}`),
45384
45607
  `Signing domain: ${String(payload.domain["name"])} v${String(payload.domain["version"])} \xB7 chain ${String(payload.domain["chainId"])}`
45385
45608
  ];
45386
45609
  }
@@ -45731,12 +45954,10 @@ init_tx_validator();
45731
45954
 
45732
45955
  // src/boundary/upstream/shared/quantum.ts
45733
45956
  var QUANTUM_WINDOW_SECONDS = 60;
45734
- var AUTH_VALIDITY_WINDOWS = 3;
45735
- function authValiditySec() {
45736
- return QUANTUM_WINDOW_SECONDS * AUTH_VALIDITY_WINDOWS;
45737
- }
45738
45957
  function isAuthFresh(issuedAtSec, nowSec) {
45739
- return issuedAtSec <= nowSec && nowSec - issuedAtSec < authValiditySec();
45958
+ const sq = Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
45959
+ const cq = Math.floor(nowSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
45960
+ return sq === cq - QUANTUM_WINDOW_SECONDS || sq === cq || sq === cq + QUANTUM_WINDOW_SECONDS;
45740
45961
  }
45741
45962
  function isStrictCurrentQuantum(issuedAtSec, nowSec) {
45742
45963
  return issuedAtSec <= nowSec && Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) === Math.floor(nowSec / QUANTUM_WINDOW_SECONDS);
@@ -45777,7 +45998,7 @@ var SafeCeremony = class {
45777
45998
  if (!auth.ok) return auth.refusal;
45778
45999
  if (!isAuthFresh(issuedAtSec, surface.nowSec())) {
45779
46000
  return this.refuse(
45780
- `${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`
46001
+ `${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`
45781
46002
  );
45782
46003
  }
45783
46004
  const raw = await executor.signTransaction({
@@ -46297,7 +46518,7 @@ var SafeModuleCeremony = class {
46297
46518
  };
46298
46519
 
46299
46520
  // src/boundary/upstream/real/plugin.ts
46300
- var import_ethers49 = require("ethers");
46521
+ var import_ethers50 = require("ethers");
46301
46522
 
46302
46523
  // node_modules/@gvnrdao/dh-sdk/dist/index.mjs
46303
46524
  var import_ethers14 = require("ethers");
@@ -46309,6 +46530,7 @@ var import_ethers19 = require("ethers");
46309
46530
  var import_ethers20 = require("ethers");
46310
46531
  var import_ethers21 = require("ethers");
46311
46532
  var import_ethers22 = require("ethers");
46533
+ var import_ethers23 = require("ethers");
46312
46534
 
46313
46535
  // node_modules/@noble/hashes/esm/utils.js
46314
46536
  function isBytes(a) {
@@ -46756,11 +46978,11 @@ var ripemd1602 = ripemd160;
46756
46978
  // node_modules/@gvnrdao/dh-sdk/dist/index.mjs
46757
46979
  var import_bech32 = __toESM(require_dist(), 1);
46758
46980
  var import_bs58check = __toESM(require_bs58check(), 1);
46759
- var import_ethers23 = require("ethers");
46760
46981
  var import_ethers24 = require("ethers");
46761
46982
  var import_ethers25 = require("ethers");
46762
46983
  var import_ethers26 = require("ethers");
46763
46984
  var import_ethers27 = require("ethers");
46985
+ var import_ethers28 = require("ethers");
46764
46986
 
46765
46987
  // node_modules/axios/lib/helpers/bind.js
46766
46988
  function bind(fn, thisArg) {
@@ -52385,7 +52607,6 @@ var {
52385
52607
  } = axios_default;
52386
52608
 
52387
52609
  // node_modules/@gvnrdao/dh-sdk/dist/index.mjs
52388
- var import_ethers28 = require("ethers");
52389
52610
  var import_ethers29 = require("ethers");
52390
52611
  var import_ethers30 = require("ethers");
52391
52612
  var import_ethers31 = require("ethers");
@@ -52394,6 +52615,7 @@ var import_ethers33 = require("ethers");
52394
52615
  var import_ethers34 = require("ethers");
52395
52616
  var import_dh_lit_ops = __toESM(require_dist3(), 1);
52396
52617
  var import_ethers35 = require("ethers");
52618
+ var import_ethers36 = require("ethers");
52397
52619
  var __create2 = Object.create;
52398
52620
  var __defProp2 = Object.defineProperty;
52399
52621
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -52495,7 +52717,6 @@ var init_deployment_addresses = __esm2({
52495
52717
  PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
52496
52718
  FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
52497
52719
  BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
52498
- CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
52499
52720
  AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
52500
52721
  DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
52501
52722
  AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
@@ -52765,8 +52986,6 @@ var init_deployment_addresses = __esm2({
52765
52986
  OPERATION_AUTHORIZATION_REGISTRY_IMPL: "0xe0D981B60351f0f8fFDA2b50C8180Fb37CeF3883",
52766
52987
  BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
52767
52988
  BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_IMPL: "0x76E0a2c9d89562fD7c50b5f554d7fa25957e39Db",
52768
- CARRY_AGENT_REGISTRY: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
52769
- CARRY_AGENT_REGISTRY_IMPL: "0x1b11a3D5e46F3672E643c997f0d569DFf0b64a01",
52770
52989
  AGENT_DELEGATION_REGISTRY: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
52771
52990
  AGENT_DELEGATION_REGISTRY_IMPL: "0xE931E4b9ceF2A48Ac7D57192da4B523756cFC310",
52772
52991
  DH_AGENT_DELEGATE: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF"
@@ -52798,7 +53017,6 @@ var init_deployment_addresses = __esm2({
52798
53017
  PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
52799
53018
  FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
52800
53019
  BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
52801
- CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
52802
53020
  AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
52803
53021
  DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
52804
53022
  AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
@@ -53773,113 +53991,113 @@ var require_pkg_src2 = __commonJS2({
53773
53991
  deployedAt: 1784569687492,
53774
53992
  size: 4140,
53775
53993
  hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
53776
- validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
53994
+ validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
53777
53995
  pkp: {
53778
53996
  publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
53779
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
53997
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53780
53998
  }
53781
53999
  },
53782
54000
  btcTransactionSigner: {
53783
- cid: "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf",
54001
+ cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
53784
54002
  authorizedCidHex: cidToHex(
53785
- "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf"
54003
+ "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
53786
54004
  ),
53787
54005
  name: "Btc Transaction Signer",
53788
54006
  description: "Production Btc Transaction Signer",
53789
54007
  version: "1.1.1",
53790
54008
  deployed: true,
53791
- deployedAt: 1787923905597,
53792
- size: 70646,
53793
- hash: "37c3bb72a660c8275d92e1b73f9482742d86b64789480b9246304c0ca1bab47a"
54009
+ deployedAt: 1790246185256,
54010
+ size: 73313,
54011
+ hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
53794
54012
  },
53795
54013
  ucdMintValidator: {
53796
- cid: "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc",
54014
+ cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
53797
54015
  authorizedCidHex: cidToHex(
53798
- "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc"
54016
+ "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
53799
54017
  ),
53800
54018
  name: "Ucd Mint Validator",
53801
54019
  description: "Production Ucd Mint Validator",
53802
- version: "1.2.1",
54020
+ version: "1.3.0",
53803
54021
  deployed: true,
53804
- deployedAt: 1787923919527,
53805
- size: 86197,
53806
- hash: "c2d80939746cc37f65ef2f63c6a3215b929214a63f10c78144e1f5c98320dabf",
53807
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
54022
+ deployedAt: 1790246219868,
54023
+ size: 90022,
54024
+ hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
54025
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53808
54026
  pkp: {
53809
54027
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
53810
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
54028
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53811
54029
  }
53812
54030
  },
53813
54031
  processPaymentValidator: {
53814
- cid: "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF",
54032
+ cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
53815
54033
  authorizedCidHex: cidToHex(
53816
- "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF"
54034
+ "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
53817
54035
  ),
53818
54036
  name: "Process Payment Validator",
53819
54037
  description: "Production Process Payment Validator",
53820
54038
  version: "1.2.1",
53821
54039
  deployed: true,
53822
- deployedAt: 1787923987153,
53823
- size: 82217,
53824
- hash: "13defa19614215ab3b1fe88955d69e530d13a09475396af932fe0e213637da2f",
53825
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
54040
+ deployedAt: 1790246225795,
54041
+ size: 85107,
54042
+ hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
54043
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53826
54044
  pkp: {
53827
54045
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
53828
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
54046
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53829
54047
  }
53830
54048
  },
53831
54049
  extendPositionValidator: {
53832
- cid: "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m",
54050
+ cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
53833
54051
  authorizedCidHex: cidToHex(
53834
- "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m"
54052
+ "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
53835
54053
  ),
53836
54054
  name: "Extend Position Validator",
53837
54055
  description: "Production Extend Position Validator",
53838
54056
  version: "1.2.1",
53839
54057
  deployed: true,
53840
- deployedAt: 1787923999294,
53841
- size: 79975,
53842
- hash: "31c1aaf883ef22f37681ddb0a4a949be5c05304b6aef178989475a2da935ef9a",
53843
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
54058
+ deployedAt: 1790246231975,
54059
+ size: 82853,
54060
+ hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
54061
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53844
54062
  pkp: {
53845
54063
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
53846
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
54064
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53847
54065
  }
53848
54066
  },
53849
54067
  btcWithdrawal: {
53850
- cid: "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY",
54068
+ cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
53851
54069
  authorizedCidHex: cidToHex(
53852
- "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY"
54070
+ "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
53853
54071
  ),
53854
54072
  name: "Btc Withdrawal",
53855
54073
  description: "Production Btc Withdrawal",
53856
54074
  version: "1.2.7",
53857
54075
  deployed: true,
53858
- deployedAt: 1787924017769,
53859
- size: 100069,
53860
- hash: "4f8e27414e4da235e63d6ae1325c63f3d2fb956464515a21aa007a99935f0f13",
53861
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
54076
+ deployedAt: 1790246239599,
54077
+ size: 101228,
54078
+ hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
54079
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53862
54080
  pkp: {
53863
54081
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
53864
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
54082
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53865
54083
  }
53866
54084
  },
53867
54085
  liquidationValidator: {
53868
- cid: "Qme6aGADhiszkQbZL977E6nmBacd2PEB7K9Hs8puVrscNx",
54086
+ cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
53869
54087
  authorizedCidHex: cidToHex(
53870
- "Qme6aGADhiszkQbZL977E6nmBacd2PEB7K9Hs8puVrscNx"
54088
+ "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
53871
54089
  ),
53872
54090
  name: "Liquidation Validator",
53873
54091
  description: "Production Liquidation Validator",
53874
54092
  version: "1.2.1",
53875
54093
  deployed: true,
53876
- deployedAt: 1785173262533,
53877
- size: 66846,
53878
- hash: "b35ee7706d733d625faa4dbe37f73c8e20f0c1befa897cd7875e827de52003de",
53879
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
54094
+ deployedAt: 1790246247904,
54095
+ size: 70308,
54096
+ hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
54097
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53880
54098
  pkp: {
53881
54099
  publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
53882
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
54100
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53883
54101
  }
53884
54102
  },
53885
54103
  priceOracle: {
@@ -53894,28 +54112,28 @@ var require_pkg_src2 = __commonJS2({
53894
54112
  deployedAt: 1781116663270,
53895
54113
  size: 8695,
53896
54114
  hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
53897
- validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
54115
+ validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
53898
54116
  pkp: {
53899
54117
  publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
53900
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
54118
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53901
54119
  }
53902
54120
  },
53903
54121
  loanVaultBtcBalance: {
53904
- cid: "QmaeQoHYvcMYobNbu9hQavGDudi8AXoW9tg3YHrvy1g2A4",
54122
+ cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
53905
54123
  authorizedCidHex: cidToHex(
53906
- "QmaeQoHYvcMYobNbu9hQavGDudi8AXoW9tg3YHrvy1g2A4"
54124
+ "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
53907
54125
  ),
53908
54126
  name: "Loan Vault Btc Balance",
53909
54127
  description: "Production Loan Vault Btc Balance",
53910
54128
  version: "1.2.1",
53911
54129
  deployed: true,
53912
- deployedAt: 1785173271802,
53913
- size: 56800,
53914
- hash: "a059133214e6ba0a73d655a15600c4b33e361fb340c98f8eecaf8ab7b95aaf83",
53915
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
54130
+ deployedAt: 1790179961079,
54131
+ size: 60046,
54132
+ hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
54133
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53916
54134
  pkp: {
53917
54135
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
53918
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
54136
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53919
54137
  }
53920
54138
  },
53921
54139
  // btc-address-balance (Option B) — address-only signed total balance via
@@ -53925,21 +54143,21 @@ var require_pkg_src2 = __commonJS2({
53925
54143
  // Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
53926
54144
  // on each target chain (the action decrypts registry slots). No OAR entry.
53927
54145
  btcAddressBalance: {
53928
- cid: "QmUXUtU9r1HhQVYgkXPN5s19SKXanhn4pMsCtFEP3GK4Kj",
54146
+ cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
53929
54147
  authorizedCidHex: cidToHex(
53930
- "QmUXUtU9r1HhQVYgkXPN5s19SKXanhn4pMsCtFEP3GK4Kj"
54148
+ "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
53931
54149
  ),
53932
54150
  name: "Btc Address Balance",
53933
54151
  description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
53934
54152
  version: "0.2.1",
53935
54153
  deployed: true,
53936
- deployedAt: 1785173280221,
53937
- size: 27309,
53938
- hash: "f0d08938713d9d89a56a3a386cacbc2b57afd5ad367ea82d827d40e1bfc70989",
53939
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
54154
+ deployedAt: 1790179971315,
54155
+ size: 30295,
54156
+ hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
54157
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53940
54158
  pkp: {
53941
54159
  publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
53942
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
54160
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53943
54161
  }
53944
54162
  },
53945
54163
  alwaysSigner: {
@@ -53969,48 +54187,48 @@ var require_pkg_src2 = __commonJS2({
53969
54187
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
53970
54188
  },
53971
54189
  agentModuleExecutor: {
53972
- cid: "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf",
54190
+ cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
53973
54191
  authorizedCidHex: cidToHex(
53974
- "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf"
54192
+ "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
53975
54193
  ),
53976
54194
  name: "Agent Module Executor",
53977
54195
  description: "Production Agent Module Executor",
53978
54196
  version: "1.1.1",
53979
54197
  deployed: true,
53980
- deployedAt: 1787924032013,
53981
- size: 13878,
53982
- hash: "a7f0204700912e26e5a354bee13a1242a2baa218643b3bb22d28481f67f9baf4"
54198
+ deployedAt: 1790179978959,
54199
+ size: 14688,
54200
+ hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
53983
54201
  },
53984
54202
  staleSpendRecoveryValidator: {
53985
- cid: "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8",
54203
+ cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
53986
54204
  authorizedCidHex: cidToHex(
53987
- "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8"
54205
+ "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
53988
54206
  ),
53989
54207
  name: "Stale Spend Recovery Validator",
53990
54208
  description: "Production Stale Spend Recovery Validator",
53991
54209
  version: "1.1.2",
53992
54210
  deployed: true,
53993
- deployedAt: 1787924048772,
53994
- size: 41424,
53995
- hash: "3c5f028d2bef4344768462993616d45e30d9d44ef126e04d6eb579821d57d99c",
53996
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
54211
+ deployedAt: 1790246256280,
54212
+ size: 48143,
54213
+ hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
54214
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53997
54215
  pkp: {
53998
54216
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
53999
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
54217
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
54000
54218
  }
54001
54219
  },
54002
54220
  btcUtxoInvalidator: {
54003
- cid: "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf",
54221
+ cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
54004
54222
  authorizedCidHex: cidToHex(
54005
- "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf"
54223
+ "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
54006
54224
  ),
54007
54225
  name: "Btc Utxo Invalidator",
54008
54226
  description: "Production Btc Utxo Invalidator",
54009
54227
  version: "1.0.0",
54010
54228
  deployed: true,
54011
- deployedAt: 1787924133241,
54012
- size: 66026,
54013
- hash: "603bc50920d7f1dee77086f2c518d9e2922ab3858a419d3fbea8221ea3a6d9e9"
54229
+ deployedAt: 1790246264563,
54230
+ size: 69219,
54231
+ hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
54014
54232
  }
54015
54233
  };
54016
54234
  function getDeploymentsForNetwork(network) {
@@ -54756,7 +54974,7 @@ ${errorReport}`);
54756
54974
  }
54757
54975
  init_debug_logger();
54758
54976
  init_session_signature_cache();
54759
- var import_ethers232 = __require("ethers");
54977
+ var import_ethers242 = __require("ethers");
54760
54978
  var EXPIRED_LOAN_MIN_LIQUIDATION_THRESHOLD_BPS = 11e3;
54761
54979
  var GRACE_PERIOD_DAYS = 30;
54762
54980
  var SATOSHIS_PER_BITCOIN = 100000000n;
@@ -54778,7 +54996,10 @@ ${errorReport}`);
54778
54996
  BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
54779
54997
  BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
54780
54998
  LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
54781
- PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
54999
+ PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
55000
+ TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
55001
+ UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
55002
+ LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
54782
55003
  },
54783
55004
  11155111: {
54784
55005
  PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
@@ -54786,7 +55007,10 @@ ${errorReport}`);
54786
55007
  BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
54787
55008
  BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
54788
55009
  LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
54789
- PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
55010
+ PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
55011
+ TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
55012
+ UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
55013
+ LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
54790
55014
  }
54791
55015
  };
54792
55016
  function getPinnedContractAddresses(chainId) {
@@ -54972,10 +55196,10 @@ ${errorReport}`);
54972
55196
  };
54973
55197
  }
54974
55198
  const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
54975
- const collateralRatioBps = Number(ratioBigInt);
55199
+ const collateralRatioBps2 = Number(ratioBigInt);
54976
55200
  return {
54977
55201
  collateralValueUsd,
54978
- collateralRatioBps
55202
+ collateralRatioBps: collateralRatioBps2
54979
55203
  };
54980
55204
  }
54981
55205
  function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
@@ -55829,6 +56053,17 @@ ${auth.clientId}`;
55829
56053
  );
55830
56054
  }
55831
56055
  }
56056
+ var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
56057
+ var BitcoinTipUnreadableError = class extends Error {
56058
+ constructor(message) {
56059
+ super(message);
56060
+ this.isBitcoinTipUnreadable = true;
56061
+ this.name = "BitcoinTipUnreadableError";
56062
+ }
56063
+ };
56064
+ function isBitcoinTipUnreadableError(error) {
56065
+ return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
56066
+ }
55832
56067
  var BitcoinDataProvider = class {
55833
56068
  constructor(config) {
55834
56069
  this.config = config;
@@ -56280,27 +56515,12 @@ ${auth.clientId}`;
56280
56515
  if (!data.status.confirmed || !data.status.block_height) {
56281
56516
  return { txid: data.txid ?? txid, confirmations: 0 };
56282
56517
  }
56283
- try {
56284
- const tipResp = await fetch(
56285
- `${this.config.providerUrl}/blocks/tip/height`,
56286
- { signal: controller.signal, headers: await this.withAuth() }
56287
- );
56288
- if (!tipResp.ok) {
56289
- return { txid: data.txid ?? txid, confirmations: 1 };
56290
- }
56291
- const tipBody = (await tipResp.text()).trim();
56292
- const tipHeight = Number.parseInt(tipBody, 10);
56293
- if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
56294
- return { txid: data.txid ?? txid, confirmations: 1 };
56295
- }
56296
- const depth = tipHeight - data.status.block_height + 1;
56297
- return {
56298
- txid: data.txid ?? txid,
56299
- confirmations: depth > 0 ? depth : 0
56300
- };
56301
- } catch {
56302
- return { txid: data.txid ?? txid, confirmations: 1 };
56303
- }
56518
+ const tipHeight = await this.fetchTipHeight(controller.signal);
56519
+ const depth = tipHeight - data.status.block_height + 1;
56520
+ return {
56521
+ txid: data.txid ?? txid,
56522
+ confirmations: depth > 0 ? depth : 0
56523
+ };
56304
56524
  }
56305
56525
  return null;
56306
56526
  } catch (error) {
@@ -56308,12 +56528,55 @@ ${auth.clientId}`;
56308
56528
  if (isAbortError(error)) {
56309
56529
  throw new Error(`Request timeout after ${this.timeout}ms`);
56310
56530
  }
56531
+ if (isBitcoinTipUnreadableError(error)) {
56532
+ throw error;
56533
+ }
56311
56534
  if (getUnknownErrorMessage(error).includes("404")) {
56312
56535
  return null;
56313
56536
  }
56314
56537
  throw error;
56315
56538
  }
56316
56539
  }
56540
+ /**
56541
+ * Current chain tip height from THIS provider — or throw.
56542
+ *
56543
+ * Every exit is a throw naming the provider and the precise failure, because
56544
+ * the only alternative is inventing a confirmation depth (see the call site).
56545
+ * The single `try` exists solely to attach that name to a transport-level
56546
+ * rejection (DNS, TLS, connection reset, abort); it re-throws the cause
56547
+ * verbatim inside the message and never substitutes a value — authorized for
56548
+ * this case by the Batch 2 plan, §C2.
56549
+ *
56550
+ * @param signal - The caller's AbortSignal, so this read shares the same
56551
+ * timeout budget as the transaction fetch it serves.
56552
+ */
56553
+ async fetchTipHeight(signal) {
56554
+ const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
56555
+ let tipResp;
56556
+ try {
56557
+ tipResp = await fetch(endpoint, {
56558
+ signal,
56559
+ headers: await this.withAuth()
56560
+ });
56561
+ } catch (error) {
56562
+ throw new BitcoinTipUnreadableError(
56563
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
56564
+ );
56565
+ }
56566
+ if (!tipResp.ok) {
56567
+ throw new BitcoinTipUnreadableError(
56568
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
56569
+ );
56570
+ }
56571
+ const tipBody = (await tipResp.text()).trim();
56572
+ const tipHeight = Number.parseInt(tipBody, 10);
56573
+ if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
56574
+ throw new BitcoinTipUnreadableError(
56575
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
56576
+ );
56577
+ }
56578
+ return tipHeight;
56579
+ }
56317
56580
  /**
56318
56581
  * Get outputs (vouts) of a Bitcoin transaction
56319
56582
  *
@@ -56951,10 +57214,13 @@ ${auth.clientId}`;
56951
57214
  * only on unanimity. The confirmed-balance consensus the validators run
56952
57215
  * covers `chain_stats` only, so without this the primary provider alone
56953
57216
  * could fabricate an unconfirmed UTXO plus a self-consistent parent proof
56954
- * and inflate the signed balance. Any provider failure or verdict
56955
- * disagreement THROWS (fail-closed) — exclusion on a suppressed proof
56956
- * would deflate the balance and open a wrongful-liquidation window, so
56957
- * neither direction may proceed without agreement.
57217
+ * and inflate the signed balance. Any verdict disagreement THROWS
57218
+ * (fail-closed) — exclusion on a suppressed proof would deflate the balance
57219
+ * and open a wrongful-liquidation window, so neither direction may proceed
57220
+ * without agreement. A provider that cannot state the chain tip — and only
57221
+ * that failure — is dropped from the quorum rather than aborting the read (it
57222
+ * never counts as agreeing), and falling below `minConsensusProviders`
57223
+ * survivors throws — see `verifyParentIsSelfSpendConsensus`.
56958
57224
  *
56959
57225
  * The same per-provider `/tx` fetch also returns the parent's outputs, and
56960
57226
  * every provider must corroborate each claimed UTXO (index, vault address,
@@ -57049,10 +57315,26 @@ ${auth.clientId}`;
57049
57315
  }
57050
57316
  /**
57051
57317
  * Run the self-spend proof against every configured provider and require
57052
- * unanimity. Fail-closed: a provider request failure or a verdict
57053
- * disagreement throws and aborts the balance calculation — see
57318
+ * unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
57319
+ * a verdict mismatch throws and aborts the balance calculation — see
57054
57320
  * classifySelfChange for why exclusion is not a safe fallback here.
57055
57321
  *
57322
+ * Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
57323
+ * provider that could not state the chain tip (`BitcoinTipUnreadableError`).
57324
+ * It is ABSENT from the quorum — never counted as agreeing, never allowed to
57325
+ * decide the verdict — and the policy floor, not "at least one", decides when
57326
+ * that absence is fatal: below `minConsensusProviders` surviving readings
57327
+ * there is no cross-check left to trust, and the read fails loudly naming
57328
+ * every provider that dropped out.
57329
+ *
57330
+ * Why only that class. `getTransaction` now throws on an unreadable tip
57331
+ * instead of fabricating `confirmations: 1`; without this carve-out one flaky
57332
+ * `/blocks/tip/height` endpoint would take every balance and spend path down
57333
+ * with it. Every OTHER failure remains fatal, as before: a provider that
57334
+ * answers "I have never seen that transaction" is making a claim about the
57335
+ * chain rather than suffering an outage, and that shape is precisely the
57336
+ * fabricated-UTXO signature the fail-closed rule exists to catch.
57337
+ *
57056
57338
  * When the parent IS a unanimous self-spend, every provider's view of the
57057
57339
  * parent's OUTPUTS must additionally corroborate the primary's claimed
57058
57340
  * UTXOs (index exists, pays the vault, exact value). Without this, a
@@ -57077,32 +57359,52 @@ ${auth.clientId}`;
57077
57359
  )
57078
57360
  )
57079
57361
  );
57080
- const failures = settled.map((r, i) => ({ r, name: providerName(i) })).filter(
57081
- (x) => x.r.status === "rejected"
57082
- ).map(
57083
- ({ r, name }) => `${name} \u2192 ${r.reason?.message ?? String(r.reason)}`
57084
- );
57362
+ const answered = [];
57363
+ const absences = [];
57364
+ const failures = [];
57365
+ settled.forEach((result, i) => {
57366
+ if (result.status === "fulfilled") {
57367
+ answered.push({ index: i, evaluation: result.value });
57368
+ return;
57369
+ }
57370
+ const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
57371
+ if (isBitcoinTipUnreadableError(result.reason)) {
57372
+ absences.push(described);
57373
+ return;
57374
+ }
57375
+ failures.push(described);
57376
+ });
57085
57377
  if (failures.length > 0) {
57086
57378
  throw new Error(
57087
57379
  `Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
57088
57380
  );
57089
57381
  }
57090
- const evaluations = settled.map(
57091
- (r) => r.value
57092
- );
57093
- const votes = evaluations.map((e) => e.selfSpend);
57094
- const disagreements = votes.map((vote, i) => ({ vote, name: providerName(i) })).filter((x) => x.vote !== votes[0]).map(
57095
- (x) => `${providerName(0)}=${votes[0]} vs ${x.name}=${x.vote}`
57382
+ const floor = Math.max(1, this.minConsensusProviders);
57383
+ if (answered.length < floor) {
57384
+ throw new Error(
57385
+ `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("; ")}`
57386
+ );
57387
+ }
57388
+ if (absences.length > 0) {
57389
+ litDebugLog(
57390
+ `[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("; ")}`
57391
+ );
57392
+ }
57393
+ const first = answered[0];
57394
+ const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
57395
+ (a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
57096
57396
  );
57097
57397
  if (disagreements.length > 0) {
57098
57398
  throw new Error(
57099
57399
  `Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
57100
57400
  );
57101
57401
  }
57102
- if (!votes[0]) {
57402
+ if (!first.evaluation.selfSpend) {
57103
57403
  return false;
57104
57404
  }
57105
- const outputMismatches = evaluations.map((e, i) => e.outputMismatch ? `${providerName(i)} \u2192 ${e.outputMismatch}` : null).filter((m) => m !== null);
57405
+ const outputMismatches = answered.map(
57406
+ (a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
57407
+ ).filter((m) => m !== null);
57106
57408
  if (outputMismatches.length > 0) {
57107
57409
  throw new Error(
57108
57410
  `Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
@@ -57345,16 +57647,6 @@ ${auth.clientId}`;
57345
57647
  minConfirmations
57346
57648
  );
57347
57649
  const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
57348
- for (const spend of authorizedSpends) {
57349
- const utxoStillExists = utxoSet.utxos.some(
57350
- (utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
57351
- );
57352
- if (utxoStillExists) {
57353
- throw new Error(
57354
- `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.`
57355
- );
57356
- }
57357
- }
57358
57650
  const authorizedBalance = authorizedSpends.reduce(
57359
57651
  (sum, spend) => sum + spend.satoshis,
57360
57652
  0n
@@ -57650,7 +57942,13 @@ ${auth.clientId}`;
57650
57942
  allowDevSinglePriceProvider: false,
57651
57943
  minBitcoinBalanceConfirmations: 1,
57652
57944
  minBitcoinSpendConfirmations: 1,
57653
- minConsensusProviders: 1
57945
+ // 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
57946
+ // "by design", so the consensus floor was documented as a mainnet-only
57947
+ // guarantee. The registry now holds two, and leaving the floor at 1 meant
57948
+ // Sepolia could never exercise the multi-provider agreement the stale-spend
57949
+ // and balance paths rely on — the one environment where that logic is
57950
+ // supposed to be proved before mainnet.
57951
+ minConsensusProviders: 2
57654
57952
  },
57655
57953
  [
57656
57954
  "ethereum"
@@ -57684,12 +57982,12 @@ ${auth.clientId}`;
57684
57982
  }
57685
57983
  async function executeVaultSnapshot(params) {
57686
57984
  global.ethers = {
57687
- ...import_ethers232.ethers,
57985
+ ...import_ethers242.ethers,
57688
57986
  providers: {
57689
- StaticJsonRpcProvider: import_ethers232.ethers.JsonRpcProvider
57987
+ StaticJsonRpcProvider: import_ethers242.ethers.JsonRpcProvider
57690
57988
  },
57691
- Contract: import_ethers232.ethers.Contract,
57692
- utils: import_ethers232.ethers
57989
+ Contract: import_ethers242.ethers.Contract,
57990
+ utils: import_ethers242.ethers
57693
57991
  // v6 moved utils to top level
57694
57992
  };
57695
57993
  global.Lit = {
@@ -57959,7 +58257,6 @@ function getSepoliaConfig() {
57959
58257
  feeRecipientRegistry: SEPOLIA_CONTRACTS.FeeRecipientRegistry || "",
57960
58258
  positionDelegateRegistry: SEPOLIA_CONTRACTS.PositionDelegateRegistry || "",
57961
58259
  bitcoinWithdrawalAddressRegistry: SEPOLIA_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
57962
- carryAgentRegistry: SEPOLIA_CONTRACTS.CarryAgentRegistry || "",
57963
58260
  agentDelegationRegistry: SEPOLIA_CONTRACTS.AgentDelegationRegistry || "",
57964
58261
  dhAgentDelegate: SEPOLIA_CONTRACTS.DHAgentDelegate || "",
57965
58262
  agentModuleFactory: SEPOLIA_CONTRACTS.AgentModuleFactory || ""
@@ -58013,7 +58310,6 @@ function getMainnetConfig() {
58013
58310
  feeRecipientRegistry: MAINNET_CONTRACTS.FeeRecipientRegistry || "",
58014
58311
  positionDelegateRegistry: MAINNET_CONTRACTS.PositionDelegateRegistry || "",
58015
58312
  bitcoinWithdrawalAddressRegistry: MAINNET_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
58016
- carryAgentRegistry: MAINNET_CONTRACTS.CarryAgentRegistry || "",
58017
58313
  agentDelegationRegistry: MAINNET_CONTRACTS.AgentDelegationRegistry || "",
58018
58314
  dhAgentDelegate: MAINNET_CONTRACTS.DHAgentDelegate || "",
58019
58315
  // Empty on mainnet until the factory is deployed there — the ceremony is Sepolia-only.
@@ -58465,14 +58761,49 @@ var SDKError = class _SDKError extends Error {
58465
58761
  };
58466
58762
  }
58467
58763
  };
58764
+ var MAX_GAS_LIMIT = 5000000n;
58765
+ var MAX_FEE_PER_GAS_WEI = 2000000000000n;
58766
+ var DEFAULT_MAX_TX_FEE_WEI = 250000000000000000n;
58767
+ var PRIORITY_FEE_FLOOR_WEI = 100000000n;
58768
+ var PRIORITY_FEE_CAP_WEI = 3000000000n;
58769
+ var DEFAULT_FEE_CEILING = {
58770
+ maxGasLimit: MAX_GAS_LIMIT,
58771
+ maxFeePerGasWei: MAX_FEE_PER_GAS_WEI,
58772
+ maxTxFeeWei: DEFAULT_MAX_TX_FEE_WEI
58773
+ };
58774
+ function fmtEth(wei) {
58775
+ return `${import_ethers16.ethers.formatEther(wei)} ETH`;
58776
+ }
58777
+ function fmtGwei(wei) {
58778
+ return `${import_ethers16.ethers.formatUnits(wei, "gwei")} gwei`;
58779
+ }
58780
+ function worstCaseFeeWei(gasLimit, maxFeePerGas) {
58781
+ if (gasLimit == null || maxFeePerGas == null)
58782
+ return null;
58783
+ return gasLimit * maxFeePerGas;
58784
+ }
58785
+ function assertFeeCeiling(gasLimit, maxFeePerGas, raise, ceiling = DEFAULT_FEE_CEILING) {
58786
+ if (gasLimit != null && gasLimit > ceiling.maxGasLimit) {
58787
+ raise(`gasLimit ${gasLimit} exceeds the signing ceiling of ${ceiling.maxGasLimit}`);
58788
+ }
58789
+ if (maxFeePerGas != null && maxFeePerGas > ceiling.maxFeePerGasWei) {
58790
+ raise(
58791
+ `maxFeePerGas ${fmtGwei(maxFeePerGas)} exceeds the signing ceiling of ${fmtGwei(ceiling.maxFeePerGasWei)}`
58792
+ );
58793
+ }
58794
+ const worst = worstCaseFeeWei(gasLimit, maxFeePerGas);
58795
+ if (worst != null && worst > ceiling.maxTxFeeWei) {
58796
+ raise(
58797
+ `worst-case transaction fee ${fmtEth(worst)} (gasLimit ${gasLimit} \xD7 ${fmtGwei(maxFeePerGas)}) exceeds the signing ceiling of ${fmtEth(ceiling.maxTxFeeWei)}.${ceiling.raiseHint ? ` ${ceiling.raiseHint}` : ""}`
58798
+ );
58799
+ }
58800
+ }
58468
58801
  var MINT_UCD_GAS_CEILING = BigInt(13e5);
58469
58802
  var WITHDRAW_BTC_GAS_CEILING = BigInt(3e6);
58470
58803
  var MAKE_PAYMENT_GAS_CEILING = BigInt(1e6);
58471
58804
  var EXTEND_POSITION_GAS_CEILING = BigInt(1e6);
58472
58805
  var LIQUIDATION_COMMIT_GAS_CEILING = BigInt(1e6);
58473
58806
  var LIQUIDATION_REVEAL_GAS_CEILING = BigInt(2e6);
58474
- var PRIORITY_FEE_FLOOR_WEI = (0, import_ethers15.parseUnits)("0.1", "gwei");
58475
- var PRIORITY_FEE_CAP_WEI = (0, import_ethers15.parseUnits)("3", "gwei");
58476
58807
  var FEE_HISTORY_BLOCK_COUNT = 20;
58477
58808
  var FEE_HISTORY_REWARD_PERCENTILE = 75;
58478
58809
  function isJsonRpcSendable(provider) {
@@ -58945,7 +59276,7 @@ async function getPKPPublicKeyFromTokenId(pkpTokenId, provider, pkpNftContractAd
58945
59276
  `pkpNftContractAddress is required for getPKPPublicKeyFromTokenId`
58946
59277
  );
58947
59278
  }
58948
- const pkpNft = new import_ethers16.Contract(
59279
+ const pkpNft = new import_ethers17.Contract(
58949
59280
  pkpNftContractAddress,
58950
59281
  PKP_NFT_ABI,
58951
59282
  provider
@@ -58982,7 +59313,7 @@ async function generateBalanceConfirmationAuthorization(positionId, chainId, sig
58982
59313
  const timestamp = calculateNextQuantumTimestamp();
58983
59314
  const caller = await signer.getAddress();
58984
59315
  const action = "confirm-balance";
58985
- const actionHash = (0, import_ethers16.keccak256)((0, import_ethers16.toUtf8Bytes)(action));
59316
+ const actionHash = (0, import_ethers17.keccak256)((0, import_ethers17.toUtf8Bytes)(action));
58986
59317
  const types = [
58987
59318
  "bytes32",
58988
59319
  // positionId
@@ -58996,8 +59327,8 @@ async function generateBalanceConfirmationAuthorization(positionId, chainId, sig
58996
59327
  // actionHash
58997
59328
  ];
58998
59329
  const values = [positionId, timestamp, chainId, caller, actionHash];
58999
- const messageHash = (0, import_ethers16.solidityPackedKeccak256)(types, values);
59000
- const messageHashBytes = (0, import_ethers16.getBytes)(messageHash);
59330
+ const messageHash = (0, import_ethers17.solidityPackedKeccak256)(types, values);
59331
+ const messageHashBytes = (0, import_ethers17.getBytes)(messageHash);
59001
59332
  const signature = await signer.signMessage(messageHashBytes);
59002
59333
  return {
59003
59334
  positionId,
@@ -59051,6 +59382,51 @@ async function resolveAuthorizationInput(provider, signer, ctx) {
59051
59382
  }
59052
59383
  return { timestamp: result.timestamp, signature: result.signature };
59053
59384
  }
59385
+ var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
59386
+ function segwitProgramShape(address) {
59387
+ const lower2 = address.trim().toLowerCase();
59388
+ if (!/^(bc1|tb1|bcrt1)/.test(lower2))
59389
+ return null;
59390
+ const sep = lower2.lastIndexOf("1");
59391
+ const data = lower2.slice(sep + 1);
59392
+ if (data.length < 8)
59393
+ return null;
59394
+ const version2 = BECH32_CHARSET.indexOf(data[0]);
59395
+ if (version2 < 0)
59396
+ return null;
59397
+ const programChars = data.length - 1 - 6;
59398
+ return { version: version2, programBytes: Math.floor(programChars * 5 / 8) };
59399
+ }
59400
+ function dustLimitForAddress(address) {
59401
+ const shape = segwitProgramShape(address);
59402
+ if (shape === null)
59403
+ return 546;
59404
+ if (shape.version === 0 && shape.programBytes === 20)
59405
+ return 294;
59406
+ if (shape.version === 0 && shape.programBytes === 32)
59407
+ return 330;
59408
+ if (shape.version === 1 && shape.programBytes === 32)
59409
+ return 330;
59410
+ return 546;
59411
+ }
59412
+ function destinationDustShortfall(targetAmount, networkFee, destination) {
59413
+ const limit = dustLimitForAddress(destination);
59414
+ return targetAmount - networkFee < limit ? limit : null;
59415
+ }
59416
+ function calculateMintFee(params) {
59417
+ const { mintAmount, mintTimestamp, originationFeeBps, previousExpiryAt, selectedTerm, totalTerm } = params;
59418
+ let mintFee = mintAmount * BigInt(originationFeeBps) / 10000n;
59419
+ if (previousExpiryAt > 0 && mintTimestamp < previousExpiryAt) {
59420
+ const tailSeconds = BigInt(previousExpiryAt) - BigInt(mintTimestamp);
59421
+ const originalTermMonths = totalTerm - selectedTerm;
59422
+ const originalTermSeconds = BigInt(
59423
+ originalTermMonths === 12 ? 365 * 86400 : originalTermMonths * 30 * 86400
59424
+ );
59425
+ const tailFee = tailSeconds * BigInt(originationFeeBps) * mintAmount / (10000n * originalTermSeconds);
59426
+ mintFee = mintFee + tailFee;
59427
+ }
59428
+ return mintFee;
59429
+ }
59054
59430
  function baseMintFeeWei(mintAmountWei, originationFeeBps) {
59055
59431
  if (mintAmountWei < 0n)
59056
59432
  throw new Error("baseMintFeeWei: mintAmountWei cannot be negative");
@@ -59069,20 +59445,34 @@ function debtAfterMintExceedsLoanCap(params) {
59069
59445
  }
59070
59446
  return currentDebtWei + mintAmountWei + mintFeeWei > maxLoanWei;
59071
59447
  }
59072
- function maxPrincipalWithinLoanCap(params) {
59073
- const { maxLoanWei, currentDebtWei, originationFeeBps } = params;
59074
- if (maxLoanWei < 0n || currentDebtWei < 0n) {
59075
- throw new Error("maxPrincipalWithinLoanCap: amounts cannot be negative");
59448
+ function collateralRatioBps(sats, price8, debtWei) {
59449
+ if (sats < 0n || price8 < 0n) {
59450
+ throw new Error("collateralRatioBps: sats and price cannot be negative");
59076
59451
  }
59077
- if (!Number.isInteger(originationFeeBps) || originationFeeBps < 0 || originationFeeBps > 1e4) {
59078
- throw new Error(
59079
- `maxPrincipalWithinLoanCap: originationFeeBps must be an integer in [0, 10000] (got ${String(originationFeeBps)})`
59080
- );
59452
+ if (debtWei <= 0n) {
59453
+ throw new Error("collateralRatioBps: debt must be positive");
59081
59454
  }
59082
- const room = maxLoanWei - currentDebtWei;
59083
- if (room <= 0n)
59084
- return 0n;
59085
- return room * 10000n / (10000n + BigInt(originationFeeBps));
59455
+ return sats * price8 * 100n * 10000n / debtWei;
59456
+ }
59457
+ function collateralRatioPercentString(sats, price8, debtWei) {
59458
+ const bps = collateralRatioBps(sats, price8, debtWei);
59459
+ return `${bps / 100n}.${(bps % 100n).toString().padStart(2, "0")}`;
59460
+ }
59461
+ function maxPrincipalForFee(room, fee) {
59462
+ if (room < 0n)
59463
+ throw new Error("maxPrincipalForFee: room cannot be negative");
59464
+ if (fee(0n) !== 0n)
59465
+ throw new Error("maxPrincipalForFee: fee(0) must be 0");
59466
+ let lo = 0n;
59467
+ let hi = room;
59468
+ while (lo < hi) {
59469
+ const mid = (lo + hi + 1n) / 2n;
59470
+ if (mid + fee(mid) <= room)
59471
+ lo = mid;
59472
+ else
59473
+ hi = mid - 1n;
59474
+ }
59475
+ return lo;
59086
59476
  }
59087
59477
  function buildLoginDomain(chainId) {
59088
59478
  return {
@@ -59129,7 +59519,7 @@ async function buildSignedLoginPayload(signer, chainId, audience, reuse, withSta
59129
59519
  ...statement ? { statement } : {},
59130
59520
  address,
59131
59521
  issuedAt: reuse?.issuedAt ?? Math.floor(Date.now() / 1e3),
59132
- nonce: reuse?.nonce ?? (0, import_ethers18.hexlify)((0, import_ethers18.randomBytes)(32)),
59522
+ nonce: reuse?.nonce ?? (0, import_ethers19.hexlify)((0, import_ethers19.randomBytes)(32)),
59133
59523
  ...audience ? { audience } : {}
59134
59524
  };
59135
59525
  const signature = await signer.signTypedData(
@@ -59730,16 +60120,13 @@ var ERROR_STRING_SELECTOR = "0x08c379a0";
59730
60120
  var PANIC_SELECTOR = "0x4e487b71";
59731
60121
  var QUANTUM_REVERT_NAMES = {
59732
60122
  "0xbe4b82c1": "DeadZoneViolation()",
59733
- "0x137f3b70": "InDeadZone()",
59734
- "0x131d9a21": "QuantumExpired()",
59735
60123
  "0x52ce5d58": "QuantumAlreadyUsed()",
59736
60124
  "0x3e76a3c9": "QuantumOutsideWindow()",
59737
- "0x8baa579f": "InvalidSignature()",
59738
60125
  "0x62278171": "InvalidValidatorSignature()",
59739
- "0x3ee5aeb5": "OperationNotAuthorized()",
59740
- "0x48f5c3ed": "Unauthorized()",
59741
- "0x70f4b32a": "UnauthorizedSigner()",
59742
- "0xd92e233d": "ValidationFailed()",
60126
+ "0x82b42900": "Unauthorized()",
60127
+ "0x3ee5aeb5": "ReentrancyGuardReentrantCall()",
60128
+ "0x0a0b0d79": "ValidationFailed()",
60129
+ "0xd92e233d": "ZeroAddress()",
59743
60130
  "0x36bfdeea": "StateHashMismatch()",
59744
60131
  "0xb9d419a7": "DebtUpdateVerificationFailed()",
59745
60132
  "0xc7e20553": "DebtUpdateVerificationFailedDetailed(bytes32,uint256,uint256,uint256,uint256,uint256)",
@@ -59755,13 +60142,13 @@ function decodeQuantumRevert(e) {
59755
60142
  if (!name && selector && data) {
59756
60143
  try {
59757
60144
  if (selector === ERROR_STRING_SELECTOR) {
59758
- const [message] = import_ethers19.AbiCoder.defaultAbiCoder().decode(
60145
+ const [message] = import_ethers20.AbiCoder.defaultAbiCoder().decode(
59759
60146
  ["string"],
59760
60147
  "0x" + data.slice(10)
59761
60148
  );
59762
60149
  name = `Error("${message}")`;
59763
60150
  } else if (selector === PANIC_SELECTOR) {
59764
- const [code] = import_ethers19.AbiCoder.defaultAbiCoder().decode(
60151
+ const [code] = import_ethers20.AbiCoder.defaultAbiCoder().decode(
59765
60152
  ["uint256"],
59766
60153
  "0x" + data.slice(10)
59767
60154
  );
@@ -60009,12 +60396,12 @@ var RECOVERY_INVALIDATE_ACTION = "btc-utxo-invalidator";
60009
60396
  var QUANTUM_SECONDS = 60;
60010
60397
  var QUANTUM_SAFE_THRESHOLD = 40;
60011
60398
  function buildInvalidateMessageHash(params) {
60012
- const positionIdBytes32 = (0, import_ethers20.zeroPadValue)(
60399
+ const positionIdBytes32 = (0, import_ethers21.zeroPadValue)(
60013
60400
  params.positionId.startsWith("0x") ? params.positionId : `0x${params.positionId}`,
60014
60401
  32
60015
60402
  );
60016
- const actionHash = (0, import_ethers20.keccak256)((0, import_ethers20.toUtf8Bytes)(RECOVERY_INVALIDATE_ACTION));
60017
- return (0, import_ethers20.solidityPackedKeccak256)(
60403
+ const actionHash = (0, import_ethers21.keccak256)((0, import_ethers21.toUtf8Bytes)(RECOVERY_INVALIDATE_ACTION));
60404
+ return (0, import_ethers21.solidityPackedKeccak256)(
60018
60405
  [
60019
60406
  "bytes32",
60020
60407
  // positionId
@@ -60060,7 +60447,7 @@ async function buildInvalidateStaleSpendEnvelope(params) {
60060
60447
  utxoTxid,
60061
60448
  utxoVout
60062
60449
  });
60063
- const signature = await signer.signMessage((0, import_ethers20.getBytes)(messageHash));
60450
+ const signature = await signer.signMessage((0, import_ethers21.getBytes)(messageHash));
60064
60451
  const borrowerAddress = await signer.getAddress();
60065
60452
  return {
60066
60453
  positionId,
@@ -60103,7 +60490,7 @@ function hashBtcInputSet(utxos) {
60103
60490
  seen.add(key);
60104
60491
  }
60105
60492
  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("|");
60106
- return (0, import_ethers21.keccak256)((0, import_ethers21.toUtf8Bytes)(canonical));
60493
+ return (0, import_ethers22.keccak256)((0, import_ethers22.toUtf8Bytes)(canonical));
60107
60494
  }
60108
60495
  async function buildBtcExecuteEnvelope(params) {
60109
60496
  const {
@@ -60148,15 +60535,15 @@ async function buildBtcExecuteEnvelope(params) {
60148
60535
  } else {
60149
60536
  timestamp = currentQuantumStart;
60150
60537
  }
60151
- const actionHash = (0, import_ethers21.keccak256)(
60152
- (0, import_ethers21.toUtf8Bytes)("execute-btc-withdrawal")
60538
+ const actionHash = (0, import_ethers22.keccak256)(
60539
+ (0, import_ethers22.toUtf8Bytes)("execute-btc-withdrawal")
60153
60540
  );
60154
60541
  const utxoIdentifier = `${txid}:${vout}`;
60155
- const positionIdBytes32 = (0, import_ethers21.zeroPadValue)(
60542
+ const positionIdBytes32 = (0, import_ethers22.zeroPadValue)(
60156
60543
  positionId.startsWith("0x") ? positionId : `0x${positionId}`,
60157
60544
  32
60158
60545
  );
60159
- const messageHash = (0, import_ethers21.solidityPackedKeccak256)(
60546
+ const messageHash = (0, import_ethers22.solidityPackedKeccak256)(
60160
60547
  [
60161
60548
  "bytes32",
60162
60549
  // positionId
@@ -60189,7 +60576,7 @@ async function buildBtcExecuteEnvelope(params) {
60189
60576
  actionHash
60190
60577
  ]
60191
60578
  );
60192
- const userSignature = await signer.signMessage((0, import_ethers21.getBytes)(messageHash));
60579
+ const userSignature = await signer.signMessage((0, import_ethers22.getBytes)(messageHash));
60193
60580
  const borrowerAddress = await signer.getAddress();
60194
60581
  return {
60195
60582
  positionId,
@@ -60557,7 +60944,7 @@ function rowToStatus(row) {
60557
60944
  return row;
60558
60945
  }
60559
60946
  async function fetchProtocolPauseStatus(provider, positionManagerAddress) {
60560
- const iface = new import_ethers23.Interface(GET_PROTOCOL_PAUSE_STATUS_ABI);
60947
+ const iface = new import_ethers24.Interface(GET_PROTOCOL_PAUSE_STATUS_ABI);
60561
60948
  const data = iface.encodeFunctionData("getProtocolPauseStatus", []);
60562
60949
  const raw = await provider.call({ to: positionManagerAddress, data });
60563
60950
  const decoded = iface.decodeFunctionResult("getProtocolPauseStatus", raw);
@@ -60747,38 +61134,38 @@ var ContractManager = class {
60747
61134
  }
60748
61135
  const contractRunner = runner;
60749
61136
  const contracts = {
60750
- positionManager: new import_ethers24.Contract(
61137
+ positionManager: new import_ethers25.Contract(
60751
61138
  contractAddresses.positionManager,
60752
61139
  POSITION_MANAGER_ABI,
60753
61140
  contractRunner
60754
61141
  ),
60755
- loanOperationsManager: new import_ethers24.Contract(
60756
- contractAddresses.loanOperationsManager || import_ethers24.ZeroAddress,
61142
+ loanOperationsManager: new import_ethers25.Contract(
61143
+ contractAddresses.loanOperationsManager || import_ethers25.ZeroAddress,
60757
61144
  LOAN_OPS_ABI,
60758
61145
  contractRunner
60759
61146
  ),
60760
- ucdController: new import_ethers24.Contract(
61147
+ ucdController: new import_ethers25.Contract(
60761
61148
  contractAddresses.ucdToken,
60762
61149
  UCD_CONTROLLER_ABI,
60763
61150
  contractRunner
60764
61151
  ),
60765
- termManager: new import_ethers24.Contract(
60766
- contractAddresses.termManager || import_ethers24.ZeroAddress,
61152
+ termManager: new import_ethers25.Contract(
61153
+ contractAddresses.termManager || import_ethers25.ZeroAddress,
60767
61154
  TERM_MANAGER_ABI,
60768
61155
  contractRunner
60769
61156
  ),
60770
- circuitBreaker: new import_ethers24.Contract(
60771
- contractAddresses.circuitBreaker || import_ethers24.ZeroAddress,
61157
+ circuitBreaker: new import_ethers25.Contract(
61158
+ contractAddresses.circuitBreaker || import_ethers25.ZeroAddress,
60772
61159
  CIRCUIT_BREAKER_ABI,
60773
61160
  contractRunner
60774
61161
  ),
60775
- liquidationManager: new import_ethers24.Contract(
60776
- contractAddresses.liquidationManager || import_ethers24.ZeroAddress,
61162
+ liquidationManager: new import_ethers25.Contract(
61163
+ contractAddresses.liquidationManager || import_ethers25.ZeroAddress,
60777
61164
  LIQUIDATION_MANAGER_ABI,
60778
61165
  contractRunner
60779
61166
  ),
60780
- bitcoinWithdrawalAddressRegistry: new import_ethers24.Contract(
60781
- contractAddresses.bitcoinWithdrawalAddressRegistry || import_ethers24.ZeroAddress,
61167
+ bitcoinWithdrawalAddressRegistry: new import_ethers25.Contract(
61168
+ contractAddresses.bitcoinWithdrawalAddressRegistry || import_ethers25.ZeroAddress,
60782
61169
  BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_ABI,
60783
61170
  contractRunner
60784
61171
  )
@@ -60827,13 +61214,13 @@ var ContractManager = class {
60827
61214
  const address = addresses[key];
60828
61215
  if (!address) {
60829
61216
  missing.push(String(key));
60830
- } else if (!(0, import_ethers24.isAddress)(address)) {
61217
+ } else if (!(0, import_ethers25.isAddress)(address)) {
60831
61218
  invalid.push(String(key));
60832
61219
  }
60833
61220
  }
60834
61221
  for (const key of optionalAddresses) {
60835
61222
  const address = addresses[key];
60836
- if (address && !(0, import_ethers24.isAddress)(address)) {
61223
+ if (address && !(0, import_ethers25.isAddress)(address)) {
60837
61224
  invalid.push(String(key));
60838
61225
  }
60839
61226
  }
@@ -62148,11 +62535,11 @@ var LoanCreator = class {
62148
62535
  try {
62149
62536
  const mainnetVaultAddress = bitcoinAddresses.mainnet;
62150
62537
  const regtestVaultAddress = bitcoinAddresses.regtest;
62151
- const pkpIdBytes32 = (0, import_ethers25.zeroPadValue)(
62152
- (0, import_ethers25.toBeHex)(BigInt(pkpData.tokenId)),
62538
+ const pkpIdBytes32 = (0, import_ethers26.zeroPadValue)(
62539
+ (0, import_ethers26.toBeHex)(BigInt(pkpData.tokenId)),
62153
62540
  32
62154
62541
  );
62155
- const pkpPublicKeyUncompressed = import_ethers25.SigningKey.computePublicKey(
62542
+ const pkpPublicKeyUncompressed = import_ethers26.SigningKey.computePublicKey(
62156
62543
  pkpData.publicKey,
62157
62544
  false
62158
62545
  );
@@ -62165,7 +62552,7 @@ var LoanCreator = class {
62165
62552
  );
62166
62553
  log.debug(`BigInt conversion: ${BigInt(pkpData.tokenId).toString()}`);
62167
62554
  log.debug(
62168
- `Hex from BigInt: ${(0, import_ethers25.toBeHex)(BigInt(pkpData.tokenId))}`
62555
+ `Hex from BigInt: ${(0, import_ethers26.toBeHex)(BigInt(pkpData.tokenId))}`
62169
62556
  );
62170
62557
  log.debug(`Final bytes32 (zero-padded): ${pkpIdBytes32}`);
62171
62558
  log.debug(
@@ -62337,8 +62724,8 @@ var LoanCreator = class {
62337
62724
  }
62338
62725
  }
62339
62726
  if (this.config.debug) {
62340
- const pkpIdBytes32Check = (0, import_ethers25.zeroPadValue)(
62341
- (0, import_ethers25.toBeHex)(BigInt(pkpData.tokenId)),
62727
+ const pkpIdBytes32Check = (0, import_ethers26.zeroPadValue)(
62728
+ (0, import_ethers26.toBeHex)(BigInt(pkpData.tokenId)),
62342
62729
  32
62343
62730
  );
62344
62731
  log.error("\u274C Loan creation transaction failed", {
@@ -62499,7 +62886,7 @@ var LoanCreator = class {
62499
62886
  const coreAddress = this.config.contractManager.getContractAddresses().positionManagerCore;
62500
62887
  if (coreAddress) {
62501
62888
  try {
62502
- const core = new import_ethers25.Contract(
62889
+ const core = new import_ethers26.Contract(
62503
62890
  coreAddress,
62504
62891
  [
62505
62892
  "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))"
@@ -62541,8 +62928,8 @@ var LoanCreator = class {
62541
62928
  const newEventAbi = [
62542
62929
  "event PositionCreated(bytes32 indexed positionId, bytes32 indexed pkpId, address indexed borrower, uint256 requestedCollateralRatio, uint256 selectedTerm, uint256 expiryAt)"
62543
62930
  ];
62544
- const oldIface = new import_ethers25.Interface(oldEventAbi);
62545
- const newIface = new import_ethers25.Interface(newEventAbi);
62931
+ const oldIface = new import_ethers26.Interface(oldEventAbi);
62932
+ const newIface = new import_ethers26.Interface(newEventAbi);
62546
62933
  let positionId;
62547
62934
  if (this.config.debug) {
62548
62935
  log.info("\u{1F50D} Parsing transaction receipt logs", {
@@ -63022,7 +63409,7 @@ var LoanQuery = class {
63022
63409
  const isChipotlePkpId2 = typeof rawId === "string" && isNormalizedChipotlePkpId(rawId);
63023
63410
  if (isChipotlePkpId2) {
63024
63411
  if (this.config.positionManagerCoreAddress && this.config.provider) {
63025
- const pmContract = new import_ethers26.Contract(
63412
+ const pmContract = new import_ethers27.Contract(
63026
63413
  this.config.positionManagerCoreAddress,
63027
63414
  POSITION_CORE_ABI,
63028
63415
  this.config.provider
@@ -63125,7 +63512,7 @@ var LoanQuery = class {
63125
63512
  */
63126
63513
  async getBorrowerUcdDebtSummary(borrower) {
63127
63514
  const trimmed = typeof borrower === "string" ? borrower.trim() : "";
63128
- if (!(0, import_ethers26.isAddress)(trimmed)) {
63515
+ if (!(0, import_ethers27.isAddress)(trimmed)) {
63129
63516
  return failure(
63130
63517
  new SDKError({
63131
63518
  message: `Borrower must be an EVM address for a UCD debt summary, got "${trimmed}"`,
@@ -63400,7 +63787,7 @@ var WithdrawalAddressModule = class {
63400
63787
  if (!res.success)
63401
63788
  return res;
63402
63789
  const target = res.value.target;
63403
- if (!target || target === import_ethers27.ZeroAddress) {
63790
+ if (!target || target === import_ethers28.ZeroAddress) {
63404
63791
  return failure(
63405
63792
  new SDKError({
63406
63793
  code: "SDK_WITHDRAWAL_REGISTRY_NOT_CONFIGURED",
@@ -63419,7 +63806,7 @@ var WithdrawalAddressModule = class {
63419
63806
  }
63420
63807
  /** keccak256 of the canonicalized address — matches the on-chain key. */
63421
63808
  static addressHash(btcAddress2) {
63422
- return (0, import_ethers27.keccak256)((0, import_ethers27.toUtf8Bytes)(normalizeBitcoinAddress(btcAddress2)));
63809
+ return (0, import_ethers28.keccak256)((0, import_ethers28.toUtf8Bytes)(normalizeBitcoinAddress(btcAddress2)));
63423
63810
  }
63424
63811
  /**
63425
63812
  * Add a Bitcoin address to the caller's allowlist. It becomes usable only
@@ -69439,7 +69826,7 @@ var _abi = [
69439
69826
  ];
69440
69827
  var _bytecode = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161485a90816100f0823960805181818161278e01526128870152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c8062f7fce91461384657806301ffc9a7146137d5578063021d28931461377c5780630871b20614613743578063114249d214610f6157806311d954f81461371a57806313da3166146136e15780631d44a904146136385780631f77bf65146135ff578063248a9ca3146135e05780632b83cccd146131205780632f2ff15d146130ee57806334bac370146130b557806334e181251461307c57806336568abe14613037578063373c86b614612ffe5780633f4ba83a14612f375780634373b57214612f0e5780634451e89b14612b3a5780634ebd25a514612b015780634f1ef2861461280c5780635273b6f6146127e357806352d1902d1461277b578063568fafca146126ed57806359d5d02a146124205780635bc26aea146123eb5780635c975abb146123bb5780635ecc27081461229d5780638456cb59146121a257806385c15d9a1461216957806389d3ad00146120a25780638bff608e146120695780639010d07c1461201657806390ad8b4014611ffa57806391d1485414611fa15780639b759bf714611f5e5780639baf58d214611f415780639f1d0f59146118a8578063a217fddf1461188c578063a3246ad3146117cf578063ad3cb1cc14611788578063b492fc691461168e578063b9f637af14611463578063bf7d911914611424578063c4c5f62414611371578063c55f15ea1461134e578063ca15c87314611317578063ca2ce65d146112de578063cc1f8ffa146112ac578063cf46075e146111a2578063d21a74ff14611165578063d2f8253614611142578063d547741f14611107578063d5d3f78b14610f9a578063d66bd52414610f61578063e1f1c4a714610f44578063e1f3962c14610f18578063ec2f96fe14610ef4578063eda5a26a14610af7578063f1a1eb8414610ab4578063f385116d14610a7b578063f77c479114610a54578063f8c8765e14610661578063faaebd2114610628578063facdfb5e14610488578063fc99bd9a14610377578063fe32e7281461033e5763ffa1ad741461030857600080fd5b3461033b578060031936011261033b57610337610323613a68565b604051918291602083526020830190613a17565b0390f35b80fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361036661392e565b168152601283522054604051908152f35b503461033b57604036600319011261033b5761039161392e565b6010546024359291906001600160a01b03163303610479576001600160a01b03168082526002602052604082205490929060ff16156104665780156104575782825260076020526040822054926103e88285613cb0565b848110610448576001600160ff1b0381116104395760008051602061482e833981519152604085968493846104369852600760205280838a205582519182526020820152a23090339061421c565b80f35b630700fcb360e11b8452600484fd5b63446c8cc960e01b8452600484fd5b63162908e360e11b8252600482fd5b506024916374ed46ad60e01b8252600452fd5b6349db3bd360e01b8252600482fd5b503461033b57602036600319011261033b576104a261392e565b6104aa613f12565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff161561061657808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa90811561060b5784916105d4575b50818111156105c5576105248282613b6c565b8215908115610570575b505060008051602061482e833981519152916040918486526007602052808387205582519182526020820152a260016000805160206147ce8339815191525580f35b61271081029080820461271014901517156105b157606484029184830460641417156105b157116105a257388061052e565b63a73af74d60e01b8452600484fd5b634e487b7160e01b86526011600452602486fd5b6105cf8183613b6c565b610524565b90506020813d602011610603575b816105ef602093836139c3565b810103126105fe575138610511565b600080fd5b3d91506105e2565b6040513d86823e3d90fd5b6374ed46ad60e01b8252600452602490fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361065061392e565b168152600483522054604051908152f35b503461033b57608036600319011261033b5761067b61392e565b610683613944565b6044356001600160a01b03811690818103610a50576064356001600160a01b0381169390849003610a4c5760008051602061480e83398151915254604081901c60ff161595906001600160401b031680159081610a44575b6001149081610a3a575b159081610a31575b50610a225760008051602061480e83398151915280546001600160401b0319166001179055856109fd575b6001600160a01b03169081156109ee576001600160a01b03169081156109df5783156109d05761074661448a565b61074e61448a565b61075661448a565b61075e61448a565b60016000805160206147ce8339815191525561077861448a565b61078061448a565b86546001600160a01b0319908116919091178755600180549182168317905560405163313ce56760e01b8152909190602081600481855afa88918161099f575b506107d457633a24e95b60e11b8852600488fd5b6001600160a81b03199092161760a091821b60ff60a01b16176001819055901c60ff16601119810161098d575061080b8186614348565b80610965575b156109205761082e816000805160206147ee833981519152614348565b8061092f575b15610920576108519060008051602061470e833981519152614348565b90816108e9575b50156108da57806108af575b5061086c5780f35b60ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160018152a180f35b601080546001600160a01b031916821790558260008051602061474e8339815191528180a338610864565b63cf5a8e3360e01b8352600483fd5b6109199060008051602061470e83398151915286526000805160206146ae833981519152602052604086206144d0565b5038610858565b63cf5a8e3360e01b8552600485fd5b6000805160206147ee83398151915286526000805160206146ae83398151915260205261095f83604088206144d0565b50610834565b8580526000805160206146ae83398151915260205261098783604088206144d0565b50610811565b63167738cf60e21b8652600452602485fd5b6109c291925060203d6020116109c9575b6109ba81836139c3565b810190613ba9565b90386107c0565b503d6109b0565b630b5eba9f60e41b8752600487fd5b63c1ab6dc160e01b8752600487fd5b6336abb4df60e11b8752600487fd5b60008051602061480e833981519152805460ff60401b1916600160401b179055610718565b63f92ee8a960e01b8752600487fd5b905015386106ed565b303b1591506106e5565b8791506106db565b8580fd5b8480fd5b503461033b578060031936011261033b57546040516001600160a01b039091168152602090f35b503461033b57602036600319011261033b576020906040906001600160a01b03610aa361392e565b168152600a83522054604051908152f35b503461033b57604036600319011261033b576020906040906001600160a01b03610adc61392e565b16815260158352818120602435825283522054604051908152f35b503461033b5761016036600319011261033b57610b1261392e565b90606435604435602435610b24613a58565b9160a4359160c43560e43561010435916101243595610144359760018060a01b03601054163303610ee5576001600160a01b038c16808c52600260205260408c2054909a9060ff16610ed1578a15610ec2578615610eb3576127108811610e99576103e88111610e815760ff82169c60128e118e8115610e76575b50610e6257803b15610e4e578915610e3a578a15610e265782610bc191614260565b84151580610e1d575b610e065785151580610dfd575b610de6578b9c602460208d9e9d604051928380926370a0823160e01b82523060048301525afa9c8d15610dda579c610da6575b506001600160ff1b038c11610d97578a8d8f9760408f97838f918f8f8f8f90859f988f99879f9660008051602061476e8339815191529f978b9f988f8d6000805160206146ce8339815191529f988e8e610d4f9b60008051602061468e8339815191529f8f8f8487526002602052878720600160ff198254161790558487526003602052878720558386526004602052868620558285526006602052878686205582855260056020528585209060ff19825416179055818452600c6020528885852055818452600d6020528985852055818452600e6020528a85852055818452600f6020528b8585205581845260076020528484205582526012602052828220558d8152601360205220558a7f991d1ef1b5c0820d213328cba6682059e00a50e49c469a454eb3557e78eaf6668e80518b81528c6020820152a28c5198899889613cbd565b0390a28151908b82526020820152a28151908782526020820152a280610d73578280f35b604060008051602061482e833981519152918151908582526020820152a281808280f35b63556e7a8160e01b8e5260048efd5b909b506020813d602011610dd2575b81610dc2602093836139c3565b810103126105fe57519a38610c0a565b3d9150610db5565b604051903d90823e3d90fd5b60448c858863dd85772b60e01b8352600452602452fd5b50838610610bd7565b60448c8487637449915760e01b8352600452602452fd5b50828510610bca565b636835314760e11b8d52600160045260248dfd5b636835314760e11b8d5260048d905260248dfd5b63377e3f9960e21b8d5260048c905260248dfd5b63ca95039160e01b8d5260048e905260248dfd5b60069150108e610b9f565b631051834f60e11b8c526004526103e860245260448bfd5b63c1e9a14160e01b8c52600488905261271060245260448cfd5b63a2ec3a5560e01b8c5260048cfd5b63df407ac560e01b8c5260048cfd5b6317f4215b60e21b8c5260048b905260248cfd5b6349db3bd360e01b8b5260048bfd5b503461033b578060031936011261033b57602060ff60015460a01c16604051908152f35b503461033b57602036600319011261033b576020610f3c610f3761392e565b613df5565b604051908152f35b503461033b578060031936011261033b5760206040516127108152f35b503461033b57602036600319011261033b576020906040906001600160a01b03610f8961392e565b168152600783522054604051908152f35b503461033b57602036600319011261033b57610fb461392e565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff16156106165780825260076020526040822054806110f1575080825260026020526040822060ff1981541690558082526003602052816040812055808252600460205281604081205580825260056020526040822060ff198154169055808252600c602052816040812055808252600d602052816040812055808252600e602052816040812055808252600f602052816040812055808252600660205281604081205580825260076020526040822054818352600760205282604081205560405190827f3302a1b37f04242bb55603f5449e7ecd690a35eef08ba1353c48c20e2aae9cda8580a2806110ce578380f35b8160409160008051602061482e8339815191529352846020820152a23880808380f35b604492916376bc059760e11b8352600452602452fd5b503461033b57604036600319011261033b5761113e600435611127613944565b9061113961113482613b79565b614088565b61411a565b5080f35b503461033b578060031936011261033b57602060ff600854166040519015158152f35b503461033b57602036600319011261033b5760209060ff906040906001600160a01b0361119061392e565b16815260058452205416604051908152f35b503461033b57602036600319011261033b576111bc61392e565b6111c4613f12565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff161561061657808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa90811561060b57849161126c575b5060008051602061482e833981519152916040918486526007602052808387205582519182526020820152a260016000805160206147ce8339815191525580f35b90506020813d6020116112a4575b81611287602093836139c3565b810103126105fe575160008051602061482e83398151915261122b565b3d915061127a565b503461033b57604036600319011261033b5760206112d46112cb61392e565b60243590613cf6565b6040519015158152f35b503461033b57602036600319011261033b576020906040906001600160a01b0361130661392e565b168152601383522054604051908152f35b503461033b57602036600319011261033b57604060209160043581526000805160206146ae83398151915283522054604051908152f35b503461033b578060031936011261033b576020604051670de0b6b3a76400008152f35b503461033b57604036600319011261033b5761138b61392e565b6010546024359291906001600160a01b03163303610479576001600160a01b031680825260076020526040822054929081841061140d578060008051602061482e8339815191526040866113e3866104369899613b6c565b84895260076020528289205583885260076020528188205482519182526020820152a2339061404c565b5091604492633cb8e07360e01b8352600452602452fd5b503461033b57602036600319011261033b5760209060ff906040906001600160a01b0361144f61392e565b168152600284522054166040519015158152f35b503461033b5761012036600319011261033b5761147e61392e565b6064359190604435602435611491613a58565b601054610104359660e4359260c4359260a43592906001600160a01b0316330361167f576001600160a01b038816808a52600260205260408a205490989060ff161561166b57861561165c576127108811611642576103e882116116285760ff83169060128211801561161e575b61160a578361150d91614260565b85151580611601575b6115ea578a1515806115e1575b6115ca579260008051602061468e83398151915297969592828c956115c4979460408e8e80825260036020528c8383205580825260046020528d838320558152600660205220558b8d52600560205260408d209060ff198254161790558a8c52600c6020528260408d20558a8c52600d6020528360408d20558a8c52600e6020528460408d20558a8c52600f6020528560408d205560405198899889613cbd565b0390a280f35b60448a868d63dd85772b60e01b8352600452602452fd5b50848b10611523565b60448a8588637449915760e01b8352600452602452fd5b50838610611516565b63ca95039160e01b8b52600482905260248bfd5b50600682106114ff565b631051834f60e11b8a5260048290526103e860245260448afd5b63c1e9a14160e01b8a52600488905261271060245260448afd5b63a2ec3a5560e01b8a5260048afd5b6374ed46ad60e01b8a52600489905260248afd5b6349db3bd360e01b8952600489fd5b503461033b57604036600319011261033b576116a861392e565b6001600160a01b0316808252600260205260408220546024359060ff16156117745780156117655761271061172a604085670de0b6b3a76400006117196117329688859a52600560205260ff85852054169080916012811061173f575b505088845260036020528484205490613a8b565b049581526004602052205484613a8b565b048092613b6c565b9082519182526020820152f35b61175e925060ff61175261175892613ad4565b16613ae5565b90613a8b565b3880611705565b63162908e360e11b8352600483fd5b6374ed46ad60e01b83526004829052602483fd5b503461033b578060031936011261033b5761033760408051906117ab81836139c3565b60058252640352e302e360dc1b602083015251918291602083526020830190613a17565b503461033b57602036600319011261033b5760043581526000805160206146ae83398151915260205260408120604051908160208254918281520190819285526020852090855b818110611876575050508261182c9103836139c3565b604051928392602084019060208552518091526040840192915b818110611854575050500390f35b82516001600160a01b0316845285945060209384019390920191600101611846565b8254845260209093019260019283019201611816565b503461033b578060031936011261033b57602090604051908152f35b503461033b576118b736613969565b9190926118c2613f12565b6118ca613f4e565b338152600960205260408120544303611f1f57338152600a602052600360408220541015611f1057338152600a602052604081206119088154613b9a565b90555b6001600160a01b0382168082526002602052604082205490929060ff16611e6f575b828252600260205260ff60408320541615610466578415610457578315611e6057828252600c60205260408220548510611e3b57828252600e60205260408220548015611e2c57808611611e155750846119869161415e565b6040516370a0823160e01b8152306004820152602081602481865afa908115611e0a578291611dd8575b506119bd8530338661421c565b6040516370a0823160e01b8152306004820152602081602481875afa908115611cef57908692918491611d9f575b50906119f691613b6c565b10611d905781815260076020526040812054611a128582613cb0565b818110611d81576001600160ff1b038111611d72576040849260008051602061482e833981519152928486526007602052808387205582519182526020820152a2818152600560205260ff604082205416849060128110611d11575b50611a8f670de0b6b3a7640000918484526003602052604084205490613a8b565b04908281526004602052612710611aaa604083205484613a8b565b0491611ab68382613b6c565b94808610611cfa57506001546040516318160ddd60e01b815290602090829060049082906001600160a01b03165afa908115611cef578391611cbd575b5082546001600160a01b0316803b15611ca45783809160846040518094819363ae494fa160e01b83523360048401528c60248401528b60448401528d60648401525af1801561060b57908491611ca8575b505083611c34575b6001546040516318160ddd60e01b81529190602090839060049082906001600160a01b03165afa801561060b578490611c00575b611b8a9250613b6c565b90808203611bea575050507fb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b611bcd602095604051918291339588429285613bdd565b0390a360016000805160206147ce83398151915255604051908152f35b632d8562a360e11b835260045260245260449150fd5b506020823d602011611c2c575b81611c1a602093836139c3565b810103126105fe57611b8a9151611b80565b3d9150611c0d565b82546001600160a01b0316803b15611ca45783809160846040518094819363ae494fa160e01b83523060048401528a60248401528b60448401528160648401525af1801561060b57908491611c8b575b5050611b4c565b81611c95916139c3565b611ca0578238611c84565b8280fd5b8380fd5b81611cb2916139c3565b611ca0578238611b44565b90506020813d602011611ce7575b81611cd8602093836139c3565b810103126105fe575138611af3565b3d9150611ccb565b6040513d85823e3d90fd5b6371c4efed60e01b83526004869052602452604482fd5b611d21915061175260ff91613ad4565b8015611d5e5780600019048511611d4f57611a8f611d48670de0b6b3a76400009287613a8b565b9150611a6e565b63035fc53d60e41b8252600482fd5b634e487b7160e01b82526012600452602482fd5b630700fcb360e11b8352600483fd5b63446c8cc960e01b8352600483fd5b639bfa3c1760e01b8152600490fd5b919250506020813d602011611dd0575b81611dbc602093836139c3565b810103126105fe57518591906119f66119eb565b3d9150611daf565b90506020813d602011611e02575b81611df3602093836139c3565b810103126105fe5751386119b0565b3d9150611de6565b6040513d84823e3d90fd5b631d7f2ac360e01b83526004869052602452604482fd5b633b5db2f360e11b8352600483fd5b50908152600c6020526040812054630d54e9e160e01b82526004849052602452604490fd5b632cd84af360e01b8252600482fd5b60405163313ce56760e01b815291939291602081600481865afa859181611eef575b50611ea55763105482c760e21b8552600485fd5b93919293838352600560205260ff806040852054169116908103611ec9575061192d565b90506044928252600560205260ff604083205416631e43476360e11b8352600452602452fd5b611f0991925060203d6020116109c9576109ba81836139c3565b9038611e91565b63a74c1c5f60e01b8152600490fd5b3381526009602052436040822055338152600a6020526001604082205561190b565b503461033b578060031936011261033b5760206040516103e88152f35b503461033b57604036600319011261033b576020906040906001600160a01b03611f8661392e565b16815260148352818120602435825283522054604051908152f35b503461033b57604036600319011261033b576040611fbd613944565b91600435815260008051602061478e833981519152602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b503461033b578060031936011261033b57602060405160648152f35b503461033b57604036600319011261033b5761205060209160043581526000805160206146ae8339815191528352604060243591206144b8565b905460405160039290921b1c6001600160a01b03168152f35b503461033b57602036600319011261033b576020906040906001600160a01b0361209161392e565b168152600983522054604051908152f35b503461033b57604036600319011261033b576120bc61392e565b60105460243591906001600160a01b0316330361215a576001600160a01b031690811561214b57604060008051602061476e8339815191529183855260136020528185205490848652601360205280838720558486526015602052828620438752602052828620548587526019602052838720558486526017602052438387205582519182526020820152a280f35b63df407ac560e01b8352600483fd5b6349db3bd360e01b8352600483fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361219161392e565b168152600383522054604051908152f35b503461033b578060031936011261033b5760008051602061470e833981519152815260008051602061478e83398151915260209081526040808320336000908152925290205460ff1615612278576121f8613f4e565b600160ff196000805160206147ae8339815191525416176000805160206147ae833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a280f35b63e2517d3f60e01b81523360045260008051602061470e833981519152602452604490fd5b503461033b57602036600319011261033b576122b761392e565b60008051602061480e8339815191525460ff8160401c169081156123a3575b506123945760008051602061480e83398151915280546001600160481b0319166003600160401b0117905581805260008051602061478e83398151915260209081526040808420336000908152925290205460ff161561237c5761233990613c5e565b60ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160038152a180f35b63e2517d3f60e01b8252336004526024829052604482fd5b63f92ee8a960e01b8252600482fd5b60036001600160401b039190911610159050386122d6565b503461033b578060031936011261033b57602060ff6000805160206147ae83398151915254166040519015158152f35b503461033b57602036600319011261033b5761240561392e565b6010546001600160a01b031633036104795761043690613c5e565b503461033b57606036600319011261033b5761243a61392e565b612442613944565b60105490926044359290916001600160a01b0316330361047957612464613f4e565b6011546001600160a01b03169182156126de5760405163babcc53960e01b81526001600160a01b0386166004820181905293602090829060249082905afa908115611e0a57829161269f575b5015612690578215612681576001546001600160a01b03928316921682036125d1576040516370a0823160e01b8152306004820152602081602481865afa908115611e0a57829161259f575b50935b841561259057600019810361258a5750835b841561257b5780851161256357505061252d836020958361404c565b7f0bf519e4b3821615dbdd874fa1a5fbb4bb651b4e6beabedd4ac318e770233b2c604080518581524287820152a3604051908152f35b630555ed4f60e31b8252600485905260245260449150fd5b632e11316f60e11b8252600482fd5b93612511565b63f09872eb60e01b8252600482fd5b90506020813d6020116125c9575b816125ba602093836139c3565b810103126105fe5751386124fc565b3d91506125ad565b8181526002602052604081205460ff161561266f576040516370a0823160e01b8152306004820152602081602481865afa908115611e0a57829161263d575b5082825260076020526040822054808211156126355761262f91613b6c565b936124ff565b50508061262f565b90506020813d602011612667575b81612658602093836139c3565b810103126105fe575138612610565b3d915061264b565b60249163eef7849760e01b8252600452fd5b634e46966960e11b8152600490fd5b63133307bb60e21b8152600490fd5b90506020813d6020116126d6575b816126ba602093836139c3565b810103126126d2575180151581036126d257386124b0565b5080fd5b3d91506126ad565b630e048e7160e41b8152600490fd5b503461033b57602036600319011261033b5761270761392e565b6010546001600160a01b03163303610479576001600160a01b0316801561276c57601180546001600160a01b0319811683179091556001600160a01b03167f1e9c406f2707909cfd9f61e744f73bcab77e5997d063276f67883c5257d51cf08380a380f35b634e46966960e11b8252600482fd5b503461033b578060031936011261033b577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031630036127d457602060405160008051602061472e8339815191528152f35b63703e46dd60e11b8152600490fd5b503461033b578060031936011261033b576010546040516001600160a01b039091168152602090f35b50604036600319011261033b5761282161392e565b602435906001600160401b038211611ca05736602383011215611ca0578160040135908361284e836139fc565b9361285c60405195866139c3565b83855260208501933660248284010111611ca057806024602093018637850101526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016308114908115612ade575b50612acf576010546001600160a01b03163303612ac0576001600160a01b038116928315612ab157813b15612aa25760008051602061472e83398151915254846128fa613a68565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f61293060405192604084526040840190613a17565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481895afa879181612a6a575b5061297e57634c9c8ce360e01b87526004869052602487fd5b908160008051602061472e83398151915288979303612a585750833b15612a44576001600160a01b031916811760008051602061472e833981519152558491907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8380a2805115612a295761113e9382915190845af43d15612a21573d91612a05836139fc565b92612a1360405194856139c3565b83523d85602085013e61460c565b60609161460c565b5050505034612a355780f35b63b398979f60e01b8152600490fd5b634c9c8ce360e01b86526004829052602486fd5b632a87526960e21b8752600452602486fd5b9091506020813d602011612a9a575b81612a86602093836139c3565b81010312612a9657519038612965565b8780fd5b3d9150612a79565b636f7c43f160e01b8552600485fd5b63e6c4247b60e01b8552600485fd5b6349db3bd360e01b8452600484fd5b63703e46dd60e11b8452600484fd5b60008051602061472e833981519152546001600160a01b031614159050386128b2565b503461033b57602036600319011261033b576020906040906001600160a01b03612b2961392e565b168152600e83522054604051908152f35b503461033b57606036600319011261033b57612b5461395a565b6024356001600160401b038111611ca057612b73903690600401613993565b916044356001600160401b038111610a5057612b93903690600401613993565b60008051602061480e8339815191529291925460ff8160401c16908115612ef6575b50612ee75760008051602061480e83398151915280546001600160481b0319166002600160401b011790556000805160206147ee833981519152865260008051602061478e83398151915260209081526040808820336000908152925290205460ff1615612ec257612c2561448a565b612c2d61448a565b60016000805160206147ce83398151915255600b549160ff8316612eb357818603612ea457612c5b86613bf9565b92612c6960405194856139c3565b868452601f19612c7888613bf9565b01366020860137875b878110612daf575060019060ff191617600b5515159460ff196008541660ff871617600855865b818110612d0c578760008051602061466e833981519152602089604051908152a160ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160028152a180f35b808860008051602061482e8339815191526040612d34612d2f600196888d613c10565b613c36565b612d3f85898c613c10565b357f8f955fa878b4aae8b1ac37b1ab715307470f2822ceff87e23d33ef1e044814a783612d6c888d613c4a565b5193898060a01b0316968793848252600660205280838320558482526007602052858383205582519182526020820152a28151908d82526020820152a201612ca8565b612dbd612d2f828a8a613c10565b612dc8828689613c10565b6001600160a01b03909116808b52600260205260408b20549091359060ff1615612e90576103e88111612e785750906020602492604051938480926370a0823160e01b82523060048301525afa8015612e6d578a90612e37575b60019250612e308288613c4a565b5201612c81565b509060203d8111612e66575b612e4d81836139c3565b6020826000928101031261033b57509060019151612e22565b503d612e43565b6040513d8c823e3d90fd5b631051834f60e11b8b526004526103e860245260448afd5b6351104c5960e01b8b52600482905260248bfd5b63512509d360e11b8752600487fd5b6324d0d1fd60e01b8752600487fd5b63e2517d3f60e01b8652336004526000805160206147ee833981519152602452604486fd5b63f92ee8a960e01b8652600486fd5b60026001600160401b03919091161015905038612bb5565b503461033b578060031936011261033b576011546040516001600160a01b039091168152602090f35b503461033b578060031936011261033b576010546001600160a01b03163303612fef576000805160206147ae8339815191525460ff811615612fe05760ff19166000805160206147ae833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a280f35b638dfc202b60e01b8252600482fd5b6349db3bd360e01b8152600490fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361302661392e565b168152601683522054604051908152f35b503461033b57604036600319011261033b57613051613944565b336001600160a01b0382160361306d5761113e9060043561411a565b63334bd91960e11b8252600482fd5b503461033b57602036600319011261033b576020906040906001600160a01b036130a461392e565b168152600c83522054604051908152f35b503461033b57602036600319011261033b576020906040906001600160a01b036130dd61392e565b168152601783522054604051908152f35b503461033b57604036600319011261033b5761113e60043561310e613944565b9061311b61113482613b79565b6140d2565b503461033b5761312f36613969565b91909261313a613f12565b613142613f4e565b3381526009602052604081205443036135be57338152600a602052600360408220541015611f1057338152600a602052604081206131808154613b9a565b90555b6001600160a01b0382168082526002602052604082205490929060ff16613543575b828252600260205260ff604083205416156104665760ff6008541615613534578415610457578315611e6057828252600d602052604082205480861061351d5750828252600f6020526040822054801561350e578086116134f857508461320b91613f78565b670de0b6b3a76400008402848104670de0b6b3a7640000036134e4578282526003602052604082205461323d91613ab4565b90828152600560205260ff604082205416601281106134c4575b50828152600660205261327c612710613274604084205485613a8b565b048093613b6c565b938085106134ac575082815260076020528360408220541061348857828152600760205260408120548481106134795760008051602061482e8339815191526040826132c9888895613b6c565b8486526007602052808387205582519182526020820152a26001546040516318160ddd60e01b815290602090829060049082906001600160a01b03165afa908115611e0a578291613447575b5081546001600160a01b0316803b15611ca057826040518092633a52b90760e11b82528183816133498d3360048401613bc2565b03925af18015611cef57613432575b506001546040516318160ddd60e01b81529190602090839060049082906001600160a01b03165afa908115611cef5783916133fc575b6133989250613b6c565b8581036133e45750507f8caf04742286d017f9ac3924388e188c73e6e5094311c5e59a61a7ef86dda8bf611bcd6020956133d386338761404c565b604051918291339588429285613bdd565b635ab6e2db60e01b8252600486905260245260449150fd5b90506020823d60201161342a575b81613417602093836139c3565b810103126105fe5761339891519061338e565b3d915061340a565b9161344081600493946139c3565b9190613358565b90506020813d602011613471575b81613462602093836139c3565b810103126126d2575138613315565b3d9150613455565b6308aed4ef60e31b8252600482fd5b82815260076020526040812054635960d22160e01b82526004526024849052604490fd5b6371c4efed60e01b8252600485905260245260449150fd5b916134d760ff6117526134dd9495613ad4565b90613ab4565b9038613257565b634e487b7160e01b82526011600452602482fd5b625502a360e91b83526004869052602452604482fd5b636c6ff70d60e11b8352600483fd5b6361767b8560e01b83526004869052602452604482fd5b630df65d9f60e01b8252600482fd5b60405163313ce56760e01b815291939291602081600481865afa85918161359d575b506135795763105482c760e21b8552600485fd5b93919293838352600560205260ff806040852054169116908103611ec957506131a5565b6135b791925060203d6020116109c9576109ba81836139c3565b9038613565565b3381526009602052436040822055338152600a60205260016040822055613183565b503461033b57602036600319011261033b576020610f3c600435613b79565b503461033b57602036600319011261033b576020906040906001600160a01b0361362761392e565b168152600f83522054604051908152f35b503461033b57604036600319011261033b5761365261392e565b60105460243591906001600160a01b0316330361215a576001600160a01b031690811561214b5760406000805160206146ce8339815191529183855260126020528185205490848652601260205280838720558486526014602052828620438752602052828620548587526018602052838720558486526016602052438387205582519182526020820152a280f35b503461033b57602036600319011261033b576020906040906001600160a01b0361370961392e565b168152600683522054604051908152f35b503461033b578060031936011261033b576001546040516001600160a01b039091168152602090f35b503461033b57602036600319011261033b576020906040906001600160a01b0361376b61392e565b168152600d83522054604051908152f35b503461033b57602036600319011261033b5761379661395a565b6010546001600160a01b0316330361047957602060008051602061466e83398151915291151560ff196008541660ff821617600855604051908152a180f35b503461033b57602036600319011261033b5760043563ffffffff60e01b81168091036126d257602090635a05180f60e01b811490811561381b575b506040519015158152f35b637965db0b60e01b811491508115613835575b5082613810565b6301ffc9a760e01b1490508261382e565b503461033b57604036600319011261033b5761386061392e565b6001600160a01b0316808252600260205260408220546024359060ff161561177457670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561391a57916138bc60409383835260036020528483205490613ab4565b91808252600560205260ff8483205416601281106138f1575b5061172a84836127109361173295526006602052205484613a8b565b846117329361390f61271094966134d760ff61175261172a97613ad4565b9593509350506138d5565b634e487b7160e01b83526011600452602483fd5b600435906001600160a01b03821682036105fe57565b602435906001600160a01b03821682036105fe57565b6004359081151582036105fe57565b60609060031901126105fe576004356001600160a01b03811681036105fe57906024359060443590565b9181601f840112156105fe578235916001600160401b0383116105fe576020808501948460051b0101116105fe57565b601f909101601f19168101906001600160401b038211908210176139e657604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116139e657601f01601f191660200190565b919082519283825260005b848110613a43575050826000602080949584010152601f8019910116010190565b80602080928401015182828601015201613a22565b6084359060ff821682036105fe57565b60405190613a776040836139c3565b6005825264322e332e3360d81b6020830152565b81810292918115918404141715613a9e57565b634e487b7160e01b600052601160045260246000fd5b8115613abe570490565b634e487b7160e01b600052601260045260246000fd5b60ff166012039060ff8211613a9e57565b8015613b665760009060208110600116604e821060011617613b5e57600a916001915b60018111613b35575082600019048211613b2157500290565b634e487b7160e01b81526011600452602490fd5b92806000190481116134e45760018416613b55575b80029260011c613b08565b80920291613b4a565b9050600a0a90565b50600190565b91908203918211613a9e57565b60005260008051602061478e83398151915260205260016040600020015490565b6000198114613a9e5760010190565b908160209103126105fe575160ff811681036105fe5790565b6001600160a01b039091168152602081019190915260400190565b9094939260609260808301968352602083015260408201520152565b6001600160401b0381116139e65760051b60200190565b9190811015613c205760051b0190565b634e487b7160e01b600052603260045260246000fd5b356001600160a01b03811681036105fe5790565b8051821015613c205760209160051b010190565b6001600160a01b03168015613c9f57601080546001600160a01b0319811683179091556001600160a01b031660008051602061474e833981519152600080a3565b63e6c4247b60e01b60005260046000fd5b91908201809211613a9e57565b94919360e0969360ff929a99989561010088019b885260208801526040870152166060850152608084015260a083015260c08201520152565b6001600160a01b03811660008181526002602052604090205490919060ff16158015613de8575b8015613de0575b613dce5781600052600f6020526040600020548015908115613dd6575b50613dce57613d66926040918251948592839262f7fce960e01b845260048401613bc2565b0381305afa918215613dc257600092613d8e575b506000526007602052604060002054101590565b9091506040813d604011613dba575b81613daa604093836139c3565b810103126105fe57519038613d7a565b3d9150613d9d565b6040513d6000823e3d90fd5b505050600090565b9050831138613d41565b508215613d24565b5060ff6008541615613d1d565b6001546001600160a01b0391821691168103613e6a576020602491604051928380926370a0823160e01b82523060048301525afa908115613dc257600091613e3b575090565b90506020813d602011613e62575b81613e56602093836139c3565b810103126105fe575190565b3d9150613e49565b80600052600260205260ff60406000205416613e865750600090565b6040516370a0823160e01b815230600482015290602082602481845afa918215613dc257600092613ede575b506000526007602052604060002054808211600014613ed757613ed491613b6c565b90565b5050600090565b90916020823d602011613f0a575b81613ef9602093836139c3565b8101031261033b5750519038613eb2565b3d9150613eec565b60026000805160206147ce8339815191525414613f3d5760026000805160206147ce83398151915255565b633ee5aeb560e01b60005260046000fd5b60ff6000805160206147ae8339815191525416613f6757565b63d93c066560e01b60005260046000fd5b6001600160a01b0316600081815260136020526040902054801561404757816000526015602052604060002043600052602052613fbb6040600020549384613cb0565b92831061403657808260005260176020524360406000205414614018575b8311613ffc57506000526015602052604060002043600052602052604060002055565b925063029359d560e41b60005260045260245260445260646000fd5b5081600052601960205261403160406000205482613cb0565b613fd9565b63446c8cc960e01b60005260046000fd5b505050565b614081614086939261407360405194859263a9059cbb60e01b602085015260248401613bc2565b03601f1981018452836139c3565b6142ed565b565b600081815260008051602061478e8339815191526020908152604080832033845290915290205460ff16156140ba5750565b63e2517d3f60e01b6000523360045260245260446000fd5b6140dc8282614348565b91826140e757505090565b60009182526000805160206146ae8339815191526020526040909120614116916001600160a01b0316906144d0565b5090565b61412482826143ea565b918261412f57505090565b60009182526000805160206146ae8339815191526020526040909120614116916001600160a01b031690614539565b6001600160a01b03166000818152601260205260409020548015614047578160005260146020526040600020436000526020526141a16040600020549384613cb0565b928310614036578082600052601660205243604060002054146141fe575b83116141e257506000526014602052604060002043600052602052604060002055565b92506319a4e2a760e01b60005260045260245260445260646000fd5b5081600052601860205261421760406000205482613cb0565b6141bf565b6040516323b872dd60e01b60208201526001600160a01b039283166024820152929091166044830152606480830193909352918152614086916140816084836139c3565b60405163313ce56760e01b81529190602090839060049082906001600160a01b03165afa600092816142cc575b506142a357631eecbb6560e01b60005260046000fd5b60ff91821691168082036142b5575050565b631e43476360e11b60005260045260245260446000fd5b6142e691935060203d6020116109c9576109ba81836139c3565b913861428d565b906000602091828151910182855af115613dc2576000513d61433f57506001600160a01b0381163b155b61431e5750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b60011415614317565b600081815260008051602061478e833981519152602090815260408083206001600160a01b038616845290915290205460ff16613ed757600081815260008051602061478e833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b600081815260008051602061478e833981519152602090815260408083206001600160a01b038616845290915290205460ff1615613ed757600081815260008051602061478e833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b60ff60008051602061480e8339815191525460401c16156144a757565b631afcd79f60e31b60005260046000fd5b8054821015613c205760005260206000200190600090565b6001810190826000528160205260406000205415600014613dce578054600160401b8110156139e65761452461450d8260018794018555846144b8565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b9060018201918160005282602052604060002054801515600014614603576000198101818111613a9e578254600019810191908211613a9e578181036145cc575b505050805480156145b657600019019061459482826144b8565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b6145ec6145dc61450d93866144b8565b90549060031b1c928392866144b8565b90556000528360205260406000205538808061457a565b50505050600090565b90614632575080511561462157602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580614664575b614643575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561463b56fe2c0a5f5ab0ba371221bb3612c2d2f90d36566279309f526000c5b354efd1b0658c67aaac7f77de07240e5a9b36dfdccb2a89c438635abbb27a73142d2aa0f629c1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200048b07fab687f450848f1df8a96db08fef7840f53415f18fdc2ec8e9f810f0930c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d275027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc17dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846c4460507c21097c15f6883572ebd157a9ee4b1d989a312314e93afd9d2ecd494002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a006d129bd71f2401cbe77f49f546d7d5f58992faecfca6e51ba06b50b261e83331a164736f6c6343000822000a";
69441
69828
  var isSuperArgs = (xs) => xs.length > 1;
69442
- var SimplePSMV2__factory = class extends import_ethers28.ContractFactory {
69829
+ var SimplePSMV2__factory = class extends import_ethers29.ContractFactory {
69443
69830
  constructor(...args) {
69444
69831
  if (isSuperArgs(args)) {
69445
69832
  super(...args);
@@ -69459,10 +69846,10 @@ var SimplePSMV2__factory = class extends import_ethers28.ContractFactory {
69459
69846
  static bytecode = _bytecode;
69460
69847
  static abi = _abi;
69461
69848
  static createInterface() {
69462
- return new import_ethers28.Interface(_abi);
69849
+ return new import_ethers29.Interface(_abi);
69463
69850
  }
69464
69851
  static connect(address, runner) {
69465
- return new import_ethers28.Contract(address, _abi, runner);
69852
+ return new import_ethers29.Contract(address, _abi, runner);
69466
69853
  }
69467
69854
  };
69468
69855
  var _abi2 = [
@@ -71157,7 +71544,7 @@ var _abi2 = [
71157
71544
  ];
71158
71545
  var _bytecode2 = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161304c90816100f0823960805181818161114401526113290152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a714611ff7575080630d33f3c214611fd35780630f3f4a9414611f885780631459457a14611be257806318c38b8914611ad15780631d44454114611a005780632106764c146119d9578063248a9ca3146119b35780632ec22d4c146118f25780632f0647ce146118775780632f2ff15d14611846578063324207441461177257806336568abe1461172c578063392f1087146116f65780633f4ba83a146115fe5780633f5aadc91461158f5780634f1ef286146112ad57806352340363146111c45780635273b6f61461119b57806352d1902d14611131578063554c4f4b146110a1578063561b7f8a14610f755780635bc26aea14610ee85780635c975abb14610eb85780636289d18c14610e375780636711cc0b14610e1b5780636e852a7814610d1a5780637e35bf6e14610ce65780638343f67414610cb95780638456cb5914610bc35780638f33527f14610b895780639010d07c14610b3557806391d1485414610adb5780639b9d30c114610ab2578063a19af3f614610a01578063a217fddf146109e5578063a3246ad314610923578063a878086414610907578063ac3c0e30146107fa578063ad3cb1cc146107b3578063b3fad6381461070e578063c34e9c26146106f2578063c86deb31146106d6578063ca15c8731461069d578063d547741f14610665578063dd71d99a14610623578063e0922fa114610576578063efa9b4ae14610507578063f2f4eb26146104de578063f68e9553146104b5578063f94f67ab146103de578063fd437d391461029f5763ffa1ad741461026657600080fd5b3461029a57600036600319011261029a576102966102826121ed565b6040519182916020835260208301906121c8565b0390f35b600080fd5b3461029a57606036600319011261029a576102b861207a565b6102c0612064565b906102c961218f565b906102d2612795565b6001600160a01b0316338190036103ce5780600052600160205260406000209283549360ff8560e01c1660038110156103b8576001036103a75781600160209261033e877fc5d5c5bbf10444998e0ea6d4725e79027b574e1c14ec929279e8a9a95c6c6e919688612c43565b818060a01b038316828060a01b031982541617815561035d878261239f565b0180546001600160401b031916426001600160401b03908116919091179091556001600160a01b0391821660008181526002855260409081902087905551969091168652951693a4005b632437e77160e11b60005260046000fd5b634e487b7160e01b600052602160045260246000fd5b62fca64560e31b60005260046000fd5b3461029a57604036600319011261029a576004356103fa6120c9565b90610403612795565b63ffffffff600554169163ffffffff8116928084109081156104ac575b5061049b5760207f6b7727cc9c3df4a29acf0afe01594c1b7e845d20f40f4a14e4c292164a9ed8e191610452846127e0565b9161046a600863ffffffff845460a01c1617836122e3565b81546001600160e01b031660e09190911b6001600160e01b0319161790556040519485526001600160a01b031693a3005b634346c13160e01b60005260046000fd5b90501584610420565b3461029a57600036600319011261029a576020604051600080516020612fe08339815191528152f35b3461029a57600036600319011261029a576003546040516001600160a01b039091168152602090f35b3461029a57602036600319011261029a57600435610523612795565b61054561052f826127e0565b9190600163ffffffff825460a01c1617906122e3565b6001600160a01b0316907f812690e0a9dff5bf3add998111b8af5c8299608d859025bfe35662060ab4267d600080a3005b3461029a57602036600319011261029a576004356001600160401b0381169081810361029a576000546001600160a01b038116330361061257600160a01b600160e01b0319811660a092831b600160a01b600160e01b031617600055604080519190921c6001600160401b0316815260208101929092527f9c195448332abd01f716db873b329752ea02f19d33f7e311fb0daf082c4edd0391a1005b6349db3bd360e01b60005260046000fd5b3461029a57602036600319011261029a576001600160a01b0361064461207a565b166000526002602052602060018060a01b0360406000205416604051908152f35b3461029a57604036600319011261029a5761069b600435610684612064565b90610696610691826122c2565b6126bf565b612751565b005b3461029a57602036600319011261029a57600435600052600080516020612ee08339815191526020526020604060002054604051908152f35b3461029a57600036600319011261029a57602060405160088152f35b3461029a57600036600319011261029a57602060405160028152f35b3461029a57602036600319011261029a576000606060405161072f81612136565b828152826020820152826040820152015260043560005260046020526080604060002063ffffffff6040519161076483612136565b548160018060a01b038216938481528160208201818560a01c16815260606040840193838760c01c168552019460e01c8552604051968752511660208601525116604084015251166060820152f35b3461029a57600036600319011261029a5761029660408051906107d68183612151565b60058252640352e302e360dc1b6020830152519182916020835260208301906121c8565b3461029a57602036600319011261029a5761081361207a565b6000608060405161082381612105565b828152826020820152826040820152826060820152015260018060a01b03166000526001602052604060002060405161085b81612105565b81546001600160a01b038116825260a081901c6001600160401b03166020830190815292604083019160e01c60ff169060038210156103b857908252600101546001600160401b0380821660608501908152604092831c821660808601908152925194516001600160a01b03168552945116602084015290519260038410156103b857604083019390935291516001600160401b0390811660608301529151909116608082015260a090f35b3461029a57600036600319011261029a57602060405160018152f35b3461029a57602036600319011261029a57600435600052600080516020612ee083398151915260205260406000206040518060208354918281520190819360005260206000209060005b8181106109cf5750505081610983910382612151565b6040519182916020830190602084525180915260408301919060005b8181106109ad575050500390f35b82516001600160a01b031684528594506020938401939092019160010161099f565b825484526020909301926001928301920161096d565b3461029a57600036600319011261029a57602060405160008152f35b3461029a57604036600319011261029a57600435610a1d6120c9565b90610a26612795565b63ffffffff600554169163ffffffff811692808410908115610aa9575b5061049b5760207f1da95b87b4c773f68c1447ffc5644e41a8a8887d55065beb64852014cf7140be91610a96610a78856127e0565b9290610a91600463ffffffff835460a01c1617826122e3565b612210565b6040519485526001600160a01b031693a3005b90501584610a43565b3461029a57600036600319011261029a576020604051600080516020612f208339815191528152f35b3461029a57604036600319011261029a57610af4612064565b600435600052600080516020612fc083398151915260205260406000209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b3461029a57604036600319011261029a57600435600052600080516020612ee08339815191526020526020610b706024356040600020612d0c565b905460405160039290921b1c6001600160a01b03168152f35b3461029a57602036600319011261029a576001600160a01b03610baa61207a565b1660005260026020526020604060002054604051908152f35b3461029a57600036600319011261029a573360009081527f0ac8cc3d209806126662940717264973110c39045b305f6ba49613325a615e09602052604090205460ff1615610c9257610c13612795565b600160ff19600080516020613000833981519152541617600080516020613000833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a2005b63e2517d3f60e01b60005233600452600080516020612f2083398151915260245260446000fd5b3461029a57600036600319011261029a5760005460405160a09190911c6001600160401b03168152602090f35b3461029a57604036600319011261029a57610d0a610d02612064565b60043561236c565b906102966040519283928361209a565b3461029a57604036600319011261029a57610d3361207a565b336000908152600080516020612f60833981519152602052604090205460ff161580610e08575b6103ce576001600160a01b03166000818152600160205260409020805460e01c60ff1660038110156103b8576001036103a757805460ff60e01b198116600160e11b1782556001919091018054600160401b600160801b03191642604090811b600160401b600160801b0316919091179091555160243581526001600160a01b0390911691907fc0499cc07ed9d734deec6857802d3f0fa8d5afaf79a7008beb8ba7bef62a271b90602090a3005b50336001600160a01b0382161415610d5a565b3461029a57600036600319011261029a57602060405160048152f35b3461029a57602036600319011261029a57610e506120b6565b6000546001600160a01b031633036106125763ffffffff8116908115610ea757600080516020612fa083398151915291610ea263ffffffff926005549284198416176005556040519384931683612233565b0390a1005b6338f3377360e21b60005260046000fd5b3461029a57600036600319011261029a57602060ff60008051602061300083398151915254166040519015158152f35b3461029a57602036600319011261029a57610f0161207a565b6000546001600160a01b0381169033829003610612576001600160a01b038316928315610f64573b15610f53576001600160a01b03191682176000908155600080516020612f808339815191529080a3005b636f7c43f160e01b60005260046000fd5b63e6c4247b60e01b60005260046000fd5b3461029a57606036600319011261029a57610f8e61207a565b610f96612064565b610f9e61218f565b91610fa7612795565b6001600160a01b031690338290036103ce57816000526001602052604060002060ff815460e01c1660038110156103b857600114611090578160209161100f867ff223dc085722c94c84dcf67427e225799be616382a2a484d378f8921c69a20339587612c43565b80546001600160a01b0319166001600160a01b038316178155611032868261239f565b6001810180546001600160801b031916426001600160401b0390811691909117909155815460ff60e01b1916600160e01b179091556001600160a01b03919091166000818152600284526040908190208690555195909116855293a3005b639d2c8fdf60e01b60005260046000fd5b3461029a57602036600319011261029a576001600160a01b036110c261207a565b166000526001602052604060002060ff60008051602061300083398151915254161580611115575b602091816110fe575b506040519015158152f35b5460a01c6001600160401b031642109050826110f3565b5060ff815460e01c169060038210156103b857906001146110ea565b3461029a57600036600319011261029a577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316300361118a576020604051600080516020612f408339815191528152f35b63703e46dd60e11b60005260046000fd5b3461029a57600036600319011261029a576000546040516001600160a01b039091168152602090f35b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b03831692831590811561129e575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff161580611283575b611272578061124563fffffffe61124b935460a01c16826122e3565b8261269b565b7fa5ffbdba01b15df97334e34ad816b9986b6057a5ddc97aba93b7e8ccd21759ed600080a3005b630a606ec360e11b60005260046000fd5b5082331415611229565b6360eb6c2360e01b60005260046000fd5b6001915060a01c1615846111fd565b604036600319011261029a576112c161207a565b602435906001600160401b03821161029a573660238301121561029a578160040135906112ed82612174565b916112fb6040519384612151565b8083526020830193366024838301011161029a57816000926024602093018737840101526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630811490811561156c575b5061118a576000546001600160a01b03163303610612576001600160a01b038116928315610f6457813b1561155b5730841461154c57600080516020612f4083398151915254846113a36121ed565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f6113d9604051926040845260408401906121c8565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481895afa60009181611518575b506114295785634c9c8ce360e01b60005260045260246000fd5b9081600080516020612f408339815191528793036115045750833b156114ef576001600160a01b0319168117600080516020612f40833981519152557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28251156114d4576000809161069b945190845af43d156114cc573d916114af83612174565b926114bd6040519485612151565b83523d6000602085013e612e7e565b606091612e7e565b505050346114de57005b63b398979f60e01b60005260046000fd5b50634c9c8ce360e01b60005260045260246000fd5b632a87526960e21b60005260045260246000fd5b9091506020813d602011611544575b8161153460209383612151565b8101031261029a5751908761140f565b3d9150611527565b614e8d60eb1b60005260046000fd5b632e07c4bd60e11b60005260046000fd5b600080516020612f40833981519152546001600160a01b03161415905084611354565b3461029a57602036600319011261029a576004356115ab612795565b6115cd6115b7826127e0565b9190600263ffffffff825460a01c1617906122e3565b6001600160a01b0316907fc2713e691344add4705edc62a0ee5aede95ba66ad68f97316efef9cb50644edd600080a3005b3461029a57600036600319011261029a57336000908152600080516020612f60833981519152602052604090205460ff1615806116e1575b6116d0576000805160206130008339815191525460ff8116156116bf5760ff1916600080516020613000833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a2005b638dfc202b60e01b60005260046000fd5b63659a07b360e11b60005260046000fd5b506000546001600160a01b0316331415611636565b3461029a57604036600319011261029a5761029661171d611715612064565b600435612306565b604093919351938493846120dc565b3461029a57604036600319011261029a57611745612064565b336001600160a01b038216036117615761069b90600435612751565b63334bd91960e11b60005260046000fd5b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b038316928315908115611837575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff16158061182d575b61127257806117f363fffffff7611806935460a01c16826122e3565b80546001600160e01b031681558261269b565b7f054490ec6650e07db9b97a06ea31d44cebd44b390c9975a380055e1b4d3cac21600080a3005b50823314156117d7565b6008915060a01c1615846117ab565b3461029a57604036600319011261029a5761069b600435611865612064565b90611872610691826122c2565b612709565b3461029a57602036600319011261029a576004356118c161189782612629565b91906118ad63fffffffb825460a01c16826122e3565b805463ffffffff60c01b191681558361269b565b6001600160a01b0316907f09cb4ec44cdef8489412844b9682f87f7900758fa2bd7e039113e9125e538e0f600080a3005b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b0383169283159081156119a4575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff16158061199a575b611272578061124563fffffffd611973935460a01c16826122e3565b7fb390ab029eab314bd18190ebe73d7e5c1c336beaa5c83ac22578378dc9ccc405600080a3005b5082331415611957565b6002915060a01c16158461192b565b3461029a57602036600319011261029a5760206119d16004356122c2565b604051908152f35b3461029a57604036600319011261029a5761029661171d6119f8612064565b60043561224a565b3461029a57604036600319011261029a57600435611a1c6120c9565b63ffffffff600554169063ffffffff811691808310908115611ac8575b5061049b57611a4783612629565b909263ffffffff845460c01c16809260018060a01b03163314159182611abd575b5050611aac57611a98827e8a218591d4362499c38c38eb1c12e7a7cc97a9068818d1fe6046a42ba4a5ba94612210565b611aa760405192839283612233565b0390a2005b634e80a40760e11b60005260046000fd5b111590508186611a68565b90501584611a39565b3461029a57602036600319011261029a57611aea6120b6565b6000805160206130208339815191525460ff8160401c16908115611bca575b50611bb957600080516020613020833981519152805460026001600160401b0319821681179092556000546001600160481b031990911690911791906001600160a01b031633036106125763ffffffff168015610ea757604081600080516020612fa08339815191529263ffffffff196005541617600555815190600082526020820152a160008051602061302083398151915255600080516020612f00833981519152602060405160028152a1005b63f92ee8a960e01b60005260046000fd5b60026001600160401b03919091161015905082611b09565b3461029a5760a036600319011261029a57611bfb61207a565b611c03612064565b906044356001600160a01b03811680820361029a576064356001600160a01b0381169182820361029a576084356001600160a01b038116949085900361029a5760008051602061302083398151915254604081901c60ff161596906001600160401b031680159081611f80575b6001149081611f76575b159081611f6d575b50611bb95760008051602061302083398151915280546001600160401b031916600117905586611f48575b611cb5612acc565b611cbd612acc565b611cc5612acc565b611ccd612acc565b6001600160a01b038116908115610f64578315610f64578515610f64576001600160a01b038916988915610f64573b15610f5357858414611f375762aa36a746148015611f2c575b8015611f21575b1580611f0f575b610f5357611d32906000612afa565b9081611ec8575b5015611e0d57611d5790600080516020612fe0833981519152612afa565b9081611e73575b5015611e0d57611d7c90600080516020612f20833981519152612afa565b9081611e1e575b5015611e0d57600080546001600160a01b031916841781556040519390600080516020612f808339815191528180a38015610f6457803b15610f5357600380546001600160a01b031916919091179055611dd957005b600080516020613020833981519152805460ff60401b1916905560018152600080516020612f0083398151915290602090a1005b63cf5a8e3360e01b60005260046000fd5b600080516020612f20833981519152600052600080516020612ee0833981519152602052611e6c907ffff5b43478fa6840382eb63777e0da6941d320b940e3f70f0ea4780feff95827612d3a565b5084611d83565b600080516020612fe0833981519152600052600080516020612ee0833981519152602052611ec1907f32d31393d541a265984ec379cddd8b1fcbe5f2b0eb8ad81dddfead454f135eaa612d3a565b5086611d5e565b60008052600080516020612ee0833981519152602052611f08907f615f0f9e84155bea8cc509fe18befeb1baf65611e38a6ba60964480fb29dfd44612d3a565b5088611d39565b50823b1580611d235750843b15611d23565b50617a694614611d1c565b506105394614611d15565b638135316560e01b60005260046000fd5b600080516020613020833981519152805460ff60401b1916600160401b179055611cad565b90501589611c82565b303b159150611c7a565b889150611c70565b3461029a57604036600319011261029a57610296611fbc611fa7612064565b600435600052600460205260406000206123c8565b611fc581612090565b60405191818392158361209a565b3461029a57600036600319011261029a57602063ffffffff60055416604051908152f35b3461029a57602036600319011261029a576004359063ffffffff60e01b821680920361029a57602091635a05180f60e01b8114908115612039575b5015158152f35b637965db0b60e01b811491508115612053575b5083612032565b6301ffc9a760e01b1490508361204c565b602435906001600160a01b038216820361029a57565b600435906001600160a01b038216820361029a57565b600811156103b857565b9015158152604081019291906020906120b283612090565b0152565b6004359063ffffffff8216820361029a57565b6024359063ffffffff8216820361029a57565b91604091949363ffffffff916060850196151585526120fa81612090565b602085015216910152565b60a081019081106001600160401b0382111761212057604052565b634e487b7160e01b600052604160045260246000fd5b608081019081106001600160401b0382111761212057604052565b601f909101601f19168101906001600160401b0382119082101761212057604052565b6001600160401b03811161212057601f01601f191660200190565b604435906001600160401b038216820361029a57565b60005b8381106121b85750506000910152565b81810151838201526020016121a8565b906020916121e1815180928185528580860191016121a5565b601f01601f1916010190565b604051906121fc604083612151565b60058252640322e312e360dc1b6020830152565b805463ffffffff60c01b191660c09290921b63ffffffff60c01b16919091179055565b63ffffffff91821681529116602082015260400190565b600052600460205261226160406000209182612485565b61226a81612090565b806122b857505460e01c63ffffffff60055416811580156122b0575b6122a35780821061229c57505b60019160009190565b9050612293565b5050600090600390600090565b508015612286565b6000929091508290565b600052600080516020612fc083398151915260205260016040600020015490565b805463ffffffff60a01b191660a09290921b63ffffffff60a01b16919091179055565b919091600052600460205261232060406000209283612511565b9161232a83612090565b826123625763ffffffff9192505460c01c1663ffffffff60055416811580156122b0576122a35780821061229c575060019160009190565b5060009190600090565b90612383916000526004602052604060002061259d565b61238c81612090565b8061239a5750600190600090565b600091565b8054600160a01b600160e01b03191660a09290921b600160a01b600160e01b0316919091179055565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6002161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b600790565b5050600690565b5050600590565b505050600490565b5050600390565b505050600290565b5050600190565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6008161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6004161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6001161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b6000908152600460205260409020805490916001600160a01b03821691821590811561268c575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff161580612682575b61127257565b508133141561267c565b6004915060a01c161538612650565b905460a01c63ffffffff16156126ae5750565b600052600460205260006040812055565b6000818152600080516020612fc08339815191526020908152604080832033845290915290205460ff16156126f15750565b63e2517d3f60e01b6000523360045260245260446000fd5b6127138282612afa565b918261271e57505090565b6000918252600080516020612ee0833981519152602052604090912061274d916001600160a01b031690612d3a565b5090565b61275b8282612ba3565b918261276657505090565b6000918252600080516020612ee0833981519152602052604090912061274d916001600160a01b031690612dab565b60ff60008051602061300083398151915254166127ae57565b63d93c066560e01b60005260046000fd5b519064ffffffffff8216820361029a57565b519061ffff8216820361029a57565b8015612abb57600354604051638d34875560e01b8152600481018390529190600090839060249082906001600160a01b03165afa918215612aaf57600092612904575b5060808201516001600160a01b0316913383900361127257610120015161284981612090565b61285281612090565b600381149081156128ef575b81156128db575b506128ca5781600052600160205260ff60406000205460e01c1660038110156103b8576001036128b957600090815260046020526040902080546001600160a01b0319166001600160a01b03831617815591565b632e68d1d360e21b60005260046000fd5b63e9f6db8560e01b60005260046000fd5b600791506128e881612090565b1438612865565b90506128fa81612090565b600581149061285e565b90913d8082843e6129158184612151565b820191602081840312612a8f578051906001600160401b038211612a975701906101a082840312612a8c57604051926101a084016001600160401b03811185821017612a9b5760409081528351855260208085015190860152838101519085015260608301516001600160401b038111612a9757830181601f82011215612a97578051906129a282612174565b926129b06040519485612151565b82845260208383010111612a9357906129cf91602080850191016121a5565b606084015260808201516001600160a01b0381168103612a8f5760808401526129fa60a083016127bf565b60a0840152612a0b60c083016127bf565b60c0840152612a1c60e083016127d1565b60e0840152612a2e61010083016127bf565b610100840152610120820151906008821015612a8c5750612a7f9161018091610120850152612a6061014082016127bf565b610140850152612a7361016082016127d1565b610160850152016127bf565b6101808201529038612823565b80fd5b5080fd5b8380fd5b8280fd5b634e487b7160e01b83526041600452602483fd5b6040513d6000823e3d90fd5b637bb0b62160e01b60005260046000fd5b60ff6000805160206130208339815191525460401c1615612ae957565b631afcd79f60e31b60005260046000fd5b6000818152600080516020612fc0833981519152602090815260408083206001600160a01b038616845290915290205460ff16612b9c576000818152600080516020612fc0833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050600090565b6000818152600080516020612fc0833981519152602090815260408083206001600160a01b038616845290915290205460ff1615612b9c576000818152600080516020612fc0833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b158015612cfb575b610f64576001600160a01b0316600090815260026020526040902054612cea576001600160401b031642811115612cd95760005460a01c6001600160401b03168015159182612cae575b5050612c9d57565b63e774e7b560e01b60005260046000fd5b909150428103908111612cc357113880612c95565b634e487b7160e01b600052601160045260246000fd5b63efa7aefd60e01b60005260046000fd5b633b53f64f60e21b60005260046000fd5b506001600160a01b03811615612c4b565b8054821015612d245760005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b6001810190826000528160205260406000205415600014612da3578054600160401b81101561212057612d8e612d77826001879401855584612d0c565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b505050600090565b9060018201918160005282602052604060002054801515600014612e75576000198101818111612cc3578254600019810191908211612cc357818103612e3e575b50505080548015612e28576000190190612e068282612d0c565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b612e5e612e4e612d779386612d0c565b90549060031b1c92839286612d0c565b905560005283602052604060002055388080612dec565b50505050600090565b90612ea45750805115612e9357602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580612ed6575b612eb5575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b15612ead56fec1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d275027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc07966f2ab141347034724e9b2a472c2f77f5cd745aeba27cacba797b8fcb708617dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846cd37bc77615afefc793aa17d75d4249a9b517ba91b0e54a49c9c4a44b3d7e228302dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800edcc084d3dcd65a1f7f23c65c46722faca6953d28e43150a467cf43e5c309238cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a164736f6c6343000822000a";
71159
71546
  var isSuperArgs2 = (xs) => xs.length > 1;
71160
- var AgentDelegationRegistry__factory = class extends import_ethers29.ContractFactory {
71547
+ var AgentDelegationRegistry__factory = class extends import_ethers30.ContractFactory {
71161
71548
  constructor(...args) {
71162
71549
  if (isSuperArgs2(args)) {
71163
71550
  super(...args);
@@ -71177,10 +71564,10 @@ var AgentDelegationRegistry__factory = class extends import_ethers29.ContractFac
71177
71564
  static bytecode = _bytecode2;
71178
71565
  static abi = _abi2;
71179
71566
  static createInterface() {
71180
- return new import_ethers29.Interface(_abi2);
71567
+ return new import_ethers30.Interface(_abi2);
71181
71568
  }
71182
71569
  static connect(address, runner) {
71183
- return new import_ethers29.Contract(
71570
+ return new import_ethers30.Contract(
71184
71571
  address,
71185
71572
  _abi2,
71186
71573
  runner
@@ -71194,7 +71581,7 @@ var POSITION_DELEGATE_REGISTRY_ABI = [
71194
71581
  "event PositionDelegateUpdated(bytes32 indexed positionId, address indexed oldDelegate, address indexed newDelegate)"
71195
71582
  ];
71196
71583
  async function setPositionDelegate(positionId, delegate, signer, registryAddress) {
71197
- const registry = new import_ethers30.Contract(
71584
+ const registry = new import_ethers31.Contract(
71198
71585
  registryAddress,
71199
71586
  POSITION_DELEGATE_REGISTRY_ABI,
71200
71587
  signer
@@ -71202,7 +71589,7 @@ async function setPositionDelegate(positionId, delegate, signer, registryAddress
71202
71589
  return registry["setPositionDelegate"](positionId, delegate);
71203
71590
  }
71204
71591
  async function getPositionDelegate(positionId, provider, registryAddress) {
71205
- const registry = new import_ethers30.Contract(
71592
+ const registry = new import_ethers31.Contract(
71206
71593
  registryAddress,
71207
71594
  POSITION_DELEGATE_REGISTRY_ABI,
71208
71595
  provider
@@ -71248,9 +71635,17 @@ async function mintAgentPkp(params) {
71248
71635
  }
71249
71636
  var AGENT_STATUS = { None: 0, Active: 1, Revoked: 2 };
71250
71637
  function planAgentBinding(params) {
71251
- const { isActive, record, nowSeconds } = params;
71638
+ const { isActive, paused, record, nowSeconds } = params;
71639
+ if (typeof paused !== "boolean") {
71640
+ throw new Error("planAgentBinding: `paused` must be read from the registry (boolean required)");
71641
+ }
71252
71642
  if (isActive)
71253
71643
  return { kind: "reuse", agent: record.agent };
71644
+ if (paused) {
71645
+ throw new Error(
71646
+ "AgentDelegationRegistry is paused \u2014 agent delegation cannot be changed until it is unpaused."
71647
+ );
71648
+ }
71254
71649
  const status = Number(record.status);
71255
71650
  if (status === AGENT_STATUS.None || status === AGENT_STATUS.Revoked) {
71256
71651
  return { kind: "register" };
@@ -71260,7 +71655,7 @@ function planAgentBinding(params) {
71260
71655
  }
71261
71656
  if (Number(record.validUntil) > nowSeconds) {
71262
71657
  throw new Error(
71263
- "AgentDelegationRegistry reports an unexpired agent as inactive \u2014 the registry is paused. Agent delegation cannot be changed until it is unpaused."
71658
+ "AgentDelegationRegistry returned an inconsistent read (an unexpired, unpaused Active agent reported inactive); retry."
71264
71659
  );
71265
71660
  }
71266
71661
  return { kind: "rotate" };
@@ -71317,7 +71712,7 @@ var SIGNABLE_FUNCTIONS2 = [
71317
71712
  // this too is client-only and never module-whitelisted.
71318
71713
  "function addAddress(string btcAddress) external"
71319
71714
  ];
71320
- var IFACE2 = new import_ethers32.ethers.Interface(SIGNABLE_FUNCTIONS2);
71715
+ var IFACE2 = new import_ethers33.ethers.Interface(SIGNABLE_FUNCTIONS2);
71321
71716
  function encodeSignable2(fn, args) {
71322
71717
  return IFACE2.encodeFunctionData(fn, args);
71323
71718
  }
@@ -71338,46 +71733,11 @@ function decodeSignable2(data) {
71338
71733
  );
71339
71734
  }
71340
71735
  }
71341
- var MAX_GAS_LIMIT = 5000000n;
71342
- var MAX_FEE_PER_GAS_WEI = 2000000000000n;
71343
- var DEFAULT_MAX_TX_FEE_WEI = 250000000000000000n;
71344
- var DEFAULT_FEE_CEILING = {
71345
- maxGasLimit: MAX_GAS_LIMIT,
71346
- maxFeePerGasWei: MAX_FEE_PER_GAS_WEI,
71347
- maxTxFeeWei: DEFAULT_MAX_TX_FEE_WEI
71348
- };
71349
- function fmtEth(wei) {
71350
- return `${import_ethers34.ethers.formatEther(wei)} ETH`;
71351
- }
71352
- function fmtGwei(wei) {
71353
- return `${import_ethers34.ethers.formatUnits(wei, "gwei")} gwei`;
71354
- }
71355
- function worstCaseFeeWei(gasLimit, maxFeePerGas) {
71356
- if (gasLimit == null || maxFeePerGas == null)
71357
- return null;
71358
- return gasLimit * maxFeePerGas;
71359
- }
71360
- function assertFeeCeiling(gasLimit, maxFeePerGas, raise, ceiling = DEFAULT_FEE_CEILING) {
71361
- if (gasLimit != null && gasLimit > ceiling.maxGasLimit) {
71362
- raise(`gasLimit ${gasLimit} exceeds the signing ceiling of ${ceiling.maxGasLimit}`);
71363
- }
71364
- if (maxFeePerGas != null && maxFeePerGas > ceiling.maxFeePerGasWei) {
71365
- raise(
71366
- `maxFeePerGas ${fmtGwei(maxFeePerGas)} exceeds the signing ceiling of ${fmtGwei(ceiling.maxFeePerGasWei)}`
71367
- );
71368
- }
71369
- const worst = worstCaseFeeWei(gasLimit, maxFeePerGas);
71370
- if (worst != null && worst > ceiling.maxTxFeeWei) {
71371
- raise(
71372
- `worst-case transaction fee ${fmtEth(worst)} (gasLimit ${gasLimit} \xD7 ${fmtGwei(maxFeePerGas)}) exceeds the signing ceiling of ${fmtEth(ceiling.maxTxFeeWei)}.${ceiling.raiseHint ? ` ${ceiling.raiseHint}` : ""}`
71373
- );
71374
- }
71375
- }
71376
71736
  function eqAddr2(a, b) {
71377
71737
  if (!a || !b)
71378
71738
  return false;
71379
71739
  try {
71380
- return import_ethers33.ethers.getAddress(a) === import_ethers33.ethers.getAddress(b);
71740
+ return import_ethers34.ethers.getAddress(a) === import_ethers34.ethers.getAddress(b);
71381
71741
  } catch {
71382
71742
  return false;
71383
71743
  }
@@ -71443,7 +71803,7 @@ function readValue2(tx2) {
71443
71803
  }
71444
71804
  function normalizePositionId2(id) {
71445
71805
  const hex = id.startsWith("0x") ? id : `0x${id}`;
71446
- return import_ethers33.ethers.zeroPadValue(hex, 32).toLowerCase();
71806
+ return import_ethers34.ethers.zeroPadValue(hex, 32).toLowerCase();
71447
71807
  }
71448
71808
  function requirePositionId(actual, expected) {
71449
71809
  const txPositionId = String(actual).toLowerCase();
@@ -71735,18 +72095,18 @@ function buildPsmRedeemTx2(p) {
71735
72095
  var PSM_READS_ABI = ["function supportedStablecoins(address) view returns (bool)"];
71736
72096
  var ERC20_READS_ABI = ["function allowance(address owner, address spender) view returns (uint256)"];
71737
72097
  function psmExchangeReadsFromProvider(provider, psmAddress) {
71738
- const psm = new import_ethers31.ethers.Contract(psmAddress, PSM_READS_ABI, provider);
72098
+ const psm = new import_ethers32.ethers.Contract(psmAddress, PSM_READS_ABI, provider);
71739
72099
  return {
71740
72100
  isStablecoinSupported: async (stablecoin) => await psm.getFunction("supportedStablecoins")(stablecoin),
71741
- allowance: async (token, owner, spender) => await new import_ethers31.ethers.Contract(token, ERC20_READS_ABI, provider).getFunction("allowance")(owner, spender)
72101
+ allowance: async (token, owner, spender) => await new import_ethers32.ethers.Contract(token, ERC20_READS_ABI, provider).getFunction("allowance")(owner, spender)
71742
72102
  };
71743
72103
  }
71744
72104
  var refuse = (direction, msg) => new TxValidationError2(msg, `PSM ${direction}`);
71745
72105
  function requireAddress(direction, label, value) {
71746
- if (!value || !import_ethers31.ethers.isAddress(value)) {
72106
+ if (!value || !import_ethers32.ethers.isAddress(value)) {
71747
72107
  throw refuse(direction, `${label} address is missing or invalid (${String(value)})`);
71748
72108
  }
71749
- return import_ethers31.ethers.getAddress(value);
72109
+ return import_ethers32.ethers.getAddress(value);
71750
72110
  }
71751
72111
  async function planPsmExchange(params) {
71752
72112
  const { direction, amountIn, minOut, vctx, reads } = params;
@@ -72063,6 +72423,384 @@ function formatLiquidationFailureMessage(loanId, errorMessage, btcVault, btcVaul
72063
72423
  const formattedBalance = formatBTCAmount(btcVaultBalance);
72064
72424
  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}`;
72065
72425
  }
72426
+ var CONTRACT_ERROR_FRAGMENTS = [
72427
+ { fragment: "error AboveMaxRedeem(uint256 amount, uint256 maximum)", contracts: ["SimplePSMV2"] },
72428
+ { fragment: "error AboveMaxSwap(uint256 amount, uint256 maximum)", contracts: ["SimplePSMV2"] },
72429
+ { fragment: "error AccessControlBadConfirmation()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72430
+ { fragment: "error AccessControlUnauthorizedAccount(address account, bytes32 neededRole)", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72431
+ { fragment: "error AddressEmptyCode(address target)", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72432
+ { fragment: "error AlreadyActive()", contracts: ["PositionManagerErrors"] },
72433
+ { fragment: "error AlreadySigned()", contracts: ["PositionManagerErrors", "OperationAuthorizationRegistry"] },
72434
+ { fragment: "error AmountMustBePositive()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
72435
+ { fragment: "error ArrayLengthMismatch()", contracts: ["BTCSpendAuthorizer", "SimplePSMV2"] },
72436
+ { fragment: "error BTCSpendAuthorizerNotSet()", contracts: ["LoanOperationsManagerModule"] },
72437
+ { fragment: "error BalanceMismatch()", contracts: ["UCDController"] },
72438
+ { fragment: "error BatchSizeTooLarge()", contracts: ["BTCSpendAuthorizer"] },
72439
+ { fragment: "error BelowMinRedeem(uint256 amount, uint256 minimum)", contracts: ["SimplePSMV2"] },
72440
+ { fragment: "error BelowMinSwap(uint256 amount, uint256 minimum)", contracts: ["SimplePSMV2"] },
72441
+ { fragment: "error BorrowerBTCSpendMutationDisabled()", contracts: ["LoanOperationsManagerModule"] },
72442
+ { fragment: "error BtcAmountTooLarge()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
72443
+ { fragment: "error BtcPriceBoundOutOfRange()", contracts: ["LoanOperationsManagerModule"] },
72444
+ { fragment: "error BtcPriceDeviationExceeded(uint256 signedPrice, uint256 chainlinkPrice, uint16 deviationBps)", contracts: ["LoanOperationsManagerModule"] },
72445
+ { fragment: "error BtcPriceFeedStale(uint256 updatedAt, uint256 maxAge)", contracts: ["LoanOperationsManagerModule"] },
72446
+ { fragment: "error BtcPriceTooHigh()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
72447
+ { fragment: "error BurnCallFailed()", contracts: ["UCDController"] },
72448
+ { fragment: "error BurnGuardFailed(uint8 code)", contracts: ["UCDController"] },
72449
+ { fragment: "error BurnVerificationFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
72450
+ { fragment: "error CannotRemoveLastTerm()", contracts: ["PositionManagerErrors"] },
72451
+ { fragment: "error CannotUpgradeToSelf()", contracts: ["PositionManagerErrors", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer"] },
72452
+ { fragment: "error CircuitBreakerNotActive()", contracts: ["PositionManagerErrors"] },
72453
+ { fragment: "error CircuitBreakerTriggered()", contracts: ["PositionManagerErrors"] },
72454
+ { fragment: "error CollateralOverflow()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
72455
+ { fragment: "error CollateralRatioTooLargeForStorage()", contracts: ["PositionManagerErrors"] },
72456
+ { fragment: "error CollateralRatioTooLow()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
72457
+ { fragment: "error ContractNotDeployed(address addr)", contracts: ["PositionManager"] },
72458
+ { fragment: "error DailyLimitExceeded()", contracts: ["UCDController"] },
72459
+ { fragment: "error DeadZoneViolation()", contracts: ["OperationAuthorizationRegistry"] },
72460
+ { fragment: "error DebtCalculationMismatch()", contracts: ["LoanOperationsManagerModule"] },
72461
+ { fragment: "error DebtNotZero()", contracts: ["PositionManager", "PositionManagerErrors"] },
72462
+ { fragment: "error DebtOverflow()", contracts: ["LoanOperationsManagerModule"] },
72463
+ { fragment: "error DebtUpdateVerificationFailed()", contracts: ["LoanOperationsValidation", "LoanOperationsManagerModule"] },
72464
+ { fragment: "error DebtUpdateVerificationFailedDetailed(bytes32 positionId, uint256 currentDebt, uint256 newDebt, uint256 quantumTimestamp, uint256 supplyAfterMint, uint256 expectedIncrease)", contracts: ["LoanOperationsManagerModule"] },
72465
+ { fragment: "error DecimalsMismatch(uint8 provided, uint8 actual)", contracts: ["SimplePSMV2"] },
72466
+ { fragment: "error DecimalsQueryFailed()", contracts: ["SimplePSMV2"] },
72467
+ { fragment: "error DivisionByZero()", contracts: ["PositionManager", "CollateralManagerModule"] },
72468
+ { fragment: "error ECDSAInvalidSignature()", contracts: ["BTCSpendAuthorizer"] },
72469
+ { fragment: "error ECDSAInvalidSignatureLength(uint256 length)", contracts: ["BTCSpendAuthorizer"] },
72470
+ { fragment: "error ECDSAInvalidSignatureS(bytes32 s)", contracts: ["BTCSpendAuthorizer"] },
72471
+ { fragment: "error ERC1967InvalidImplementation(address implementation)", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72472
+ { fragment: "error ERC1967NonPayable()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72473
+ { fragment: "error EnforcedPause()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72474
+ { fragment: "error EntryFeeTooHigh(uint256 fee, uint256 max)", contracts: ["SimplePSMV2"] },
72475
+ { fragment: "error ExceedsFeeBalance(uint256 requested, uint256 max)", contracts: ["SimplePSMV2"] },
72476
+ { fragment: "error ExceedsMaxLoan()", contracts: ["PositionManagerErrors"] },
72477
+ { fragment: "error ExitFeeTooHigh(uint256 fee, uint256 max)", contracts: ["SimplePSMV2"] },
72478
+ { fragment: "error ExpectedPause()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72479
+ { fragment: "error ExtensionFeeMintingFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
72480
+ { fragment: "error ExtensionNotAllowed()", contracts: ["PositionManagerErrors"] },
72481
+ { fragment: "error FailedCall()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72482
+ { fragment: "error FailedToGetStablecoinDecimals()", contracts: ["SimplePSMV2"] },
72483
+ { fragment: "error FailedToGetUCDDecimals()", contracts: ["SimplePSMV2"] },
72484
+ { fragment: "error FeeOnTransferNotSupported()", contracts: ["SimplePSMV2"] },
72485
+ { fragment: "error FeeTooHigh(uint256 fee, uint256 max)", contracts: ["PositionManagerErrors"] },
72486
+ { fragment: "error FeeTooLow(uint256 fee, uint256 min)", contracts: ["PositionManagerErrors"] },
72487
+ { fragment: "error ImplNotDeployed()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer"] },
72488
+ { fragment: "error ImplementationNotDeployed()", contracts: ["UCDController"] },
72489
+ { fragment: "error InitialBalanceTooLarge()", contracts: ["SimplePSMV2"] },
72490
+ { fragment: "error InsufficientBalance()", contracts: ["PositionManagerErrors"] },
72491
+ { fragment: "error InsufficientCollateralForAmount()", contracts: ["PositionManagerErrors"] },
72492
+ { fragment: "error InsufficientCollateralRatio()", contracts: ["CollateralManagerModule"] },
72493
+ { fragment: "error InsufficientFeeBal()", contracts: ["LoanOperationsManagerModule"] },
72494
+ { fragment: "error InsufficientReserves(uint256 available, uint256 required)", contracts: ["SimplePSMV2"] },
72495
+ { fragment: "error InsufficientSignatures()", contracts: ["OperationAuthorizationRegistry"] },
72496
+ { fragment: "error IntegrityCheckFailed()", contracts: ["PositionManagerErrors"] },
72497
+ { fragment: "error InvalidActionHash()", contracts: ["CollateralManagerModule"] },
72498
+ { fragment: "error InvalidAddress()", contracts: ["PositionManager", "PositionManagerErrors", "OperationAuthorizationRegistry", "CollateralManagerModule", "SimplePSMV2"] },
72499
+ { fragment: "error InvalidAdmin()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer", "SimplePSMV2"] },
72500
+ { fragment: "error InvalidAmount()", contracts: ["PositionManagerErrors", "SimplePSMV2"] },
72501
+ { fragment: "error InvalidBTCPrice()", contracts: ["PositionManager", "PositionManagerErrors"] },
72502
+ { fragment: "error InvalidBytes32()", contracts: ["PositionManager"] },
72503
+ { fragment: "error InvalidCollateralAmount()", contracts: ["PositionManager", "PositionManagerErrors"] },
72504
+ { fragment: "error InvalidController()", contracts: ["SimplePSMV2"] },
72505
+ { fragment: "error InvalidDecimals(uint8 decimals)", contracts: ["SimplePSMV2"] },
72506
+ { fragment: "error InvalidExchangeRate()", contracts: ["SimplePSMV2"] },
72507
+ { fragment: "error InvalidImpl()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer"] },
72508
+ { fragment: "error InvalidImplementation()", contracts: ["UCDController"] },
72509
+ { fragment: "error InvalidInitialization()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72510
+ { fragment: "error InvalidLitSignature()", contracts: ["BTCSpendAuthorizer"] },
72511
+ { fragment: "error InvalidLoanOps()", contracts: ["BTCSpendAuthorizer"] },
72512
+ { fragment: "error InvalidModuleAddress()", contracts: ["UCDController"] },
72513
+ { fragment: "error InvalidNetwork()", contracts: ["PositionManager", "PositionManagerErrors"] },
72514
+ { fragment: "error InvalidNetworkMode()", contracts: ["PositionManagerErrors"] },
72515
+ { fragment: "error InvalidOracleConfig()", contracts: ["LoanOperationsManagerModule"] },
72516
+ { fragment: "error InvalidPKPId()", contracts: ["PositionManagerErrors"] },
72517
+ { fragment: "error InvalidParameter()", contracts: ["UCDController"] },
72518
+ { fragment: "error InvalidPkpPublicKey()", contracts: ["PositionManager", "PositionManagerErrors"] },
72519
+ { fragment: "error InvalidPosMgr()", contracts: ["LoanOperationsManagerModule"] },
72520
+ { fragment: "error InvalidPositionId()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsValidation", "LoanOperationsManagerModule", "CollateralManagerModule"] },
72521
+ { fragment: "error InvalidPositionState()", contracts: ["LoanOperationsManagerModule"] },
72522
+ { fragment: "error InvalidPriceFeed()", contracts: ["LoanOperationsManagerModule"] },
72523
+ { fragment: "error InvalidRecipient()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
72524
+ { fragment: "error InvalidRegistry()", contracts: ["LoanOperationsManagerModule"] },
72525
+ { fragment: "error InvalidRequestedExpiryDate()", contracts: ["PositionManagerErrors"] },
72526
+ { fragment: "error InvalidSignature(string reason)", contracts: ["PositionManager"] },
72527
+ { fragment: "error InvalidSignatureLength()", contracts: ["PositionManagerErrors"] },
72528
+ { fragment: "error InvalidStablecoinAddress()", contracts: ["SimplePSMV2"] },
72529
+ { fragment: "error InvalidStaleSpendAttestation()", contracts: ["BTCSpendAuthorizer"] },
72530
+ { fragment: "error InvalidString(string value)", contracts: ["PositionManager"] },
72531
+ { fragment: "error InvalidTerm()", contracts: ["PositionManager", "PositionManagerErrors"] },
72532
+ { fragment: "error InvalidTerm(uint256 term, uint256 min, uint256 max)", contracts: ["PositionManager"] },
72533
+ { fragment: "error InvalidTermMgr()", contracts: ["LoanOperationsManagerModule"] },
72534
+ { fragment: "error InvalidTermStartTime()", contracts: ["PositionManagerErrors"] },
72535
+ { fragment: "error InvalidToken()", contracts: ["SimplePSMV2"] },
72536
+ { fragment: "error InvalidUCDCtrl()", contracts: ["LoanOperationsManagerModule"] },
72537
+ { fragment: "error InvalidUCDDecimals(uint8 decimals)", contracts: ["SimplePSMV2"] },
72538
+ { fragment: "error InvalidUCDToken()", contracts: ["LoanOperationsManagerModule"] },
72539
+ { fragment: "error InvalidValidatorAddress()", contracts: ["BTCSpendAuthorizer"] },
72540
+ { fragment: "error InvalidValidatorSignature()", contracts: ["PositionManagerErrors"] },
72541
+ { fragment: "error InvalidVaultAddress()", contracts: ["PositionManagerErrors"] },
72542
+ { fragment: "error InvalidVolumeCap(bool isRedeem)", contracts: ["SimplePSMV2"] },
72543
+ { fragment: "error InvalidWithdrawalAddress()", contracts: ["CollateralManagerModule"] },
72544
+ { fragment: "error InvalidWithdrawalLoanStatusType()", contracts: ["CollateralManagerModule"] },
72545
+ { fragment: "error LiquidationsPaused()", contracts: ["PositionManager", "PositionManagerErrors"] },
72546
+ { fragment: "error LoanAmountTooHigh()", contracts: ["PositionManagerErrors"] },
72547
+ { fragment: "error LoanAmountTooLow()", contracts: ["PositionManagerErrors"] },
72548
+ { fragment: "error MaxAuthorizedSpendsReached()", contracts: ["BTCSpendAuthorizer"] },
72549
+ { fragment: "error MaxLoanOutOfBounds()", contracts: ["LoanOperationsManagerModule"] },
72550
+ { fragment: "error MaxRedeemBelowMin(uint256 maximum, uint256 minimum)", contracts: ["SimplePSMV2"] },
72551
+ { fragment: "error MaxRedeemCapDisabled()", contracts: ["SimplePSMV2"] },
72552
+ { fragment: "error MaxSupplyExceeded()", contracts: ["UCDController"] },
72553
+ { fragment: "error MaxSwapBelowMin(uint256 maximum, uint256 minimum)", contracts: ["SimplePSMV2"] },
72554
+ { fragment: "error MaxSwapCapDisabled()", contracts: ["SimplePSMV2"] },
72555
+ { fragment: "error MinLoanOutOfBounds()", contracts: ["LoanOperationsManagerModule"] },
72556
+ { fragment: "error MintBorrowerMismatch()", contracts: ["LoanOperationsManagerModule"] },
72557
+ { fragment: "error MintCallFailed()", contracts: ["UCDController"] },
72558
+ { fragment: "error MintFailed()", contracts: ["LoanOperationsManagerModule"] },
72559
+ { fragment: "error MintGuardFailed(uint8 code)", contracts: ["UCDController"] },
72560
+ { fragment: "error MintVerificationFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
72561
+ { fragment: "error MintVerificationMismatch(uint256 expectedSupply, uint256 currentSupply)", contracts: ["PositionManager", "PositionManagerErrors"] },
72562
+ { fragment: "error MissingVERSION()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer", "UCDController"] },
72563
+ { fragment: "error MissingVersion()", contracts: ["PositionManagerErrors", "CollateralManagerModule"] },
72564
+ { fragment: "error ModuleCallFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
72565
+ { fragment: "error NoFeesToTransfer()", contracts: ["SimplePSMV2"] },
72566
+ { fragment: "error NoRegistry()", contracts: ["PositionManager", "PositionManagerErrors"] },
72567
+ { fragment: "error NoVersion()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer", "UCDController"] },
72568
+ { fragment: "error NonZeroReserves(address stablecoin, uint256 reserves)", contracts: ["SimplePSMV2"] },
72569
+ { fragment: "error NormalizationOverflow()", contracts: ["SimplePSMV2"] },
72570
+ { fragment: "error NotAdminModule()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72571
+ { fragment: "error NotAuthorized()", contracts: ["PositionManager", "PositionManagerErrors"] },
72572
+ { fragment: "error NotAuthorizedConsumer()", contracts: ["OperationAuthorizationRegistry"] },
72573
+ { fragment: "error NotAuthorizedSigner()", contracts: ["OperationAuthorizationRegistry"] },
72574
+ { fragment: "error NotBorrower()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
72575
+ { fragment: "error NotContract()", contracts: ["PositionManagerErrors", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "SimplePSMV2"] },
72576
+ { fragment: "error NotInitializing()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72577
+ { fragment: "error NotLiquidationPkpOwner()", contracts: ["PositionManager", "PositionManagerErrors"] },
72578
+ { fragment: "error NotLiquidator()", contracts: ["PositionManager", "PositionManagerErrors"] },
72579
+ { fragment: "error NotOwner()", contracts: ["OperationAuthorizationRegistry"] },
72580
+ { fragment: "error NotPendingOwner()", contracts: ["OperationAuthorizationRegistry"] },
72581
+ { fragment: "error NotProductionAuthorizer()", contracts: ["PositionManagerErrors", "LoanOperationsManagerModule"] },
72582
+ { fragment: "error NotProductionRegistry()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
72583
+ { fragment: "error OnlyCore()", contracts: ["CollateralManagerModule"] },
72584
+ { fragment: "error OnlyLoanOps()", contracts: ["BTCSpendAuthorizer"] },
72585
+ { fragment: "error OnlyPosMgr()", contracts: ["LoanOperationsManagerModule"] },
72586
+ { fragment: "error OnlyPositionManager()", contracts: ["LoanOperationsManagerModule"] },
72587
+ { fragment: "error OperationInProgress()", contracts: ["PositionManager", "PositionManagerErrors"] },
72588
+ { fragment: "error OracleDecimalMismatch()", contracts: ["LoanOperationsManagerModule"] },
72589
+ { fragment: "error PKPAlreadyUsed()", contracts: ["PositionManagerErrors"] },
72590
+ { fragment: "error PaymentAmountTooLarge()", contracts: ["PositionManager", "PositionManagerErrors"] },
72591
+ { fragment: "error PaymentAmountZero()", contracts: ["PositionManager", "PositionManagerErrors"] },
72592
+ { fragment: "error PaymentMustBeLessThanDebt()", contracts: ["LoanOperationsManagerModule"] },
72593
+ { fragment: "error PaymentMustBePositive()", contracts: ["LoanOperationsManagerModule"] },
72594
+ { fragment: "error PositionAlreadyExists()", contracts: ["PositionManager", "PositionManagerErrors"] },
72595
+ { fragment: "error PositionDoesNotExist()", contracts: ["CollateralManagerModule"] },
72596
+ { fragment: "error PositionLiquidatable()", contracts: ["PositionManagerErrors"] },
72597
+ { fragment: "error PositionManagerNotContract()", contracts: ["LoanOperationsValidation"] },
72598
+ { fragment: "error PositionManagerNotSet()", contracts: ["LoanOperationsValidation"] },
72599
+ { fragment: "error PositionNotActive()", contracts: ["PositionManager", "PositionManagerErrors"] },
72600
+ { fragment: "error PositionNotEligible()", contracts: ["LoanOperationsManagerModule"] },
72601
+ { fragment: "error PositionNotEligibleForOperation()", contracts: ["PositionManager", "PositionManagerErrors"] },
72602
+ { fragment: "error PositionNotFound()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
72603
+ { fragment: "error PositionNotInCore()", contracts: ["LoanOperationsValidation"] },
72604
+ { fragment: "error PositionStatusInvalid()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
72605
+ { fragment: "error PositionWouldBecomeLiquidatable()", contracts: ["PositionManagerErrors"] },
72606
+ { fragment: "error ProposalAlreadyExecuted()", contracts: ["OperationAuthorizationRegistry"] },
72607
+ { fragment: "error ProposalAlreadyExists()", contracts: ["OperationAuthorizationRegistry"] },
72608
+ { fragment: "error ProposalCancelled()", contracts: ["OperationAuthorizationRegistry"] },
72609
+ { fragment: "error ProposalNotFound()", contracts: ["OperationAuthorizationRegistry"] },
72610
+ { fragment: "error PsmBurnSupplyMismatch(uint256 expected, uint256 actual)", contracts: ["SimplePSMV2"] },
72611
+ { fragment: "error PsmMintSupplyMismatch(uint256 expected, uint256 actual)", contracts: ["SimplePSMV2"] },
72612
+ { fragment: "error QuantumAlreadyUsed()", contracts: ["OperationAuthorizationRegistry"] },
72613
+ { fragment: "error QuantumOutsideWindow()", contracts: ["OperationAuthorizationRegistry"] },
72614
+ { fragment: "error RateLimitExceeded()", contracts: ["SimplePSMV2"] },
72615
+ { fragment: "error RatioOverflow()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
72616
+ { fragment: "error RecipientNotAllowed()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
72617
+ { fragment: "error RedeemVolumeExceededThisBlock(address stablecoin, uint256 attempted, uint256 cap)", contracts: ["SimplePSMV2"] },
72618
+ { fragment: "error RedemptionsPaused()", contracts: ["SimplePSMV2"] },
72619
+ { fragment: "error ReentrancyGuardReentrantCall()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72620
+ { fragment: "error RegistryNotSet()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
72621
+ { fragment: "error ReserveOverflow()", contracts: ["SimplePSMV2"] },
72622
+ { fragment: "error ReserveTooLarge()", contracts: ["SimplePSMV2"] },
72623
+ { fragment: "error ReserveUnderflow()", contracts: ["SimplePSMV2"] },
72624
+ { fragment: "error SafeERC20FailedOperation(address token)", contracts: ["PositionManager", "LoanOperationsManagerModule", "SimplePSMV2"] },
72625
+ { fragment: "error SameBlockInteraction()", contracts: ["PositionManager", "PositionManagerErrors"] },
72626
+ { fragment: "error SameImpl()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer"] },
72627
+ { fragment: "error SameImplementation()", contracts: ["PositionManagerErrors", "CollateralManagerModule"] },
72628
+ { fragment: "error SignatureVerificationFailed(bytes4 selector, address recovered, address expected, bytes32 messageHash, uint8 errorCode)", contracts: ["OperationAuthorizationRegistry"] },
72629
+ { fragment: "error SlippageExceeded(uint256 got, uint256 minimum)", contracts: ["SimplePSMV2"] },
72630
+ { fragment: "error SlippageProtectionRequired()", contracts: ["SimplePSMV2"] },
72631
+ { fragment: "error StablecoinAlreadySupported(address stablecoin)", contracts: ["SimplePSMV2"] },
72632
+ { fragment: "error StablecoinNotContract(address stablecoin)", contracts: ["SimplePSMV2"] },
72633
+ { fragment: "error StablecoinNotSupported(address stablecoin)", contracts: ["SimplePSMV2"] },
72634
+ { fragment: "error StablecoinNotSupportedInV1(address stablecoin)", contracts: ["SimplePSMV2"] },
72635
+ { fragment: "error StaleAttestationMismatch()", contracts: ["BTCSpendAuthorizer"] },
72636
+ { fragment: "error StaleAttestationTooOld()", contracts: ["BTCSpendAuthorizer"] },
72637
+ { fragment: "error StaleSpendValidatorNotSet()", contracts: ["BTCSpendAuthorizer"] },
72638
+ { fragment: "error StateHashMismatch()", contracts: ["LoanOperationsValidation", "LoanOperationsManagerModule", "CollateralManagerModule"] },
72639
+ { fragment: "error SwapVolumeExceededThisBlock(address stablecoin, uint256 attempted, uint256 cap)", contracts: ["SimplePSMV2"] },
72640
+ { fragment: "error SyncDriftTooLarge()", contracts: ["SimplePSMV2"] },
72641
+ { fragment: "error TargetAddrRequired()", contracts: ["BTCSpendAuthorizer"] },
72642
+ { fragment: "error TargetExceedsInputValue()", contracts: ["BTCSpendAuthorizer"] },
72643
+ { fragment: "error TargetMustBePositive()", contracts: ["BTCSpendAuthorizer"] },
72644
+ { fragment: "error TermAlreadyExists()", contracts: ["PositionManagerErrors"] },
72645
+ { fragment: "error TermExceedsMaximum()", contracts: ["PositionManager", "PositionManagerErrors"] },
72646
+ { fragment: "error TermNotFound()", contracts: ["PositionManagerErrors"] },
72647
+ { fragment: "error ThresholdTooHigh()", contracts: ["LoanOperationsManagerModule"] },
72648
+ { fragment: "error TimelockNotMet()", contracts: ["OperationAuthorizationRegistry"] },
72649
+ { fragment: "error TimelockRequiredOnThisChain()", contracts: ["OperationAuthorizationRegistry"] },
72650
+ { fragment: "error TimestampOverflow()", contracts: ["LoanOperationsManagerModule"] },
72651
+ { fragment: "error TooManySigners()", contracts: ["OperationAuthorizationRegistry"] },
72652
+ { fragment: "error UTXOAlreadyAuthorized()", contracts: ["BTCSpendAuthorizer"] },
72653
+ { fragment: "error UTXONotAuthorized()", contracts: ["BTCSpendAuthorizer"] },
72654
+ { fragment: "error UUPSUnauthorizedCallContext()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72655
+ { fragment: "error UUPSUnsupportedProxiableUUID(bytes32 slot)", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72656
+ { fragment: "error UcdAmountTooLarge()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
72657
+ { fragment: "error Unauthorized()", contracts: ["UCDController"] },
72658
+ { fragment: "error UnexpectedRoleGrantFailure()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
72659
+ { fragment: "error UnsupportedFeeToken(address token)", contracts: ["SimplePSMV2"] },
72660
+ { fragment: "error UserDailyMintLimitExceeded()", contracts: ["LoanOperationsManagerModule"] },
72661
+ { fragment: "error V2AlreadyInitialized()", contracts: ["SimplePSMV2"] },
72662
+ { fragment: "error ValidationFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
72663
+ { fragment: "error ValidatorNotActive()", contracts: ["OperationAuthorizationRegistry"] },
72664
+ { fragment: "error WithdrawalAddressNotApproved()", contracts: ["CollateralManagerModule"] },
72665
+ { fragment: "error WithdrawalExceedsReserves(uint256 amount, uint256 reserves)", contracts: ["SimplePSMV2"] },
72666
+ { fragment: "error ZeroAddress()", contracts: ["PositionManager", "UCDController"] },
72667
+ { fragment: "error ZeroAmount()", contracts: ["UCDController"] }
72668
+ ];
72669
+ var TABLE = null;
72670
+ function contractErrorTable() {
72671
+ if (TABLE)
72672
+ return TABLE;
72673
+ const table = /* @__PURE__ */ new Map();
72674
+ const iface = new import_ethers35.Interface(CONTRACT_ERROR_FRAGMENTS.map((e) => e.fragment));
72675
+ const contractsByName = new Map(
72676
+ CONTRACT_ERROR_FRAGMENTS.map((e) => [e.fragment.slice("error ".length, e.fragment.indexOf("(")), e.contracts])
72677
+ );
72678
+ iface.forEachError((fragment) => {
72679
+ const existing = table.get(fragment.selector);
72680
+ const contracts = contractsByName.get(fragment.name) ?? [];
72681
+ if (existing) {
72682
+ for (const c of contracts)
72683
+ if (!existing.contracts.includes(c))
72684
+ existing.contracts.push(c);
72685
+ return;
72686
+ }
72687
+ table.set(fragment.selector, {
72688
+ signature: fragment.format("sighash"),
72689
+ fragment,
72690
+ contracts: [...contracts]
72691
+ });
72692
+ });
72693
+ TABLE = table;
72694
+ return table;
72695
+ }
72696
+ function lookupContractError(selector) {
72697
+ return contractErrorTable().get(selector.toLowerCase()) ?? null;
72698
+ }
72699
+ function extractErrorData(error) {
72700
+ const viaQuantum = decodeQuantumRevert(error).data;
72701
+ if (viaQuantum && viaQuantum.length >= 10)
72702
+ return viaQuantum;
72703
+ const candidates = [
72704
+ error?.error?.error?.error?.data,
72705
+ error?.error?.error?.data,
72706
+ error?.data?.data,
72707
+ error?.transaction?.data
72708
+ ];
72709
+ for (const data of candidates) {
72710
+ if (typeof data === "string" && data.startsWith("0x") && data.length >= 10)
72711
+ return data;
72712
+ }
72713
+ const body = typeof error?.body === "string" ? error.body : null;
72714
+ if (body) {
72715
+ try {
72716
+ const parsed = JSON.parse(body);
72717
+ const data = parsed?.error?.data;
72718
+ if (typeof data === "string" && data.startsWith("0x") && data.length >= 10)
72719
+ return data;
72720
+ } catch {
72721
+ }
72722
+ }
72723
+ return null;
72724
+ }
72725
+ function extractRevertString(error) {
72726
+ if (typeof error?.reason === "string" && error.reason.length > 0)
72727
+ return error.reason;
72728
+ const message = typeof error?.message === "string" ? error.message : null;
72729
+ if (!message)
72730
+ return null;
72731
+ const withReasonString = message.match(/reverted with reason string ['"](.+?)['"]/);
72732
+ if (withReasonString)
72733
+ return withReasonString[1];
72734
+ const withReason = message.match(/reason: ['"](.+?)['"]/);
72735
+ return withReason ? withReason[1] : null;
72736
+ }
72737
+ function renderArgs(args) {
72738
+ return args.map((arg) => typeof arg === "object" && arg !== null ? JSON.stringify(arg) : String(arg)).join(", ");
72739
+ }
72740
+ function decodeContractError(error) {
72741
+ const errorData = extractErrorData(error);
72742
+ if (!errorData) {
72743
+ const revertString2 = extractRevertString(error);
72744
+ if (revertString2 && !revertString2.includes("cannot estimate gas")) {
72745
+ return {
72746
+ name: "RevertString",
72747
+ selector: "0x00000000",
72748
+ args: [revertString2],
72749
+ contract: "Unknown",
72750
+ message: `Revert: ${revertString2}`
72751
+ };
72752
+ }
72753
+ return null;
72754
+ }
72755
+ const selector = errorData.slice(0, 10).toLowerCase();
72756
+ if (selector === ERROR_STRING_SELECTOR || selector === PANIC_SELECTOR) {
72757
+ const { name } = decodeQuantumRevert(error);
72758
+ if (name) {
72759
+ return { name, selector, args: [], contract: "Solidity", message: name };
72760
+ }
72761
+ }
72762
+ const entry = lookupContractError(selector);
72763
+ if (entry) {
72764
+ const contract = entry.contracts.join(" | ");
72765
+ let args = [];
72766
+ try {
72767
+ const decoded = new import_ethers35.Interface([entry.fragment]).decodeErrorResult(entry.fragment, errorData);
72768
+ args = Array.from(decoded);
72769
+ } catch {
72770
+ args = [];
72771
+ }
72772
+ return {
72773
+ name: entry.fragment.name,
72774
+ selector,
72775
+ args,
72776
+ contract,
72777
+ message: `${contract}.${entry.fragment.name}(${renderArgs(args)})`
72778
+ };
72779
+ }
72780
+ const revertString = extractRevertString(error);
72781
+ if (revertString && !revertString.includes("cannot estimate gas")) {
72782
+ return {
72783
+ name: "RevertString",
72784
+ selector,
72785
+ args: [revertString],
72786
+ contract: "Unknown",
72787
+ message: `Revert: ${revertString}`
72788
+ };
72789
+ }
72790
+ return {
72791
+ name: "UnknownError",
72792
+ selector,
72793
+ args: [],
72794
+ contract: "Unknown",
72795
+ message: `Unknown error (selector: ${selector})`
72796
+ };
72797
+ }
72798
+ function formatDecodedError(decoded) {
72799
+ if (decoded.args && decoded.args.length > 0) {
72800
+ return `${decoded.contract}.${decoded.name}(${renderArgs(decoded.args)})`;
72801
+ }
72802
+ return `${decoded.contract}.${decoded.name}()`;
72803
+ }
72066
72804
  function normalizeBigNumberish(value) {
72067
72805
  if (value === null || value === void 0) {
72068
72806
  return "0";
@@ -72086,7 +72824,7 @@ function normalizeBigNumberish(value) {
72086
72824
  }
72087
72825
  return value;
72088
72826
  }
72089
- if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function") {
72827
+ if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
72090
72828
  const result = value.toString();
72091
72829
  if (typeof result === "object" && result !== null && "_hex" in result) {
72092
72830
  const resultObj = result;
@@ -73508,12 +74246,21 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
73508
74246
  maxLoanWei: maxLoanValueWei
73509
74247
  })) {
73510
74248
  const debtAfterWei = currentDebtWei + requestAmountWei + baseFeeWei;
74249
+ const suggestionStamp = calculateNextQuantumTimestamp();
74250
+ const room = maxLoanValueWei > currentDebtWei ? maxLoanValueWei - currentDebtWei : 0n;
73511
74251
  const maxPrincipalUcd = Number(
73512
- maxPrincipalWithinLoanCap({
73513
- maxLoanWei: maxLoanValueWei,
73514
- currentDebtWei,
73515
- originationFeeBps: positionTerm.originationFeeBps
73516
- }) / BigInt(10 ** 18)
74252
+ maxPrincipalForFee(
74253
+ room,
74254
+ (principal) => calculateMintFee({
74255
+ mintAmount: principal,
74256
+ mintTimestamp: suggestionStamp,
74257
+ originationFeeBps: positionTerm.originationFeeBps,
74258
+ expiryAt: Number(position2.expiryAt),
74259
+ previousExpiryAt: Number(position2.previousExpiryAt),
74260
+ selectedTerm: Number(position2.selectedTerm),
74261
+ totalTerm: Number(position2.totalTerm)
74262
+ })
74263
+ ) / BigInt(10 ** 18)
73517
74264
  );
73518
74265
  return {
73519
74266
  success: false,
@@ -74251,7 +74998,6 @@ Mint/debt diagnostics (LoanOperationsManager mint path \u2192 increaseDebtFromMi
74251
74998
  let quantumContext = "";
74252
74999
  if (selector === "0x131d9a21" || // QuantumExpired()
74253
75000
  selector === "0x52ce5d58" || // QuantumAlreadyUsed()
74254
- selector === "0x137f3b70" || // InDeadZone()
74255
75001
  selector === "0xbe4b82c1" || // DeadZoneViolation()
74256
75002
  selector === "0x3e76a3c9") {
74257
75003
  const nowSecs = Math.floor(Date.now() / 1e3);
@@ -74374,33 +75120,14 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
74374
75120
  return result;
74375
75121
  } catch (error) {
74376
75122
  let customErrorDetails = "";
74377
- const errorData = error?.data || error?.error?.data?.data || error?.error?.data;
74378
- if (errorData && typeof errorData === "string" && errorData.startsWith("0x") && errorData.length > 10) {
74379
- const selector = errorData.slice(0, 10);
74380
- const knownErrors = {
74381
- "0x8baa579f": "InvalidSignature()",
74382
- "0xd92e233d": "ValidationFailed()",
74383
- "0x3ee5aeb5": "OperationNotAuthorized()",
74384
- "0x70f4b32a": "UnauthorizedSigner()",
74385
- "0x48f5c3ed": "Unauthorized()",
74386
- "0x36bfdeea": "StateHashMismatch()",
74387
- "0xb9d419a7": "DebtUpdateVerificationFailed()",
74388
- "0xc7e20553": "DebtUpdateVerificationFailedDetailed(bytes32,uint256,uint256,uint256,uint256,uint256)",
74389
- "0x0cfd2a97": "MintVerificationMismatch(uint256,uint256)",
74390
- "0x07637bd8": "MintFailed()",
74391
- "0x131d9a21": "QuantumExpired() - Signature quantum window has closed",
74392
- "0x52ce5d58": "QuantumAlreadyUsed() - This quantum was already used for this position",
74393
- "0x137f3b70": "InDeadZone() - Timestamp in dead zone (near quantum boundary)",
74394
- "0xbe4b82c1": "DeadZoneViolation() - Non-current-quantum signature mined in the last 8s of the current quantum",
74395
- "0x3e76a3c9": "QuantumOutsideWindow() - Timestamp not in past/current/next quantum window"
74396
- };
74397
- const errorName = knownErrors[selector] || `Unknown error ${selector}`;
74398
- customErrorDetails = ` [${errorName}]`;
75123
+ const decoded = decodeContractError(error);
75124
+ if (decoded) {
75125
+ customErrorDetails = ` [${formatDecodedError(decoded)}]`;
74399
75126
  if (this.config.debug) {
74400
75127
  log.error("Custom error decoded from transaction receipt", {
74401
- selector,
74402
- errorName,
74403
- errorData
75128
+ selector: decoded.selector,
75129
+ errorName: decoded.name,
75130
+ contract: decoded.contract
74404
75131
  });
74405
75132
  }
74406
75133
  }
@@ -74611,11 +75338,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
74611
75338
  const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
74612
75339
  const btcPrice2 = litActionResult.btcPrice || "0";
74613
75340
  const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
74614
- const usdPricePerBTC = Number(btcPrice2) / 1e8;
74615
- const btcAmount = Number(btcVaultBalance) / 1e8;
74616
- const btcValueUSD = btcAmount * usdPricePerBTC;
74617
- const debtUSD = Number(debt) / 1e18;
74618
- const ratio = debtUSD > 0 ? (btcValueUSD / debtUSD * 100).toFixed(2) : "0.00";
75341
+ const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
74619
75342
  const message = formatLiquidationSkippedMessage(
74620
75343
  request.positionId,
74621
75344
  ratio,
@@ -75104,14 +75827,15 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
75104
75827
  }
75105
75828
  const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
75106
75829
  const btcPrice2 = litActionResult.btcPrice || "0";
75107
- const ratio = debt !== "0" ? (Number(positionDetails.btcVaultBalance || "0") * Number(btcPrice2) / Number(debt) * 100 / 1e8).toFixed(2) : "0.00";
75830
+ const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
75831
+ const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
75108
75832
  const message = formatLiquidationSuccessMessage(
75109
75833
  request.positionId,
75110
75834
  ratio,
75111
75835
  `${liquidationThreshold / 100}`,
75112
75836
  // Convert to percentage
75113
75837
  positionDetails.btcVault || "unknown",
75114
- positionDetails.btcVaultBalance || "0",
75838
+ btcVaultBalance,
75115
75839
  debt,
75116
75840
  btcPrice2
75117
75841
  );
@@ -77595,6 +78319,17 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
77595
78319
  error: `networkFee=${request.networkFee} is \u2265 50% of targetAmount=${request.targetAmount}. Refusing to broadcast \u2014 real Bitcoin fees are typically <1% of value.`
77596
78320
  };
77597
78321
  }
78322
+ const destinationDustLimit = destinationDustShortfall(
78323
+ request.targetAmount,
78324
+ request.networkFee,
78325
+ request.destination
78326
+ );
78327
+ if (destinationDustLimit !== null) {
78328
+ return {
78329
+ success: false,
78330
+ 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.`
78331
+ };
78332
+ }
77598
78333
  const [txid, voutStr] = request.utxoIdentifier.split(":");
77599
78334
  const vout = parseInt(voutStr || "0", 10);
77600
78335
  if (!txid || isNaN(vout)) {
@@ -79070,8 +79805,9 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
79070
79805
  const user = await signer.getAddress();
79071
79806
  const registry = AgentDelegationRegistry__factory.connect(addr, signer);
79072
79807
  let agentAddress;
79073
- const [isActive, record, latestBlock] = await Promise.all([
79808
+ const [isActive, paused, record, latestBlock] = await Promise.all([
79074
79809
  registry.isAgentActive(user),
79810
+ registry.paused(),
79075
79811
  registry.agentOf(user),
79076
79812
  this.getProviderOrThrow().getBlock("latest")
79077
79813
  ]);
@@ -79083,7 +79819,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
79083
79819
  /* HIGH */
79084
79820
  });
79085
79821
  }
79086
- const plan = planAgentBinding({ isActive, record, nowSeconds: latestBlock.timestamp });
79822
+ const plan = planAgentBinding({ isActive, paused, record, nowSeconds: latestBlock.timestamp });
79087
79823
  if (plan.kind === "reuse") {
79088
79824
  agentAddress = plan.agent;
79089
79825
  } else {
@@ -80486,15 +81222,15 @@ var SUPPORTED_STABLECOINS = `
80486
81222
  }`;
80487
81223
 
80488
81224
  // src/boundary/upstream/real/psm-calls.ts
80489
- var import_ethers42 = require("ethers");
81225
+ var import_ethers43 = require("ethers");
80490
81226
 
80491
81227
  // node_modules/@gvnrdao/dh-sdk/dist/sign-guard.mjs
80492
- var import_ethers36 = require("ethers");
80493
81228
  var import_ethers37 = require("ethers");
80494
81229
  var import_ethers38 = require("ethers");
80495
81230
  var import_ethers39 = require("ethers");
80496
81231
  var import_ethers40 = require("ethers");
80497
81232
  var import_ethers41 = require("ethers");
81233
+ var import_ethers42 = require("ethers");
80498
81234
  var TxValidationError3 = class extends Error {
80499
81235
  /**
80500
81236
  * @param subject What is being refused. Defaults to the server-returned transaction the
@@ -80541,7 +81277,7 @@ var SIGNABLE_FUNCTIONS3 = [
80541
81277
  // this too is client-only and never module-whitelisted.
80542
81278
  "function addAddress(string btcAddress) external"
80543
81279
  ];
80544
- var IFACE3 = new import_ethers36.ethers.Interface(SIGNABLE_FUNCTIONS3);
81280
+ var IFACE3 = new import_ethers37.ethers.Interface(SIGNABLE_FUNCTIONS3);
80545
81281
  function encodeSignable3(fn, args) {
80546
81282
  return IFACE3.encodeFunctionData(fn, args);
80547
81283
  }
@@ -80571,10 +81307,10 @@ var DEFAULT_FEE_CEILING2 = {
80571
81307
  maxTxFeeWei: DEFAULT_MAX_TX_FEE_WEI2
80572
81308
  };
80573
81309
  function fmtEth2(wei) {
80574
- return `${import_ethers37.ethers.formatEther(wei)} ETH`;
81310
+ return `${import_ethers38.ethers.formatEther(wei)} ETH`;
80575
81311
  }
80576
81312
  function fmtGwei2(wei) {
80577
- return `${import_ethers37.ethers.formatUnits(wei, "gwei")} gwei`;
81313
+ return `${import_ethers38.ethers.formatUnits(wei, "gwei")} gwei`;
80578
81314
  }
80579
81315
  function worstCaseFeeWei2(gasLimit, maxFeePerGas) {
80580
81316
  if (gasLimit == null || maxFeePerGas == null)
@@ -80601,7 +81337,7 @@ function eqAddr3(a, b) {
80601
81337
  if (!a || !b)
80602
81338
  return false;
80603
81339
  try {
80604
- return import_ethers38.ethers.getAddress(a) === import_ethers38.ethers.getAddress(b);
81340
+ return import_ethers39.ethers.getAddress(a) === import_ethers39.ethers.getAddress(b);
80605
81341
  } catch {
80606
81342
  return false;
80607
81343
  }
@@ -80667,7 +81403,7 @@ function readValue3(tx2) {
80667
81403
  }
80668
81404
  function normalizePositionId3(id) {
80669
81405
  const hex = id.startsWith("0x") ? id : `0x${id}`;
80670
- return import_ethers38.ethers.zeroPadValue(hex, 32).toLowerCase();
81406
+ return import_ethers39.ethers.zeroPadValue(hex, 32).toLowerCase();
80671
81407
  }
80672
81408
  function requirePositionId2(actual, expected) {
80673
81409
  const txPositionId = String(actual).toLowerCase();
@@ -80962,18 +81698,18 @@ function buildPsmRedeemTx3(p) {
80962
81698
  var PSM_READS_ABI2 = ["function supportedStablecoins(address) view returns (bool)"];
80963
81699
  var ERC20_READS_ABI2 = ["function allowance(address owner, address spender) view returns (uint256)"];
80964
81700
  function psmExchangeReadsFromProvider2(provider, psmAddress) {
80965
- const psm = new import_ethers41.ethers.Contract(psmAddress, PSM_READS_ABI2, provider);
81701
+ const psm = new import_ethers42.ethers.Contract(psmAddress, PSM_READS_ABI2, provider);
80966
81702
  return {
80967
81703
  isStablecoinSupported: async (stablecoin) => await psm.getFunction("supportedStablecoins")(stablecoin),
80968
- allowance: async (token, owner, spender) => await new import_ethers41.ethers.Contract(token, ERC20_READS_ABI2, provider).getFunction("allowance")(owner, spender)
81704
+ allowance: async (token, owner, spender) => await new import_ethers42.ethers.Contract(token, ERC20_READS_ABI2, provider).getFunction("allowance")(owner, spender)
80969
81705
  };
80970
81706
  }
80971
81707
  var refuse2 = (direction, msg) => new TxValidationError3(msg, `PSM ${direction}`);
80972
81708
  function requireAddress2(direction, label, value) {
80973
- if (!value || !import_ethers41.ethers.isAddress(value)) {
81709
+ if (!value || !import_ethers42.ethers.isAddress(value)) {
80974
81710
  throw refuse2(direction, `${label} address is missing or invalid (${String(value)})`);
80975
81711
  }
80976
- return import_ethers41.ethers.getAddress(value);
81712
+ return import_ethers42.ethers.getAddress(value);
80977
81713
  }
80978
81714
  async function planPsmExchange2(params) {
80979
81715
  const { direction, amountIn, minOut, vctx, reads } = params;
@@ -81100,8 +81836,8 @@ var PsmCalls = class {
81100
81836
  constructor(deps) {
81101
81837
  this.deps = deps;
81102
81838
  const abi = [...PSM_VIEW_FRAGMENTS, ...PSM_ERROR_FRAGMENTS];
81103
- this.iface = new import_ethers42.ethers.Interface(abi);
81104
- this.psm = new import_ethers42.ethers.Contract(deps.psmAddress, abi, deps.provider);
81839
+ this.iface = new import_ethers43.ethers.Interface(abi);
81840
+ this.psm = new import_ethers43.ethers.Contract(deps.psmAddress, abi, deps.provider);
81105
81841
  }
81106
81842
  psm;
81107
81843
  iface;
@@ -81130,8 +81866,8 @@ var PsmCalls = class {
81130
81866
  });
81131
81867
  }
81132
81868
  return this.call(async () => {
81133
- const ucd = new import_ethers42.ethers.Contract(ucdToken, ERC20_FRAGMENTS, this.deps.provider);
81134
- const stable = new import_ethers42.ethers.Contract(this.deps.stablecoinAddress, ERC20_FRAGMENTS, this.deps.provider);
81869
+ const ucd = new import_ethers43.ethers.Contract(ucdToken, ERC20_FRAGMENTS, this.deps.provider);
81870
+ const stable = new import_ethers43.ethers.Contract(this.deps.stablecoinAddress, ERC20_FRAGMENTS, this.deps.provider);
81135
81871
  const [ucdWei, stablecoinUnits] = await Promise.all([ucd["balanceOf"](holder), stable["balanceOf"](holder)]);
81136
81872
  return { ucdWei: ucdWei.toString(), stablecoinUnits: stablecoinUnits.toString() };
81137
81873
  });
@@ -81249,7 +81985,7 @@ var PsmCalls = class {
81249
81985
  };
81250
81986
 
81251
81987
  // src/boundary/upstream/real/session.ts
81252
- var import_ethers43 = require("ethers");
81988
+ var import_ethers44 = require("ethers");
81253
81989
  var REFRESH_LEEWAY_SEC = 30;
81254
81990
  var LOGIN_TYPES_WITH_AUDIENCE3 = {
81255
81991
  DiamondHands: [
@@ -81297,7 +82033,7 @@ var LitOpsSession = class {
81297
82033
  const message = {
81298
82034
  address: this.wallet.address,
81299
82035
  issuedAt: Math.floor(Date.now() / 1e3),
81300
- nonce: "0x" + Buffer.from(import_ethers43.ethers.randomBytes(32)).toString("hex"),
82036
+ nonce: "0x" + Buffer.from(import_ethers44.ethers.randomBytes(32)).toString("hex"),
81301
82037
  audience: this.serviceEndpoint
81302
82038
  };
81303
82039
  const signature = await this.wallet.signTypedData(
@@ -81339,7 +82075,7 @@ function decodeJwtExp(token) {
81339
82075
  }
81340
82076
 
81341
82077
  // src/boundary/upstream/real/write-ops.ts
81342
- var import_ethers45 = require("ethers");
82078
+ var import_ethers46 = require("ethers");
81343
82079
 
81344
82080
  // src/signer/types.ts
81345
82081
  var OperationDeclined = class extends Error {
@@ -81349,7 +82085,7 @@ var OperationDeclined = class extends Error {
81349
82085
  init_tx_validator();
81350
82086
 
81351
82087
  // src/boundary/upstream/shared/external-bridge/page-crypto.ts
81352
- var import_ethers44 = require("ethers");
82088
+ var import_ethers45 = require("ethers");
81353
82089
  var PERSONAL_SIGN_LAYOUTS = {
81354
82090
  "dh-op-envelope-v1": {
81355
82091
  types: ["bytes32", "uint256", "uint256", "uint256", "bytes32"],
@@ -81370,9 +82106,9 @@ function hashForLayout(layout, fields) {
81370
82106
  const values = def.fieldOrder.map((name) => {
81371
82107
  const raw = fields[name];
81372
82108
  if (raw === void 0) throw new Error(`page-crypto: layout "${layout}" missing field "${name}"`);
81373
- return hashUtf8.has(name) ? import_ethers44.ethers.keccak256(import_ethers44.ethers.toUtf8Bytes(raw)) : raw;
82109
+ return hashUtf8.has(name) ? import_ethers45.ethers.keccak256(import_ethers45.ethers.toUtf8Bytes(raw)) : raw;
81374
82110
  });
81375
- return import_ethers44.ethers.solidityPackedKeccak256(def.types, values);
82111
+ return import_ethers45.ethers.solidityPackedKeccak256(def.types, values);
81376
82112
  }
81377
82113
  var PAGE_CRYPTO_JS = `"use strict";
81378
82114
  (function () {
@@ -81615,7 +82351,7 @@ function mcpExpected(leg) {
81615
82351
  }
81616
82352
  var OP_LAYOUT = "dh-op-envelope-v1";
81617
82353
  function randomNonceHex() {
81618
- return "0x" + Buffer.from(import_ethers45.ethers.randomBytes(16)).toString("hex");
82354
+ return "0x" + Buffer.from(import_ethers46.ethers.randomBytes(16)).toString("hex");
81619
82355
  }
81620
82356
  async function postJson(url2, body, headers) {
81621
82357
  const res = await fetch(url2, {
@@ -81676,7 +82412,7 @@ function buildWriteOps(deps) {
81676
82412
  return {
81677
82413
  to: String(tx2["to"] ?? ""),
81678
82414
  data: String(tx2["data"] ?? "0x"),
81679
- value: tx2["value"] != null ? import_ethers45.ethers.toBeHex(BigInt(String(tx2["value"]))) : "0x0",
82415
+ value: tx2["value"] != null ? import_ethers46.ethers.toBeHex(BigInt(String(tx2["value"]))) : "0x0",
81680
82416
  chainId: tx2["chainId"] != null ? Number(tx2["chainId"]) : chainId
81681
82417
  };
81682
82418
  }
@@ -81842,7 +82578,7 @@ function buildWriteOps(deps) {
81842
82578
  mintedUcdWei: minted,
81843
82579
  feeUcdWei: mintFee,
81844
82580
  echoedAmountUcdWei: minted,
81845
- authorization: auth(action, `mint ${import_ethers45.ethers.formatEther(amountWei)} UCD against ${p.positionId}`, r.value.digest)
82581
+ authorization: auth(action, `mint ${import_ethers46.ethers.formatEther(amountWei)} UCD against ${p.positionId}`, r.value.digest)
81846
82582
  },
81847
82583
  { id: SOURCE5, kind: "lit-ops", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }
81848
82584
  );
@@ -81883,7 +82619,7 @@ function buildWriteOps(deps) {
81883
82619
  txRef: { kind: "eth-tx", id: r.value.txHash },
81884
82620
  paidUcdWei: paid,
81885
82621
  echoedAmountUcdWei: paid,
81886
- authorization: auth(action, `repay ${import_ethers45.ethers.formatEther(amountWei)} UCD on ${p.positionId}`, r.value.digest)
82622
+ authorization: auth(action, `repay ${import_ethers46.ethers.formatEther(amountWei)} UCD on ${p.positionId}`, r.value.digest)
81887
82623
  },
81888
82624
  { id: SOURCE5, kind: "lit-ops", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }
81889
82625
  );
@@ -82146,7 +82882,7 @@ function buildWriteOps(deps) {
82146
82882
  }
82147
82883
 
82148
82884
  // src/signer/eoa-dh.ts
82149
- var import_ethers46 = require("ethers");
82885
+ var import_ethers47 = require("ethers");
82150
82886
  var EoaDHSigner = class {
82151
82887
  constructor(wallet, broadcast, clock = Date.now) {
82152
82888
  this.wallet = wallet;
@@ -82163,7 +82899,7 @@ var EoaDHSigner = class {
82163
82899
  async signAuthorization(spec) {
82164
82900
  const quantumTs = nextQuantumTimestamp(this.clock());
82165
82901
  const { fields, hashHex } = spec.stamp(quantumTs);
82166
- const signature = await this.wallet.signMessage(import_ethers46.ethers.getBytes(hashHex));
82902
+ const signature = await this.wallet.signMessage(import_ethers47.ethers.getBytes(hashHex));
82167
82903
  return { signature, quantumTs, fields };
82168
82904
  }
82169
82905
  async wrapInnerTx(innerTx) {
@@ -82181,10 +82917,10 @@ var EoaDHSigner = class {
82181
82917
 
82182
82918
  // src/signer/external-eoa.ts
82183
82919
  var import_node_crypto7 = require("crypto");
82184
- var import_ethers48 = require("ethers");
82920
+ var import_ethers49 = require("ethers");
82185
82921
 
82186
82922
  // src/boundary/upstream/shared/external-bridge/verify-landed-tx.ts
82187
- var import_ethers47 = require("ethers");
82923
+ var import_ethers48 = require("ethers");
82188
82924
  function eq2(a, b) {
82189
82925
  return a.toLowerCase() === b.toLowerCase();
82190
82926
  }
@@ -82207,7 +82943,7 @@ function compareLandedTx(landed, approved, borrower) {
82207
82943
  return { status: "verified", from: landed.from, hash: landed.hash };
82208
82944
  }
82209
82945
  function verifyRawSignedTx(rawSignedTx, approved, borrower) {
82210
- const parsed = import_ethers47.ethers.Transaction.from(rawSignedTx);
82946
+ const parsed = import_ethers48.ethers.Transaction.from(rawSignedTx);
82211
82947
  if (!parsed.from || !parsed.to || !parsed.hash) {
82212
82948
  return { status: "mismatch", hash: parsed.hash ?? "0x", reason: "the returned raw transaction is unsigned or malformed" };
82213
82949
  }
@@ -82245,7 +82981,7 @@ async function gasHintAcrossBlocks(provider, from, tx2, action) {
82245
82981
  for (let attempt = 0; attempt < 4; attempt++) {
82246
82982
  try {
82247
82983
  const est = await provider.estimateGas({ from, to: tx2.to, data: tx2.data, value: BigInt(tx2.value) });
82248
- return import_ethers48.ethers.toBeHex(est * 15n / 10n);
82984
+ return import_ethers49.ethers.toBeHex(est * 15n / 10n);
82249
82985
  } catch (e) {
82250
82986
  lastErr = e;
82251
82987
  await new Promise((r) => setTimeout(r, 13e3));
@@ -82295,7 +83031,7 @@ var ExternalEoaDHSigner = class {
82295
83031
  throw new OperationDeclined(`the ${spec.action} authorization was not signed: ${describeOutcome(outcome)}`);
82296
83032
  }
82297
83033
  const finalHash = spec.stamp(used.quantumTs).hashHex;
82298
- const recovered = import_ethers48.ethers.verifyMessage(import_ethers48.ethers.getBytes(finalHash), outcome.signature);
83034
+ const recovered = import_ethers49.ethers.verifyMessage(import_ethers49.ethers.getBytes(finalHash), outcome.signature);
82299
83035
  if (recovered.toLowerCase() !== this.deps.borrower.toLowerCase()) {
82300
83036
  throw new Error(`the ${spec.action} authorization was signed by ${recovered}, not the borrower ${this.deps.borrower}`);
82301
83037
  }
@@ -82306,7 +83042,7 @@ var ExternalEoaDHSigner = class {
82306
83042
  }
82307
83043
  async submitValidatedTx(outerTx, ctx) {
82308
83044
  const approved = toApprovedTx(outerTx, this.deps.chainId);
82309
- const gas = outerTx.gasLimit != null ? import_ethers48.ethers.toBeHex(BigInt(String(outerTx.gasLimit))) : await gasHintAcrossBlocks(this.deps.provider, this.deps.borrower, approved, ctx.action);
83045
+ const gas = outerTx.gasLimit != null ? import_ethers49.ethers.toBeHex(BigInt(String(outerTx.gasLimit))) : await gasHintAcrossBlocks(this.deps.provider, this.deps.borrower, approved, ctx.action);
82310
83046
  const outcome = await this.deps.bridge.requestSignature({
82311
83047
  id: (0, import_node_crypto7.randomUUID)(),
82312
83048
  kind: "transaction",
@@ -82340,7 +83076,7 @@ var ExternalEoaDHSigner = class {
82340
83076
  return new BridgeEthersSigner(this.deps);
82341
83077
  }
82342
83078
  };
82343
- var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers48.ethers.AbstractSigner {
83079
+ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers49.ethers.AbstractSigner {
82344
83080
  constructor(deps) {
82345
83081
  super(deps.provider);
82346
83082
  this.deps = deps;
@@ -82351,13 +83087,13 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers48.ether
82351
83087
  return this.deps.borrower;
82352
83088
  }
82353
83089
  async signMessage(message) {
82354
- const bytes = typeof message === "string" ? import_ethers48.ethers.toUtf8Bytes(message) : message;
83090
+ const bytes = typeof message === "string" ? import_ethers49.ethers.toUtf8Bytes(message) : message;
82355
83091
  if (bytes.length !== 32) {
82356
83092
  throw new Error(
82357
83093
  `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.`
82358
83094
  );
82359
83095
  }
82360
- const hashHex = import_ethers48.ethers.hexlify(bytes).toLowerCase();
83096
+ const hashHex = import_ethers49.ethers.hexlify(bytes).toLowerCase();
82361
83097
  const nowMs = (this.deps.clock ?? Date.now)();
82362
83098
  const expiresAtSec = nextQuantumTimestamp(nowMs);
82363
83099
  const secondsLeft = Math.max(0, expiresAtSec - Math.floor(nowMs / 1e3));
@@ -82387,7 +83123,7 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers48.ether
82387
83123
  if (outcome.status !== "approved" || !outcome.signature) {
82388
83124
  throw new OperationDeclined(`the btc-withdrawal authorization was not signed: ${describeOutcome(outcome)}`);
82389
83125
  }
82390
- const recovered = import_ethers48.ethers.verifyMessage(bytes, outcome.signature);
83126
+ const recovered = import_ethers49.ethers.verifyMessage(bytes, outcome.signature);
82391
83127
  if (recovered.toLowerCase() !== this.deps.borrower.toLowerCase()) {
82392
83128
  throw new Error(`the btc-withdrawal authorization was signed by ${recovered}, not the borrower ${this.deps.borrower}`);
82393
83129
  }
@@ -82421,11 +83157,11 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers48.ether
82421
83157
  const approved = {
82422
83158
  to: tx2.to,
82423
83159
  data: tx2.data,
82424
- value: tx2.value != null ? import_ethers48.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
83160
+ value: tx2.value != null ? import_ethers49.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
82425
83161
  chainId: tx2.chainId != null ? Number(tx2.chainId) : this.deps.chainId
82426
83162
  };
82427
83163
  const card = cardForTx(approved);
82428
- 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));
83164
+ const gas = tx2.gasLimit != null ? import_ethers49.ethers.toBeHex(BigInt(String(tx2.gasLimit))) : await gasHintAcrossBlocks(this.deps.provider, this.deps.borrower, approved, describeFn(approved.data));
82429
83165
  const outcome = await this.deps.bridge.requestSignature({
82430
83166
  id: (0, import_node_crypto7.randomUUID)(),
82431
83167
  kind: "transaction",
@@ -82467,7 +83203,7 @@ function toApprovedTx(tx2, fallbackChainId) {
82467
83203
  return {
82468
83204
  to: tx2.to,
82469
83205
  data: tx2.data,
82470
- value: tx2.value != null ? import_ethers48.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
83206
+ value: tx2.value != null ? import_ethers49.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
82471
83207
  chainId: tx2.chainId != null ? Number(tx2.chainId) : fallbackChainId
82472
83208
  };
82473
83209
  }
@@ -82511,7 +83247,7 @@ var MIN_CONFIRMATIONS = { mainnet: 6, sepolia: 1 };
82511
83247
  var RealUpstreamPlugin = class {
82512
83248
  constructor(config, wallet, runtime) {
82513
83249
  this.config = config;
82514
- this.provider = new import_ethers49.ethers.JsonRpcProvider(config.rpcUrl, config.chainId);
83250
+ this.provider = new import_ethers50.ethers.JsonRpcProvider(config.rpcUrl, config.chainId);
82515
83251
  this.wallet = wallet ?? null;
82516
83252
  this.runtime = runtime ?? null;
82517
83253
  this.session = wallet ? new LitOpsSession(wallet.connect(this.provider), config.serviceEndpoint, config.chainId) : null;
@@ -82548,11 +83284,16 @@ var RealUpstreamPlugin = class {
82548
83284
  this.src("subgraph")
82549
83285
  );
82550
83286
  },
82551
- getPositionEvents: async () => upFail({
82552
- kind: "unavailable",
82553
- source: "subgraph",
82554
- message: "event history is not mapped in this delivery of the real adapter (indexer projection pending)"
82555
- })
83287
+ getPositionEvents: async () => (
83288
+ // PERMANENT capability gap, not a transient outage: the real adapter has no indexer
83289
+ // projection for event history, and this build never will. `unsupported` →
83290
+ // NOT_IMPLEMENTED so the guide does not tell the model to retry it (C-44).
83291
+ upFail({
83292
+ kind: "unsupported",
83293
+ source: "subgraph",
83294
+ 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"
83295
+ })
83296
+ )
82556
83297
  };
82557
83298
  this.chain = {
82558
83299
  getPositionDetails: (id) => this.chainRead(() => this.readPositionDetails(id)),
@@ -82813,14 +83554,14 @@ var RealUpstreamPlugin = class {
82813
83554
  if (!pkpValidation) {
82814
83555
  throw new Error(`the SDK's ${this.config.network} deployment table has no PKPValidation address \u2014 cannot verify validator version ${version2}.`);
82815
83556
  }
82816
- const registry = new import_ethers49.ethers.Contract(pkpValidation, ["function validatorForVersion(uint256) view returns (address)"], this.provider);
83557
+ const registry = new import_ethers50.ethers.Contract(pkpValidation, ["function validatorForVersion(uint256) view returns (address)"], this.provider);
82817
83558
  let validator;
82818
83559
  try {
82819
83560
  validator = await registry.validatorForVersion(version2);
82820
83561
  } catch (e) {
82821
83562
  throw new Error(`could not verify validator version ${version2} on-chain (PKPValidation ${pkpValidation}): ${e.message}`);
82822
83563
  }
82823
- if (validator === import_ethers49.ethers.ZeroAddress) {
83564
+ if (validator === import_ethers50.ethers.ZeroAddress) {
82824
83565
  throw new Error(
82825
83566
  `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.`
82826
83567
  );
@@ -83096,7 +83837,7 @@ var RealUpstreamPlugin = class {
83096
83837
  );
83097
83838
  if (!r.ok) return r;
83098
83839
  const raw = r.value.data.supportedStablecoins ?? [];
83099
- const bad = raw.find((x) => !import_ethers49.ethers.isAddress(String(x.address)) || !Number.isFinite(Number(x.decimals)));
83840
+ const bad = raw.find((x) => !import_ethers50.ethers.isAddress(String(x.address)) || !Number.isFinite(Number(x.decimals)));
83100
83841
  if (bad) {
83101
83842
  return {
83102
83843
  ok: false,
@@ -83179,7 +83920,7 @@ var RealUpstreamPlugin = class {
83179
83920
  };
83180
83921
  }
83181
83922
  const symbol = raw.toLowerCase();
83182
- if (import_ethers49.ethers.isAddress(raw)) return this.psmCallsFor(symbol);
83923
+ if (import_ethers50.ethers.isAddress(raw)) return this.psmCallsFor(symbol);
83183
83924
  const verified = await this.verifiedStablecoins();
83184
83925
  if (!verified.ok) return { ok: false, failure: verified.failure };
83185
83926
  const hits = verified.rows.filter((r) => r.symbol.toLowerCase() === symbol);
@@ -83217,7 +83958,7 @@ var RealUpstreamPlugin = class {
83217
83958
  * chain, then sign.
83218
83959
  */
83219
83960
  async psmCallsFor(stablecoinAddress) {
83220
- if (!import_ethers49.ethers.isAddress(stablecoinAddress)) {
83961
+ if (!import_ethers50.ethers.isAddress(stablecoinAddress)) {
83221
83962
  throw new Error(`psmCallsFor requires a resolved 0x address, got '${stablecoinAddress}' \u2014 resolve through psmCallsForChoice`);
83222
83963
  }
83223
83964
  const key = stablecoinAddress.toLowerCase();
@@ -83237,9 +83978,9 @@ var RealUpstreamPlugin = class {
83237
83978
  let supported;
83238
83979
  let symbol;
83239
83980
  try {
83240
- const psm = new import_ethers49.ethers.Contract(psmAddress, ["function supportedStablecoins(address) view returns (bool)"], this.provider);
83981
+ const psm = new import_ethers50.ethers.Contract(psmAddress, ["function supportedStablecoins(address) view returns (bool)"], this.provider);
83241
83982
  supported = await psm["supportedStablecoins"](key);
83242
- const erc20 = new import_ethers49.ethers.Contract(key, ["function symbol() view returns (string)"], this.provider);
83983
+ const erc20 = new import_ethers50.ethers.Contract(key, ["function symbol() view returns (string)"], this.provider);
83243
83984
  symbol = await erc20["symbol"]();
83244
83985
  } catch (e) {
83245
83986
  return { ok: false, failure: { kind: "unavailable", source: "chain-rpc", message: `PSM stablecoin check failed for ${key}: ${e.message}` } };
@@ -83452,7 +84193,7 @@ var RealUpstreamPlugin = class {
83452
84193
  const pm = this.contracts["PositionManager"];
83453
84194
  if (!pm) return false;
83454
84195
  try {
83455
- const c = new import_ethers49.ethers.Contract(pm, PAUSABLE_ABI, this.provider);
84196
+ const c = new import_ethers50.ethers.Contract(pm, PAUSABLE_ABI, this.provider);
83456
84197
  return Boolean(await c["paused"]());
83457
84198
  } catch {
83458
84199
  return false;
@@ -83461,16 +84202,16 @@ var RealUpstreamPlugin = class {
83461
84202
  async readPositionDetails(id) {
83462
84203
  const core = this.contracts["PositionManagerCoreModule"] ?? this.contracts["PositionManager"];
83463
84204
  if (!core) throw new Error(`no PositionManager address for network ${this.config.network}`);
83464
- const c = new import_ethers49.ethers.Contract(core, POSITION_DETAILS_ABI, this.provider);
84205
+ const c = new import_ethers50.ethers.Contract(core, POSITION_DETAILS_ABI, this.provider);
83465
84206
  let d;
83466
84207
  try {
83467
- d = await c["getPositionDetails"](import_ethers49.ethers.zeroPadValue(id, 32));
84208
+ d = await c["getPositionDetails"](import_ethers50.ethers.zeroPadValue(id, 32));
83468
84209
  } catch (e) {
83469
84210
  if (e.code === "CALL_EXCEPTION") return null;
83470
84211
  throw e;
83471
84212
  }
83472
84213
  const borrower = String(d["borrower"]);
83473
- if (borrower === import_ethers49.ethers.ZeroAddress) return null;
84214
+ if (borrower === import_ethers50.ethers.ZeroAddress) return null;
83474
84215
  return {
83475
84216
  positionId: String(d["positionId"]),
83476
84217
  pkpId: String(d["pkpId"]),
@@ -83967,6 +84708,8 @@ var SignatureBridge = class {
83967
84708
  wcTransport = null;
83968
84709
  /** True while a WalletConnect session is THE wallet — ceremonies route over WC. */
83969
84710
  wcActive = false;
84711
+ /** Page session that most recently asked for a pairing QR — see `serveWcPairing`. */
84712
+ pairingSessionId = null;
83970
84713
  keystoreUnlock;
83971
84714
  unlockToken = null;
83972
84715
  unlockSession = null;
@@ -84097,7 +84840,8 @@ var SignatureBridge = class {
84097
84840
  ...handlers?.finalize ? { finalize: handlers.finalize } : {},
84098
84841
  owner: this.wcActive ? "wc" : "page",
84099
84842
  dispatched: false,
84100
- lastAttachedMs: now
84843
+ lastAttachedMs: now,
84844
+ finalizedBy: null
84101
84845
  };
84102
84846
  this.pending.set(request.id, entry);
84103
84847
  if (entry.owner === "wc") {
@@ -84130,7 +84874,8 @@ var SignatureBridge = class {
84130
84874
  // ceremony could not reach quorum through the very pages it is broadcast to.
84131
84875
  owner: "both",
84132
84876
  dispatched: false,
84133
- lastAttachedMs: now
84877
+ lastAttachedMs: now,
84878
+ finalizedBy: null
84134
84879
  };
84135
84880
  this.pending.set(request.id, entry);
84136
84881
  this.pushEntry(entry);
@@ -84228,7 +84973,7 @@ var SignatureBridge = class {
84228
84973
  * receives nothing cannot show anything. Distinct from `attachedNow()`, which counts
84229
84974
  * WalletConnect and must stay global for the connector's eviction predicate. */
84230
84975
  pageAttached() {
84231
- for (const s of this.sessions.values()) if (!s.refused && s.sse) return true;
84976
+ for (const s of this.sessions.values()) if (s.sse && this.authorized(s)) return true;
84232
84977
  return false;
84233
84978
  }
84234
84979
  /** Attachment for ONE entry — the wallet that entry is actually waiting on. The global
@@ -84245,6 +84990,7 @@ var SignatureBridge = class {
84245
84990
  * the deadline is checked first so expiry semantics stay pinned (T-EXT-03). */
84246
84991
  sweep() {
84247
84992
  const now = this.clock();
84993
+ this.evictDeadSessions();
84248
84994
  for (const entry of this.pending.values()) {
84249
84995
  if (entry.settled) continue;
84250
84996
  if (now >= entry.deadlineMs) {
@@ -84357,12 +85103,13 @@ var SignatureBridge = class {
84357
85103
  this.deny(res, 403, "this approval link has expired \u2014 ask for a fresh one (signer_setup status) and reopen");
84358
85104
  return;
84359
85105
  }
85106
+ this.makeRoomForSession();
84360
85107
  if (this.sessions.size >= MAX_SESSIONS) {
84361
85108
  this.deny(res, 429, `too many open approval pages (${MAX_SESSIONS}) \u2014 close one and retry`);
84362
85109
  return;
84363
85110
  }
84364
85111
  const sessionId = (0, import_node_crypto8.randomBytes)(24).toString("hex");
84365
- this.sessions.set(sessionId, { wallet: null, sse: null, refused: null });
85112
+ this.sessions.set(sessionId, { wallet: null, sse: null, refused: null, lastSeenMs: this.clock(), wcPaired: false });
84366
85113
  const page = htmlPageSecurityHeaders();
84367
85114
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
84368
85115
  res.end(renderApprovalPage(sessionId, page.nonce));
@@ -84377,6 +85124,7 @@ var SignatureBridge = class {
84377
85124
  * fresh pairing URI. A wallet approving the pairing becomes THE wallet. */
84378
85125
  async serveWcPairing(url2, res) {
84379
85126
  if (!this.checkSession(url2.searchParams.get("s"), res)) return;
85127
+ this.pairingSessionId = url2.searchParams.get("s");
84380
85128
  if (!this.wcConfig) {
84381
85129
  this.deny(res, 404, "WalletConnect is not configured (set DH_WC_PROJECT_ID)");
84382
85130
  return;
@@ -84400,6 +85148,10 @@ var SignatureBridge = class {
84400
85148
  }
84401
85149
  this.wcActive = info !== null;
84402
85150
  this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
85151
+ if (info && this.pairingSessionId) {
85152
+ const paired = this.sessions.get(this.pairingSessionId);
85153
+ if (paired) paired.wcPaired = true;
85154
+ }
84403
85155
  if (info === null) {
84404
85156
  for (const entry of this.pending.values()) {
84405
85157
  if (!entry.settled && !entry.collect) {
@@ -84477,9 +85229,7 @@ var SignatureBridge = class {
84477
85229
  res.write(":connected\n\n");
84478
85230
  session.sse?.end();
84479
85231
  session.sse = res;
84480
- for (const entry of this.pending.values()) {
84481
- if (!entry.settled) res.write(this.wireFor(entry));
84482
- }
85232
+ this.replayPending(session);
84483
85233
  const keepAlive = setInterval(() => res.write(":ka\n\n"), 2e4);
84484
85234
  keepAlive.unref();
84485
85235
  res.on("close", () => {
@@ -84504,6 +85254,7 @@ var SignatureBridge = class {
84504
85254
  }
84505
85255
  session.wallet = { account, chainId };
84506
85256
  this.wallet = { account, chainId };
85257
+ this.replayPending(session);
84507
85258
  this.ok(res);
84508
85259
  }
84509
85260
  /** C-47: the single predicate every wallet account is admitted through. There are THREE
@@ -84587,7 +85338,9 @@ var SignatureBridge = class {
84587
85338
  /** Click-time re-stamp (A0.9): returns the FRESH personal-sign payload for a pending
84588
85339
  * request. Idempotent for requests without a finalize handler (payload as enqueued). */
84589
85340
  async onFinalize(body, res) {
84590
- if (!this.sessionOf(body["sessionId"], res)) return;
85341
+ const sessionId = String(body["sessionId"] ?? "");
85342
+ const session = this.decidingSessionOf(body["sessionId"], res);
85343
+ if (!session) return;
84591
85344
  const entry = this.pending.get(String(body["requestId"] ?? ""));
84592
85345
  if (!entry || entry.settled) {
84593
85346
  this.deny(res, 404, "unknown or already-settled requestId");
@@ -84601,6 +85354,12 @@ var SignatureBridge = class {
84601
85354
  this.deny(res, 409, "a mobile wallet is holding this approval \u2014 it is read-only here; approve or decline it in the wallet");
84602
85355
  return;
84603
85356
  }
85357
+ const holder = entry.finalizedBy ? this.sessions.get(entry.finalizedBy) : void 0;
85358
+ if (entry.finalizedBy && entry.finalizedBy !== sessionId && holder?.sse) {
85359
+ this.deny(res, 409, "another approval page is signing this request \u2014 approve it there, or close that page and retry");
85360
+ return;
85361
+ }
85362
+ entry.finalizedBy = sessionId;
84604
85363
  if (entry.finalize) {
84605
85364
  let fresh;
84606
85365
  try {
@@ -84620,7 +85379,7 @@ var SignatureBridge = class {
84620
85379
  res.end(JSON.stringify({ request: entry.request }));
84621
85380
  }
84622
85381
  onResult(body, res) {
84623
- if (!this.sessionOf(body["sessionId"], res)) return;
85382
+ if (!this.decidingSessionOf(body["sessionId"], res)) return;
84624
85383
  const entry = this.pending.get(String(body["requestId"] ?? ""));
84625
85384
  if (!entry || entry.settled) {
84626
85385
  this.deny(res, 404, "unknown or already-settled requestId");
@@ -84693,7 +85452,7 @@ var SignatureBridge = class {
84693
85452
  /** Broadcast a pending entry to EVERY open page (multi-owner links — plan 06 §1.5). */
84694
85453
  pushEntry(entry) {
84695
85454
  const data = this.wireFor(entry);
84696
- for (const s of this.sessions.values()) if (!s.refused) s.sse?.write(data);
85455
+ for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
84697
85456
  }
84698
85457
  /** Progress goes out as a NAMED event so `es.onmessage` request handling never sees it. */
84699
85458
  pushProgress(payload) {
@@ -84701,7 +85460,51 @@ var SignatureBridge = class {
84701
85460
  data: ${JSON.stringify(payload)}
84702
85461
 
84703
85462
  `;
84704
- for (const s of this.sessions.values()) if (!s.refused) s.sse?.write(data);
85463
+ for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
85464
+ }
85465
+ /** Replay every undecided card to ONE session — used when a session becomes authorized
85466
+ * (hello) after its stream was already open, which is the ordinary page order: the page
85467
+ * attaches its EventSource, then the wallet prompt resolves. Without this the newly
85468
+ * connected page would sit blank until the next push. */
85469
+ replayPending(session) {
85470
+ if (!session.sse || !this.authorized(session)) return;
85471
+ for (const entry of this.pending.values()) {
85472
+ if (!entry.settled) session.sse.write(this.wireFor(entry));
85473
+ }
85474
+ }
85475
+ /** Retire quarantined sessions that hold no stream. Always safe: a refused session is
85476
+ * denied on every route anyway, so keeping it costs a slot and buys nothing. */
85477
+ evictDeadSessions() {
85478
+ for (const [id, s] of this.sessions) if (s.refused && !s.sse) this.sessions.delete(id);
85479
+ }
85480
+ /**
85481
+ * Free a slot for an incoming page load when the ceiling is reached.
85482
+ *
85483
+ * MAX_SESSIONS was a ceiling with NO eviction — nothing but `close()` ever removed a
85484
+ * session — and every page load mints one (a reload is a new session). A long-lived
85485
+ * hosted bridge therefore reached 16 through ordinary use and 429'd the user out of
85486
+ * approving their own ceremonies, permanently, with "close one and retry" as the advice
85487
+ * for pages that were already closed.
85488
+ *
85489
+ * Eviction is ON DEMAND and never touches a session with a live SSE stream: that stream
85490
+ * is a page open in a browser right now, and the C1 contract is that live sessions
85491
+ * survive. Among the streamless it takes the least recently seen — the closed tab.
85492
+ */
85493
+ makeRoomForSession() {
85494
+ this.evictDeadSessions();
85495
+ while (this.sessions.size >= MAX_SESSIONS) {
85496
+ let oldestId = null;
85497
+ let oldestSeen = Infinity;
85498
+ for (const [id, s] of this.sessions) {
85499
+ if (s.sse) continue;
85500
+ if (s.lastSeenMs < oldestSeen) {
85501
+ oldestSeen = s.lastSeenMs;
85502
+ oldestId = id;
85503
+ }
85504
+ }
85505
+ if (oldestId === null) return;
85506
+ this.sessions.delete(oldestId);
85507
+ }
84705
85508
  }
84706
85509
  /**
84707
85510
  * C-47: `this.wallet` is DERIVED, never guessed.
@@ -84744,12 +85547,46 @@ data: ${JSON.stringify(payload)}
84744
85547
  }
84745
85548
  this.rebuildSharedWallet();
84746
85549
  }
85550
+ /**
85551
+ * A session that may SEE cards and DECIDE them — one where a PERSON has proven to be at
85552
+ * the page: `hello` with an admissible account, or a WalletConnect pairing a wallet
85553
+ * actually answered (`wcPaired`).
85554
+ *
85555
+ * `sessionOf` only ever asked "does this session id exist and is it un-quarantined". A
85556
+ * session id is minted by LOADING the page, and on the hosted tier the mount URL travels
85557
+ * through the conversation by design — so anyone holding it could mint a session, never
85558
+ * connect a wallet, and still receive every approval card on /events (the card is the
85559
+ * operation in readable form: position, destination, amounts) and still POST /result to
85560
+ * decline, or /finalize to re-stamp, someone else's ceremony. Quarantine never caught
85561
+ * them: it fires on an OFFERED account, and they offered none.
85562
+ *
85563
+ * Opening the stream without a wallet stays legal — that is how the real page bootstraps
85564
+ * before the user connects. It simply receives nothing and decides nothing until it has
85565
+ * connected. Requesting a pairing is likewise not enough: anyone with the link can ask
85566
+ * for a QR, so only a pairing a WALLET ANSWERED counts.
85567
+ */
85568
+ authorized(session) {
85569
+ if (session.refused) return false;
85570
+ if (session.wallet) return this.accountRefusal(session.wallet.account) === null;
85571
+ return session.wcPaired;
85572
+ }
85573
+ /** `sessionOf`, plus the wallet binding above — for the routes that decide a ceremony. */
85574
+ decidingSessionOf(candidate, res) {
85575
+ const session = this.sessionOf(candidate, res);
85576
+ if (!session) return null;
85577
+ if (!this.authorized(session)) {
85578
+ this.deny(res, 403, "connect your wallet on this page before approving, declining or finalizing a request");
85579
+ return null;
85580
+ }
85581
+ return session;
85582
+ }
84747
85583
  sessionOf(candidate, res) {
84748
85584
  const session = typeof candidate === "string" ? this.sessions.get(candidate) ?? null : null;
84749
85585
  if (!session) {
84750
85586
  this.deny(res, 403, "missing or wrong session");
84751
85587
  return null;
84752
85588
  }
85589
+ session.lastSeenMs = this.clock();
84753
85590
  if (session.refused) {
84754
85591
  this.deny(res, 403, session.refused);
84755
85592
  return null;
@@ -85072,8 +85909,8 @@ async function buildBoundary(configResult, overrides) {
85072
85909
  );
85073
85910
  }
85074
85911
  try {
85075
- const decrypted = await import_ethers50.ethers.Wallet.fromEncryptedJson(keystoreJson, config.keystorePassword);
85076
- if (!(decrypted instanceof import_ethers50.ethers.Wallet)) {
85912
+ const decrypted = await import_ethers51.ethers.Wallet.fromEncryptedJson(keystoreJson, config.keystorePassword);
85913
+ if (!(decrypted instanceof import_ethers51.ethers.Wallet)) {
85077
85914
  return bootError("DH_KEYSTORE_PATH did not decrypt to an EOA wallet keystore.", ["DH_KEYSTORE_PATH"]);
85078
85915
  }
85079
85916
  wallet = decrypted;
@@ -85442,8 +86279,13 @@ function authorizationModeBullets(d) {
85442
86279
  that one \u2014 say it before the popup. Walkthrough: \`guide connect-wallet\`.`);
85443
86280
  }
85444
86281
  if (offers(d, "keystore")) {
85445
- bullets.push(` - \`keystore\` \u2014 a local encrypted keystore signs automatically after each confirmation.
85446
- Real adapter and mock.`);
86282
+ bullets.push(` - \`keystore\` \u2014 a local encrypted keystore signs AUTOMATICALLY, with no per-operation
86283
+ human prompt. Real adapter and mock. Say this plainly when the user picks it: the
86284
+ password is asked ONCE, at unlock; after that the key signs every write this session
86285
+ without a popup, an approval page or any second human step. The \`confirmed: true\` gate
86286
+ is the ASSISTANT's \u2014 it is not the user seeing and approving the operation \u2014 so in this
86287
+ mode you must show the operation and get a real answer before you set it. A user who
86288
+ wants to inspect each operation as it signs wants \`external\`.`);
85447
86289
  }
85448
86290
  if (offers(d, "safe") || offers(d, "safe-module")) {
85449
86291
  bullets.push(` - \`safe\` / \`safe-module\` \u2014 PRACTICE-ONLY today: on the real adapter these modes
@@ -85454,6 +86296,9 @@ function authorizationModeBullets(d) {
85454
86296
  }
85455
86297
  return bullets.join("\n");
85456
86298
  }
86299
+ function readsNeedSignIn(d) {
86300
+ 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.";
86301
+ }
85457
86302
  function keystoreAbsenceParagraph(d) {
85458
86303
  if (offers(d, "keystore")) return "";
85459
86304
  return `
@@ -85497,9 +86342,11 @@ install matrix. ${connectorInstallNote(d)}
85497
86342
 
85498
86343
  Nothing needs a config file. Three steps:
85499
86344
 
85500
- **1. Know your world.** Read \`boundary://info\` (its \`capabilities\` block) and
85501
- \`protocol_status\`, then tell the user what THIS deployment is: ${worldAxes(d)}; which
85502
- signer modes exist; current terms (\`protocol_terms\`).
86345
+ **1. Know your world.** Read \`boundary://info\` (its \`capabilities\` block) \u2014 that
86346
+ resource always answers, with no sign-in \u2014 and tell the user what THIS deployment is:
86347
+ ${worldAxes(d)}; which signer modes exist. ${readsNeedSignIn(d)} So the live reads
86348
+ (\`protocol_status\`, current terms via \`protocol_terms\`) come right after step 2, not
86349
+ before it.
85503
86350
 
85504
86351
  **2. Choose HOW to authorize operations** (the user's choice, made by talking):
85505
86352
  - **"Use my own wallet"** \u2192 call \`signer_setup\` action \`use\`, mode \`external\` \u2014 works
@@ -85519,8 +86366,9 @@ ${offers(d, "safe") || offers(d, "safe-module") ? `- **Safe / delegation modes (
85519
86366
  surface is the wallet ceremony and nothing else; \`signer_setup\` lists no other mode.
85520
86367
  \`guide safe\` and \`guide delegation\` state what exists elsewhere.`}
85521
86368
  - Not sure? \`signer_setup\` action \`status\` explains what is active and what is missing.
85522
- - **No signer is also a valid start:** every public read works without one \u2014
85523
- \`position_list {borrower}\` with the user's address needs no signer and no login.
86369
+ - **A read is not a signer-less shortcut:** the sign-in in step 2 is what turns reads ON.
86370
+ Until then \`position_list {borrower}\`, \`protocol_status\` and \`protocol_terms\` refuse
86371
+ on the real adapter \u2014 do step 2 first, then reads work.
85524
86372
  ${d.networks.length > 1 ? `- **Wrong network?** On the real adapter the user can switch sepolia \u2194 mainnet by
85525
86373
  talking (\`network_switch\`, human-confirmed) \u2014 see \`guide switch-network\`. State
85526
86374
  the money reality after any switch.` : `- **Wrong network?** This deployment is rolled out to ${d.networks[0]} alone \u2014
@@ -86009,7 +86857,12 @@ ${wrongNetworkTroubleshootingRow(d)}
86009
86857
  owed, wrong position state, or the USER DECLINED in the wallet. The message says which.
86010
86858
  A decline is not an error to fix \u2014 it is the user's decision.
86011
86859
  - **UPSTREAM_UNAVAILABLE** \u2014 a data source or the signature bridge is unreachable/expired.
86012
- Usually transient; re-check with \`protocol_status\` and retry once.
86860
+ Usually transient; re-check with \`protocol_status\` and retry once. (A PERMANENT gap
86861
+ answers \`NOT_IMPLEMENTED\`, below \u2014 that one is not retryable.)
86862
+ - **NOT_IMPLEMENTED** \u2014 a capability this adapter does NOT implement in this build, and never
86863
+ will \u2014 PERMANENT, not a transient outage, so do NOT retry it. \`position_events\` on the
86864
+ real adapter is the case: there is no indexer projection for event history here. Say the
86865
+ history is unavailable on this deployment and move on; the practice (mock) world has it.
86013
86866
  - **NOT_FOUND** \u2014 the position id doesn't exist in this world (check \`position_list\`).
86014
86867
  - **STATE_DIVERGENCE / STALE_DATA warnings** \u2014 sources disagree or lag; the envelope says
86015
86868
  which source and when from. Prefer chain-sourced values; re-read before acting.
@@ -86194,7 +87047,7 @@ var import_mcp2 = require("@modelcontextprotocol/sdk/server/mcp.js");
86194
87047
 
86195
87048
  // src/tools/loan.ts
86196
87049
  var import_zod = require("zod");
86197
- var import_ethers51 = require("ethers");
87050
+ var import_ethers52 = require("ethers");
86198
87051
 
86199
87052
  // src/util/format.ts
86200
87053
  function bigintReplacer(_key, value) {
@@ -86243,7 +87096,7 @@ function requireConfirmation(confirmed, actionLabel) {
86243
87096
  type: "text",
86244
87097
  text: `CONFIRMATION REQUIRED \u2014 refusing to run "${actionLabel}".
86245
87098
  This is an irreversible, fund-moving action. A human must explicitly authorize it.
86246
- Re-invoke with confirmed: true ONLY after a human has approved this exact operation. Do not set confirmed on your own.`
87099
+ 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.`
86247
87100
  }
86248
87101
  ],
86249
87102
  isError: true
@@ -86382,7 +87235,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
86382
87235
  const b = getB();
86383
87236
  if (!b.ok) return renderError(b.error);
86384
87237
  return renderEnvelope(
86385
- await b.boundary.mintUcd({ positionId, amountUcdWei: (0, import_ethers51.parseEther)(amountUcd.toString()).toString() })
87238
+ await b.boundary.mintUcd({ positionId, amountUcdWei: (0, import_ethers52.parseEther)(amountUcd.toString()).toString() })
86386
87239
  );
86387
87240
  })
86388
87241
  );
@@ -86420,7 +87273,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
86420
87273
  if (BigInt(detail.data.debtUcdWei) === 0n) return validationFailed("the position has no outstanding debt");
86421
87274
  amountUcdWei = detail.data.debtUcdWei;
86422
87275
  } else {
86423
- amountUcdWei = (0, import_ethers51.parseEther)(amountUcd.toString()).toString();
87276
+ amountUcdWei = (0, import_ethers52.parseEther)(amountUcd.toString()).toString();
86424
87277
  }
86425
87278
  return renderEnvelope(await b.boundary.repayUcd({ positionId, amountUcdWei }));
86426
87279
  })
@@ -86680,7 +87533,7 @@ function registerPositionTools(server, getB) {
86680
87533
  "position_events",
86681
87534
  {
86682
87535
  title: "Get a position's event history",
86683
- description: "Return mint, payment, withdrawal, renewal, and liquidation events for a position (indexer view).",
87536
+ 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.",
86684
87537
  inputSchema: {
86685
87538
  id: positionIdSchema2
86686
87539
  }
@@ -87023,7 +87876,7 @@ function registerMockControlTool(server, control, chainId = 1337) {
87023
87876
 
87024
87877
  // src/tools/signer.ts
87025
87878
  var import_zod6 = require("zod");
87026
- var import_ethers52 = require("ethers");
87879
+ var import_ethers53 = require("ethers");
87027
87880
  var MODES = ["external", "keystore", "safe", "safe-module", "mock-simulated"];
87028
87881
  var ACTIONS2 = ["status", "use", "reset-borrower", "unlock-keystore", "connect", "disconnect"];
87029
87882
  var EXTERNAL_ONLY_MODES = ["external"];
@@ -87065,7 +87918,7 @@ function registerSignerTool(server, getRuntime, opts) {
87065
87918
  if (mode !== void 0 && !offeredModes.includes(mode)) {
87066
87919
  return validationFailed(looksSecretShaped(mode) ? SECRET_REFUSAL : `mode '${mode}' is not one of: ${offeredModes.join(" | ")}`);
87067
87920
  }
87068
- if (safeAddress !== void 0 && !import_ethers52.ethers.isAddress(safeAddress)) {
87921
+ if (safeAddress !== void 0 && !import_ethers53.ethers.isAddress(safeAddress)) {
87069
87922
  return validationFailed(looksSecretShaped(safeAddress) ? SECRET_REFUSAL : `'${safeAddress}' is not a valid Safe address`);
87070
87923
  }
87071
87924
  if (action === "status") {
@@ -87226,7 +88079,7 @@ function registerGuidePrompts(server, deployment = LOCAL_GUIDE_DEPLOYMENT) {
87226
88079
  role: "user",
87227
88080
  content: {
87228
88081
  type: "text",
87229
- 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."
88082
+ 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."
87230
88083
  }
87231
88084
  }
87232
88085
  ]
@@ -87414,7 +88267,7 @@ function registerProtocolResources(server, getB) {
87414
88267
  "protocol://psm",
87415
88268
  {
87416
88269
  title: "PSM status (UCD \u2194 USDC exchange)",
87417
- 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.",
88270
+ 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.",
87418
88271
  mimeType: "application/json"
87419
88272
  },
87420
88273
  async (uri) => {
@@ -87898,6 +88751,10 @@ function composeConnector(opts, rawPublicOrigin) {
87898
88751
  }
87899
88752
  const app = (0, import_express.default)();
87900
88753
  app.set("trust proxy", trustProxyHops);
88754
+ app.use((_req, res, next) => {
88755
+ res.setHeader(STRICT_TRANSPORT_SECURITY.name, STRICT_TRANSPORT_SECURITY.value);
88756
+ next();
88757
+ });
87901
88758
  app.use((_req, res, next) => {
87902
88759
  if (!allowGlobal()) {
87903
88760
  deny(res, 429, `rate limit: this connector exceeded ${globalPerMin} requests/minute across all clients \u2014 a shared-capacity protection; wait for the minute window to pass and retry`);
@@ -87905,6 +88762,31 @@ function composeConnector(opts, rawPublicOrigin) {
87905
88762
  }
87906
88763
  next();
87907
88764
  });
88765
+ const expectedHost = opts.publicOrigin ? new URL(publicOrigin).host.toLowerCase() : null;
88766
+ app.use((req, res, next) => {
88767
+ if (expectedHost === null) {
88768
+ next();
88769
+ return;
88770
+ }
88771
+ const p = (req.originalUrl ?? req.url).split("?")[0].toLowerCase();
88772
+ const sensitive = ["/mcp", "/token", "/register", "/revoke", "/authorize"].some(
88773
+ (r) => p === r || p.startsWith(`${r}/`)
88774
+ );
88775
+ if (!sensitive) {
88776
+ next();
88777
+ return;
88778
+ }
88779
+ const host = (req.headers.host ?? "").toLowerCase();
88780
+ if (host !== expectedHost) {
88781
+ deny(
88782
+ res,
88783
+ 421,
88784
+ `misdirected request: this connector serves ${expectedHost} \u2014 the request arrived on Host '${req.headers.host ?? "(none)"}'. Use the canonical origin advertised in the discovery documents.`
88785
+ );
88786
+ return;
88787
+ }
88788
+ next();
88789
+ });
87908
88790
  app.use((req, res, next) => {
87909
88791
  const path5 = (req.originalUrl ?? req.url).split("?")[0];
87910
88792
  if (path5 === "/mcp" || path5.startsWith("/approval/")) {