@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/boundary.js +344 -71
- package/dist/connector-embed.js +344 -71
- package/dist/connector.js +344 -71
- package/dist/index.js +344 -71
- package/package.json +2 -2
package/dist/connector-embed.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:
|
|
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:
|
|
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:
|
|
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:
|
|
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: "
|
|
14641
|
+
cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
|
|
14642
14642
|
authorizedCidHex: cidToHex(
|
|
14643
|
-
"
|
|
14643
|
+
"QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
|
|
14644
14644
|
),
|
|
14645
14645
|
name: "Btc Withdrawal",
|
|
14646
14646
|
description: "Production Btc Withdrawal",
|
|
14647
|
-
|
|
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:
|
|
14654
|
-
size:
|
|
14655
|
-
hash: "
|
|
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
|
-
|
|
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
|
-
"
|
|
14765
|
+
"QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
|
|
14773
14766
|
),
|
|
14774
14767
|
name: "Agent Module Executor",
|
|
14775
|
-
description: "
|
|
14776
|
-
version: "1.
|
|
14768
|
+
description: "Production Agent Module Executor",
|
|
14769
|
+
version: "1.1.1",
|
|
14777
14770
|
deployed: true,
|
|
14778
|
-
|
|
14779
|
-
|
|
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:
|
|
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}` }
|
|
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:
|
|
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}:`,
|
|
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
|
});
|
|
@@ -51443,6 +51443,14 @@ var init_deployment_addresses = __esm2({
|
|
|
51443
51443
|
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.",
|
|
51444
51444
|
executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
|
|
51445
51445
|
block: 25673200
|
|
51446
|
+
},
|
|
51447
|
+
AgentDelegationRegistry: {
|
|
51448
|
+
newImplementation: "0xa9fF405Edd4329fc3159a64F56B37EBD253e4928",
|
|
51449
|
+
upgradedAt: "2026-07-31T22:03:35.000Z",
|
|
51450
|
+
upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f in tx 0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4 (block 25655710)",
|
|
51451
|
+
reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
|
|
51452
|
+
executeTx: "0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4",
|
|
51453
|
+
block: 25655710
|
|
51446
51454
|
}
|
|
51447
51455
|
},
|
|
51448
51456
|
latestEnv: {
|
|
@@ -52258,7 +52266,7 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52258
52266
|
description: "Production Btc Transaction Signer",
|
|
52259
52267
|
version: "1.1.1",
|
|
52260
52268
|
deployed: true,
|
|
52261
|
-
deployedAt:
|
|
52269
|
+
deployedAt: 1786465606156,
|
|
52262
52270
|
size: 67999,
|
|
52263
52271
|
hash: "83f3644c68819215e05ba8db3225571354a009458fc1437f606df6cb9142d3f9"
|
|
52264
52272
|
},
|
|
@@ -52271,7 +52279,7 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52271
52279
|
description: "Production Ucd Mint Validator",
|
|
52272
52280
|
version: "1.2.1",
|
|
52273
52281
|
deployed: true,
|
|
52274
|
-
deployedAt:
|
|
52282
|
+
deployedAt: 1786465627201,
|
|
52275
52283
|
size: 82739,
|
|
52276
52284
|
hash: "2bdd9aebdaad58a43a4731d5b7284f2531b7a9caaf8caf5719d891c4ed33cb2e",
|
|
52277
52285
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
@@ -52289,7 +52297,7 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52289
52297
|
description: "Production Process Payment Validator",
|
|
52290
52298
|
version: "1.2.1",
|
|
52291
52299
|
deployed: true,
|
|
52292
|
-
deployedAt:
|
|
52300
|
+
deployedAt: 1786465654796,
|
|
52293
52301
|
size: 78736,
|
|
52294
52302
|
hash: "17191ecc9c009e0fa5ab52c876330beb2a9a75d30cccb92e7c0c04f169df088b",
|
|
52295
52303
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
@@ -52307,7 +52315,7 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52307
52315
|
description: "Production Extend Position Validator",
|
|
52308
52316
|
version: "1.2.1",
|
|
52309
52317
|
deployed: true,
|
|
52310
|
-
deployedAt:
|
|
52318
|
+
deployedAt: 1786465681874,
|
|
52311
52319
|
size: 76515,
|
|
52312
52320
|
hash: "1d4e085335af80f194a663a577876902c83015177e95906a0b461fa93bd5da08",
|
|
52313
52321
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
@@ -52317,21 +52325,17 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52317
52325
|
}
|
|
52318
52326
|
},
|
|
52319
52327
|
btcWithdrawal: {
|
|
52320
|
-
cid: "
|
|
52328
|
+
cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
|
|
52321
52329
|
authorizedCidHex: cidToHex(
|
|
52322
|
-
"
|
|
52330
|
+
"QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
|
|
52323
52331
|
),
|
|
52324
52332
|
name: "Btc Withdrawal",
|
|
52325
52333
|
description: "Production Btc Withdrawal",
|
|
52326
|
-
|
|
52327
|
-
// stamped its cohort 1.2.1, but this action was already at 1.2.3 from the vout
|
|
52328
|
-
// canonicalization fix. Reusing the cohort stamp made a newer CID read as older
|
|
52329
|
-
// than the one it replaced, which a rotation ceremony would treat as a rollback.
|
|
52330
|
-
version: "1.2.4",
|
|
52334
|
+
version: "1.2.7",
|
|
52331
52335
|
deployed: true,
|
|
52332
|
-
deployedAt:
|
|
52333
|
-
size:
|
|
52334
|
-
hash: "
|
|
52336
|
+
deployedAt: 1786446046614,
|
|
52337
|
+
size: 97456,
|
|
52338
|
+
hash: "3cae8250861832f91ee3c573abeb50ff27b9acd34148176071cbfbabb359fc91",
|
|
52335
52339
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
52336
52340
|
pkp: {
|
|
52337
52341
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
@@ -52443,19 +52447,17 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52443
52447
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
52444
52448
|
},
|
|
52445
52449
|
agentModuleExecutor: {
|
|
52446
|
-
|
|
52447
|
-
// holds this action and no PKPs until an agent is minted into it. NOT yet
|
|
52448
|
-
// bound on mainnet — the Base `DH-Agent-Mainnet` group is created at rollout.
|
|
52449
|
-
cid: "QmVgjGXUuxoGf8XyddW8a7btaazT9yEotpKoBgb65oPvcF",
|
|
52450
|
+
cid: "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ",
|
|
52450
52451
|
authorizedCidHex: cidToHex(
|
|
52451
|
-
"
|
|
52452
|
+
"QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
|
|
52452
52453
|
),
|
|
52453
52454
|
name: "Agent Module Executor",
|
|
52454
|
-
description: "
|
|
52455
|
-
version: "1.
|
|
52455
|
+
description: "Production Agent Module Executor",
|
|
52456
|
+
version: "1.1.1",
|
|
52456
52457
|
deployed: true,
|
|
52457
|
-
|
|
52458
|
-
|
|
52458
|
+
deployedAt: 1786446108348,
|
|
52459
|
+
size: 11655,
|
|
52460
|
+
hash: "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec"
|
|
52459
52461
|
},
|
|
52460
52462
|
staleSpendRecoveryValidator: {
|
|
52461
52463
|
cid: "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm",
|
|
@@ -52484,7 +52486,7 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52484
52486
|
description: "Production Btc Utxo Invalidator",
|
|
52485
52487
|
version: "1.0.0",
|
|
52486
52488
|
deployed: true,
|
|
52487
|
-
deployedAt:
|
|
52489
|
+
deployedAt: 1786465704240,
|
|
52488
52490
|
size: 62553,
|
|
52489
52491
|
hash: "1dcea2b49e545c423195be22e072dc5e3039ed1c95a8490b23505956029f5b33"
|
|
52490
52492
|
}
|
|
@@ -62728,6 +62730,169 @@ function normalizePkpId2(pkpId) {
|
|
|
62728
62730
|
}
|
|
62729
62731
|
return pkpId;
|
|
62730
62732
|
}
|
|
62733
|
+
function hasLoanEventsFilter(filter2) {
|
|
62734
|
+
if (!filter2)
|
|
62735
|
+
return false;
|
|
62736
|
+
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;
|
|
62737
|
+
}
|
|
62738
|
+
var WALLET_LOAN_EVENTS_QUERY = `
|
|
62739
|
+
query GetWalletLoanEvents($borrower: Bytes!, $first: Int!, $limit: Int!, $orderDirection: OrderDirection!) {
|
|
62740
|
+
positions(where: { borrower: $borrower }, first: $first, orderBy: id) {
|
|
62741
|
+
id
|
|
62742
|
+
payments(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62743
|
+
id
|
|
62744
|
+
payer { id }
|
|
62745
|
+
amount
|
|
62746
|
+
type
|
|
62747
|
+
transactionHash
|
|
62748
|
+
timestamp
|
|
62749
|
+
blockNumber
|
|
62750
|
+
logIndex
|
|
62751
|
+
newDebt
|
|
62752
|
+
newCollateralRatio
|
|
62753
|
+
}
|
|
62754
|
+
statusUpdates(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62755
|
+
id
|
|
62756
|
+
oldStatus
|
|
62757
|
+
newStatus
|
|
62758
|
+
reason
|
|
62759
|
+
timestamp
|
|
62760
|
+
blockNumber
|
|
62761
|
+
transactionHash
|
|
62762
|
+
}
|
|
62763
|
+
liquidation {
|
|
62764
|
+
id
|
|
62765
|
+
liquidator
|
|
62766
|
+
liquidatedAmount
|
|
62767
|
+
collateralSeized
|
|
62768
|
+
transactionHash
|
|
62769
|
+
timestamp
|
|
62770
|
+
blockNumber
|
|
62771
|
+
commitHash
|
|
62772
|
+
commitTimestamp
|
|
62773
|
+
revealDelay
|
|
62774
|
+
}
|
|
62775
|
+
withdrawals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62776
|
+
id
|
|
62777
|
+
withdrawalAmount
|
|
62778
|
+
withdrawalAddress
|
|
62779
|
+
networkFee
|
|
62780
|
+
timestamp
|
|
62781
|
+
blockNumber
|
|
62782
|
+
transactionHash
|
|
62783
|
+
logIndex
|
|
62784
|
+
}
|
|
62785
|
+
renewals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62786
|
+
id
|
|
62787
|
+
extensionTerm
|
|
62788
|
+
extensionFee
|
|
62789
|
+
newExpiryDate
|
|
62790
|
+
timestamp
|
|
62791
|
+
blockNumber
|
|
62792
|
+
transactionHash
|
|
62793
|
+
logIndex
|
|
62794
|
+
}
|
|
62795
|
+
operationFailures(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62796
|
+
id
|
|
62797
|
+
operationType
|
|
62798
|
+
reason
|
|
62799
|
+
errorCode
|
|
62800
|
+
amount
|
|
62801
|
+
timestamp
|
|
62802
|
+
blockNumber
|
|
62803
|
+
transactionHash
|
|
62804
|
+
logIndex
|
|
62805
|
+
}
|
|
62806
|
+
mintRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62807
|
+
id
|
|
62808
|
+
pkpId
|
|
62809
|
+
borrower { id }
|
|
62810
|
+
mintAmount
|
|
62811
|
+
originationFee
|
|
62812
|
+
newDebt
|
|
62813
|
+
newCollateralRatio
|
|
62814
|
+
btcPrice
|
|
62815
|
+
quantumTimestamp
|
|
62816
|
+
opId
|
|
62817
|
+
timestamp
|
|
62818
|
+
blockNumber
|
|
62819
|
+
transactionHash
|
|
62820
|
+
logIndex
|
|
62821
|
+
}
|
|
62822
|
+
burnRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62823
|
+
id
|
|
62824
|
+
pkpId
|
|
62825
|
+
borrower { id }
|
|
62826
|
+
burnAmount
|
|
62827
|
+
remainingDebt
|
|
62828
|
+
newCollateralRatio
|
|
62829
|
+
opId
|
|
62830
|
+
timestamp
|
|
62831
|
+
blockNumber
|
|
62832
|
+
transactionHash
|
|
62833
|
+
logIndex
|
|
62834
|
+
}
|
|
62835
|
+
mintingFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62836
|
+
id
|
|
62837
|
+
borrower { id }
|
|
62838
|
+
feeAmount
|
|
62839
|
+
mintAmount
|
|
62840
|
+
newDebt
|
|
62841
|
+
btcPrice
|
|
62842
|
+
quantumTimestamp
|
|
62843
|
+
timestamp
|
|
62844
|
+
blockNumber
|
|
62845
|
+
transactionHash
|
|
62846
|
+
logIndex
|
|
62847
|
+
}
|
|
62848
|
+
renewalFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62849
|
+
id
|
|
62850
|
+
borrower { id }
|
|
62851
|
+
feeAmount
|
|
62852
|
+
extensionTerm
|
|
62853
|
+
newExpiryDate
|
|
62854
|
+
timestamp
|
|
62855
|
+
blockNumber
|
|
62856
|
+
transactionHash
|
|
62857
|
+
logIndex
|
|
62858
|
+
}
|
|
62859
|
+
positionCreatedEvents(first: 1, orderBy: timestamp, orderDirection: asc) {
|
|
62860
|
+
id
|
|
62861
|
+
pkpId
|
|
62862
|
+
borrower { id }
|
|
62863
|
+
requestedCollateralRatio
|
|
62864
|
+
selectedTerm
|
|
62865
|
+
expiryAt
|
|
62866
|
+
timestamp
|
|
62867
|
+
blockNumber
|
|
62868
|
+
transactionHash
|
|
62869
|
+
}
|
|
62870
|
+
}
|
|
62871
|
+
ucdmintEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62872
|
+
id
|
|
62873
|
+
position { id }
|
|
62874
|
+
amount
|
|
62875
|
+
proof
|
|
62876
|
+
minter { id }
|
|
62877
|
+
isCommunityMint
|
|
62878
|
+
timestamp
|
|
62879
|
+
blockNumber
|
|
62880
|
+
transactionHash
|
|
62881
|
+
}
|
|
62882
|
+
collateralEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62883
|
+
id
|
|
62884
|
+
position { id }
|
|
62885
|
+
eventType
|
|
62886
|
+
networkFee
|
|
62887
|
+
remainingCollateral
|
|
62888
|
+
collateralRatio
|
|
62889
|
+
timestamp
|
|
62890
|
+
blockNumber
|
|
62891
|
+
transactionHash
|
|
62892
|
+
logIndex
|
|
62893
|
+
}
|
|
62894
|
+
}
|
|
62895
|
+
`;
|
|
62731
62896
|
var DiamondHandsGraph = class {
|
|
62732
62897
|
client;
|
|
62733
62898
|
defaultPageSize;
|
|
@@ -62833,7 +62998,7 @@ var DiamondHandsGraph = class {
|
|
|
62833
62998
|
/**
|
|
62834
62999
|
* Get user positions from subgraph
|
|
62835
63000
|
*/
|
|
62836
|
-
async
|
|
63001
|
+
async getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection) {
|
|
62837
63002
|
const query = `
|
|
62838
63003
|
query GetUserPositions($borrower: Bytes!, $first: Int, $skip: Int, $orderBy: Position_orderBy, $orderDirection: OrderDirection) {
|
|
62839
63004
|
user(id: $borrower) {
|
|
@@ -62874,17 +63039,28 @@ var DiamondHandsGraph = class {
|
|
|
62874
63039
|
query,
|
|
62875
63040
|
variables
|
|
62876
63041
|
);
|
|
62877
|
-
const total = await this.getTotalCountPaginated("{ borrower: $borrower }", {
|
|
62878
|
-
borrower: userAddress.toLowerCase()
|
|
62879
|
-
});
|
|
62880
63042
|
let positions = [];
|
|
62881
63043
|
if (result && result.user && Array.isArray(result.user.positions)) {
|
|
62882
63044
|
positions = result.user.positions.filter((p) => p != null).map((p) => this.transformGraphPositionToLoanData(p));
|
|
62883
63045
|
}
|
|
62884
|
-
return
|
|
62885
|
-
|
|
62886
|
-
|
|
62887
|
-
|
|
63046
|
+
return positions;
|
|
63047
|
+
}
|
|
63048
|
+
/**
|
|
63049
|
+
* Get user positions, plus an accurate total count.
|
|
63050
|
+
*
|
|
63051
|
+
* The count is a SECOND round trip (`getTotalCountPaginated`, which pages to handle
|
|
63052
|
+
* >1000 items). Callers that only need the rows should use `getUserPositionsOnly` and
|
|
63053
|
+
* skip it — the event paths did not, and paid for a count they immediately discarded on
|
|
63054
|
+
* every activity refresh.
|
|
63055
|
+
*/
|
|
63056
|
+
async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
|
|
63057
|
+
const [positions, total] = await Promise.all([
|
|
63058
|
+
this.getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection),
|
|
63059
|
+
this.getTotalCountPaginated("{ borrower: $borrower }", {
|
|
63060
|
+
borrower: userAddress.toLowerCase()
|
|
63061
|
+
})
|
|
63062
|
+
]);
|
|
63063
|
+
return { positions, total };
|
|
62888
63064
|
}
|
|
62889
63065
|
/**
|
|
62890
63066
|
* Get user positions with enriched Bitcoin balance data
|
|
@@ -63975,6 +64151,16 @@ var DiamondHandsGraph = class {
|
|
|
63975
64151
|
orderDirection
|
|
63976
64152
|
};
|
|
63977
64153
|
const result = await this.client.execute(query, variables);
|
|
64154
|
+
return this.assembleLoanEvents(positionId, result);
|
|
64155
|
+
}
|
|
64156
|
+
/**
|
|
64157
|
+
* Map one position's raw event payload into `LoanEvents`.
|
|
64158
|
+
*
|
|
64159
|
+
* Extracted verbatim from getLoanEvents so the wallet-collapsed path produces
|
|
64160
|
+
* byte-identical objects by construction rather than by a second implementation
|
|
64161
|
+
* that has to be kept in step by hand.
|
|
64162
|
+
*/
|
|
64163
|
+
assembleLoanEvents(positionId, result) {
|
|
63978
64164
|
const rawCreated = result.positionCreatedEvents?.[0];
|
|
63979
64165
|
const positionCreated = rawCreated ? {
|
|
63980
64166
|
id: rawCreated.id,
|
|
@@ -64179,7 +64365,22 @@ var DiamondHandsGraph = class {
|
|
|
64179
64365
|
* @returns One LoanEvents object per position; empty array if the wallet has none.
|
|
64180
64366
|
*/
|
|
64181
64367
|
async getWalletLoanEvents(userAddress, filter2) {
|
|
64182
|
-
|
|
64368
|
+
if (!hasLoanEventsFilter(filter2)) {
|
|
64369
|
+
return this.getWalletLoanEventsCollapsed(userAddress);
|
|
64370
|
+
}
|
|
64371
|
+
return this.getWalletLoanEventsFanout(userAddress, filter2);
|
|
64372
|
+
}
|
|
64373
|
+
/**
|
|
64374
|
+
* The per-position path: enumerate the wallet's positions, then one `GetLoanEvents` each.
|
|
64375
|
+
*
|
|
64376
|
+
* Used for filtered calls, and as the completeness fallback when the collapsed document
|
|
64377
|
+
* hits a page limit. Costs `1 + N` requests, which is exactly why it is not the default.
|
|
64378
|
+
*/
|
|
64379
|
+
async getWalletLoanEventsFanout(userAddress, filter2) {
|
|
64380
|
+
const positions = await this.getUserPositionsOnly(
|
|
64381
|
+
userAddress,
|
|
64382
|
+
THE_GRAPH_MAX_BATCH_SIZE
|
|
64383
|
+
);
|
|
64183
64384
|
const positionIds = positions.map((p) => p?.id != null ? String(p.id) : "").filter((id) => id.length > 0);
|
|
64184
64385
|
if (positionIds.length === 0)
|
|
64185
64386
|
return [];
|
|
@@ -64194,6 +64395,81 @@ var DiamondHandsGraph = class {
|
|
|
64194
64395
|
}
|
|
64195
64396
|
return results;
|
|
64196
64397
|
}
|
|
64398
|
+
/**
|
|
64399
|
+
* The whole wallet's event history in ONE request.
|
|
64400
|
+
*
|
|
64401
|
+
* Replaces `1 + N` round trips (one position enumeration plus one per position) with a
|
|
64402
|
+
* single document. Measured on Sepolia: a wallet holding 44 positions cost 46 requests
|
|
64403
|
+
* per activity refresh against a per-wallet budget of 30/min — this makes it 1.
|
|
64404
|
+
*
|
|
64405
|
+
* Three subgraph facts make it possible, all verified against the deployed schema rather
|
|
64406
|
+
* than assumed:
|
|
64407
|
+
* - ten event collections are `@derivedFrom` on Position, so they nest under a
|
|
64408
|
+
* borrower-filtered `positions(...)`;
|
|
64409
|
+
* - `positionCreatedEvents` is ALSO derived on Position — `getLoanEvents` queries it
|
|
64410
|
+
* top-level, which it never needed to;
|
|
64411
|
+
* - `ucdmintEvents` / `collateralEvents` are not derived and carry no `borrower`
|
|
64412
|
+
* field, but graph-node's nested `position_: { borrower }` filter reaches them.
|
|
64413
|
+
* Without that last one this would be two requests, not one.
|
|
64414
|
+
*/
|
|
64415
|
+
async getWalletLoanEventsCollapsed(userAddress) {
|
|
64416
|
+
const borrower = userAddress.toLowerCase();
|
|
64417
|
+
const pageSize = THE_GRAPH_MAX_BATCH_SIZE;
|
|
64418
|
+
const result = await this.client.execute(
|
|
64419
|
+
WALLET_LOAN_EVENTS_QUERY,
|
|
64420
|
+
{
|
|
64421
|
+
borrower,
|
|
64422
|
+
first: pageSize,
|
|
64423
|
+
limit: pageSize,
|
|
64424
|
+
orderDirection: "desc"
|
|
64425
|
+
}
|
|
64426
|
+
);
|
|
64427
|
+
const positions = result.positions || [];
|
|
64428
|
+
const ucdmintEvents = result.ucdmintEvents || [];
|
|
64429
|
+
const collateralEvents = result.collateralEvents || [];
|
|
64430
|
+
const truncated = positions.length >= pageSize || ucdmintEvents.length >= pageSize || collateralEvents.length >= pageSize;
|
|
64431
|
+
if (truncated) {
|
|
64432
|
+
log.warn(
|
|
64433
|
+
"[DiamondHandsGraph] wallet event page limit reached \u2014 falling back to the per-position path to avoid returning a partial history",
|
|
64434
|
+
{
|
|
64435
|
+
borrower,
|
|
64436
|
+
pageSize,
|
|
64437
|
+
positions: positions.length,
|
|
64438
|
+
ucdmintEvents: ucdmintEvents.length,
|
|
64439
|
+
collateralEvents: collateralEvents.length
|
|
64440
|
+
}
|
|
64441
|
+
);
|
|
64442
|
+
return this.getWalletLoanEventsFanout(userAddress);
|
|
64443
|
+
}
|
|
64444
|
+
if (positions.length === 0)
|
|
64445
|
+
return [];
|
|
64446
|
+
const mintsByPosition = /* @__PURE__ */ new Map();
|
|
64447
|
+
for (const m of result.ucdmintEvents || []) {
|
|
64448
|
+
const key = m.position?.id;
|
|
64449
|
+
if (!key)
|
|
64450
|
+
continue;
|
|
64451
|
+
const bucket = mintsByPosition.get(key) || [];
|
|
64452
|
+
bucket.push(m);
|
|
64453
|
+
mintsByPosition.set(key, bucket);
|
|
64454
|
+
}
|
|
64455
|
+
const collateralByPosition = /* @__PURE__ */ new Map();
|
|
64456
|
+
for (const c of result.collateralEvents || []) {
|
|
64457
|
+
const key = c.position?.id;
|
|
64458
|
+
if (!key)
|
|
64459
|
+
continue;
|
|
64460
|
+
const bucket = collateralByPosition.get(key) || [];
|
|
64461
|
+
bucket.push(c);
|
|
64462
|
+
collateralByPosition.set(key, bucket);
|
|
64463
|
+
}
|
|
64464
|
+
return positions.map(
|
|
64465
|
+
(p) => this.assembleLoanEvents(p.id, {
|
|
64466
|
+
position: p,
|
|
64467
|
+
positionCreatedEvents: p.positionCreatedEvents || [],
|
|
64468
|
+
ucdmintEvents: mintsByPosition.get(p.id) || [],
|
|
64469
|
+
collateralEvents: collateralByPosition.get(p.id) || []
|
|
64470
|
+
})
|
|
64471
|
+
);
|
|
64472
|
+
}
|
|
64197
64473
|
// ============================================================================
|
|
64198
64474
|
// Protocol-wide Events
|
|
64199
64475
|
// ============================================================================
|
|
@@ -69053,16 +69329,6 @@ function createMockTokenManager(config) {
|
|
|
69053
69329
|
}
|
|
69054
69330
|
}
|
|
69055
69331
|
var import_dh_lit_actions2 = __toESM2(require_pkg_src2());
|
|
69056
|
-
var TelegramBot = null;
|
|
69057
|
-
try {
|
|
69058
|
-
if (typeof window === "undefined" && typeof global !== "undefined") {
|
|
69059
|
-
TelegramBot = __require("node-telegram-bot-api");
|
|
69060
|
-
}
|
|
69061
|
-
} catch (error) {
|
|
69062
|
-
log.warn("Telegram bot API not available", {
|
|
69063
|
-
error: error instanceof Error ? error.message : String(error)
|
|
69064
|
-
});
|
|
69065
|
-
}
|
|
69066
69332
|
function formatMintMessage(mintAmount, loanId, txHash) {
|
|
69067
69333
|
return `\u2705 DH SDK: ${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
|
|
69068
69334
|
}
|
|
@@ -75079,6 +75345,13 @@ Message: ${causeMessage}${quantumContext}${mintDebtDiagnostics}`
|
|
|
75079
75345
|
error: "ethRpcUrl required for recoverStaleSpend \u2014 set DiamondHandsSDKConfig.ethRpcUrl or pass rpcUrl"
|
|
75080
75346
|
};
|
|
75081
75347
|
}
|
|
75348
|
+
if (!this.config.contractSigner) {
|
|
75349
|
+
return {
|
|
75350
|
+
success: false,
|
|
75351
|
+
failedStep: "config",
|
|
75352
|
+
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."
|
|
75353
|
+
};
|
|
75354
|
+
}
|
|
75082
75355
|
const sdkBitcoinProviderUrl = this.config.bitcoinProviders?.[0]?.url;
|
|
75083
75356
|
attRes = await this.litOps.requestStaleSpendRecoveryAttestation({
|
|
75084
75357
|
chainId,
|