@gvnrdao/dh-mcp 0.5.4 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/connector.js CHANGED
@@ -14579,7 +14579,7 @@ var require_pkg_src = __commonJS({
14579
14579
  description: "Production Btc Transaction Signer",
14580
14580
  version: "1.1.1",
14581
14581
  deployed: true,
14582
- deployedAt: 1786113907707,
14582
+ deployedAt: 1786465606156,
14583
14583
  size: 67999,
14584
14584
  hash: "83f3644c68819215e05ba8db3225571354a009458fc1437f606df6cb9142d3f9"
14585
14585
  },
@@ -14592,7 +14592,7 @@ var require_pkg_src = __commonJS({
14592
14592
  description: "Production Ucd Mint Validator",
14593
14593
  version: "1.2.1",
14594
14594
  deployed: true,
14595
- deployedAt: 1786113908489,
14595
+ deployedAt: 1786465627201,
14596
14596
  size: 82739,
14597
14597
  hash: "2bdd9aebdaad58a43a4731d5b7284f2531b7a9caaf8caf5719d891c4ed33cb2e",
14598
14598
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
@@ -14610,7 +14610,7 @@ var require_pkg_src = __commonJS({
14610
14610
  description: "Production Process Payment Validator",
14611
14611
  version: "1.2.1",
14612
14612
  deployed: true,
14613
- deployedAt: 1786113909138,
14613
+ deployedAt: 1786465654796,
14614
14614
  size: 78736,
14615
14615
  hash: "17191ecc9c009e0fa5ab52c876330beb2a9a75d30cccb92e7c0c04f169df088b",
14616
14616
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
@@ -14628,7 +14628,7 @@ var require_pkg_src = __commonJS({
14628
14628
  description: "Production Extend Position Validator",
14629
14629
  version: "1.2.1",
14630
14630
  deployed: true,
14631
- deployedAt: 1786113909872,
14631
+ deployedAt: 1786465681874,
14632
14632
  size: 76515,
14633
14633
  hash: "1d4e085335af80f194a663a577876902c83015177e95906a0b461fa93bd5da08",
14634
14634
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
@@ -14638,21 +14638,17 @@ var require_pkg_src = __commonJS({
14638
14638
  }
14639
14639
  },
14640
14640
  btcWithdrawal: {
14641
- cid: "QmZuR3qSBajutXfRd91ffpyFrRMgmaMh7fDEHRiQQF8Ljp",
14641
+ cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
14642
14642
  authorizedCidHex: cidToHex(
14643
- "QmZuR3qSBajutXfRd91ffpyFrRMgmaMh7fDEHRiQQF8Ljp"
14643
+ "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
14644
14644
  ),
14645
14645
  name: "Btc Withdrawal",
14646
14646
  description: "Production Btc Withdrawal",
14647
- // Monotonic per action, NOT a shared release train — the EIP-1271 rotation
14648
- // stamped its cohort 1.2.1, but this action was already at 1.2.3 from the vout
14649
- // canonicalization fix. Reusing the cohort stamp made a newer CID read as older
14650
- // than the one it replaced, which a rotation ceremony would treat as a rollback.
14651
- version: "1.2.4",
14647
+ version: "1.2.7",
14652
14648
  deployed: true,
14653
- deployedAt: 1786113910531,
14654
- size: 95313,
14655
- hash: "ce12f11e3b5469953bc919586e4f3b8b5d594224b58b799dd9a3b60e3749559c",
14649
+ deployedAt: 1786446046614,
14650
+ size: 97456,
14651
+ hash: "3cae8250861832f91ee3c573abeb50ff27b9acd34148176071cbfbabb359fc91",
14656
14652
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14657
14653
  pkp: {
14658
14654
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
@@ -14764,19 +14760,17 @@ var require_pkg_src = __commonJS({
14764
14760
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
14765
14761
  },
14766
14762
  agentModuleExecutor: {
14767
- // Bound to the isolated Sepolia agent group 7 ("DH-Agent-Sepolia"), which
14768
- // holds this action and no PKPs until an agent is minted into it. NOT yet
14769
- // bound on mainnet — the Base `DH-Agent-Mainnet` group is created at rollout.
14770
- cid: "QmVgjGXUuxoGf8XyddW8a7btaazT9yEotpKoBgb65oPvcF",
14763
+ cid: "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ",
14771
14764
  authorizedCidHex: cidToHex(
14772
- "QmVgjGXUuxoGf8XyddW8a7btaazT9yEotpKoBgb65oPvcF"
14765
+ "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
14773
14766
  ),
14774
14767
  name: "Agent Module Executor",
14775
- description: "Capability gate for multi-sig Safe agent delegation: binds the agent PKP to the AgentDelegationRegistry record before signing (authorize | execute modes)",
14776
- version: "1.0.0",
14768
+ description: "Production Agent Module Executor",
14769
+ version: "1.1.1",
14777
14770
  deployed: true,
14778
- size: 11785,
14779
- hash: "fa294e164273c2158f9ef11a0ccfd735c343c0e3759fcb4b37e0f8a5d1ab0d29"
14771
+ deployedAt: 1786446108348,
14772
+ size: 11655,
14773
+ hash: "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec"
14780
14774
  },
14781
14775
  staleSpendRecoveryValidator: {
14782
14776
  cid: "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm",
@@ -14805,7 +14799,7 @@ var require_pkg_src = __commonJS({
14805
14799
  description: "Production Btc Utxo Invalidator",
14806
14800
  version: "1.0.0",
14807
14801
  deployed: true,
14808
- deployedAt: 1786113911948,
14802
+ deployedAt: 1786465704240,
14809
14803
  size: 62553,
14810
14804
  hash: "1dcea2b49e545c423195be22e072dc5e3039ed1c95a8490b23505956029f5b33"
14811
14805
  }
@@ -23571,6 +23565,7 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23571
23565
  exports2.fetchLitActionCodeFromIpfs = fetchLitActionCodeFromIpfs;
23572
23566
  var axios_1 = __importDefault(require_axios());
23573
23567
  var ipfsCodeCache = /* @__PURE__ */ new Map();
23568
+ var GATEWAY_TIMEOUT_MS = 2e4;
23574
23569
  var buildGatewayList = (cid, pinataJwt) => {
23575
23570
  const gateways = [];
23576
23571
  if (pinataJwt) {
@@ -23579,7 +23574,7 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23579
23574
  headers: { Authorization: `Bearer ${pinataJwt}` }
23580
23575
  });
23581
23576
  }
23582
- gateways.push({ url: `https://${cid}.ipfs.dweb.link/` }, { url: `https://dweb.link/ipfs/${cid}` }, { url: `https://ipfs.io/ipfs/${cid}` }, { url: `https://gateway.pinata.cloud/ipfs/${cid}` }, { url: `https://cloudflare-ipfs.com/ipfs/${cid}` });
23577
+ gateways.push({ url: `https://${cid}.ipfs.dweb.link/` }, { url: `https://dweb.link/ipfs/${cid}` }, { url: `https://ipfs.io/ipfs/${cid}` }, { url: `https://gateway.pinata.cloud/ipfs/${cid}` });
23583
23578
  return gateways;
23584
23579
  };
23585
23580
  async function fetchLitActionCodeFromIpfs(cid, options = {}) {
@@ -23593,13 +23588,14 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23593
23588
  const pinataJwt = options.pinataJwt ?? process.env.PINATA_JWT;
23594
23589
  const extraGateways = options.extraGateways?.map((t) => ({ url: t.replace("{cid}", cid) })) ?? [];
23595
23590
  const gateways = [...extraGateways, ...buildGatewayList(cid, pinataJwt)];
23591
+ const failures = [];
23596
23592
  for (const gateway of gateways) {
23597
23593
  try {
23598
23594
  if (options.debug) {
23599
23595
  console.log(`\u{1F4E1} [fetchLitActionCodeFromIpfs] Trying ${gateway.url}...`);
23600
23596
  }
23601
23597
  const response = await axios_1.default.get(gateway.url, {
23602
- timeout: 1e4,
23598
+ timeout: GATEWAY_TIMEOUT_MS,
23603
23599
  headers: {
23604
23600
  Accept: "text/plain, application/javascript, text/javascript",
23605
23601
  ...gateway.headers
@@ -23612,13 +23608,17 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23612
23608
  ipfsCodeCache.set(cid, response.data);
23613
23609
  return response.data;
23614
23610
  }
23611
+ failures.push(`${gateway.url}: HTTP ${response.status} returned ${typeof response.data}, expected string`);
23615
23612
  } catch (error) {
23613
+ const message = error instanceof Error ? error.message : String(error);
23614
+ failures.push(`${gateway.url}: ${message}`);
23616
23615
  if (options.debug) {
23617
- console.log(`\u274C [fetchLitActionCodeFromIpfs] ${gateway.url}:`, error instanceof Error ? error.message : error);
23616
+ console.log(`\u274C [fetchLitActionCodeFromIpfs] ${gateway.url}:`, message);
23618
23617
  }
23619
23618
  }
23620
23619
  }
23621
- throw new Error(`Failed to fetch LIT Action from IPFS CID: ${cid}`);
23620
+ throw new Error(`Failed to fetch LIT Action from IPFS CID: ${cid} \u2014 all ${gateways.length} gateway(s) failed:
23621
+ ` + failures.map((f) => ` - ${f}`).join("\n"));
23622
23622
  }
23623
23623
  }
23624
23624
  });
@@ -51437,6 +51437,14 @@ var init_deployment_addresses = __esm2({
51437
51437
  reason: "2026-08 agent-stack release. The mainnet PositionManagerViews at 0x9225647a was deployed as a BARE implementation (EIP-1967 slot 0x00), so upgradeToAndCall reverts UUPSUnauthorizedCallContext \u2014 it could never be upgraded. PositionManager.setViews (added in the same Execute B batch) removed the repoint blocker, so Views was replaced behind a new proxy rather than upgraded. This makes the Pashov F3 renewal debt-ceiling check REACHABLE for the first time: ExceedsMaxLoan (0x499e7985) is present in 0xE68DC096 and absent from 0x9225647a. Views holds no protocol state (8 wiring slots + roles + pause), which is what made replacement safe. The old contract is ABANDONED, not decommissioned \u2014 it stays live and callable as the rollback target for setViews. NOTE: VERSION reads 1.1.1 on both sides; verify by address.",
51438
51438
  executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
51439
51439
  block: 25673200
51440
+ },
51441
+ AgentDelegationRegistry: {
51442
+ newImplementation: "0xa9fF405Edd4329fc3159a64F56B37EBD253e4928",
51443
+ upgradedAt: "2026-07-31T22:03:35.000Z",
51444
+ upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f in tx 0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4 (block 25655710)",
51445
+ reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
51446
+ executeTx: "0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4",
51447
+ block: 25655710
51440
51448
  }
51441
51449
  },
51442
51450
  latestEnv: {
@@ -52252,7 +52260,7 @@ var require_pkg_src2 = __commonJS2({
52252
52260
  description: "Production Btc Transaction Signer",
52253
52261
  version: "1.1.1",
52254
52262
  deployed: true,
52255
- deployedAt: 1786113907707,
52263
+ deployedAt: 1786465606156,
52256
52264
  size: 67999,
52257
52265
  hash: "83f3644c68819215e05ba8db3225571354a009458fc1437f606df6cb9142d3f9"
52258
52266
  },
@@ -52265,7 +52273,7 @@ var require_pkg_src2 = __commonJS2({
52265
52273
  description: "Production Ucd Mint Validator",
52266
52274
  version: "1.2.1",
52267
52275
  deployed: true,
52268
- deployedAt: 1786113908489,
52276
+ deployedAt: 1786465627201,
52269
52277
  size: 82739,
52270
52278
  hash: "2bdd9aebdaad58a43a4731d5b7284f2531b7a9caaf8caf5719d891c4ed33cb2e",
52271
52279
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
@@ -52283,7 +52291,7 @@ var require_pkg_src2 = __commonJS2({
52283
52291
  description: "Production Process Payment Validator",
52284
52292
  version: "1.2.1",
52285
52293
  deployed: true,
52286
- deployedAt: 1786113909138,
52294
+ deployedAt: 1786465654796,
52287
52295
  size: 78736,
52288
52296
  hash: "17191ecc9c009e0fa5ab52c876330beb2a9a75d30cccb92e7c0c04f169df088b",
52289
52297
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
@@ -52301,7 +52309,7 @@ var require_pkg_src2 = __commonJS2({
52301
52309
  description: "Production Extend Position Validator",
52302
52310
  version: "1.2.1",
52303
52311
  deployed: true,
52304
- deployedAt: 1786113909872,
52312
+ deployedAt: 1786465681874,
52305
52313
  size: 76515,
52306
52314
  hash: "1d4e085335af80f194a663a577876902c83015177e95906a0b461fa93bd5da08",
52307
52315
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
@@ -52311,21 +52319,17 @@ var require_pkg_src2 = __commonJS2({
52311
52319
  }
52312
52320
  },
52313
52321
  btcWithdrawal: {
52314
- cid: "QmZuR3qSBajutXfRd91ffpyFrRMgmaMh7fDEHRiQQF8Ljp",
52322
+ cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
52315
52323
  authorizedCidHex: cidToHex(
52316
- "QmZuR3qSBajutXfRd91ffpyFrRMgmaMh7fDEHRiQQF8Ljp"
52324
+ "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
52317
52325
  ),
52318
52326
  name: "Btc Withdrawal",
52319
52327
  description: "Production Btc Withdrawal",
52320
- // Monotonic per action, NOT a shared release train — the EIP-1271 rotation
52321
- // stamped its cohort 1.2.1, but this action was already at 1.2.3 from the vout
52322
- // canonicalization fix. Reusing the cohort stamp made a newer CID read as older
52323
- // than the one it replaced, which a rotation ceremony would treat as a rollback.
52324
- version: "1.2.4",
52328
+ version: "1.2.7",
52325
52329
  deployed: true,
52326
- deployedAt: 1786113910531,
52327
- size: 95313,
52328
- hash: "ce12f11e3b5469953bc919586e4f3b8b5d594224b58b799dd9a3b60e3749559c",
52330
+ deployedAt: 1786446046614,
52331
+ size: 97456,
52332
+ hash: "3cae8250861832f91ee3c573abeb50ff27b9acd34148176071cbfbabb359fc91",
52329
52333
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52330
52334
  pkp: {
52331
52335
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
@@ -52437,19 +52441,17 @@ var require_pkg_src2 = __commonJS2({
52437
52441
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
52438
52442
  },
52439
52443
  agentModuleExecutor: {
52440
- // Bound to the isolated Sepolia agent group 7 ("DH-Agent-Sepolia"), which
52441
- // holds this action and no PKPs until an agent is minted into it. NOT yet
52442
- // bound on mainnet — the Base `DH-Agent-Mainnet` group is created at rollout.
52443
- cid: "QmVgjGXUuxoGf8XyddW8a7btaazT9yEotpKoBgb65oPvcF",
52444
+ cid: "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ",
52444
52445
  authorizedCidHex: cidToHex(
52445
- "QmVgjGXUuxoGf8XyddW8a7btaazT9yEotpKoBgb65oPvcF"
52446
+ "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
52446
52447
  ),
52447
52448
  name: "Agent Module Executor",
52448
- description: "Capability gate for multi-sig Safe agent delegation: binds the agent PKP to the AgentDelegationRegistry record before signing (authorize | execute modes)",
52449
- version: "1.0.0",
52449
+ description: "Production Agent Module Executor",
52450
+ version: "1.1.1",
52450
52451
  deployed: true,
52451
- size: 11785,
52452
- hash: "fa294e164273c2158f9ef11a0ccfd735c343c0e3759fcb4b37e0f8a5d1ab0d29"
52452
+ deployedAt: 1786446108348,
52453
+ size: 11655,
52454
+ hash: "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec"
52453
52455
  },
52454
52456
  staleSpendRecoveryValidator: {
52455
52457
  cid: "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm",
@@ -52478,7 +52480,7 @@ var require_pkg_src2 = __commonJS2({
52478
52480
  description: "Production Btc Utxo Invalidator",
52479
52481
  version: "1.0.0",
52480
52482
  deployed: true,
52481
- deployedAt: 1786113911948,
52483
+ deployedAt: 1786465704240,
52482
52484
  size: 62553,
52483
52485
  hash: "1dcea2b49e545c423195be22e072dc5e3039ed1c95a8490b23505956029f5b33"
52484
52486
  }
@@ -62722,6 +62724,169 @@ function normalizePkpId2(pkpId) {
62722
62724
  }
62723
62725
  return pkpId;
62724
62726
  }
62727
+ function hasLoanEventsFilter(filter2) {
62728
+ if (!filter2)
62729
+ return false;
62730
+ return filter2.eventTypes !== void 0 || filter2.fromTimestamp !== void 0 || filter2.toTimestamp !== void 0 || filter2.fromBlock !== void 0 || filter2.toBlock !== void 0 || filter2.limit !== void 0 || filter2.orderDirection !== void 0;
62731
+ }
62732
+ var WALLET_LOAN_EVENTS_QUERY = `
62733
+ query GetWalletLoanEvents($borrower: Bytes!, $first: Int!, $limit: Int!, $orderDirection: OrderDirection!) {
62734
+ positions(where: { borrower: $borrower }, first: $first, orderBy: id) {
62735
+ id
62736
+ payments(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
62737
+ id
62738
+ payer { id }
62739
+ amount
62740
+ type
62741
+ transactionHash
62742
+ timestamp
62743
+ blockNumber
62744
+ logIndex
62745
+ newDebt
62746
+ newCollateralRatio
62747
+ }
62748
+ statusUpdates(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
62749
+ id
62750
+ oldStatus
62751
+ newStatus
62752
+ reason
62753
+ timestamp
62754
+ blockNumber
62755
+ transactionHash
62756
+ }
62757
+ liquidation {
62758
+ id
62759
+ liquidator
62760
+ liquidatedAmount
62761
+ collateralSeized
62762
+ transactionHash
62763
+ timestamp
62764
+ blockNumber
62765
+ commitHash
62766
+ commitTimestamp
62767
+ revealDelay
62768
+ }
62769
+ withdrawals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
62770
+ id
62771
+ withdrawalAmount
62772
+ withdrawalAddress
62773
+ networkFee
62774
+ timestamp
62775
+ blockNumber
62776
+ transactionHash
62777
+ logIndex
62778
+ }
62779
+ renewals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
62780
+ id
62781
+ extensionTerm
62782
+ extensionFee
62783
+ newExpiryDate
62784
+ timestamp
62785
+ blockNumber
62786
+ transactionHash
62787
+ logIndex
62788
+ }
62789
+ operationFailures(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
62790
+ id
62791
+ operationType
62792
+ reason
62793
+ errorCode
62794
+ amount
62795
+ timestamp
62796
+ blockNumber
62797
+ transactionHash
62798
+ logIndex
62799
+ }
62800
+ mintRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
62801
+ id
62802
+ pkpId
62803
+ borrower { id }
62804
+ mintAmount
62805
+ originationFee
62806
+ newDebt
62807
+ newCollateralRatio
62808
+ btcPrice
62809
+ quantumTimestamp
62810
+ opId
62811
+ timestamp
62812
+ blockNumber
62813
+ transactionHash
62814
+ logIndex
62815
+ }
62816
+ burnRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
62817
+ id
62818
+ pkpId
62819
+ borrower { id }
62820
+ burnAmount
62821
+ remainingDebt
62822
+ newCollateralRatio
62823
+ opId
62824
+ timestamp
62825
+ blockNumber
62826
+ transactionHash
62827
+ logIndex
62828
+ }
62829
+ mintingFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
62830
+ id
62831
+ borrower { id }
62832
+ feeAmount
62833
+ mintAmount
62834
+ newDebt
62835
+ btcPrice
62836
+ quantumTimestamp
62837
+ timestamp
62838
+ blockNumber
62839
+ transactionHash
62840
+ logIndex
62841
+ }
62842
+ renewalFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
62843
+ id
62844
+ borrower { id }
62845
+ feeAmount
62846
+ extensionTerm
62847
+ newExpiryDate
62848
+ timestamp
62849
+ blockNumber
62850
+ transactionHash
62851
+ logIndex
62852
+ }
62853
+ positionCreatedEvents(first: 1, orderBy: timestamp, orderDirection: asc) {
62854
+ id
62855
+ pkpId
62856
+ borrower { id }
62857
+ requestedCollateralRatio
62858
+ selectedTerm
62859
+ expiryAt
62860
+ timestamp
62861
+ blockNumber
62862
+ transactionHash
62863
+ }
62864
+ }
62865
+ ucdmintEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
62866
+ id
62867
+ position { id }
62868
+ amount
62869
+ proof
62870
+ minter { id }
62871
+ isCommunityMint
62872
+ timestamp
62873
+ blockNumber
62874
+ transactionHash
62875
+ }
62876
+ collateralEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
62877
+ id
62878
+ position { id }
62879
+ eventType
62880
+ networkFee
62881
+ remainingCollateral
62882
+ collateralRatio
62883
+ timestamp
62884
+ blockNumber
62885
+ transactionHash
62886
+ logIndex
62887
+ }
62888
+ }
62889
+ `;
62725
62890
  var DiamondHandsGraph = class {
62726
62891
  client;
62727
62892
  defaultPageSize;
@@ -62827,7 +62992,7 @@ var DiamondHandsGraph = class {
62827
62992
  /**
62828
62993
  * Get user positions from subgraph
62829
62994
  */
62830
- async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
62995
+ async getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection) {
62831
62996
  const query = `
62832
62997
  query GetUserPositions($borrower: Bytes!, $first: Int, $skip: Int, $orderBy: Position_orderBy, $orderDirection: OrderDirection) {
62833
62998
  user(id: $borrower) {
@@ -62868,17 +63033,28 @@ var DiamondHandsGraph = class {
62868
63033
  query,
62869
63034
  variables
62870
63035
  );
62871
- const total = await this.getTotalCountPaginated("{ borrower: $borrower }", {
62872
- borrower: userAddress.toLowerCase()
62873
- });
62874
63036
  let positions = [];
62875
63037
  if (result && result.user && Array.isArray(result.user.positions)) {
62876
63038
  positions = result.user.positions.filter((p) => p != null).map((p) => this.transformGraphPositionToLoanData(p));
62877
63039
  }
62878
- return {
62879
- positions,
62880
- total
62881
- };
63040
+ return positions;
63041
+ }
63042
+ /**
63043
+ * Get user positions, plus an accurate total count.
63044
+ *
63045
+ * The count is a SECOND round trip (`getTotalCountPaginated`, which pages to handle
63046
+ * >1000 items). Callers that only need the rows should use `getUserPositionsOnly` and
63047
+ * skip it — the event paths did not, and paid for a count they immediately discarded on
63048
+ * every activity refresh.
63049
+ */
63050
+ async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
63051
+ const [positions, total] = await Promise.all([
63052
+ this.getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection),
63053
+ this.getTotalCountPaginated("{ borrower: $borrower }", {
63054
+ borrower: userAddress.toLowerCase()
63055
+ })
63056
+ ]);
63057
+ return { positions, total };
62882
63058
  }
62883
63059
  /**
62884
63060
  * Get user positions with enriched Bitcoin balance data
@@ -63969,6 +64145,16 @@ var DiamondHandsGraph = class {
63969
64145
  orderDirection
63970
64146
  };
63971
64147
  const result = await this.client.execute(query, variables);
64148
+ return this.assembleLoanEvents(positionId, result);
64149
+ }
64150
+ /**
64151
+ * Map one position's raw event payload into `LoanEvents`.
64152
+ *
64153
+ * Extracted verbatim from getLoanEvents so the wallet-collapsed path produces
64154
+ * byte-identical objects by construction rather than by a second implementation
64155
+ * that has to be kept in step by hand.
64156
+ */
64157
+ assembleLoanEvents(positionId, result) {
63972
64158
  const rawCreated = result.positionCreatedEvents?.[0];
63973
64159
  const positionCreated = rawCreated ? {
63974
64160
  id: rawCreated.id,
@@ -64173,7 +64359,22 @@ var DiamondHandsGraph = class {
64173
64359
  * @returns One LoanEvents object per position; empty array if the wallet has none.
64174
64360
  */
64175
64361
  async getWalletLoanEvents(userAddress, filter2) {
64176
- const { positions } = await this.getUserPositions(userAddress);
64362
+ if (!hasLoanEventsFilter(filter2)) {
64363
+ return this.getWalletLoanEventsCollapsed(userAddress);
64364
+ }
64365
+ return this.getWalletLoanEventsFanout(userAddress, filter2);
64366
+ }
64367
+ /**
64368
+ * The per-position path: enumerate the wallet's positions, then one `GetLoanEvents` each.
64369
+ *
64370
+ * Used for filtered calls, and as the completeness fallback when the collapsed document
64371
+ * hits a page limit. Costs `1 + N` requests, which is exactly why it is not the default.
64372
+ */
64373
+ async getWalletLoanEventsFanout(userAddress, filter2) {
64374
+ const positions = await this.getUserPositionsOnly(
64375
+ userAddress,
64376
+ THE_GRAPH_MAX_BATCH_SIZE
64377
+ );
64177
64378
  const positionIds = positions.map((p) => p?.id != null ? String(p.id) : "").filter((id) => id.length > 0);
64178
64379
  if (positionIds.length === 0)
64179
64380
  return [];
@@ -64188,6 +64389,81 @@ var DiamondHandsGraph = class {
64188
64389
  }
64189
64390
  return results;
64190
64391
  }
64392
+ /**
64393
+ * The whole wallet's event history in ONE request.
64394
+ *
64395
+ * Replaces `1 + N` round trips (one position enumeration plus one per position) with a
64396
+ * single document. Measured on Sepolia: a wallet holding 44 positions cost 46 requests
64397
+ * per activity refresh against a per-wallet budget of 30/min — this makes it 1.
64398
+ *
64399
+ * Three subgraph facts make it possible, all verified against the deployed schema rather
64400
+ * than assumed:
64401
+ * - ten event collections are `@derivedFrom` on Position, so they nest under a
64402
+ * borrower-filtered `positions(...)`;
64403
+ * - `positionCreatedEvents` is ALSO derived on Position — `getLoanEvents` queries it
64404
+ * top-level, which it never needed to;
64405
+ * - `ucdmintEvents` / `collateralEvents` are not derived and carry no `borrower`
64406
+ * field, but graph-node's nested `position_: { borrower }` filter reaches them.
64407
+ * Without that last one this would be two requests, not one.
64408
+ */
64409
+ async getWalletLoanEventsCollapsed(userAddress) {
64410
+ const borrower = userAddress.toLowerCase();
64411
+ const pageSize = THE_GRAPH_MAX_BATCH_SIZE;
64412
+ const result = await this.client.execute(
64413
+ WALLET_LOAN_EVENTS_QUERY,
64414
+ {
64415
+ borrower,
64416
+ first: pageSize,
64417
+ limit: pageSize,
64418
+ orderDirection: "desc"
64419
+ }
64420
+ );
64421
+ const positions = result.positions || [];
64422
+ const ucdmintEvents = result.ucdmintEvents || [];
64423
+ const collateralEvents = result.collateralEvents || [];
64424
+ const truncated = positions.length >= pageSize || ucdmintEvents.length >= pageSize || collateralEvents.length >= pageSize;
64425
+ if (truncated) {
64426
+ log.warn(
64427
+ "[DiamondHandsGraph] wallet event page limit reached \u2014 falling back to the per-position path to avoid returning a partial history",
64428
+ {
64429
+ borrower,
64430
+ pageSize,
64431
+ positions: positions.length,
64432
+ ucdmintEvents: ucdmintEvents.length,
64433
+ collateralEvents: collateralEvents.length
64434
+ }
64435
+ );
64436
+ return this.getWalletLoanEventsFanout(userAddress);
64437
+ }
64438
+ if (positions.length === 0)
64439
+ return [];
64440
+ const mintsByPosition = /* @__PURE__ */ new Map();
64441
+ for (const m of result.ucdmintEvents || []) {
64442
+ const key = m.position?.id;
64443
+ if (!key)
64444
+ continue;
64445
+ const bucket = mintsByPosition.get(key) || [];
64446
+ bucket.push(m);
64447
+ mintsByPosition.set(key, bucket);
64448
+ }
64449
+ const collateralByPosition = /* @__PURE__ */ new Map();
64450
+ for (const c of result.collateralEvents || []) {
64451
+ const key = c.position?.id;
64452
+ if (!key)
64453
+ continue;
64454
+ const bucket = collateralByPosition.get(key) || [];
64455
+ bucket.push(c);
64456
+ collateralByPosition.set(key, bucket);
64457
+ }
64458
+ return positions.map(
64459
+ (p) => this.assembleLoanEvents(p.id, {
64460
+ position: p,
64461
+ positionCreatedEvents: p.positionCreatedEvents || [],
64462
+ ucdmintEvents: mintsByPosition.get(p.id) || [],
64463
+ collateralEvents: collateralByPosition.get(p.id) || []
64464
+ })
64465
+ );
64466
+ }
64191
64467
  // ============================================================================
64192
64468
  // Protocol-wide Events
64193
64469
  // ============================================================================
@@ -69047,16 +69323,6 @@ function createMockTokenManager(config) {
69047
69323
  }
69048
69324
  }
69049
69325
  var import_dh_lit_actions2 = __toESM2(require_pkg_src2());
69050
- var TelegramBot = null;
69051
- try {
69052
- if (typeof window === "undefined" && typeof global !== "undefined") {
69053
- TelegramBot = null /* stubbed post-build: dh-mcp never uses telegram (F-PUB-2) */;
69054
- }
69055
- } catch (error) {
69056
- log.warn("Telegram bot API not available", {
69057
- error: error instanceof Error ? error.message : String(error)
69058
- });
69059
- }
69060
69326
  function formatMintMessage(mintAmount, loanId, txHash) {
69061
69327
  return `\u2705 DH SDK: ${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
69062
69328
  }
@@ -75073,6 +75339,13 @@ Message: ${causeMessage}${quantumContext}${mintDebtDiagnostics}`
75073
75339
  error: "ethRpcUrl required for recoverStaleSpend \u2014 set DiamondHandsSDKConfig.ethRpcUrl or pass rpcUrl"
75074
75340
  };
75075
75341
  }
75342
+ if (!this.config.contractSigner) {
75343
+ return {
75344
+ success: false,
75345
+ failedStep: "config",
75346
+ error: "Contract signer not configured \u2014 recoverStaleSpend submits its own recovery transaction in direct mode. Set DiamondHandsSDKConfig.contractSigner, or use service mode, where the server relays and pays for it."
75347
+ };
75348
+ }
75076
75349
  const sdkBitcoinProviderUrl = this.config.bitcoinProviders?.[0]?.url;
75077
75350
  attRes = await this.litOps.requestStaleSpendRecoveryAttestation({
75078
75351
  chainId,