@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/index.js
CHANGED
|
@@ -14460,7 +14460,7 @@ var require_pkg_src = __commonJS({
|
|
|
14460
14460
|
description: "Production Btc Transaction Signer",
|
|
14461
14461
|
version: "1.1.1",
|
|
14462
14462
|
deployed: true,
|
|
14463
|
-
deployedAt:
|
|
14463
|
+
deployedAt: 1786465606156,
|
|
14464
14464
|
size: 67999,
|
|
14465
14465
|
hash: "83f3644c68819215e05ba8db3225571354a009458fc1437f606df6cb9142d3f9"
|
|
14466
14466
|
},
|
|
@@ -14473,7 +14473,7 @@ var require_pkg_src = __commonJS({
|
|
|
14473
14473
|
description: "Production Ucd Mint Validator",
|
|
14474
14474
|
version: "1.2.1",
|
|
14475
14475
|
deployed: true,
|
|
14476
|
-
deployedAt:
|
|
14476
|
+
deployedAt: 1786465627201,
|
|
14477
14477
|
size: 82739,
|
|
14478
14478
|
hash: "2bdd9aebdaad58a43a4731d5b7284f2531b7a9caaf8caf5719d891c4ed33cb2e",
|
|
14479
14479
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
@@ -14491,7 +14491,7 @@ var require_pkg_src = __commonJS({
|
|
|
14491
14491
|
description: "Production Process Payment Validator",
|
|
14492
14492
|
version: "1.2.1",
|
|
14493
14493
|
deployed: true,
|
|
14494
|
-
deployedAt:
|
|
14494
|
+
deployedAt: 1786465654796,
|
|
14495
14495
|
size: 78736,
|
|
14496
14496
|
hash: "17191ecc9c009e0fa5ab52c876330beb2a9a75d30cccb92e7c0c04f169df088b",
|
|
14497
14497
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
@@ -14509,7 +14509,7 @@ var require_pkg_src = __commonJS({
|
|
|
14509
14509
|
description: "Production Extend Position Validator",
|
|
14510
14510
|
version: "1.2.1",
|
|
14511
14511
|
deployed: true,
|
|
14512
|
-
deployedAt:
|
|
14512
|
+
deployedAt: 1786465681874,
|
|
14513
14513
|
size: 76515,
|
|
14514
14514
|
hash: "1d4e085335af80f194a663a577876902c83015177e95906a0b461fa93bd5da08",
|
|
14515
14515
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
@@ -14519,21 +14519,17 @@ var require_pkg_src = __commonJS({
|
|
|
14519
14519
|
}
|
|
14520
14520
|
},
|
|
14521
14521
|
btcWithdrawal: {
|
|
14522
|
-
cid: "
|
|
14522
|
+
cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
|
|
14523
14523
|
authorizedCidHex: cidToHex(
|
|
14524
|
-
"
|
|
14524
|
+
"QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
|
|
14525
14525
|
),
|
|
14526
14526
|
name: "Btc Withdrawal",
|
|
14527
14527
|
description: "Production Btc Withdrawal",
|
|
14528
|
-
|
|
14529
|
-
// stamped its cohort 1.2.1, but this action was already at 1.2.3 from the vout
|
|
14530
|
-
// canonicalization fix. Reusing the cohort stamp made a newer CID read as older
|
|
14531
|
-
// than the one it replaced, which a rotation ceremony would treat as a rollback.
|
|
14532
|
-
version: "1.2.4",
|
|
14528
|
+
version: "1.2.7",
|
|
14533
14529
|
deployed: true,
|
|
14534
|
-
deployedAt:
|
|
14535
|
-
size:
|
|
14536
|
-
hash: "
|
|
14530
|
+
deployedAt: 1786446046614,
|
|
14531
|
+
size: 97456,
|
|
14532
|
+
hash: "3cae8250861832f91ee3c573abeb50ff27b9acd34148176071cbfbabb359fc91",
|
|
14537
14533
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
14538
14534
|
pkp: {
|
|
14539
14535
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
@@ -14645,19 +14641,17 @@ var require_pkg_src = __commonJS({
|
|
|
14645
14641
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
14646
14642
|
},
|
|
14647
14643
|
agentModuleExecutor: {
|
|
14648
|
-
|
|
14649
|
-
// holds this action and no PKPs until an agent is minted into it. NOT yet
|
|
14650
|
-
// bound on mainnet — the Base `DH-Agent-Mainnet` group is created at rollout.
|
|
14651
|
-
cid: "QmVgjGXUuxoGf8XyddW8a7btaazT9yEotpKoBgb65oPvcF",
|
|
14644
|
+
cid: "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ",
|
|
14652
14645
|
authorizedCidHex: cidToHex(
|
|
14653
|
-
"
|
|
14646
|
+
"QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
|
|
14654
14647
|
),
|
|
14655
14648
|
name: "Agent Module Executor",
|
|
14656
|
-
description: "
|
|
14657
|
-
version: "1.
|
|
14649
|
+
description: "Production Agent Module Executor",
|
|
14650
|
+
version: "1.1.1",
|
|
14658
14651
|
deployed: true,
|
|
14659
|
-
|
|
14660
|
-
|
|
14652
|
+
deployedAt: 1786446108348,
|
|
14653
|
+
size: 11655,
|
|
14654
|
+
hash: "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec"
|
|
14661
14655
|
},
|
|
14662
14656
|
staleSpendRecoveryValidator: {
|
|
14663
14657
|
cid: "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm",
|
|
@@ -14686,7 +14680,7 @@ var require_pkg_src = __commonJS({
|
|
|
14686
14680
|
description: "Production Btc Utxo Invalidator",
|
|
14687
14681
|
version: "1.0.0",
|
|
14688
14682
|
deployed: true,
|
|
14689
|
-
deployedAt:
|
|
14683
|
+
deployedAt: 1786465704240,
|
|
14690
14684
|
size: 62553,
|
|
14691
14685
|
hash: "1dcea2b49e545c423195be22e072dc5e3039ed1c95a8490b23505956029f5b33"
|
|
14692
14686
|
}
|
|
@@ -23452,6 +23446,7 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
23452
23446
|
exports2.fetchLitActionCodeFromIpfs = fetchLitActionCodeFromIpfs;
|
|
23453
23447
|
var axios_1 = __importDefault(require_axios());
|
|
23454
23448
|
var ipfsCodeCache = /* @__PURE__ */ new Map();
|
|
23449
|
+
var GATEWAY_TIMEOUT_MS = 2e4;
|
|
23455
23450
|
var buildGatewayList = (cid, pinataJwt) => {
|
|
23456
23451
|
const gateways = [];
|
|
23457
23452
|
if (pinataJwt) {
|
|
@@ -23460,7 +23455,7 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
23460
23455
|
headers: { Authorization: `Bearer ${pinataJwt}` }
|
|
23461
23456
|
});
|
|
23462
23457
|
}
|
|
23463
|
-
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}` }
|
|
23458
|
+
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}` });
|
|
23464
23459
|
return gateways;
|
|
23465
23460
|
};
|
|
23466
23461
|
async function fetchLitActionCodeFromIpfs(cid, options = {}) {
|
|
@@ -23474,13 +23469,14 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
23474
23469
|
const pinataJwt = options.pinataJwt ?? process.env.PINATA_JWT;
|
|
23475
23470
|
const extraGateways = options.extraGateways?.map((t) => ({ url: t.replace("{cid}", cid) })) ?? [];
|
|
23476
23471
|
const gateways = [...extraGateways, ...buildGatewayList(cid, pinataJwt)];
|
|
23472
|
+
const failures = [];
|
|
23477
23473
|
for (const gateway of gateways) {
|
|
23478
23474
|
try {
|
|
23479
23475
|
if (options.debug) {
|
|
23480
23476
|
console.log(`\u{1F4E1} [fetchLitActionCodeFromIpfs] Trying ${gateway.url}...`);
|
|
23481
23477
|
}
|
|
23482
23478
|
const response = await axios_1.default.get(gateway.url, {
|
|
23483
|
-
timeout:
|
|
23479
|
+
timeout: GATEWAY_TIMEOUT_MS,
|
|
23484
23480
|
headers: {
|
|
23485
23481
|
Accept: "text/plain, application/javascript, text/javascript",
|
|
23486
23482
|
...gateway.headers
|
|
@@ -23493,13 +23489,17 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
23493
23489
|
ipfsCodeCache.set(cid, response.data);
|
|
23494
23490
|
return response.data;
|
|
23495
23491
|
}
|
|
23492
|
+
failures.push(`${gateway.url}: HTTP ${response.status} returned ${typeof response.data}, expected string`);
|
|
23496
23493
|
} catch (error) {
|
|
23494
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
23495
|
+
failures.push(`${gateway.url}: ${message}`);
|
|
23497
23496
|
if (options.debug) {
|
|
23498
|
-
console.log(`\u274C [fetchLitActionCodeFromIpfs] ${gateway.url}:`,
|
|
23497
|
+
console.log(`\u274C [fetchLitActionCodeFromIpfs] ${gateway.url}:`, message);
|
|
23499
23498
|
}
|
|
23500
23499
|
}
|
|
23501
23500
|
}
|
|
23502
|
-
throw new Error(`Failed to fetch LIT Action from IPFS CID: ${cid}
|
|
23501
|
+
throw new Error(`Failed to fetch LIT Action from IPFS CID: ${cid} \u2014 all ${gateways.length} gateway(s) failed:
|
|
23502
|
+
` + failures.map((f) => ` - ${f}`).join("\n"));
|
|
23503
23503
|
}
|
|
23504
23504
|
}
|
|
23505
23505
|
});
|
|
@@ -50996,6 +50996,14 @@ var init_deployment_addresses = __esm2({
|
|
|
50996
50996
|
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.",
|
|
50997
50997
|
executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
|
|
50998
50998
|
block: 25673200
|
|
50999
|
+
},
|
|
51000
|
+
AgentDelegationRegistry: {
|
|
51001
|
+
newImplementation: "0xa9fF405Edd4329fc3159a64F56B37EBD253e4928",
|
|
51002
|
+
upgradedAt: "2026-07-31T22:03:35.000Z",
|
|
51003
|
+
upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f in tx 0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4 (block 25655710)",
|
|
51004
|
+
reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
|
|
51005
|
+
executeTx: "0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4",
|
|
51006
|
+
block: 25655710
|
|
50999
51007
|
}
|
|
51000
51008
|
},
|
|
51001
51009
|
latestEnv: {
|
|
@@ -51811,7 +51819,7 @@ var require_pkg_src2 = __commonJS2({
|
|
|
51811
51819
|
description: "Production Btc Transaction Signer",
|
|
51812
51820
|
version: "1.1.1",
|
|
51813
51821
|
deployed: true,
|
|
51814
|
-
deployedAt:
|
|
51822
|
+
deployedAt: 1786465606156,
|
|
51815
51823
|
size: 67999,
|
|
51816
51824
|
hash: "83f3644c68819215e05ba8db3225571354a009458fc1437f606df6cb9142d3f9"
|
|
51817
51825
|
},
|
|
@@ -51824,7 +51832,7 @@ var require_pkg_src2 = __commonJS2({
|
|
|
51824
51832
|
description: "Production Ucd Mint Validator",
|
|
51825
51833
|
version: "1.2.1",
|
|
51826
51834
|
deployed: true,
|
|
51827
|
-
deployedAt:
|
|
51835
|
+
deployedAt: 1786465627201,
|
|
51828
51836
|
size: 82739,
|
|
51829
51837
|
hash: "2bdd9aebdaad58a43a4731d5b7284f2531b7a9caaf8caf5719d891c4ed33cb2e",
|
|
51830
51838
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
@@ -51842,7 +51850,7 @@ var require_pkg_src2 = __commonJS2({
|
|
|
51842
51850
|
description: "Production Process Payment Validator",
|
|
51843
51851
|
version: "1.2.1",
|
|
51844
51852
|
deployed: true,
|
|
51845
|
-
deployedAt:
|
|
51853
|
+
deployedAt: 1786465654796,
|
|
51846
51854
|
size: 78736,
|
|
51847
51855
|
hash: "17191ecc9c009e0fa5ab52c876330beb2a9a75d30cccb92e7c0c04f169df088b",
|
|
51848
51856
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
@@ -51860,7 +51868,7 @@ var require_pkg_src2 = __commonJS2({
|
|
|
51860
51868
|
description: "Production Extend Position Validator",
|
|
51861
51869
|
version: "1.2.1",
|
|
51862
51870
|
deployed: true,
|
|
51863
|
-
deployedAt:
|
|
51871
|
+
deployedAt: 1786465681874,
|
|
51864
51872
|
size: 76515,
|
|
51865
51873
|
hash: "1d4e085335af80f194a663a577876902c83015177e95906a0b461fa93bd5da08",
|
|
51866
51874
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
@@ -51870,21 +51878,17 @@ var require_pkg_src2 = __commonJS2({
|
|
|
51870
51878
|
}
|
|
51871
51879
|
},
|
|
51872
51880
|
btcWithdrawal: {
|
|
51873
|
-
cid: "
|
|
51881
|
+
cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
|
|
51874
51882
|
authorizedCidHex: cidToHex(
|
|
51875
|
-
"
|
|
51883
|
+
"QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
|
|
51876
51884
|
),
|
|
51877
51885
|
name: "Btc Withdrawal",
|
|
51878
51886
|
description: "Production Btc Withdrawal",
|
|
51879
|
-
|
|
51880
|
-
// stamped its cohort 1.2.1, but this action was already at 1.2.3 from the vout
|
|
51881
|
-
// canonicalization fix. Reusing the cohort stamp made a newer CID read as older
|
|
51882
|
-
// than the one it replaced, which a rotation ceremony would treat as a rollback.
|
|
51883
|
-
version: "1.2.4",
|
|
51887
|
+
version: "1.2.7",
|
|
51884
51888
|
deployed: true,
|
|
51885
|
-
deployedAt:
|
|
51886
|
-
size:
|
|
51887
|
-
hash: "
|
|
51889
|
+
deployedAt: 1786446046614,
|
|
51890
|
+
size: 97456,
|
|
51891
|
+
hash: "3cae8250861832f91ee3c573abeb50ff27b9acd34148176071cbfbabb359fc91",
|
|
51888
51892
|
validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
|
|
51889
51893
|
pkp: {
|
|
51890
51894
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
@@ -51996,19 +52000,17 @@ var require_pkg_src2 = __commonJS2({
|
|
|
51996
52000
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
51997
52001
|
},
|
|
51998
52002
|
agentModuleExecutor: {
|
|
51999
|
-
|
|
52000
|
-
// holds this action and no PKPs until an agent is minted into it. NOT yet
|
|
52001
|
-
// bound on mainnet — the Base `DH-Agent-Mainnet` group is created at rollout.
|
|
52002
|
-
cid: "QmVgjGXUuxoGf8XyddW8a7btaazT9yEotpKoBgb65oPvcF",
|
|
52003
|
+
cid: "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ",
|
|
52003
52004
|
authorizedCidHex: cidToHex(
|
|
52004
|
-
"
|
|
52005
|
+
"QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
|
|
52005
52006
|
),
|
|
52006
52007
|
name: "Agent Module Executor",
|
|
52007
|
-
description: "
|
|
52008
|
-
version: "1.
|
|
52008
|
+
description: "Production Agent Module Executor",
|
|
52009
|
+
version: "1.1.1",
|
|
52009
52010
|
deployed: true,
|
|
52010
|
-
|
|
52011
|
-
|
|
52011
|
+
deployedAt: 1786446108348,
|
|
52012
|
+
size: 11655,
|
|
52013
|
+
hash: "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec"
|
|
52012
52014
|
},
|
|
52013
52015
|
staleSpendRecoveryValidator: {
|
|
52014
52016
|
cid: "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm",
|
|
@@ -52037,7 +52039,7 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52037
52039
|
description: "Production Btc Utxo Invalidator",
|
|
52038
52040
|
version: "1.0.0",
|
|
52039
52041
|
deployed: true,
|
|
52040
|
-
deployedAt:
|
|
52042
|
+
deployedAt: 1786465704240,
|
|
52041
52043
|
size: 62553,
|
|
52042
52044
|
hash: "1dcea2b49e545c423195be22e072dc5e3039ed1c95a8490b23505956029f5b33"
|
|
52043
52045
|
}
|
|
@@ -62281,6 +62283,169 @@ function normalizePkpId2(pkpId) {
|
|
|
62281
62283
|
}
|
|
62282
62284
|
return pkpId;
|
|
62283
62285
|
}
|
|
62286
|
+
function hasLoanEventsFilter(filter2) {
|
|
62287
|
+
if (!filter2)
|
|
62288
|
+
return false;
|
|
62289
|
+
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;
|
|
62290
|
+
}
|
|
62291
|
+
var WALLET_LOAN_EVENTS_QUERY = `
|
|
62292
|
+
query GetWalletLoanEvents($borrower: Bytes!, $first: Int!, $limit: Int!, $orderDirection: OrderDirection!) {
|
|
62293
|
+
positions(where: { borrower: $borrower }, first: $first, orderBy: id) {
|
|
62294
|
+
id
|
|
62295
|
+
payments(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62296
|
+
id
|
|
62297
|
+
payer { id }
|
|
62298
|
+
amount
|
|
62299
|
+
type
|
|
62300
|
+
transactionHash
|
|
62301
|
+
timestamp
|
|
62302
|
+
blockNumber
|
|
62303
|
+
logIndex
|
|
62304
|
+
newDebt
|
|
62305
|
+
newCollateralRatio
|
|
62306
|
+
}
|
|
62307
|
+
statusUpdates(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62308
|
+
id
|
|
62309
|
+
oldStatus
|
|
62310
|
+
newStatus
|
|
62311
|
+
reason
|
|
62312
|
+
timestamp
|
|
62313
|
+
blockNumber
|
|
62314
|
+
transactionHash
|
|
62315
|
+
}
|
|
62316
|
+
liquidation {
|
|
62317
|
+
id
|
|
62318
|
+
liquidator
|
|
62319
|
+
liquidatedAmount
|
|
62320
|
+
collateralSeized
|
|
62321
|
+
transactionHash
|
|
62322
|
+
timestamp
|
|
62323
|
+
blockNumber
|
|
62324
|
+
commitHash
|
|
62325
|
+
commitTimestamp
|
|
62326
|
+
revealDelay
|
|
62327
|
+
}
|
|
62328
|
+
withdrawals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62329
|
+
id
|
|
62330
|
+
withdrawalAmount
|
|
62331
|
+
withdrawalAddress
|
|
62332
|
+
networkFee
|
|
62333
|
+
timestamp
|
|
62334
|
+
blockNumber
|
|
62335
|
+
transactionHash
|
|
62336
|
+
logIndex
|
|
62337
|
+
}
|
|
62338
|
+
renewals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62339
|
+
id
|
|
62340
|
+
extensionTerm
|
|
62341
|
+
extensionFee
|
|
62342
|
+
newExpiryDate
|
|
62343
|
+
timestamp
|
|
62344
|
+
blockNumber
|
|
62345
|
+
transactionHash
|
|
62346
|
+
logIndex
|
|
62347
|
+
}
|
|
62348
|
+
operationFailures(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62349
|
+
id
|
|
62350
|
+
operationType
|
|
62351
|
+
reason
|
|
62352
|
+
errorCode
|
|
62353
|
+
amount
|
|
62354
|
+
timestamp
|
|
62355
|
+
blockNumber
|
|
62356
|
+
transactionHash
|
|
62357
|
+
logIndex
|
|
62358
|
+
}
|
|
62359
|
+
mintRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62360
|
+
id
|
|
62361
|
+
pkpId
|
|
62362
|
+
borrower { id }
|
|
62363
|
+
mintAmount
|
|
62364
|
+
originationFee
|
|
62365
|
+
newDebt
|
|
62366
|
+
newCollateralRatio
|
|
62367
|
+
btcPrice
|
|
62368
|
+
quantumTimestamp
|
|
62369
|
+
opId
|
|
62370
|
+
timestamp
|
|
62371
|
+
blockNumber
|
|
62372
|
+
transactionHash
|
|
62373
|
+
logIndex
|
|
62374
|
+
}
|
|
62375
|
+
burnRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62376
|
+
id
|
|
62377
|
+
pkpId
|
|
62378
|
+
borrower { id }
|
|
62379
|
+
burnAmount
|
|
62380
|
+
remainingDebt
|
|
62381
|
+
newCollateralRatio
|
|
62382
|
+
opId
|
|
62383
|
+
timestamp
|
|
62384
|
+
blockNumber
|
|
62385
|
+
transactionHash
|
|
62386
|
+
logIndex
|
|
62387
|
+
}
|
|
62388
|
+
mintingFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62389
|
+
id
|
|
62390
|
+
borrower { id }
|
|
62391
|
+
feeAmount
|
|
62392
|
+
mintAmount
|
|
62393
|
+
newDebt
|
|
62394
|
+
btcPrice
|
|
62395
|
+
quantumTimestamp
|
|
62396
|
+
timestamp
|
|
62397
|
+
blockNumber
|
|
62398
|
+
transactionHash
|
|
62399
|
+
logIndex
|
|
62400
|
+
}
|
|
62401
|
+
renewalFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62402
|
+
id
|
|
62403
|
+
borrower { id }
|
|
62404
|
+
feeAmount
|
|
62405
|
+
extensionTerm
|
|
62406
|
+
newExpiryDate
|
|
62407
|
+
timestamp
|
|
62408
|
+
blockNumber
|
|
62409
|
+
transactionHash
|
|
62410
|
+
logIndex
|
|
62411
|
+
}
|
|
62412
|
+
positionCreatedEvents(first: 1, orderBy: timestamp, orderDirection: asc) {
|
|
62413
|
+
id
|
|
62414
|
+
pkpId
|
|
62415
|
+
borrower { id }
|
|
62416
|
+
requestedCollateralRatio
|
|
62417
|
+
selectedTerm
|
|
62418
|
+
expiryAt
|
|
62419
|
+
timestamp
|
|
62420
|
+
blockNumber
|
|
62421
|
+
transactionHash
|
|
62422
|
+
}
|
|
62423
|
+
}
|
|
62424
|
+
ucdmintEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62425
|
+
id
|
|
62426
|
+
position { id }
|
|
62427
|
+
amount
|
|
62428
|
+
proof
|
|
62429
|
+
minter { id }
|
|
62430
|
+
isCommunityMint
|
|
62431
|
+
timestamp
|
|
62432
|
+
blockNumber
|
|
62433
|
+
transactionHash
|
|
62434
|
+
}
|
|
62435
|
+
collateralEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
|
|
62436
|
+
id
|
|
62437
|
+
position { id }
|
|
62438
|
+
eventType
|
|
62439
|
+
networkFee
|
|
62440
|
+
remainingCollateral
|
|
62441
|
+
collateralRatio
|
|
62442
|
+
timestamp
|
|
62443
|
+
blockNumber
|
|
62444
|
+
transactionHash
|
|
62445
|
+
logIndex
|
|
62446
|
+
}
|
|
62447
|
+
}
|
|
62448
|
+
`;
|
|
62284
62449
|
var DiamondHandsGraph = class {
|
|
62285
62450
|
client;
|
|
62286
62451
|
defaultPageSize;
|
|
@@ -62386,7 +62551,7 @@ var DiamondHandsGraph = class {
|
|
|
62386
62551
|
/**
|
|
62387
62552
|
* Get user positions from subgraph
|
|
62388
62553
|
*/
|
|
62389
|
-
async
|
|
62554
|
+
async getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection) {
|
|
62390
62555
|
const query = `
|
|
62391
62556
|
query GetUserPositions($borrower: Bytes!, $first: Int, $skip: Int, $orderBy: Position_orderBy, $orderDirection: OrderDirection) {
|
|
62392
62557
|
user(id: $borrower) {
|
|
@@ -62427,17 +62592,28 @@ var DiamondHandsGraph = class {
|
|
|
62427
62592
|
query,
|
|
62428
62593
|
variables
|
|
62429
62594
|
);
|
|
62430
|
-
const total = await this.getTotalCountPaginated("{ borrower: $borrower }", {
|
|
62431
|
-
borrower: userAddress.toLowerCase()
|
|
62432
|
-
});
|
|
62433
62595
|
let positions = [];
|
|
62434
62596
|
if (result && result.user && Array.isArray(result.user.positions)) {
|
|
62435
62597
|
positions = result.user.positions.filter((p) => p != null).map((p) => this.transformGraphPositionToLoanData(p));
|
|
62436
62598
|
}
|
|
62437
|
-
return
|
|
62438
|
-
|
|
62439
|
-
|
|
62440
|
-
|
|
62599
|
+
return positions;
|
|
62600
|
+
}
|
|
62601
|
+
/**
|
|
62602
|
+
* Get user positions, plus an accurate total count.
|
|
62603
|
+
*
|
|
62604
|
+
* The count is a SECOND round trip (`getTotalCountPaginated`, which pages to handle
|
|
62605
|
+
* >1000 items). Callers that only need the rows should use `getUserPositionsOnly` and
|
|
62606
|
+
* skip it — the event paths did not, and paid for a count they immediately discarded on
|
|
62607
|
+
* every activity refresh.
|
|
62608
|
+
*/
|
|
62609
|
+
async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
|
|
62610
|
+
const [positions, total] = await Promise.all([
|
|
62611
|
+
this.getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection),
|
|
62612
|
+
this.getTotalCountPaginated("{ borrower: $borrower }", {
|
|
62613
|
+
borrower: userAddress.toLowerCase()
|
|
62614
|
+
})
|
|
62615
|
+
]);
|
|
62616
|
+
return { positions, total };
|
|
62441
62617
|
}
|
|
62442
62618
|
/**
|
|
62443
62619
|
* Get user positions with enriched Bitcoin balance data
|
|
@@ -63528,6 +63704,16 @@ var DiamondHandsGraph = class {
|
|
|
63528
63704
|
orderDirection
|
|
63529
63705
|
};
|
|
63530
63706
|
const result = await this.client.execute(query, variables);
|
|
63707
|
+
return this.assembleLoanEvents(positionId, result);
|
|
63708
|
+
}
|
|
63709
|
+
/**
|
|
63710
|
+
* Map one position's raw event payload into `LoanEvents`.
|
|
63711
|
+
*
|
|
63712
|
+
* Extracted verbatim from getLoanEvents so the wallet-collapsed path produces
|
|
63713
|
+
* byte-identical objects by construction rather than by a second implementation
|
|
63714
|
+
* that has to be kept in step by hand.
|
|
63715
|
+
*/
|
|
63716
|
+
assembleLoanEvents(positionId, result) {
|
|
63531
63717
|
const rawCreated = result.positionCreatedEvents?.[0];
|
|
63532
63718
|
const positionCreated = rawCreated ? {
|
|
63533
63719
|
id: rawCreated.id,
|
|
@@ -63732,7 +63918,22 @@ var DiamondHandsGraph = class {
|
|
|
63732
63918
|
* @returns One LoanEvents object per position; empty array if the wallet has none.
|
|
63733
63919
|
*/
|
|
63734
63920
|
async getWalletLoanEvents(userAddress, filter2) {
|
|
63735
|
-
|
|
63921
|
+
if (!hasLoanEventsFilter(filter2)) {
|
|
63922
|
+
return this.getWalletLoanEventsCollapsed(userAddress);
|
|
63923
|
+
}
|
|
63924
|
+
return this.getWalletLoanEventsFanout(userAddress, filter2);
|
|
63925
|
+
}
|
|
63926
|
+
/**
|
|
63927
|
+
* The per-position path: enumerate the wallet's positions, then one `GetLoanEvents` each.
|
|
63928
|
+
*
|
|
63929
|
+
* Used for filtered calls, and as the completeness fallback when the collapsed document
|
|
63930
|
+
* hits a page limit. Costs `1 + N` requests, which is exactly why it is not the default.
|
|
63931
|
+
*/
|
|
63932
|
+
async getWalletLoanEventsFanout(userAddress, filter2) {
|
|
63933
|
+
const positions = await this.getUserPositionsOnly(
|
|
63934
|
+
userAddress,
|
|
63935
|
+
THE_GRAPH_MAX_BATCH_SIZE
|
|
63936
|
+
);
|
|
63736
63937
|
const positionIds = positions.map((p) => p?.id != null ? String(p.id) : "").filter((id) => id.length > 0);
|
|
63737
63938
|
if (positionIds.length === 0)
|
|
63738
63939
|
return [];
|
|
@@ -63747,6 +63948,81 @@ var DiamondHandsGraph = class {
|
|
|
63747
63948
|
}
|
|
63748
63949
|
return results;
|
|
63749
63950
|
}
|
|
63951
|
+
/**
|
|
63952
|
+
* The whole wallet's event history in ONE request.
|
|
63953
|
+
*
|
|
63954
|
+
* Replaces `1 + N` round trips (one position enumeration plus one per position) with a
|
|
63955
|
+
* single document. Measured on Sepolia: a wallet holding 44 positions cost 46 requests
|
|
63956
|
+
* per activity refresh against a per-wallet budget of 30/min — this makes it 1.
|
|
63957
|
+
*
|
|
63958
|
+
* Three subgraph facts make it possible, all verified against the deployed schema rather
|
|
63959
|
+
* than assumed:
|
|
63960
|
+
* - ten event collections are `@derivedFrom` on Position, so they nest under a
|
|
63961
|
+
* borrower-filtered `positions(...)`;
|
|
63962
|
+
* - `positionCreatedEvents` is ALSO derived on Position — `getLoanEvents` queries it
|
|
63963
|
+
* top-level, which it never needed to;
|
|
63964
|
+
* - `ucdmintEvents` / `collateralEvents` are not derived and carry no `borrower`
|
|
63965
|
+
* field, but graph-node's nested `position_: { borrower }` filter reaches them.
|
|
63966
|
+
* Without that last one this would be two requests, not one.
|
|
63967
|
+
*/
|
|
63968
|
+
async getWalletLoanEventsCollapsed(userAddress) {
|
|
63969
|
+
const borrower = userAddress.toLowerCase();
|
|
63970
|
+
const pageSize = THE_GRAPH_MAX_BATCH_SIZE;
|
|
63971
|
+
const result = await this.client.execute(
|
|
63972
|
+
WALLET_LOAN_EVENTS_QUERY,
|
|
63973
|
+
{
|
|
63974
|
+
borrower,
|
|
63975
|
+
first: pageSize,
|
|
63976
|
+
limit: pageSize,
|
|
63977
|
+
orderDirection: "desc"
|
|
63978
|
+
}
|
|
63979
|
+
);
|
|
63980
|
+
const positions = result.positions || [];
|
|
63981
|
+
const ucdmintEvents = result.ucdmintEvents || [];
|
|
63982
|
+
const collateralEvents = result.collateralEvents || [];
|
|
63983
|
+
const truncated = positions.length >= pageSize || ucdmintEvents.length >= pageSize || collateralEvents.length >= pageSize;
|
|
63984
|
+
if (truncated) {
|
|
63985
|
+
log.warn(
|
|
63986
|
+
"[DiamondHandsGraph] wallet event page limit reached \u2014 falling back to the per-position path to avoid returning a partial history",
|
|
63987
|
+
{
|
|
63988
|
+
borrower,
|
|
63989
|
+
pageSize,
|
|
63990
|
+
positions: positions.length,
|
|
63991
|
+
ucdmintEvents: ucdmintEvents.length,
|
|
63992
|
+
collateralEvents: collateralEvents.length
|
|
63993
|
+
}
|
|
63994
|
+
);
|
|
63995
|
+
return this.getWalletLoanEventsFanout(userAddress);
|
|
63996
|
+
}
|
|
63997
|
+
if (positions.length === 0)
|
|
63998
|
+
return [];
|
|
63999
|
+
const mintsByPosition = /* @__PURE__ */ new Map();
|
|
64000
|
+
for (const m of result.ucdmintEvents || []) {
|
|
64001
|
+
const key = m.position?.id;
|
|
64002
|
+
if (!key)
|
|
64003
|
+
continue;
|
|
64004
|
+
const bucket = mintsByPosition.get(key) || [];
|
|
64005
|
+
bucket.push(m);
|
|
64006
|
+
mintsByPosition.set(key, bucket);
|
|
64007
|
+
}
|
|
64008
|
+
const collateralByPosition = /* @__PURE__ */ new Map();
|
|
64009
|
+
for (const c of result.collateralEvents || []) {
|
|
64010
|
+
const key = c.position?.id;
|
|
64011
|
+
if (!key)
|
|
64012
|
+
continue;
|
|
64013
|
+
const bucket = collateralByPosition.get(key) || [];
|
|
64014
|
+
bucket.push(c);
|
|
64015
|
+
collateralByPosition.set(key, bucket);
|
|
64016
|
+
}
|
|
64017
|
+
return positions.map(
|
|
64018
|
+
(p) => this.assembleLoanEvents(p.id, {
|
|
64019
|
+
position: p,
|
|
64020
|
+
positionCreatedEvents: p.positionCreatedEvents || [],
|
|
64021
|
+
ucdmintEvents: mintsByPosition.get(p.id) || [],
|
|
64022
|
+
collateralEvents: collateralByPosition.get(p.id) || []
|
|
64023
|
+
})
|
|
64024
|
+
);
|
|
64025
|
+
}
|
|
63750
64026
|
// ============================================================================
|
|
63751
64027
|
// Protocol-wide Events
|
|
63752
64028
|
// ============================================================================
|
|
@@ -68606,16 +68882,6 @@ function createMockTokenManager(config) {
|
|
|
68606
68882
|
}
|
|
68607
68883
|
}
|
|
68608
68884
|
var import_dh_lit_actions2 = __toESM2(require_pkg_src2());
|
|
68609
|
-
var TelegramBot = null;
|
|
68610
|
-
try {
|
|
68611
|
-
if (typeof window === "undefined" && typeof global !== "undefined") {
|
|
68612
|
-
TelegramBot = null /* stubbed post-build: dh-mcp never uses telegram (F-PUB-2) */;
|
|
68613
|
-
}
|
|
68614
|
-
} catch (error) {
|
|
68615
|
-
log.warn("Telegram bot API not available", {
|
|
68616
|
-
error: error instanceof Error ? error.message : String(error)
|
|
68617
|
-
});
|
|
68618
|
-
}
|
|
68619
68885
|
function formatMintMessage(mintAmount, loanId, txHash) {
|
|
68620
68886
|
return `\u2705 DH SDK: ${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
|
|
68621
68887
|
}
|
|
@@ -74632,6 +74898,13 @@ Message: ${causeMessage}${quantumContext}${mintDebtDiagnostics}`
|
|
|
74632
74898
|
error: "ethRpcUrl required for recoverStaleSpend \u2014 set DiamondHandsSDKConfig.ethRpcUrl or pass rpcUrl"
|
|
74633
74899
|
};
|
|
74634
74900
|
}
|
|
74901
|
+
if (!this.config.contractSigner) {
|
|
74902
|
+
return {
|
|
74903
|
+
success: false,
|
|
74904
|
+
failedStep: "config",
|
|
74905
|
+
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."
|
|
74906
|
+
};
|
|
74907
|
+
}
|
|
74635
74908
|
const sdkBitcoinProviderUrl = this.config.bitcoinProviders?.[0]?.url;
|
|
74636
74909
|
attRes = await this.litOps.requestStaleSpendRecoveryAttestation({
|
|
74637
74910
|
chainId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gvnrdao/dh-mcp",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "MCP server for the Diamond Hands protocol — Bitcoin-collateralized UCD lending with human-approved signing (sepolia practice by default; mainnet fully enabled)",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@anthropic-ai/mcpb": "2.1.2",
|
|
56
|
-
"@gvnrdao/dh-sdk": "^0.0.
|
|
56
|
+
"@gvnrdao/dh-sdk": "^0.0.330",
|
|
57
57
|
"@types/express": "5.0.3",
|
|
58
58
|
"@types/jest": "29.5.12",
|
|
59
59
|
"@types/node": "20.14.10",
|