@gvnrdao/dh-mcp 0.5.21 → 0.5.23

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
@@ -40,6 +40,7 @@ __export(wc_transport_exports, {
40
40
  WC_DAPP_METADATA: () => WC_DAPP_METADATA,
41
41
  WC_SESSION_METHODS: () => WC_SESSION_METHODS,
42
42
  WcTransport: () => WcTransport,
43
+ guardRelayFatal: () => guardRelayFatal,
43
44
  newIsolatedCore: () => newIsolatedCore,
44
45
  wcSessionNamespaces: () => wcSessionNamespaces,
45
46
  withEip712DomainType: () => withEip712DomainType
@@ -73,7 +74,27 @@ function newIsolatedCore(cfg, label) {
73
74
  });
74
75
  return { core, scratch };
75
76
  }
76
- var import_core, import_sign_client, os, path, import_node_fs, WC_SESSION_METHODS, WC_DAPP_METADATA, EVENTS, WcTransport;
77
+ function guardRelayFatal(core, health, onFatal) {
78
+ const relayer = core.relayer;
79
+ const register = relayer.registerProviderListeners;
80
+ if (typeof register !== "function") {
81
+ throw new Error(
82
+ "@walletconnect/core no longer exposes relayer.registerProviderListeners \u2014 the fatal-close guard (D-4) cannot be installed. Re-verify the relay error path for this WalletConnect version before shipping it."
83
+ );
84
+ }
85
+ const record = (e) => {
86
+ if (health.fatal !== null) return;
87
+ health.fatal = e.message;
88
+ console.error(`[dh-mcp] WalletConnect relay failed fatally: ${e.message}`);
89
+ onFatal(e.message);
90
+ };
91
+ relayer.on("relayer_error", record);
92
+ relayer.registerProviderListeners = () => {
93
+ register.call(relayer);
94
+ relayer.provider.on("error", record);
95
+ };
96
+ }
97
+ var import_core, import_sign_client, os, path, import_node_fs, import_ethers, WC_SESSION_METHODS, WC_DAPP_METADATA, EVENTS, WcTransport;
77
98
  var init_wc_transport = __esm({
78
99
  "src/boundary/upstream/shared/external-bridge/wc-transport.ts"() {
79
100
  "use strict";
@@ -82,6 +103,7 @@ var init_wc_transport = __esm({
82
103
  os = __toESM(require("os"));
83
104
  path = __toESM(require("path"));
84
105
  import_node_fs = require("fs");
106
+ import_ethers = require("ethers");
85
107
  WC_SESSION_METHODS = ["personal_sign", "eth_signTypedData_v4", "eth_sendTransaction"];
86
108
  WC_DAPP_METADATA = {
87
109
  name: "Diamond Hands MCP",
@@ -91,11 +113,14 @@ var init_wc_transport = __esm({
91
113
  };
92
114
  EVENTS = ["accountsChanged", "chainChanged"];
93
115
  WcTransport = class _WcTransport {
94
- constructor(client, cfg, scratch) {
116
+ constructor(client, cfg, scratch, health) {
95
117
  this.client = client;
96
118
  this.cfg = cfg;
97
119
  this.scratch = scratch;
120
+ this.health = health;
98
121
  client.on("session_delete", ({ topic }) => {
122
+ const pending = this.candidates.get(topic);
123
+ if (pending) pending.deleted = true;
99
124
  if (this.session === null || this.session.topic !== topic) return;
100
125
  this.session = null;
101
126
  this.sessionListener?.(null);
@@ -103,14 +128,35 @@ var init_wc_transport = __esm({
103
128
  }
104
129
  session = null;
105
130
  sessionListener = null;
131
+ /** Sessions announced but not yet adopted (awaiting a deferred verdict), by topic. */
132
+ candidates = /* @__PURE__ */ new Map();
106
133
  static async create(cfg) {
107
134
  const { core, scratch } = newIsolatedCore(cfg, "dh-wc-dapp");
135
+ const health = { fatal: null };
136
+ let transport = null;
137
+ guardRelayFatal(core, health, () => transport?.dropForFatal());
108
138
  const client = await import_sign_client.default.init({
109
139
  core,
110
140
  projectId: cfg.projectId,
111
141
  metadata: cfg.metadata ?? WC_DAPP_METADATA
112
142
  });
113
- return new _WcTransport(client, cfg, scratch);
143
+ transport = new _WcTransport(client, cfg, scratch, health);
144
+ return transport;
145
+ }
146
+ /** The relay is gone for good: no adopted session may outlive it. Listeners hear a
147
+ * disconnect, exactly as if the wallet had left. */
148
+ dropForFatal() {
149
+ if (this.session === null) return;
150
+ this.session = null;
151
+ void this.sessionListener?.(null);
152
+ }
153
+ /** Refuse to start new work over a relay that has failed fatally — naming why. */
154
+ assertRelayHealthy() {
155
+ if (this.health.fatal !== null) {
156
+ throw new Error(
157
+ `the WalletConnect relay refused this connector (${this.health.fatal}) \u2014 mobile-wallet signing is unavailable until the relay accepts its project id (DH_WC_PROJECT_ID); use the browser-wallet approval page instead`
158
+ );
159
+ }
114
160
  }
115
161
  /** Wallet-session state changes (connect/disconnect) — the bridge mirrors them. */
116
162
  onSession(cb) {
@@ -121,6 +167,7 @@ var init_wc_transport = __esm({
121
167
  }
122
168
  /** Create a pairing URI; resolves the session in the background when a wallet approves. */
123
169
  async createPairing() {
170
+ this.assertRelayHealthy();
124
171
  const { uri, approval } = await this.client.connect({
125
172
  // sign-client 2.21 deprecates requiredNamespaces (auto-downgraded to optional).
126
173
  optionalNamespaces: wcSessionNamespaces(this.cfg.chainId)
@@ -128,22 +175,51 @@ var init_wc_transport = __esm({
128
175
  if (!uri) throw new Error("WalletConnect returned no pairing URI");
129
176
  const pairingId = /^wc:([0-9a-f]+)@/i.exec(uri)?.[1];
130
177
  if (!pairingId) throw new Error(`WalletConnect pairing URI has no recognisable topic: ${uri.slice(0, 12)}\u2026`);
131
- void approval().then((session) => {
178
+ let candidateTopic = null;
179
+ void approval().then(async (session) => {
132
180
  const first = session.namespaces["eip155"]?.accounts[0];
133
181
  if (!first) throw new Error("WalletConnect session carries no eip155 account");
134
182
  const [, chainIdStr, account] = first.split(":");
183
+ candidateTopic = session.topic;
184
+ const candidate = { topic: session.topic, account, chainId: Number(chainIdStr) };
185
+ const prove = async (statement) => {
186
+ this.assertRelayHealthy();
187
+ return await this.client.request({
188
+ topic: candidate.topic,
189
+ chainId: `eip155:${candidate.chainId}`,
190
+ request: { method: "personal_sign", params: [import_ethers.ethers.hexlify(import_ethers.ethers.toUtf8Bytes(statement)), candidate.account] }
191
+ });
192
+ };
193
+ const state = { deleted: false };
194
+ const live = () => !state.deleted && this.health.fatal === null;
135
195
  const previous = this.session;
136
- this.session = { topic: session.topic, account, chainId: Number(chainIdStr) };
137
- const verdict = this.sessionListener?.({ ...this.active(), pairingId });
138
- if (verdict === false) {
196
+ this.session = candidate;
197
+ this.candidates.set(candidate.topic, state);
198
+ const verdict = this.sessionListener?.({ account: candidate.account, chainId: candidate.chainId, pairingId, prove, live });
199
+ let adopted;
200
+ if (verdict instanceof Promise) {
139
201
  this.session = previous;
202
+ adopted = await verdict.finally(() => this.candidates.delete(candidate.topic)).then((v) => v !== false);
203
+ if (adopted) this.session = candidate;
204
+ } else {
205
+ this.candidates.delete(candidate.topic);
206
+ adopted = verdict !== false;
207
+ if (!adopted) this.session = previous;
208
+ }
209
+ if (!adopted) {
140
210
  void this.client.disconnect({ topic: session.topic, reason: { code: 6e3, message: "session refused by the bridge" } }).catch(() => void 0);
141
211
  }
142
- }).catch((e) => console.error(`[dh-mcp] WalletConnect pairing failed: ${e.message}`));
212
+ }).catch((e) => {
213
+ console.error(`[dh-mcp] WalletConnect pairing failed: ${e.message}`);
214
+ if (candidateTopic !== null && this.session?.topic !== candidateTopic) {
215
+ void this.client.disconnect({ topic: candidateTopic, reason: { code: 6e3, message: "session not adopted" } }).catch(() => void 0);
216
+ }
217
+ });
143
218
  return { uri, pairingId };
144
219
  }
145
220
  /** Route one wallet request over the active session. Throws on user rejection. */
146
221
  async request(method, params) {
222
+ this.assertRelayHealthy();
147
223
  if (!this.session) throw new Error("no active WalletConnect session");
148
224
  return this.client.request({
149
225
  topic: this.session.topic,
@@ -181,7 +257,7 @@ function decodeSignable(data) {
181
257
  function eqAddr(a, b) {
182
258
  if (!a || !b) return false;
183
259
  try {
184
- return import_ethers4.ethers.getAddress(a) === import_ethers4.ethers.getAddress(b);
260
+ return import_ethers5.ethers.getAddress(a) === import_ethers5.ethers.getAddress(b);
185
261
  } catch {
186
262
  return false;
187
263
  }
@@ -228,7 +304,7 @@ function decode(data) {
228
304
  }
229
305
  function normalizePositionId(id) {
230
306
  const hex = id.startsWith("0x") ? id : `0x${id}`;
231
- return import_ethers4.ethers.zeroPadValue(hex, 32).toLowerCase();
307
+ return import_ethers5.ethers.zeroPadValue(hex, 32).toLowerCase();
232
308
  }
233
309
  function validateUnsignedTx(unsignedTx, expected, vctx) {
234
310
  const txChainId = readChainId(unsignedTx);
@@ -386,11 +462,11 @@ function describeUnsignedTx(unsignedTx) {
386
462
  }
387
463
  return { to, fn, chainId };
388
464
  }
389
- var import_ethers4, SIGNABLE_FUNCTIONS, IFACE, TxValidationError;
465
+ var import_ethers5, SIGNABLE_FUNCTIONS, IFACE, TxValidationError;
390
466
  var init_tx_validator = __esm({
391
467
  "src/boundary/upstream/shared/tx-validator.ts"() {
392
468
  "use strict";
393
- import_ethers4 = require("ethers");
469
+ import_ethers5 = require("ethers");
394
470
  SIGNABLE_FUNCTIONS = [
395
471
  "function mintUCD(bytes32 positionId, uint256 mintAmount, uint256 mintFee, uint256 newDebt, uint256 newCollateral, uint256 btcPrice, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, bytes32 contractHash, uint256 quantumTimestamp, bytes calldata mintValidatorSignature) external returns (bool)",
396
472
  "function makePayment(bytes32 positionId, uint256 paymentAmount, uint256 quantumTimestamp, uint256 btcPrice, bytes calldata paymentValidatorSignature) external returns (bool)",
@@ -408,7 +484,7 @@ var init_tx_validator = __esm({
408
484
  "function createPosition(bytes32 pkpId, bytes validatorSignature, string mainnetVaultAddress, string regtestVaultAddress, uint256 selectedTermMonths, uint256 validatorVersion, bytes pkpPublicKey) external returns (bytes32)",
409
485
  "function addAddress(string btcAddress) external"
410
486
  ];
411
- IFACE = new import_ethers4.ethers.Interface(SIGNABLE_FUNCTIONS);
487
+ IFACE = new import_ethers5.ethers.Interface(SIGNABLE_FUNCTIONS);
412
488
  TxValidationError = class extends Error {
413
489
  constructor(msg) {
414
490
  super(`Refusing to sign server-returned transaction: ${msg}`);
@@ -15592,7 +15668,7 @@ ${errorReport}`);
15592
15668
  }
15593
15669
  init_debug_logger();
15594
15670
  init_session_signature_cache();
15595
- var import_ethers56 = require("ethers");
15671
+ var import_ethers57 = require("ethers");
15596
15672
  var EXPIRED_LOAN_MIN_LIQUIDATION_THRESHOLD_BPS = 11e3;
15597
15673
  var GRACE_PERIOD_DAYS = 30;
15598
15674
  var SATOSHIS_PER_BITCOIN = 100000000n;
@@ -18588,12 +18664,12 @@ ${auth.clientId}`;
18588
18664
  }
18589
18665
  async function executeVaultSnapshot(params) {
18590
18666
  global.ethers = {
18591
- ...import_ethers56.ethers,
18667
+ ...import_ethers57.ethers,
18592
18668
  providers: {
18593
- StaticJsonRpcProvider: import_ethers56.ethers.JsonRpcProvider
18669
+ StaticJsonRpcProvider: import_ethers57.ethers.JsonRpcProvider
18594
18670
  },
18595
- Contract: import_ethers56.ethers.Contract,
18596
- utils: import_ethers56.ethers
18671
+ Contract: import_ethers57.ethers.Contract,
18672
+ utils: import_ethers57.ethers
18597
18673
  // v6 moved utils to top level
18598
18674
  };
18599
18675
  global.Lit = {
@@ -27526,7 +27602,7 @@ var require_lit_ops_module = __commonJS({
27526
27602
  litActionParams.rpcUrl = request.rpcUrl;
27527
27603
  litActionParams.customRpcUrl = request.rpcUrl;
27528
27604
  if (this.config.debug) {
27529
- console.log(" RPC URL override:", request.rpcUrl);
27605
+ console.log(" RPC URL override host:", new URL(request.rpcUrl).host);
27530
27606
  }
27531
27607
  }
27532
27608
  if (this.config.network === "chipotle") {
@@ -27702,7 +27778,7 @@ var require_lit_ops_module = __commonJS({
27702
27778
  litActionParams.rpcUrl = request.rpcUrl;
27703
27779
  litActionParams.customRpcUrl = request.rpcUrl;
27704
27780
  if (this.config.debug) {
27705
- console.log(" RPC URL override:", request.rpcUrl);
27781
+ console.log(" RPC URL override host:", new URL(request.rpcUrl).host);
27706
27782
  }
27707
27783
  }
27708
27784
  if (this.config.network === "chipotle") {
@@ -28040,7 +28116,7 @@ var require_lit_ops_module = __commonJS({
28040
28116
  litActionParams.rpcUrl = request.rpcUrl;
28041
28117
  litActionParams.customRpcUrl = request.rpcUrl;
28042
28118
  if (this.config.debug) {
28043
- console.log(" RPC URL override:", request.rpcUrl);
28119
+ console.log(" RPC URL override host:", new URL(request.rpcUrl).host);
28044
28120
  }
28045
28121
  }
28046
28122
  if (this.config.network === "chipotle") {
@@ -28256,7 +28332,7 @@ var require_lit_ops_module = __commonJS({
28256
28332
  litActionParams.rpcUrl = request.rpcUrl;
28257
28333
  litActionParams.customRpcUrl = request.rpcUrl;
28258
28334
  if (this.config.debug) {
28259
- console.log(" EVM RPC URL override:", request.rpcUrl);
28335
+ console.log(" EVM RPC URL override host:", new URL(request.rpcUrl).host);
28260
28336
  }
28261
28337
  }
28262
28338
  if (this.config.debug) {
@@ -28386,7 +28462,12 @@ var require_lit_ops_module = __commonJS({
28386
28462
  if (!moduleAddress || !provisionerPk || !baseRpc) {
28387
28463
  throw new Error("LIT_VAULT_PROVISION_MODE=module requires LIT_ONCHAIN_VAULT_MODULE_ADDRESS, LIT_ONCHAIN_PROVISIONER_PRIVATE_KEY, BASE_RPC_URL");
28388
28464
  }
28389
- const provider = new ethers_1.JsonRpcProvider(baseRpc);
28465
+ const baseRequest = new ethers_1.FetchRequest(baseRpc);
28466
+ const drpcKey = process.env.DRPC_API_KEY;
28467
+ if (drpcKey && /(^|\.)drpc\.(org|live)$/.test(new URL(baseRpc).hostname)) {
28468
+ baseRequest.setHeader("Drpc-Key", drpcKey);
28469
+ }
28470
+ const provider = new ethers_1.JsonRpcProvider(baseRequest);
28390
28471
  const signer = new ethers_1.Wallet(provisionerPk, provider);
28391
28472
  const chainId = Number(process.env.BASE_CHAIN_ID || "8453");
28392
28473
  const issuedAt = Math.floor(Date.now() / 1e3);
@@ -28437,7 +28518,7 @@ var require_lit_ops_module = __commonJS({
28437
28518
  async chipotleCreateWalletAndAddToGroup(accountApiKey) {
28438
28519
  const baseUrl = _LitOps.LIT_CORE_API_BASE;
28439
28520
  const createResp = await fetch(`${baseUrl}/create_wallet`, {
28440
- method: "GET",
28521
+ method: "POST",
28441
28522
  headers: {
28442
28523
  "X-Api-Key": accountApiKey
28443
28524
  }
@@ -41153,11 +41234,11 @@ function htmlPageSecurityHeaders(extra) {
41153
41234
  }
41154
41235
 
41155
41236
  // src/version.ts
41156
- var SERVER_VERSION = "0.5.21";
41237
+ var SERVER_VERSION = "0.5.23";
41157
41238
 
41158
41239
  // src/connector/siwe-oauth.ts
41159
41240
  var import_node_crypto3 = require("crypto");
41160
- var import_ethers = require("ethers");
41241
+ var import_ethers2 = require("ethers");
41161
41242
  var import_errors = require("@modelcontextprotocol/sdk/server/auth/errors.js");
41162
41243
 
41163
41244
  // src/util/house-style.ts
@@ -41551,8 +41632,8 @@ var SiweOAuthProvider = class {
41551
41632
  siweMessage(flowId, address) {
41552
41633
  const flow = this.liveFlow(flowId);
41553
41634
  if (!flow) return { ok: false, status: 404, reason: "unknown or expired sign-in flow \u2014 restart the connection from claude.ai" };
41554
- if (!import_ethers.ethers.isAddress(address)) return { ok: false, status: 400, reason: "not a valid wallet address" };
41555
- const checksummed = import_ethers.ethers.getAddress(address);
41635
+ if (!import_ethers2.ethers.isAddress(address)) return { ok: false, status: 400, reason: "not a valid wallet address" };
41636
+ const checksummed = import_ethers2.ethers.getAddress(address);
41556
41637
  flow.siwe = { address: checksummed, message: this.mintSiweMessage(checksummed, flow) };
41557
41638
  return { ok: true, message: flow.siwe.message };
41558
41639
  }
@@ -41674,17 +41755,17 @@ Issued At: ${new Date(this.clock()).toISOString()}`;
41674
41755
  true
41675
41756
  );
41676
41757
  };
41677
- if (!import_ethers.ethers.isAddress(account)) {
41758
+ if (!import_ethers2.ethers.isAddress(account)) {
41678
41759
  fail(400, "the connected wallet reported an invalid address");
41679
41760
  return;
41680
41761
  }
41681
- const checksummed = import_ethers.ethers.getAddress(account);
41762
+ const checksummed = import_ethers2.ethers.getAddress(account);
41682
41763
  const message2 = this.mintSiweMessage(checksummed, flow);
41683
41764
  flow.siwe = { address: checksummed, message: message2 };
41684
41765
  flow.wc.state = "awaiting-signature";
41685
41766
  let signature;
41686
41767
  try {
41687
- signature = await transport.request("personal_sign", [import_ethers.ethers.hexlify(import_ethers.ethers.toUtf8Bytes(message2)), checksummed]);
41768
+ signature = await transport.request("personal_sign", [import_ethers2.ethers.hexlify(import_ethers2.ethers.toUtf8Bytes(message2)), checksummed]);
41688
41769
  } catch (e) {
41689
41770
  const msg = e instanceof Error ? e.message : String(e);
41690
41771
  const declined = e.code === 4001 || /reject|declin|denied|cancel/i.test(msg);
@@ -41693,7 +41774,7 @@ Issued At: ${new Date(this.clock()).toISOString()}`;
41693
41774
  }
41694
41775
  let recovered;
41695
41776
  try {
41696
- recovered = import_ethers.ethers.verifyMessage(message2, signature);
41777
+ recovered = import_ethers2.ethers.verifyMessage(message2, signature);
41697
41778
  } catch {
41698
41779
  fail(400, "the signature is not a valid Ethereum signature");
41699
41780
  return;
@@ -41767,7 +41848,7 @@ Issued At: ${new Date(this.clock()).toISOString()}`;
41767
41848
  if (!flow.siwe) return { ok: false, status: 400, reason: "no wallet address was reported for this flow yet" };
41768
41849
  let recovered;
41769
41850
  try {
41770
- recovered = import_ethers.ethers.verifyMessage(flow.siwe.message, signature);
41851
+ recovered = import_ethers2.ethers.verifyMessage(flow.siwe.message, signature);
41771
41852
  } catch {
41772
41853
  return { ok: false, status: 400, reason: "the signature is not a valid Ethereum signature" };
41773
41854
  }
@@ -41936,7 +42017,7 @@ Issued At: ${new Date(this.clock()).toISOString()}`;
41936
42017
  };
41937
42018
 
41938
42019
  // src/connector/wc-min-version.ts
41939
- var WC_MIN_SAFE_VERSION = "0.5.21";
42020
+ var WC_MIN_SAFE_VERSION = "0.5.22";
41940
42021
  function parseVersion(label, v) {
41941
42022
  const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/.exec(v);
41942
42023
  if (!m) throw new Error(`${label} '${v}' is not a MAJOR.MINOR.PATCH[-prerelease] version`);
@@ -41998,6 +42079,11 @@ function resolveWcProjectId(raw, problems) {
41998
42079
  }
41999
42080
  var RPC_PROXY_ORIGIN = "https://api.gvnr.xyz";
42000
42081
  var rpcProxy = (chainId) => `${RPC_PROXY_ORIGIN}/v1/proxy/rpc/${chainId}`;
42082
+ var publicRpcUrl = rpcProxy;
42083
+ var DRPC_ENDPOINT = {
42084
+ mainnet: "https://lb.drpc.live/ethereum",
42085
+ sepolia: "https://lb.drpc.live/sepolia"
42086
+ };
42001
42087
  var NETWORK_DEFAULTS = {
42002
42088
  sepolia: {
42003
42089
  rpcUrl: rpcProxy(11155111),
@@ -42130,7 +42216,11 @@ function resolveRealConfig(env) {
42130
42216
  problems.push(`DH_NETWORK='${network}' is not supported. Allowed: ${Object.keys(NETWORKS).join(" | ")}.`);
42131
42217
  }
42132
42218
  const defaults2 = NETWORK_DEFAULTS[network] ?? NETWORK_DEFAULTS.mainnet;
42133
- const rpcUrl = env["ETH_RPC_URL"] || defaults2.rpcUrl;
42219
+ const rpcDrpcKey = env["DRPC_API_KEY"] || void 0;
42220
+ if (rpcDrpcKey !== void 0 && env["ETH_RPC_URL"]) {
42221
+ problems.push("DRPC_API_KEY and ETH_RPC_URL are both set \u2014 set one: DRPC_API_KEY (dRPC, key sent as a header) or ETH_RPC_URL (your own endpoint).");
42222
+ }
42223
+ const rpcUrl = rpcDrpcKey !== void 0 ? DRPC_ENDPOINT[network] ?? DRPC_ENDPOINT.mainnet : env["ETH_RPC_URL"] || defaults2.rpcUrl;
42134
42224
  const serviceEndpoint = env["DH_SERVICE_ENDPOINT"] || defaults2.serviceEndpoint;
42135
42225
  if (!/^https:\/\//.test(serviceEndpoint) && !/^http:\/\/(localhost|127\.0\.0\.1)/.test(serviceEndpoint)) {
42136
42226
  problems.push(`DH_SERVICE_ENDPOINT='${serviceEndpoint}' must be https:// (or http:// on loopback).`);
@@ -42179,6 +42269,7 @@ function resolveRealConfig(env) {
42179
42269
  network,
42180
42270
  chainId: NETWORKS[network],
42181
42271
  rpcUrl,
42272
+ ...rpcDrpcKey !== void 0 ? { rpcDrpcKey } : {},
42182
42273
  serviceEndpoint,
42183
42274
  litNetwork,
42184
42275
  ...keystorePath && keystorePassword ? { keystorePath, keystorePassword } : {},
@@ -42194,14 +42285,14 @@ function resolveRealConfig(env) {
42194
42285
 
42195
42286
  // src/boot.ts
42196
42287
  var fs6 = __toESM(require("fs"));
42197
- var import_ethers53 = require("ethers");
42288
+ var import_ethers54 = require("ethers");
42198
42289
 
42199
42290
  // src/boundary/index.ts
42200
42291
  var import_node_crypto10 = require("crypto");
42201
42292
  var fs5 = __toESM(require("fs"));
42202
42293
  var os2 = __toESM(require("os"));
42203
42294
  var path4 = __toESM(require("path"));
42204
- var import_ethers52 = require("ethers");
42295
+ var import_ethers53 = require("ethers");
42205
42296
 
42206
42297
  // src/boundary/envelope.ts
42207
42298
  function okEnvelope(data, source, warnings = []) {
@@ -42260,6 +42351,16 @@ function checkBtcAddress(addr, expected) {
42260
42351
  }
42261
42352
  }
42262
42353
 
42354
+ // src/util/redact-url.ts
42355
+ var URL_PATTERN = /\b((?:https?|wss?):\/\/)([^\s/?#"'`<>\\]+)([^\s"'`<>\\]*)/gi;
42356
+ function redactUrls(text) {
42357
+ return text.replace(URL_PATTERN, (_whole, scheme, authority, rest) => {
42358
+ const host = authority.includes("@") ? authority.slice(authority.lastIndexOf("@") + 1) : authority;
42359
+ const cut = rest.length > 0 || host !== authority;
42360
+ return `${scheme}${host}${cut ? "/\u2026" : ""}`;
42361
+ });
42362
+ }
42363
+
42263
42364
  // src/boundary/math.ts
42264
42365
  function collateralValueUcdWei(sats, priceUsd8) {
42265
42366
  return sats * priceUsd8 * 100n;
@@ -42292,10 +42393,11 @@ function stablecoinKindFor(network, stablecoinAddress) {
42292
42393
  }
42293
42394
  function failureToError(f) {
42294
42395
  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";
42295
- const message2 = f.kind === "malformed" ? `${f.message} (upstream response failed integrity checks)` : f.message;
42396
+ const text = redactUrls(f.message);
42397
+ const message2 = f.kind === "malformed" ? `${text} (upstream response failed integrity checks)` : text;
42296
42398
  return boundaryError(code, message2, {
42297
42399
  source: f.source,
42298
- ...f.raw ? { details: { upstreamMessage: f.raw } } : {}
42400
+ ...f.raw ? { details: { upstreamMessage: redactUrls(f.raw) } } : {}
42299
42401
  });
42300
42402
  }
42301
42403
  var BoundaryCore = class {
@@ -43265,10 +43367,10 @@ var DEFAULT_SEED = {
43265
43367
 
43266
43368
  // src/boundary/upstream/mock/world.ts
43267
43369
  var import_node_crypto4 = require("crypto");
43268
- var import_ethers3 = require("ethers");
43370
+ var import_ethers4 = require("ethers");
43269
43371
 
43270
43372
  // src/signer/safe.ts
43271
- var import_ethers2 = require("ethers");
43373
+ var import_ethers3 = require("ethers");
43272
43374
  var SAFE_TX_TYPES = {
43273
43375
  SafeTx: [
43274
43376
  { name: "to", type: "address" },
@@ -43289,18 +43391,18 @@ var SAFE_MESSAGE_TYPES = {
43289
43391
  var EXEC_TRANSACTION_ABI = [
43290
43392
  "function execTransaction(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,bytes signatures) returns (bool)"
43291
43393
  ];
43292
- var execIface = new import_ethers2.ethers.Interface(EXEC_TRANSACTION_ABI);
43394
+ var execIface = new import_ethers3.ethers.Interface(EXEC_TRANSACTION_ABI);
43293
43395
  function buildSafeTx(p) {
43294
43396
  return {
43295
- to: import_ethers2.ethers.getAddress(p.to),
43397
+ to: import_ethers3.ethers.getAddress(p.to),
43296
43398
  value: 0n,
43297
43399
  data: p.data,
43298
43400
  operation: 0,
43299
43401
  safeTxGas: 0n,
43300
43402
  baseGas: 0n,
43301
43403
  gasPrice: 0n,
43302
- gasToken: import_ethers2.ethers.ZeroAddress,
43303
- refundReceiver: import_ethers2.ethers.ZeroAddress,
43404
+ gasToken: import_ethers3.ethers.ZeroAddress,
43405
+ refundReceiver: import_ethers3.ethers.ZeroAddress,
43304
43406
  nonce: p.nonce
43305
43407
  };
43306
43408
  }
@@ -43310,11 +43412,11 @@ function assertPinnedSafeTx(tx2) {
43310
43412
  if (tx2.safeTxGas !== 0n) throw new Error(`SafeTx refused: non-zero safeTxGas ${tx2.safeTxGas}`);
43311
43413
  if (tx2.baseGas !== 0n) throw new Error(`SafeTx refused: non-zero baseGas ${tx2.baseGas}`);
43312
43414
  if (tx2.gasPrice !== 0n) throw new Error(`SafeTx refused: non-zero gasPrice ${tx2.gasPrice} \u2014 refund surface is closed`);
43313
- if (tx2.gasToken !== import_ethers2.ethers.ZeroAddress) throw new Error(`SafeTx refused: non-zero gasToken ${tx2.gasToken}`);
43314
- if (tx2.refundReceiver !== import_ethers2.ethers.ZeroAddress) throw new Error(`SafeTx refused: non-zero refundReceiver ${tx2.refundReceiver}`);
43415
+ if (tx2.gasToken !== import_ethers3.ethers.ZeroAddress) throw new Error(`SafeTx refused: non-zero gasToken ${tx2.gasToken}`);
43416
+ if (tx2.refundReceiver !== import_ethers3.ethers.ZeroAddress) throw new Error(`SafeTx refused: non-zero refundReceiver ${tx2.refundReceiver}`);
43315
43417
  }
43316
43418
  function domainOf(safe) {
43317
- return { chainId: safe.chainId, verifyingContract: import_ethers2.ethers.getAddress(safe.address) };
43419
+ return { chainId: safe.chainId, verifyingContract: import_ethers3.ethers.getAddress(safe.address) };
43318
43420
  }
43319
43421
  function safeTxTypedData(safe, tx2) {
43320
43422
  assertPinnedSafeTx(tx2);
@@ -43337,7 +43439,7 @@ function safeTxTypedData(safe, tx2) {
43337
43439
  }
43338
43440
  function safeTxHash(safe, tx2) {
43339
43441
  const p = safeTxTypedData(safe, tx2);
43340
- return import_ethers2.ethers.TypedDataEncoder.hash(p.domain, p.types, p.message);
43442
+ return import_ethers3.ethers.TypedDataEncoder.hash(p.domain, p.types, p.message);
43341
43443
  }
43342
43444
  function safeMessageTypedData(safe, innerHash) {
43343
43445
  if (!/^0x[0-9a-fA-F]{64}$/.test(innerHash)) {
@@ -43347,20 +43449,20 @@ function safeMessageTypedData(safe, innerHash) {
43347
43449
  }
43348
43450
  function safeMessageHash(safe, innerHash) {
43349
43451
  const p = safeMessageTypedData(safe, innerHash);
43350
- return import_ethers2.ethers.TypedDataEncoder.hash(p.domain, p.types, p.message);
43452
+ return import_ethers3.ethers.TypedDataEncoder.hash(p.domain, p.types, p.message);
43351
43453
  }
43352
43454
  function aggregateSignatures(p) {
43353
43455
  const ownerSet = new Set(p.owners.map((o) => o.toLowerCase()));
43354
43456
  const entries = [];
43355
43457
  for (const signature of p.signatures) {
43356
- if (import_ethers2.ethers.dataLength(signature) !== 65) {
43357
- throw new Error(`signature aggregation refused: expected 65-byte ECDSA signature, got ${import_ethers2.ethers.dataLength(signature)} bytes`);
43458
+ if (import_ethers3.ethers.dataLength(signature) !== 65) {
43459
+ throw new Error(`signature aggregation refused: expected 65-byte ECDSA signature, got ${import_ethers3.ethers.dataLength(signature)} bytes`);
43358
43460
  }
43359
- const v = import_ethers2.ethers.dataSlice(signature, 64, 65);
43461
+ const v = import_ethers3.ethers.dataSlice(signature, 64, 65);
43360
43462
  if (v !== "0x1b" && v !== "0x1c") {
43361
43463
  throw new Error(`signature aggregation refused: v=${v} is not a typed-data signature (v must be 27 or 28 \u2014 eth_sign and approved-hash encodings are forbidden)`);
43362
43464
  }
43363
- const signer = import_ethers2.ethers.recoverAddress(p.hash, signature);
43465
+ const signer = import_ethers3.ethers.recoverAddress(p.hash, signature);
43364
43466
  if (!ownerSet.has(signer.toLowerCase())) {
43365
43467
  throw new Error(`signature aggregation refused: ${signer} is not an owner of this Safe`);
43366
43468
  }
@@ -43370,11 +43472,11 @@ function aggregateSignatures(p) {
43370
43472
  entries.push({ signer, signature });
43371
43473
  }
43372
43474
  entries.sort((a, b) => BigInt(a.signer) < BigInt(b.signer) ? -1 : 1);
43373
- return { signers: entries.map((e) => e.signer), blob: import_ethers2.ethers.concat(entries.map((e) => e.signature)) };
43475
+ return { signers: entries.map((e) => e.signer), blob: import_ethers3.ethers.concat(entries.map((e) => e.signature)) };
43374
43476
  }
43375
43477
  function verifyThreshold(p) {
43376
43478
  if (p.threshold < 1) return { ok: false, reason: `threshold ${p.threshold} is not positive` };
43377
- const len = import_ethers2.ethers.dataLength(p.blob);
43479
+ const len = import_ethers3.ethers.dataLength(p.blob);
43378
43480
  if (len < p.threshold * 65) {
43379
43481
  return { ok: false, reason: `signatures blob carries ${Math.floor(len / 65)} signature(s) \u2014 threshold is ${p.threshold}` };
43380
43482
  }
@@ -43382,10 +43484,10 @@ function verifyThreshold(p) {
43382
43484
  const signers = [];
43383
43485
  let last = 0n;
43384
43486
  for (let i = 0; i < p.threshold; i++) {
43385
- const sig2 = import_ethers2.ethers.dataSlice(p.blob, i * 65, (i + 1) * 65);
43487
+ const sig2 = import_ethers3.ethers.dataSlice(p.blob, i * 65, (i + 1) * 65);
43386
43488
  let signer;
43387
43489
  try {
43388
- signer = import_ethers2.ethers.recoverAddress(p.hash, sig2);
43490
+ signer = import_ethers3.ethers.recoverAddress(p.hash, sig2);
43389
43491
  } catch (e) {
43390
43492
  return { ok: false, reason: `signature ${i + 1} does not recover: ${e.message}` };
43391
43493
  }
@@ -43429,8 +43531,8 @@ function safeTxFromJson(j) {
43429
43531
  }
43430
43532
 
43431
43533
  // src/boundary/upstream/mock/world.ts
43432
- var ethersIsAddress = (v) => import_ethers3.ethers.isAddress(v);
43433
- var toChecksum = (v) => import_ethers3.ethers.getAddress(v);
43534
+ var ethersIsAddress = (v) => import_ethers4.ethers.isAddress(v);
43535
+ var toChecksum = (v) => import_ethers4.ethers.getAddress(v);
43434
43536
  function termSeconds(months) {
43435
43537
  return months === 12 ? 365 * 24 * 3600 : months * SECONDS_PER_TERM_MONTH;
43436
43538
  }
@@ -44608,9 +44710,9 @@ var MockControl = class {
44608
44710
  };
44609
44711
 
44610
44712
  // src/boundary/upstream/mock/tx-builder.ts
44611
- var import_ethers5 = require("ethers");
44713
+ var import_ethers6 = require("ethers");
44612
44714
  init_tx_validator();
44613
- var ZERO32 = import_ethers5.ethers.ZeroHash;
44715
+ var ZERO32 = import_ethers6.ethers.ZeroHash;
44614
44716
  var EMPTY_SIG = "0x" + "00".repeat(65);
44615
44717
  function tx(ctx, data) {
44616
44718
  return { to: ctx.positionManager, data, value: "0x0", chainId: ctx.chainId };
@@ -44671,9 +44773,9 @@ function psmApprovalSteps(allowanceBefore, amountIn) {
44671
44773
  }
44672
44774
 
44673
44775
  // src/boundary/upstream/mock/sink-contracts.ts
44674
- var import_ethers6 = require("ethers");
44776
+ var import_ethers7 = require("ethers");
44675
44777
  function sinkAddress(label) {
44676
- return import_ethers6.ethers.getAddress("0x" + import_ethers6.ethers.keccak256(import_ethers6.ethers.toUtf8Bytes(`dh-mock-sink:${label}`)).slice(-40));
44778
+ return import_ethers7.ethers.getAddress("0x" + import_ethers7.ethers.keccak256(import_ethers7.ethers.toUtf8Bytes(`dh-mock-sink:${label}`)).slice(-40));
44677
44779
  }
44678
44780
  var SINK_CONTRACTS = {
44679
44781
  PositionManager: sinkAddress("PositionManager"),
@@ -44687,7 +44789,7 @@ var SINK_CONTRACTS = {
44687
44789
 
44688
44790
  // src/boundary/signer-manager.ts
44689
44791
  var fs2 = __toESM(require("fs"));
44690
- var import_ethers7 = require("ethers");
44792
+ var import_ethers8 = require("ethers");
44691
44793
  function memorySignerPersistence() {
44692
44794
  let state = null;
44693
44795
  return {
@@ -44770,7 +44872,7 @@ var SignerManager = class {
44770
44872
  return { ok: false, reason: `mode '${mode}' needs the Safe's address \u2014 say for example: use ${mode} 0xYourSafeAddress` };
44771
44873
  }
44772
44874
  const truncated = `${String(addr).slice(0, 12)}\u2026`;
44773
- if (!import_ethers7.ethers.isAddress(addr)) return { ok: false, reason: `'${truncated}' is not a valid Safe address` };
44875
+ if (!import_ethers8.ethers.isAddress(addr)) return { ok: false, reason: `'${truncated}' is not a valid Safe address` };
44774
44876
  if (!this.deps.safeInfo) return { ok: false, reason: "this boundary construction has no Safe discovery \u2014 mode 'safe' is unavailable here" };
44775
44877
  const info = this.deps.safeInfo(addr);
44776
44878
  if (!info) {
@@ -44783,7 +44885,7 @@ var SignerManager = class {
44783
44885
  const role = mode === "safe-module" ? "the delegated AGENT key" : "owner-signer and executor";
44784
44886
  return { ok: false, reason: `mode '${mode}' needs the keystore as ${role}: ${ready.reason}` };
44785
44887
  }
44786
- const checksummed = import_ethers7.ethers.getAddress(addr);
44888
+ const checksummed = import_ethers8.ethers.getAddress(addr);
44787
44889
  if (this.state.borrower && this.state.borrower.toLowerCase() !== checksummed.toLowerCase()) {
44788
44890
  return {
44789
44891
  ok: false,
@@ -44876,8 +44978,8 @@ var KeystoreProvider = class {
44876
44978
  /** Runtime provisioning (bridge unlock page): decrypt pasted/on-disk material. */
44877
44979
  async unlock(keystoreJson, password) {
44878
44980
  try {
44879
- const decrypted = await import_ethers7.ethers.Wallet.fromEncryptedJson(keystoreJson, password);
44880
- if (!(decrypted instanceof import_ethers7.ethers.Wallet)) return { ok: false, reason: "the keystore did not decrypt to an EOA wallet" };
44981
+ const decrypted = await import_ethers8.ethers.Wallet.fromEncryptedJson(keystoreJson, password);
44982
+ if (!(decrypted instanceof import_ethers8.ethers.Wallet)) return { ok: false, reason: "the keystore did not decrypt to an EOA wallet" };
44881
44983
  this.wallet = decrypted;
44882
44984
  return { ok: true, address: decrypted.address };
44883
44985
  } catch {
@@ -44894,10 +44996,10 @@ var KeystoreProvider = class {
44894
44996
  }
44895
44997
  /** Generate a FRESH keystore encrypted with the page-provided password, save it, unlock it. */
44896
44998
  async generateAndSave(password, savePath) {
44897
- const wallet = import_ethers7.ethers.Wallet.createRandom();
44898
- const json = await new import_ethers7.ethers.Wallet(wallet.privateKey).encrypt(password);
44999
+ const wallet = import_ethers8.ethers.Wallet.createRandom();
45000
+ const json = await new import_ethers8.ethers.Wallet(wallet.privateKey).encrypt(password);
44899
45001
  fs2.writeFileSync(savePath, json);
44900
- this.wallet = new import_ethers7.ethers.Wallet(wallet.privateKey);
45002
+ this.wallet = new import_ethers8.ethers.Wallet(wallet.privateKey);
44901
45003
  return { ok: true, address: wallet.address, savedTo: savePath };
44902
45004
  }
44903
45005
  async ensureReady() {
@@ -45820,10 +45922,10 @@ var MockUpstreamPlugin = class {
45820
45922
  // src/boundary/upstream/mock/external-ceremony.ts
45821
45923
  var import_node_crypto6 = require("crypto");
45822
45924
  var import_node_child_process = require("child_process");
45823
- var import_ethers10 = require("ethers");
45925
+ var import_ethers11 = require("ethers");
45824
45926
 
45825
45927
  // src/boundary/upstream/shared/external-bridge/card.ts
45826
- var import_ethers8 = require("ethers");
45928
+ var import_ethers9 = require("ethers");
45827
45929
  init_tx_validator();
45828
45930
 
45829
45931
  // src/boundary/upstream/shared/external-bridge/card-escape.ts
@@ -45990,12 +46092,12 @@ function operationTypedData(p) {
45990
46092
  detail: p.detail,
45991
46093
  borrower: p.borrower,
45992
46094
  issuedAt: p.issuedAtSec,
45993
- nonce: "0x" + Buffer.from(import_ethers8.ethers.randomBytes(32)).toString("hex")
46095
+ nonce: "0x" + Buffer.from(import_ethers9.ethers.randomBytes(32)).toString("hex")
45994
46096
  }
45995
46097
  };
45996
46098
  }
45997
46099
  function recoverOperationSigner(payload, signature) {
45998
- return import_ethers8.ethers.verifyTypedData(
46100
+ return import_ethers9.ethers.verifyTypedData(
45999
46101
  payload.domain,
46000
46102
  payload.types,
46001
46103
  payload.message,
@@ -46007,7 +46109,7 @@ function recoverOperationSigner(payload, signature) {
46007
46109
  init_tx_validator();
46008
46110
 
46009
46111
  // src/signer/keystore-signer.ts
46010
- var import_ethers9 = require("ethers");
46112
+ var import_ethers10 = require("ethers");
46011
46113
  var LOGIN_DOMAIN = (chainId) => ({ name: "Diamond Hands", version: "1", chainId });
46012
46114
  var LOGIN_TYPES = {
46013
46115
  DiamondHands: [
@@ -46032,14 +46134,14 @@ function buildLoginTypedData(chainId, address, audience) {
46032
46134
  message: {
46033
46135
  address,
46034
46136
  issuedAt: Math.floor(Date.now() / 1e3),
46035
- nonce: "0x" + Buffer.from(import_ethers9.ethers.randomBytes(32)).toString("hex"),
46137
+ nonce: "0x" + Buffer.from(import_ethers10.ethers.randomBytes(32)).toString("hex"),
46036
46138
  ...audience ? { audience } : {}
46037
46139
  }
46038
46140
  };
46039
46141
  }
46040
46142
  function recoverLoginSigner(payload) {
46041
46143
  const types = payload.message.audience ? LOGIN_TYPES_WITH_AUDIENCE : LOGIN_TYPES;
46042
- return import_ethers9.ethers.verifyTypedData(LOGIN_DOMAIN(payload.chainId), types, payload.message, payload.signature);
46144
+ return import_ethers10.ethers.verifyTypedData(LOGIN_DOMAIN(payload.chainId), types, payload.message, payload.signature);
46043
46145
  }
46044
46146
 
46045
46147
  // src/boundary/upstream/mock/external-ceremony.ts
@@ -46176,7 +46278,7 @@ var ExternalCeremony = class {
46176
46278
  * back, else fetched from the sink chain by hash (the MetaMask path). */
46177
46279
  async readSignedTx(outcome) {
46178
46280
  if (outcome.rawSignedTx) {
46179
- const parsed = import_ethers10.ethers.Transaction.from(outcome.rawSignedTx);
46281
+ const parsed = import_ethers11.ethers.Transaction.from(outcome.rawSignedTx);
46180
46282
  if (!parsed.from || !parsed.to || !parsed.hash) {
46181
46283
  return this.refuse("rejected", "the returned raw transaction is unsigned or malformed");
46182
46284
  }
@@ -46192,7 +46294,7 @@ var ExternalCeremony = class {
46192
46294
  "the wallet broadcast a transaction but DH_MOCK_SINK_RPC is not set \u2014 the bridge cannot verify what was signed"
46193
46295
  );
46194
46296
  }
46195
- const provider = new import_ethers10.ethers.JsonRpcProvider(this.deps.sinkRpcUrl, this.deps.chainId, { staticNetwork: true });
46297
+ const provider = new import_ethers11.ethers.JsonRpcProvider(this.deps.sinkRpcUrl, this.deps.chainId, { staticNetwork: true });
46196
46298
  let tx2 = null;
46197
46299
  for (let i = 0; i < TX_FETCH_ATTEMPTS && tx2 === null; i++) {
46198
46300
  tx2 = await provider.getTransaction(hash);
@@ -46238,7 +46340,7 @@ function openInBrowser(url2) {
46238
46340
  }
46239
46341
 
46240
46342
  // src/boundary/upstream/mock/keystore-ceremony.ts
46241
- var import_ethers11 = require("ethers");
46343
+ var import_ethers12 = require("ethers");
46242
46344
  init_tx_validator();
46243
46345
  var SOURCE2 = "keystore-signer";
46244
46346
  var KeystoreCeremony = class {
@@ -46270,7 +46372,7 @@ var KeystoreCeremony = class {
46270
46372
  data: p.tx.data,
46271
46373
  value: BigInt(p.tx.value)
46272
46374
  });
46273
- const parsed = import_ethers11.ethers.Transaction.from(raw);
46375
+ const parsed = import_ethers12.ethers.Transaction.from(raw);
46274
46376
  if (!parsed.from || parsed.from.toLowerCase() !== p.borrower.toLowerCase() || !parsed.hash) {
46275
46377
  return this.refuse(`${p.action}: keystore signature did not recover to the borrower \u2014 refusing to apply state`);
46276
46378
  }
@@ -46314,7 +46416,7 @@ var KeystoreCeremony = class {
46314
46416
 
46315
46417
  // src/boundary/upstream/mock/safe-ceremony.ts
46316
46418
  var import_node_crypto7 = require("crypto");
46317
- var import_ethers12 = require("ethers");
46419
+ var import_ethers13 = require("ethers");
46318
46420
  init_tx_validator();
46319
46421
 
46320
46422
  // src/boundary/upstream/shared/quantum.ts
@@ -46378,7 +46480,7 @@ var SafeCeremony = class {
46378
46480
  data: p.tx.data,
46379
46481
  value: BigInt(p.tx.value)
46380
46482
  });
46381
- const parsed = import_ethers12.ethers.Transaction.from(raw);
46483
+ const parsed = import_ethers13.ethers.Transaction.from(raw);
46382
46484
  if (!parsed.from || parsed.from.toLowerCase() !== executor.address.toLowerCase() || !parsed.hash) {
46383
46485
  return this.refuse(`${p.action}: executor signature did not recover \u2014 refusing to apply state`);
46384
46486
  }
@@ -46414,7 +46516,7 @@ var SafeCeremony = class {
46414
46516
  if (!auth.ok) return auth.refusal;
46415
46517
  plane1Signers = auth.signers;
46416
46518
  }
46417
- const intentData = import_ethers12.ethers.AbiCoder.defaultAbiCoder().encode(["string", "string"], [`dh-mock-${p.action}`, p.detail]);
46519
+ const intentData = import_ethers13.ethers.AbiCoder.defaultAbiCoder().encode(["string", "string"], [`dh-mock-${p.action}`, p.detail]);
46418
46520
  const tx2 = buildSafeTx({ to: this.txContext().positionManager, data: intentData, nonce: BigInt(safe.nonce) });
46419
46521
  const collected = await this.collectSafeTxBlob({ action: p.action, safe, tx: tx2 });
46420
46522
  if (!collected.ok) return collected.refusal;
@@ -46532,7 +46634,7 @@ var SafeCeremony = class {
46532
46634
  detail: p.detail,
46533
46635
  issuedAtSec: p.issuedAtSec
46534
46636
  });
46535
- const envelopeHash = import_ethers12.ethers.TypedDataEncoder.hash(
46637
+ const envelopeHash = import_ethers13.ethers.TypedDataEncoder.hash(
46536
46638
  envelope.domain,
46537
46639
  envelope.types,
46538
46640
  envelope.message
@@ -46629,7 +46731,7 @@ var SafeCeremony = class {
46629
46731
  onApproval: (_account, signature) => {
46630
46732
  let signer;
46631
46733
  try {
46632
- signer = import_ethers12.ethers.recoverAddress(build.hash, signature);
46734
+ signer = import_ethers13.ethers.recoverAddress(build.hash, signature);
46633
46735
  } catch {
46634
46736
  return { verdict: "rejected", reason: `signature does not recover \u2014 wrong payload or wallet`, done: false, progress: progress() };
46635
46737
  }
@@ -46699,7 +46801,7 @@ var SafeCeremony = class {
46699
46801
  }
46700
46802
  safeMessageHashOf(safe, innerHash) {
46701
46803
  const payload = safeMessageTypedData({ address: safe.address, chainId: safe.chainId }, innerHash);
46702
- return import_ethers12.ethers.TypedDataEncoder.hash(payload.domain, payload.types, payload.message);
46804
+ return import_ethers13.ethers.TypedDataEncoder.hash(payload.domain, payload.types, payload.message);
46703
46805
  }
46704
46806
  /** The card pierces every wrapper (M6-5): base decode + Safe context. */
46705
46807
  safeCard(base, safe, extra) {
@@ -46720,7 +46822,7 @@ var SafeCeremony = class {
46720
46822
  };
46721
46823
 
46722
46824
  // src/boundary/upstream/mock/safe-module-ceremony.ts
46723
- var import_ethers13 = require("ethers");
46825
+ var import_ethers14 = require("ethers");
46724
46826
  init_tx_validator();
46725
46827
  var SOURCE4 = "safe-module";
46726
46828
  var SafeModuleCeremony = class {
@@ -46766,7 +46868,7 @@ var SafeModuleCeremony = class {
46766
46868
  const innerCard = cardForTx(p.tx);
46767
46869
  const mod = world.moduleInfo(safe);
46768
46870
  if (!mod) return this.refuse(`${p.action}: module vanished mid-ceremony`);
46769
- const outerData = new import_ethers13.ethers.Interface(["function execute(address target, bytes data)"]).encodeFunctionData("execute", [
46871
+ const outerData = new import_ethers14.ethers.Interface(["function execute(address target, bytes data)"]).encodeFunctionData("execute", [
46770
46872
  p.tx.to,
46771
46873
  p.tx.data
46772
46874
  ]);
@@ -46782,7 +46884,7 @@ var SafeModuleCeremony = class {
46782
46884
  data: outerData,
46783
46885
  value: 0n
46784
46886
  });
46785
- const parsed = import_ethers13.ethers.Transaction.from(raw);
46887
+ const parsed = import_ethers14.ethers.Transaction.from(raw);
46786
46888
  if (!parsed.from || parsed.from.toLowerCase() !== agent.address.toLowerCase() || !parsed.hash) {
46787
46889
  return this.refuse(`${p.action}: agent signature did not recover \u2014 refusing to apply state`);
46788
46890
  }
@@ -46815,7 +46917,7 @@ var SafeModuleCeremony = class {
46815
46917
  issuedAtSec: world.nowSec()
46816
46918
  });
46817
46919
  const sig2 = await agent.signTypedData(envelope.domain, envelope.types, envelope.message);
46818
- const recovered = import_ethers13.ethers.verifyTypedData(envelope.domain, envelope.types, envelope.message, sig2);
46920
+ const recovered = import_ethers14.ethers.verifyTypedData(envelope.domain, envelope.types, envelope.message, sig2);
46819
46921
  if (recovered.toLowerCase() !== agent.address.toLowerCase()) {
46820
46922
  return this.refuse(`${p.action}: agent signature did not recover \u2014 refusing to apply state`);
46821
46923
  }
@@ -46827,7 +46929,7 @@ var SafeModuleCeremony = class {
46827
46929
  signer: agent.address,
46828
46930
  action: p.action,
46829
46931
  card: this.moduleCard(cardForTypedData(p.action, envelope), safe, mod?.moduleAddress ?? "?", agent.address),
46830
- digest: import_ethers13.ethers.TypedDataEncoder.hash(envelope.domain, envelope.types, envelope.message)
46932
+ digest: import_ethers14.ethers.TypedDataEncoder.hash(envelope.domain, envelope.types, envelope.message)
46831
46933
  }
46832
46934
  };
46833
46935
  }
@@ -46851,7 +46953,7 @@ var SafeModuleCeremony = class {
46851
46953
  `Submitted by agent ${agent.address} through AgentModule ${mod?.moduleAddress ?? "?"} (msg.sender = the Safe)`,
46852
46954
  p.detail
46853
46955
  ].join("\n"),
46854
- digest: import_ethers13.ethers.id(`dh-module-withdraw:${safe}:${env.issuedAtSec}:${p.detail}`)
46956
+ digest: import_ethers14.ethers.id(`dh-module-withdraw:${safe}:${env.issuedAtSec}:${p.detail}`)
46855
46957
  }
46856
46958
  };
46857
46959
  }
@@ -46883,10 +46985,9 @@ var SafeModuleCeremony = class {
46883
46985
  };
46884
46986
 
46885
46987
  // src/boundary/upstream/real/plugin.ts
46886
- var import_ethers50 = require("ethers");
46988
+ var import_ethers51 = require("ethers");
46887
46989
 
46888
46990
  // node_modules/@gvnrdao/dh-sdk/dist/index.mjs
46889
- var import_ethers14 = require("ethers");
46890
46991
  var import_ethers15 = require("ethers");
46891
46992
  var import_ethers16 = require("ethers");
46892
46993
  var import_ethers17 = require("ethers");
@@ -46896,6 +46997,7 @@ var import_ethers20 = require("ethers");
46896
46997
  var import_ethers21 = require("ethers");
46897
46998
  var import_ethers22 = require("ethers");
46898
46999
  var import_ethers23 = require("ethers");
47000
+ var import_ethers24 = require("ethers");
46899
47001
 
46900
47002
  // node_modules/@noble/hashes/esm/utils.js
46901
47003
  function isBytes(a) {
@@ -47343,11 +47445,11 @@ var ripemd1602 = ripemd160;
47343
47445
  // node_modules/@gvnrdao/dh-sdk/dist/index.mjs
47344
47446
  var import_bech32 = __toESM(require_dist(), 1);
47345
47447
  var import_bs58check = __toESM(require_bs58check(), 1);
47346
- var import_ethers24 = require("ethers");
47347
47448
  var import_ethers25 = require("ethers");
47348
47449
  var import_ethers26 = require("ethers");
47349
47450
  var import_ethers27 = require("ethers");
47350
47451
  var import_ethers28 = require("ethers");
47452
+ var import_ethers29 = require("ethers");
47351
47453
 
47352
47454
  // node_modules/axios/lib/helpers/bind.js
47353
47455
  function bind(fn, thisArg) {
@@ -52972,15 +53074,15 @@ var {
52972
53074
  } = axios_default;
52973
53075
 
52974
53076
  // node_modules/@gvnrdao/dh-sdk/dist/index.mjs
52975
- var import_ethers29 = require("ethers");
52976
53077
  var import_ethers30 = require("ethers");
52977
53078
  var import_ethers31 = require("ethers");
52978
53079
  var import_ethers32 = require("ethers");
52979
53080
  var import_ethers33 = require("ethers");
52980
53081
  var import_ethers34 = require("ethers");
52981
- var import_dh_lit_ops = __toESM(require_dist3(), 1);
52982
53082
  var import_ethers35 = require("ethers");
53083
+ var import_dh_lit_ops = __toESM(require_dist3(), 1);
52983
53084
  var import_ethers36 = require("ethers");
53085
+ var import_ethers37 = require("ethers");
52984
53086
  var __create2 = Object.create;
52985
53087
  var __defProp2 = Object.defineProperty;
52986
53088
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -59163,10 +59265,10 @@ var DEFAULT_FEE_CEILING = {
59163
59265
  maxTxFeeWei: DEFAULT_MAX_TX_FEE_WEI
59164
59266
  };
59165
59267
  function fmtEth(wei) {
59166
- return `${import_ethers16.ethers.formatEther(wei)} ETH`;
59268
+ return `${import_ethers17.ethers.formatEther(wei)} ETH`;
59167
59269
  }
59168
59270
  function fmtGwei(wei) {
59169
- return `${import_ethers16.ethers.formatUnits(wei, "gwei")} gwei`;
59271
+ return `${import_ethers17.ethers.formatUnits(wei, "gwei")} gwei`;
59170
59272
  }
59171
59273
  function worstCaseFeeWei(gasLimit, maxFeePerGas) {
59172
59274
  if (gasLimit == null || maxFeePerGas == null)
@@ -59215,12 +59317,12 @@ function parseFeeHistory(raw) {
59215
59317
  `eth_feeHistory returned no reward percentiles \u2014 the RPC ignored the rewardPercentiles argument: ${JSON.stringify(raw)}`
59216
59318
  );
59217
59319
  }
59218
- const nextBaseFee = (0, import_ethers15.getBigInt)(baseFeePerGas[baseFeePerGas.length - 1], "baseFeePerGas");
59320
+ const nextBaseFee = (0, import_ethers16.getBigInt)(baseFeePerGas[baseFeePerGas.length - 1], "baseFeePerGas");
59219
59321
  const tips = reward.map((perBlock, i) => {
59220
59322
  if (!Array.isArray(perBlock) || perBlock.length === 0) {
59221
59323
  throw new Error(`eth_feeHistory reward row ${i} is empty: ${JSON.stringify(raw)}`);
59222
59324
  }
59223
- return (0, import_ethers15.getBigInt)(perBlock[0], `reward[${i}]`);
59325
+ return (0, import_ethers16.getBigInt)(perBlock[0], `reward[${i}]`);
59224
59326
  });
59225
59327
  return { nextBaseFee, tips };
59226
59328
  }
@@ -59254,7 +59356,7 @@ async function resolveEip1559FeeFields(feeProvider) {
59254
59356
  }
59255
59357
  const history = parseFeeHistory(
59256
59358
  await feeProvider.send("eth_feeHistory", [
59257
- (0, import_ethers15.toQuantity)(FEE_HISTORY_BLOCK_COUNT),
59359
+ (0, import_ethers16.toQuantity)(FEE_HISTORY_BLOCK_COUNT),
59258
59360
  "latest",
59259
59361
  [FEE_HISTORY_REWARD_PERCENTILE]
59260
59362
  ])
@@ -59667,7 +59769,7 @@ async function getPKPPublicKeyFromTokenId(pkpTokenId, provider, pkpNftContractAd
59667
59769
  `pkpNftContractAddress is required for getPKPPublicKeyFromTokenId`
59668
59770
  );
59669
59771
  }
59670
- const pkpNft = new import_ethers17.Contract(
59772
+ const pkpNft = new import_ethers18.Contract(
59671
59773
  pkpNftContractAddress,
59672
59774
  PKP_NFT_ABI,
59673
59775
  provider
@@ -59704,7 +59806,7 @@ async function generateBalanceConfirmationAuthorization(positionId, chainId, sig
59704
59806
  const timestamp = calculateNextQuantumTimestamp();
59705
59807
  const caller = await signer.getAddress();
59706
59808
  const action = "confirm-balance";
59707
- const actionHash = (0, import_ethers17.keccak256)((0, import_ethers17.toUtf8Bytes)(action));
59809
+ const actionHash = (0, import_ethers18.keccak256)((0, import_ethers18.toUtf8Bytes)(action));
59708
59810
  const types = [
59709
59811
  "bytes32",
59710
59812
  // positionId
@@ -59718,8 +59820,8 @@ async function generateBalanceConfirmationAuthorization(positionId, chainId, sig
59718
59820
  // actionHash
59719
59821
  ];
59720
59822
  const values = [positionId, timestamp, chainId, caller, actionHash];
59721
- const messageHash = (0, import_ethers17.solidityPackedKeccak256)(types, values);
59722
- const messageHashBytes = (0, import_ethers17.getBytes)(messageHash);
59823
+ const messageHash = (0, import_ethers18.solidityPackedKeccak256)(types, values);
59824
+ const messageHashBytes = (0, import_ethers18.getBytes)(messageHash);
59723
59825
  const signature = await signer.signMessage(messageHashBytes);
59724
59826
  return {
59725
59827
  positionId,
@@ -59910,7 +60012,7 @@ async function buildSignedLoginPayload(signer, chainId, audience, reuse, withSta
59910
60012
  ...statement ? { statement } : {},
59911
60013
  address,
59912
60014
  issuedAt: reuse?.issuedAt ?? Math.floor(Date.now() / 1e3),
59913
- nonce: reuse?.nonce ?? (0, import_ethers19.hexlify)((0, import_ethers19.randomBytes)(32)),
60015
+ nonce: reuse?.nonce ?? (0, import_ethers20.hexlify)((0, import_ethers20.randomBytes)(32)),
59914
60016
  ...audience ? { audience } : {}
59915
60017
  };
59916
60018
  const signature = await signer.signTypedData(
@@ -60533,13 +60635,13 @@ function decodeQuantumRevert(e) {
60533
60635
  if (!name && selector && data) {
60534
60636
  try {
60535
60637
  if (selector === ERROR_STRING_SELECTOR) {
60536
- const [message2] = import_ethers20.AbiCoder.defaultAbiCoder().decode(
60638
+ const [message2] = import_ethers21.AbiCoder.defaultAbiCoder().decode(
60537
60639
  ["string"],
60538
60640
  "0x" + data.slice(10)
60539
60641
  );
60540
60642
  name = `Error("${message2}")`;
60541
60643
  } else if (selector === PANIC_SELECTOR) {
60542
- const [code] = import_ethers20.AbiCoder.defaultAbiCoder().decode(
60644
+ const [code] = import_ethers21.AbiCoder.defaultAbiCoder().decode(
60543
60645
  ["uint256"],
60544
60646
  "0x" + data.slice(10)
60545
60647
  );
@@ -60787,12 +60889,12 @@ var RECOVERY_INVALIDATE_ACTION = "btc-utxo-invalidator";
60787
60889
  var QUANTUM_SECONDS = 60;
60788
60890
  var QUANTUM_SAFE_THRESHOLD = 40;
60789
60891
  function buildInvalidateMessageHash(params) {
60790
- const positionIdBytes32 = (0, import_ethers21.zeroPadValue)(
60892
+ const positionIdBytes32 = (0, import_ethers22.zeroPadValue)(
60791
60893
  params.positionId.startsWith("0x") ? params.positionId : `0x${params.positionId}`,
60792
60894
  32
60793
60895
  );
60794
- const actionHash = (0, import_ethers21.keccak256)((0, import_ethers21.toUtf8Bytes)(RECOVERY_INVALIDATE_ACTION));
60795
- return (0, import_ethers21.solidityPackedKeccak256)(
60896
+ const actionHash = (0, import_ethers22.keccak256)((0, import_ethers22.toUtf8Bytes)(RECOVERY_INVALIDATE_ACTION));
60897
+ return (0, import_ethers22.solidityPackedKeccak256)(
60796
60898
  [
60797
60899
  "bytes32",
60798
60900
  // positionId
@@ -60838,7 +60940,7 @@ async function buildInvalidateStaleSpendEnvelope(params) {
60838
60940
  utxoTxid,
60839
60941
  utxoVout
60840
60942
  });
60841
- const signature = await signer.signMessage((0, import_ethers21.getBytes)(messageHash));
60943
+ const signature = await signer.signMessage((0, import_ethers22.getBytes)(messageHash));
60842
60944
  const borrowerAddress = await signer.getAddress();
60843
60945
  return {
60844
60946
  positionId,
@@ -60881,7 +60983,7 @@ function hashBtcInputSet(utxos) {
60881
60983
  seen.add(key);
60882
60984
  }
60883
60985
  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("|");
60884
- return (0, import_ethers22.keccak256)((0, import_ethers22.toUtf8Bytes)(canonical));
60986
+ return (0, import_ethers23.keccak256)((0, import_ethers23.toUtf8Bytes)(canonical));
60885
60987
  }
60886
60988
  async function buildBtcExecuteEnvelope(params) {
60887
60989
  const {
@@ -60926,15 +61028,15 @@ async function buildBtcExecuteEnvelope(params) {
60926
61028
  } else {
60927
61029
  timestamp = currentQuantumStart;
60928
61030
  }
60929
- const actionHash = (0, import_ethers22.keccak256)(
60930
- (0, import_ethers22.toUtf8Bytes)("execute-btc-withdrawal")
61031
+ const actionHash = (0, import_ethers23.keccak256)(
61032
+ (0, import_ethers23.toUtf8Bytes)("execute-btc-withdrawal")
60931
61033
  );
60932
61034
  const utxoIdentifier = `${txid}:${vout}`;
60933
- const positionIdBytes32 = (0, import_ethers22.zeroPadValue)(
61035
+ const positionIdBytes32 = (0, import_ethers23.zeroPadValue)(
60934
61036
  positionId.startsWith("0x") ? positionId : `0x${positionId}`,
60935
61037
  32
60936
61038
  );
60937
- const messageHash = (0, import_ethers22.solidityPackedKeccak256)(
61039
+ const messageHash = (0, import_ethers23.solidityPackedKeccak256)(
60938
61040
  [
60939
61041
  "bytes32",
60940
61042
  // positionId
@@ -60967,7 +61069,7 @@ async function buildBtcExecuteEnvelope(params) {
60967
61069
  actionHash
60968
61070
  ]
60969
61071
  );
60970
- const userSignature = await signer.signMessage((0, import_ethers22.getBytes)(messageHash));
61072
+ const userSignature = await signer.signMessage((0, import_ethers23.getBytes)(messageHash));
60971
61073
  const borrowerAddress = await signer.getAddress();
60972
61074
  return {
60973
61075
  positionId,
@@ -61335,7 +61437,7 @@ function rowToStatus(row) {
61335
61437
  return row;
61336
61438
  }
61337
61439
  async function fetchProtocolPauseStatus(provider, positionManagerAddress) {
61338
- const iface = new import_ethers24.Interface(GET_PROTOCOL_PAUSE_STATUS_ABI);
61440
+ const iface = new import_ethers25.Interface(GET_PROTOCOL_PAUSE_STATUS_ABI);
61339
61441
  const data = iface.encodeFunctionData("getProtocolPauseStatus", []);
61340
61442
  const raw = await provider.call({ to: positionManagerAddress, data });
61341
61443
  const decoded = iface.decodeFunctionResult("getProtocolPauseStatus", raw);
@@ -61525,38 +61627,38 @@ var ContractManager = class {
61525
61627
  }
61526
61628
  const contractRunner = runner;
61527
61629
  const contracts = {
61528
- positionManager: new import_ethers25.Contract(
61630
+ positionManager: new import_ethers26.Contract(
61529
61631
  contractAddresses.positionManager,
61530
61632
  POSITION_MANAGER_ABI,
61531
61633
  contractRunner
61532
61634
  ),
61533
- loanOperationsManager: new import_ethers25.Contract(
61534
- contractAddresses.loanOperationsManager || import_ethers25.ZeroAddress,
61635
+ loanOperationsManager: new import_ethers26.Contract(
61636
+ contractAddresses.loanOperationsManager || import_ethers26.ZeroAddress,
61535
61637
  LOAN_OPS_ABI,
61536
61638
  contractRunner
61537
61639
  ),
61538
- ucdController: new import_ethers25.Contract(
61640
+ ucdController: new import_ethers26.Contract(
61539
61641
  contractAddresses.ucdToken,
61540
61642
  UCD_CONTROLLER_ABI,
61541
61643
  contractRunner
61542
61644
  ),
61543
- termManager: new import_ethers25.Contract(
61544
- contractAddresses.termManager || import_ethers25.ZeroAddress,
61645
+ termManager: new import_ethers26.Contract(
61646
+ contractAddresses.termManager || import_ethers26.ZeroAddress,
61545
61647
  TERM_MANAGER_ABI,
61546
61648
  contractRunner
61547
61649
  ),
61548
- circuitBreaker: new import_ethers25.Contract(
61549
- contractAddresses.circuitBreaker || import_ethers25.ZeroAddress,
61650
+ circuitBreaker: new import_ethers26.Contract(
61651
+ contractAddresses.circuitBreaker || import_ethers26.ZeroAddress,
61550
61652
  CIRCUIT_BREAKER_ABI,
61551
61653
  contractRunner
61552
61654
  ),
61553
- liquidationManager: new import_ethers25.Contract(
61554
- contractAddresses.liquidationManager || import_ethers25.ZeroAddress,
61655
+ liquidationManager: new import_ethers26.Contract(
61656
+ contractAddresses.liquidationManager || import_ethers26.ZeroAddress,
61555
61657
  LIQUIDATION_MANAGER_ABI,
61556
61658
  contractRunner
61557
61659
  ),
61558
- bitcoinWithdrawalAddressRegistry: new import_ethers25.Contract(
61559
- contractAddresses.bitcoinWithdrawalAddressRegistry || import_ethers25.ZeroAddress,
61660
+ bitcoinWithdrawalAddressRegistry: new import_ethers26.Contract(
61661
+ contractAddresses.bitcoinWithdrawalAddressRegistry || import_ethers26.ZeroAddress,
61560
61662
  BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_ABI,
61561
61663
  contractRunner
61562
61664
  )
@@ -61605,13 +61707,13 @@ var ContractManager = class {
61605
61707
  const address = addresses[key];
61606
61708
  if (!address) {
61607
61709
  missing.push(String(key));
61608
- } else if (!(0, import_ethers25.isAddress)(address)) {
61710
+ } else if (!(0, import_ethers26.isAddress)(address)) {
61609
61711
  invalid2.push(String(key));
61610
61712
  }
61611
61713
  }
61612
61714
  for (const key of optionalAddresses) {
61613
61715
  const address = addresses[key];
61614
- if (address && !(0, import_ethers25.isAddress)(address)) {
61716
+ if (address && !(0, import_ethers26.isAddress)(address)) {
61615
61717
  invalid2.push(String(key));
61616
61718
  }
61617
61719
  }
@@ -62926,11 +63028,11 @@ var LoanCreator = class {
62926
63028
  try {
62927
63029
  const mainnetVaultAddress = bitcoinAddresses.mainnet;
62928
63030
  const regtestVaultAddress = bitcoinAddresses.regtest;
62929
- const pkpIdBytes32 = (0, import_ethers26.zeroPadValue)(
62930
- (0, import_ethers26.toBeHex)(BigInt(pkpData.tokenId)),
63031
+ const pkpIdBytes32 = (0, import_ethers27.zeroPadValue)(
63032
+ (0, import_ethers27.toBeHex)(BigInt(pkpData.tokenId)),
62931
63033
  32
62932
63034
  );
62933
- const pkpPublicKeyUncompressed = import_ethers26.SigningKey.computePublicKey(
63035
+ const pkpPublicKeyUncompressed = import_ethers27.SigningKey.computePublicKey(
62934
63036
  pkpData.publicKey,
62935
63037
  false
62936
63038
  );
@@ -62943,7 +63045,7 @@ var LoanCreator = class {
62943
63045
  );
62944
63046
  log.debug(`BigInt conversion: ${BigInt(pkpData.tokenId).toString()}`);
62945
63047
  log.debug(
62946
- `Hex from BigInt: ${(0, import_ethers26.toBeHex)(BigInt(pkpData.tokenId))}`
63048
+ `Hex from BigInt: ${(0, import_ethers27.toBeHex)(BigInt(pkpData.tokenId))}`
62947
63049
  );
62948
63050
  log.debug(`Final bytes32 (zero-padded): ${pkpIdBytes32}`);
62949
63051
  log.debug(
@@ -63115,8 +63217,8 @@ var LoanCreator = class {
63115
63217
  }
63116
63218
  }
63117
63219
  if (this.config.debug) {
63118
- const pkpIdBytes32Check = (0, import_ethers26.zeroPadValue)(
63119
- (0, import_ethers26.toBeHex)(BigInt(pkpData.tokenId)),
63220
+ const pkpIdBytes32Check = (0, import_ethers27.zeroPadValue)(
63221
+ (0, import_ethers27.toBeHex)(BigInt(pkpData.tokenId)),
63120
63222
  32
63121
63223
  );
63122
63224
  log.error("\u274C Loan creation transaction failed", {
@@ -63277,7 +63379,7 @@ var LoanCreator = class {
63277
63379
  const coreAddress = this.config.contractManager.getContractAddresses().positionManagerCore;
63278
63380
  if (coreAddress) {
63279
63381
  try {
63280
- const core = new import_ethers26.Contract(
63382
+ const core = new import_ethers27.Contract(
63281
63383
  coreAddress,
63282
63384
  [
63283
63385
  "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))"
@@ -63319,8 +63421,8 @@ var LoanCreator = class {
63319
63421
  const newEventAbi = [
63320
63422
  "event PositionCreated(bytes32 indexed positionId, bytes32 indexed pkpId, address indexed borrower, uint256 requestedCollateralRatio, uint256 selectedTerm, uint256 expiryAt)"
63321
63423
  ];
63322
- const oldIface = new import_ethers26.Interface(oldEventAbi);
63323
- const newIface = new import_ethers26.Interface(newEventAbi);
63424
+ const oldIface = new import_ethers27.Interface(oldEventAbi);
63425
+ const newIface = new import_ethers27.Interface(newEventAbi);
63324
63426
  let positionId;
63325
63427
  if (this.config.debug) {
63326
63428
  log.info("\u{1F50D} Parsing transaction receipt logs", {
@@ -63800,7 +63902,7 @@ var LoanQuery = class {
63800
63902
  const isChipotlePkpId2 = typeof rawId === "string" && isNormalizedChipotlePkpId(rawId);
63801
63903
  if (isChipotlePkpId2) {
63802
63904
  if (this.config.positionManagerCoreAddress && this.config.provider) {
63803
- const pmContract = new import_ethers27.Contract(
63905
+ const pmContract = new import_ethers28.Contract(
63804
63906
  this.config.positionManagerCoreAddress,
63805
63907
  POSITION_CORE_ABI,
63806
63908
  this.config.provider
@@ -63903,7 +64005,7 @@ var LoanQuery = class {
63903
64005
  */
63904
64006
  async getBorrowerUcdDebtSummary(borrower) {
63905
64007
  const trimmed = typeof borrower === "string" ? borrower.trim() : "";
63906
- if (!(0, import_ethers27.isAddress)(trimmed)) {
64008
+ if (!(0, import_ethers28.isAddress)(trimmed)) {
63907
64009
  return failure(
63908
64010
  new SDKError({
63909
64011
  message: `Borrower must be an EVM address for a UCD debt summary, got "${trimmed}"`,
@@ -64178,7 +64280,7 @@ var WithdrawalAddressModule = class {
64178
64280
  if (!res.success)
64179
64281
  return res;
64180
64282
  const target = res.value.target;
64181
- if (!target || target === import_ethers28.ZeroAddress) {
64283
+ if (!target || target === import_ethers29.ZeroAddress) {
64182
64284
  return failure(
64183
64285
  new SDKError({
64184
64286
  code: "SDK_WITHDRAWAL_REGISTRY_NOT_CONFIGURED",
@@ -64197,7 +64299,7 @@ var WithdrawalAddressModule = class {
64197
64299
  }
64198
64300
  /** keccak256 of the canonicalized address — matches the on-chain key. */
64199
64301
  static addressHash(btcAddress2) {
64200
- return (0, import_ethers28.keccak256)((0, import_ethers28.toUtf8Bytes)(normalizeBitcoinAddress(btcAddress2)));
64302
+ return (0, import_ethers29.keccak256)((0, import_ethers29.toUtf8Bytes)(normalizeBitcoinAddress(btcAddress2)));
64201
64303
  }
64202
64304
  /**
64203
64305
  * Add a Bitcoin address to the caller's allowlist. It becomes usable only
@@ -70217,7 +70319,7 @@ var _abi = [
70217
70319
  ];
70218
70320
  var _bytecode = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161485a90816100f0823960805181818161278e01526128870152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c8062f7fce91461384657806301ffc9a7146137d5578063021d28931461377c5780630871b20614613743578063114249d214610f6157806311d954f81461371a57806313da3166146136e15780631d44a904146136385780631f77bf65146135ff578063248a9ca3146135e05780632b83cccd146131205780632f2ff15d146130ee57806334bac370146130b557806334e181251461307c57806336568abe14613037578063373c86b614612ffe5780633f4ba83a14612f375780634373b57214612f0e5780634451e89b14612b3a5780634ebd25a514612b015780634f1ef2861461280c5780635273b6f6146127e357806352d1902d1461277b578063568fafca146126ed57806359d5d02a146124205780635bc26aea146123eb5780635c975abb146123bb5780635ecc27081461229d5780638456cb59146121a257806385c15d9a1461216957806389d3ad00146120a25780638bff608e146120695780639010d07c1461201657806390ad8b4014611ffa57806391d1485414611fa15780639b759bf714611f5e5780639baf58d214611f415780639f1d0f59146118a8578063a217fddf1461188c578063a3246ad3146117cf578063ad3cb1cc14611788578063b492fc691461168e578063b9f637af14611463578063bf7d911914611424578063c4c5f62414611371578063c55f15ea1461134e578063ca15c87314611317578063ca2ce65d146112de578063cc1f8ffa146112ac578063cf46075e146111a2578063d21a74ff14611165578063d2f8253614611142578063d547741f14611107578063d5d3f78b14610f9a578063d66bd52414610f61578063e1f1c4a714610f44578063e1f3962c14610f18578063ec2f96fe14610ef4578063eda5a26a14610af7578063f1a1eb8414610ab4578063f385116d14610a7b578063f77c479114610a54578063f8c8765e14610661578063faaebd2114610628578063facdfb5e14610488578063fc99bd9a14610377578063fe32e7281461033e5763ffa1ad741461030857600080fd5b3461033b578060031936011261033b57610337610323613a68565b604051918291602083526020830190613a17565b0390f35b80fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361036661392e565b168152601283522054604051908152f35b503461033b57604036600319011261033b5761039161392e565b6010546024359291906001600160a01b03163303610479576001600160a01b03168082526002602052604082205490929060ff16156104665780156104575782825260076020526040822054926103e88285613cb0565b848110610448576001600160ff1b0381116104395760008051602061482e833981519152604085968493846104369852600760205280838a205582519182526020820152a23090339061421c565b80f35b630700fcb360e11b8452600484fd5b63446c8cc960e01b8452600484fd5b63162908e360e11b8252600482fd5b506024916374ed46ad60e01b8252600452fd5b6349db3bd360e01b8252600482fd5b503461033b57602036600319011261033b576104a261392e565b6104aa613f12565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff161561061657808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa90811561060b5784916105d4575b50818111156105c5576105248282613b6c565b8215908115610570575b505060008051602061482e833981519152916040918486526007602052808387205582519182526020820152a260016000805160206147ce8339815191525580f35b61271081029080820461271014901517156105b157606484029184830460641417156105b157116105a257388061052e565b63a73af74d60e01b8452600484fd5b634e487b7160e01b86526011600452602486fd5b6105cf8183613b6c565b610524565b90506020813d602011610603575b816105ef602093836139c3565b810103126105fe575138610511565b600080fd5b3d91506105e2565b6040513d86823e3d90fd5b6374ed46ad60e01b8252600452602490fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361065061392e565b168152600483522054604051908152f35b503461033b57608036600319011261033b5761067b61392e565b610683613944565b6044356001600160a01b03811690818103610a50576064356001600160a01b0381169390849003610a4c5760008051602061480e83398151915254604081901c60ff161595906001600160401b031680159081610a44575b6001149081610a3a575b159081610a31575b50610a225760008051602061480e83398151915280546001600160401b0319166001179055856109fd575b6001600160a01b03169081156109ee576001600160a01b03169081156109df5783156109d05761074661448a565b61074e61448a565b61075661448a565b61075e61448a565b60016000805160206147ce8339815191525561077861448a565b61078061448a565b86546001600160a01b0319908116919091178755600180549182168317905560405163313ce56760e01b8152909190602081600481855afa88918161099f575b506107d457633a24e95b60e11b8852600488fd5b6001600160a81b03199092161760a091821b60ff60a01b16176001819055901c60ff16601119810161098d575061080b8186614348565b80610965575b156109205761082e816000805160206147ee833981519152614348565b8061092f575b15610920576108519060008051602061470e833981519152614348565b90816108e9575b50156108da57806108af575b5061086c5780f35b60ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160018152a180f35b601080546001600160a01b031916821790558260008051602061474e8339815191528180a338610864565b63cf5a8e3360e01b8352600483fd5b6109199060008051602061470e83398151915286526000805160206146ae833981519152602052604086206144d0565b5038610858565b63cf5a8e3360e01b8552600485fd5b6000805160206147ee83398151915286526000805160206146ae83398151915260205261095f83604088206144d0565b50610834565b8580526000805160206146ae83398151915260205261098783604088206144d0565b50610811565b63167738cf60e21b8652600452602485fd5b6109c291925060203d6020116109c9575b6109ba81836139c3565b810190613ba9565b90386107c0565b503d6109b0565b630b5eba9f60e41b8752600487fd5b63c1ab6dc160e01b8752600487fd5b6336abb4df60e11b8752600487fd5b60008051602061480e833981519152805460ff60401b1916600160401b179055610718565b63f92ee8a960e01b8752600487fd5b905015386106ed565b303b1591506106e5565b8791506106db565b8580fd5b8480fd5b503461033b578060031936011261033b57546040516001600160a01b039091168152602090f35b503461033b57602036600319011261033b576020906040906001600160a01b03610aa361392e565b168152600a83522054604051908152f35b503461033b57604036600319011261033b576020906040906001600160a01b03610adc61392e565b16815260158352818120602435825283522054604051908152f35b503461033b5761016036600319011261033b57610b1261392e565b90606435604435602435610b24613a58565b9160a4359160c43560e43561010435916101243595610144359760018060a01b03601054163303610ee5576001600160a01b038c16808c52600260205260408c2054909a9060ff16610ed1578a15610ec2578615610eb3576127108811610e99576103e88111610e815760ff82169c60128e118e8115610e76575b50610e6257803b15610e4e578915610e3a578a15610e265782610bc191614260565b84151580610e1d575b610e065785151580610dfd575b610de6578b9c602460208d9e9d604051928380926370a0823160e01b82523060048301525afa9c8d15610dda579c610da6575b506001600160ff1b038c11610d97578a8d8f9760408f97838f918f8f8f8f90859f988f99879f9660008051602061476e8339815191529f978b9f988f8d6000805160206146ce8339815191529f988e8e610d4f9b60008051602061468e8339815191529f8f8f8487526002602052878720600160ff198254161790558487526003602052878720558386526004602052868620558285526006602052878686205582855260056020528585209060ff19825416179055818452600c6020528885852055818452600d6020528985852055818452600e6020528a85852055818452600f6020528b8585205581845260076020528484205582526012602052828220558d8152601360205220558a7f991d1ef1b5c0820d213328cba6682059e00a50e49c469a454eb3557e78eaf6668e80518b81528c6020820152a28c5198899889613cbd565b0390a28151908b82526020820152a28151908782526020820152a280610d73578280f35b604060008051602061482e833981519152918151908582526020820152a281808280f35b63556e7a8160e01b8e5260048efd5b909b506020813d602011610dd2575b81610dc2602093836139c3565b810103126105fe57519a38610c0a565b3d9150610db5565b604051903d90823e3d90fd5b60448c858863dd85772b60e01b8352600452602452fd5b50838610610bd7565b60448c8487637449915760e01b8352600452602452fd5b50828510610bca565b636835314760e11b8d52600160045260248dfd5b636835314760e11b8d5260048d905260248dfd5b63377e3f9960e21b8d5260048c905260248dfd5b63ca95039160e01b8d5260048e905260248dfd5b60069150108e610b9f565b631051834f60e11b8c526004526103e860245260448bfd5b63c1e9a14160e01b8c52600488905261271060245260448cfd5b63a2ec3a5560e01b8c5260048cfd5b63df407ac560e01b8c5260048cfd5b6317f4215b60e21b8c5260048b905260248cfd5b6349db3bd360e01b8b5260048bfd5b503461033b578060031936011261033b57602060ff60015460a01c16604051908152f35b503461033b57602036600319011261033b576020610f3c610f3761392e565b613df5565b604051908152f35b503461033b578060031936011261033b5760206040516127108152f35b503461033b57602036600319011261033b576020906040906001600160a01b03610f8961392e565b168152600783522054604051908152f35b503461033b57602036600319011261033b57610fb461392e565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff16156106165780825260076020526040822054806110f1575080825260026020526040822060ff1981541690558082526003602052816040812055808252600460205281604081205580825260056020526040822060ff198154169055808252600c602052816040812055808252600d602052816040812055808252600e602052816040812055808252600f602052816040812055808252600660205281604081205580825260076020526040822054818352600760205282604081205560405190827f3302a1b37f04242bb55603f5449e7ecd690a35eef08ba1353c48c20e2aae9cda8580a2806110ce578380f35b8160409160008051602061482e8339815191529352846020820152a23880808380f35b604492916376bc059760e11b8352600452602452fd5b503461033b57604036600319011261033b5761113e600435611127613944565b9061113961113482613b79565b614088565b61411a565b5080f35b503461033b578060031936011261033b57602060ff600854166040519015158152f35b503461033b57602036600319011261033b5760209060ff906040906001600160a01b0361119061392e565b16815260058452205416604051908152f35b503461033b57602036600319011261033b576111bc61392e565b6111c4613f12565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff161561061657808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa90811561060b57849161126c575b5060008051602061482e833981519152916040918486526007602052808387205582519182526020820152a260016000805160206147ce8339815191525580f35b90506020813d6020116112a4575b81611287602093836139c3565b810103126105fe575160008051602061482e83398151915261122b565b3d915061127a565b503461033b57604036600319011261033b5760206112d46112cb61392e565b60243590613cf6565b6040519015158152f35b503461033b57602036600319011261033b576020906040906001600160a01b0361130661392e565b168152601383522054604051908152f35b503461033b57602036600319011261033b57604060209160043581526000805160206146ae83398151915283522054604051908152f35b503461033b578060031936011261033b576020604051670de0b6b3a76400008152f35b503461033b57604036600319011261033b5761138b61392e565b6010546024359291906001600160a01b03163303610479576001600160a01b031680825260076020526040822054929081841061140d578060008051602061482e8339815191526040866113e3866104369899613b6c565b84895260076020528289205583885260076020528188205482519182526020820152a2339061404c565b5091604492633cb8e07360e01b8352600452602452fd5b503461033b57602036600319011261033b5760209060ff906040906001600160a01b0361144f61392e565b168152600284522054166040519015158152f35b503461033b5761012036600319011261033b5761147e61392e565b6064359190604435602435611491613a58565b601054610104359660e4359260c4359260a43592906001600160a01b0316330361167f576001600160a01b038816808a52600260205260408a205490989060ff161561166b57861561165c576127108811611642576103e882116116285760ff83169060128211801561161e575b61160a578361150d91614260565b85151580611601575b6115ea578a1515806115e1575b6115ca579260008051602061468e83398151915297969592828c956115c4979460408e8e80825260036020528c8383205580825260046020528d838320558152600660205220558b8d52600560205260408d209060ff198254161790558a8c52600c6020528260408d20558a8c52600d6020528360408d20558a8c52600e6020528460408d20558a8c52600f6020528560408d205560405198899889613cbd565b0390a280f35b60448a868d63dd85772b60e01b8352600452602452fd5b50848b10611523565b60448a8588637449915760e01b8352600452602452fd5b50838610611516565b63ca95039160e01b8b52600482905260248bfd5b50600682106114ff565b631051834f60e11b8a5260048290526103e860245260448afd5b63c1e9a14160e01b8a52600488905261271060245260448afd5b63a2ec3a5560e01b8a5260048afd5b6374ed46ad60e01b8a52600489905260248afd5b6349db3bd360e01b8952600489fd5b503461033b57604036600319011261033b576116a861392e565b6001600160a01b0316808252600260205260408220546024359060ff16156117745780156117655761271061172a604085670de0b6b3a76400006117196117329688859a52600560205260ff85852054169080916012811061173f575b505088845260036020528484205490613a8b565b049581526004602052205484613a8b565b048092613b6c565b9082519182526020820152f35b61175e925060ff61175261175892613ad4565b16613ae5565b90613a8b565b3880611705565b63162908e360e11b8352600483fd5b6374ed46ad60e01b83526004829052602483fd5b503461033b578060031936011261033b5761033760408051906117ab81836139c3565b60058252640352e302e360dc1b602083015251918291602083526020830190613a17565b503461033b57602036600319011261033b5760043581526000805160206146ae83398151915260205260408120604051908160208254918281520190819285526020852090855b818110611876575050508261182c9103836139c3565b604051928392602084019060208552518091526040840192915b818110611854575050500390f35b82516001600160a01b0316845285945060209384019390920191600101611846565b8254845260209093019260019283019201611816565b503461033b578060031936011261033b57602090604051908152f35b503461033b576118b736613969565b9190926118c2613f12565b6118ca613f4e565b338152600960205260408120544303611f1f57338152600a602052600360408220541015611f1057338152600a602052604081206119088154613b9a565b90555b6001600160a01b0382168082526002602052604082205490929060ff16611e6f575b828252600260205260ff60408320541615610466578415610457578315611e6057828252600c60205260408220548510611e3b57828252600e60205260408220548015611e2c57808611611e155750846119869161415e565b6040516370a0823160e01b8152306004820152602081602481865afa908115611e0a578291611dd8575b506119bd8530338661421c565b6040516370a0823160e01b8152306004820152602081602481875afa908115611cef57908692918491611d9f575b50906119f691613b6c565b10611d905781815260076020526040812054611a128582613cb0565b818110611d81576001600160ff1b038111611d72576040849260008051602061482e833981519152928486526007602052808387205582519182526020820152a2818152600560205260ff604082205416849060128110611d11575b50611a8f670de0b6b3a7640000918484526003602052604084205490613a8b565b04908281526004602052612710611aaa604083205484613a8b565b0491611ab68382613b6c565b94808610611cfa57506001546040516318160ddd60e01b815290602090829060049082906001600160a01b03165afa908115611cef578391611cbd575b5082546001600160a01b0316803b15611ca45783809160846040518094819363ae494fa160e01b83523360048401528c60248401528b60448401528d60648401525af1801561060b57908491611ca8575b505083611c34575b6001546040516318160ddd60e01b81529190602090839060049082906001600160a01b03165afa801561060b578490611c00575b611b8a9250613b6c565b90808203611bea575050507fb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b611bcd602095604051918291339588429285613bdd565b0390a360016000805160206147ce83398151915255604051908152f35b632d8562a360e11b835260045260245260449150fd5b506020823d602011611c2c575b81611c1a602093836139c3565b810103126105fe57611b8a9151611b80565b3d9150611c0d565b82546001600160a01b0316803b15611ca45783809160846040518094819363ae494fa160e01b83523060048401528a60248401528b60448401528160648401525af1801561060b57908491611c8b575b5050611b4c565b81611c95916139c3565b611ca0578238611c84565b8280fd5b8380fd5b81611cb2916139c3565b611ca0578238611b44565b90506020813d602011611ce7575b81611cd8602093836139c3565b810103126105fe575138611af3565b3d9150611ccb565b6040513d85823e3d90fd5b6371c4efed60e01b83526004869052602452604482fd5b611d21915061175260ff91613ad4565b8015611d5e5780600019048511611d4f57611a8f611d48670de0b6b3a76400009287613a8b565b9150611a6e565b63035fc53d60e41b8252600482fd5b634e487b7160e01b82526012600452602482fd5b630700fcb360e11b8352600483fd5b63446c8cc960e01b8352600483fd5b639bfa3c1760e01b8152600490fd5b919250506020813d602011611dd0575b81611dbc602093836139c3565b810103126105fe57518591906119f66119eb565b3d9150611daf565b90506020813d602011611e02575b81611df3602093836139c3565b810103126105fe5751386119b0565b3d9150611de6565b6040513d84823e3d90fd5b631d7f2ac360e01b83526004869052602452604482fd5b633b5db2f360e11b8352600483fd5b50908152600c6020526040812054630d54e9e160e01b82526004849052602452604490fd5b632cd84af360e01b8252600482fd5b60405163313ce56760e01b815291939291602081600481865afa859181611eef575b50611ea55763105482c760e21b8552600485fd5b93919293838352600560205260ff806040852054169116908103611ec9575061192d565b90506044928252600560205260ff604083205416631e43476360e11b8352600452602452fd5b611f0991925060203d6020116109c9576109ba81836139c3565b9038611e91565b63a74c1c5f60e01b8152600490fd5b3381526009602052436040822055338152600a6020526001604082205561190b565b503461033b578060031936011261033b5760206040516103e88152f35b503461033b57604036600319011261033b576020906040906001600160a01b03611f8661392e565b16815260148352818120602435825283522054604051908152f35b503461033b57604036600319011261033b576040611fbd613944565b91600435815260008051602061478e833981519152602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b503461033b578060031936011261033b57602060405160648152f35b503461033b57604036600319011261033b5761205060209160043581526000805160206146ae8339815191528352604060243591206144b8565b905460405160039290921b1c6001600160a01b03168152f35b503461033b57602036600319011261033b576020906040906001600160a01b0361209161392e565b168152600983522054604051908152f35b503461033b57604036600319011261033b576120bc61392e565b60105460243591906001600160a01b0316330361215a576001600160a01b031690811561214b57604060008051602061476e8339815191529183855260136020528185205490848652601360205280838720558486526015602052828620438752602052828620548587526019602052838720558486526017602052438387205582519182526020820152a280f35b63df407ac560e01b8352600483fd5b6349db3bd360e01b8352600483fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361219161392e565b168152600383522054604051908152f35b503461033b578060031936011261033b5760008051602061470e833981519152815260008051602061478e83398151915260209081526040808320336000908152925290205460ff1615612278576121f8613f4e565b600160ff196000805160206147ae8339815191525416176000805160206147ae833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a280f35b63e2517d3f60e01b81523360045260008051602061470e833981519152602452604490fd5b503461033b57602036600319011261033b576122b761392e565b60008051602061480e8339815191525460ff8160401c169081156123a3575b506123945760008051602061480e83398151915280546001600160481b0319166003600160401b0117905581805260008051602061478e83398151915260209081526040808420336000908152925290205460ff161561237c5761233990613c5e565b60ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160038152a180f35b63e2517d3f60e01b8252336004526024829052604482fd5b63f92ee8a960e01b8252600482fd5b60036001600160401b039190911610159050386122d6565b503461033b578060031936011261033b57602060ff6000805160206147ae83398151915254166040519015158152f35b503461033b57602036600319011261033b5761240561392e565b6010546001600160a01b031633036104795761043690613c5e565b503461033b57606036600319011261033b5761243a61392e565b612442613944565b60105490926044359290916001600160a01b0316330361047957612464613f4e565b6011546001600160a01b03169182156126de5760405163babcc53960e01b81526001600160a01b0386166004820181905293602090829060249082905afa908115611e0a57829161269f575b5015612690578215612681576001546001600160a01b03928316921682036125d1576040516370a0823160e01b8152306004820152602081602481865afa908115611e0a57829161259f575b50935b841561259057600019810361258a5750835b841561257b5780851161256357505061252d836020958361404c565b7f0bf519e4b3821615dbdd874fa1a5fbb4bb651b4e6beabedd4ac318e770233b2c604080518581524287820152a3604051908152f35b630555ed4f60e31b8252600485905260245260449150fd5b632e11316f60e11b8252600482fd5b93612511565b63f09872eb60e01b8252600482fd5b90506020813d6020116125c9575b816125ba602093836139c3565b810103126105fe5751386124fc565b3d91506125ad565b8181526002602052604081205460ff161561266f576040516370a0823160e01b8152306004820152602081602481865afa908115611e0a57829161263d575b5082825260076020526040822054808211156126355761262f91613b6c565b936124ff565b50508061262f565b90506020813d602011612667575b81612658602093836139c3565b810103126105fe575138612610565b3d915061264b565b60249163eef7849760e01b8252600452fd5b634e46966960e11b8152600490fd5b63133307bb60e21b8152600490fd5b90506020813d6020116126d6575b816126ba602093836139c3565b810103126126d2575180151581036126d257386124b0565b5080fd5b3d91506126ad565b630e048e7160e41b8152600490fd5b503461033b57602036600319011261033b5761270761392e565b6010546001600160a01b03163303610479576001600160a01b0316801561276c57601180546001600160a01b0319811683179091556001600160a01b03167f1e9c406f2707909cfd9f61e744f73bcab77e5997d063276f67883c5257d51cf08380a380f35b634e46966960e11b8252600482fd5b503461033b578060031936011261033b577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031630036127d457602060405160008051602061472e8339815191528152f35b63703e46dd60e11b8152600490fd5b503461033b578060031936011261033b576010546040516001600160a01b039091168152602090f35b50604036600319011261033b5761282161392e565b602435906001600160401b038211611ca05736602383011215611ca0578160040135908361284e836139fc565b9361285c60405195866139c3565b83855260208501933660248284010111611ca057806024602093018637850101526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016308114908115612ade575b50612acf576010546001600160a01b03163303612ac0576001600160a01b038116928315612ab157813b15612aa25760008051602061472e83398151915254846128fa613a68565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f61293060405192604084526040840190613a17565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481895afa879181612a6a575b5061297e57634c9c8ce360e01b87526004869052602487fd5b908160008051602061472e83398151915288979303612a585750833b15612a44576001600160a01b031916811760008051602061472e833981519152558491907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8380a2805115612a295761113e9382915190845af43d15612a21573d91612a05836139fc565b92612a1360405194856139c3565b83523d85602085013e61460c565b60609161460c565b5050505034612a355780f35b63b398979f60e01b8152600490fd5b634c9c8ce360e01b86526004829052602486fd5b632a87526960e21b8752600452602486fd5b9091506020813d602011612a9a575b81612a86602093836139c3565b81010312612a9657519038612965565b8780fd5b3d9150612a79565b636f7c43f160e01b8552600485fd5b63e6c4247b60e01b8552600485fd5b6349db3bd360e01b8452600484fd5b63703e46dd60e11b8452600484fd5b60008051602061472e833981519152546001600160a01b031614159050386128b2565b503461033b57602036600319011261033b576020906040906001600160a01b03612b2961392e565b168152600e83522054604051908152f35b503461033b57606036600319011261033b57612b5461395a565b6024356001600160401b038111611ca057612b73903690600401613993565b916044356001600160401b038111610a5057612b93903690600401613993565b60008051602061480e8339815191529291925460ff8160401c16908115612ef6575b50612ee75760008051602061480e83398151915280546001600160481b0319166002600160401b011790556000805160206147ee833981519152865260008051602061478e83398151915260209081526040808820336000908152925290205460ff1615612ec257612c2561448a565b612c2d61448a565b60016000805160206147ce83398151915255600b549160ff8316612eb357818603612ea457612c5b86613bf9565b92612c6960405194856139c3565b868452601f19612c7888613bf9565b01366020860137875b878110612daf575060019060ff191617600b5515159460ff196008541660ff871617600855865b818110612d0c578760008051602061466e833981519152602089604051908152a160ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160028152a180f35b808860008051602061482e8339815191526040612d34612d2f600196888d613c10565b613c36565b612d3f85898c613c10565b357f8f955fa878b4aae8b1ac37b1ab715307470f2822ceff87e23d33ef1e044814a783612d6c888d613c4a565b5193898060a01b0316968793848252600660205280838320558482526007602052858383205582519182526020820152a28151908d82526020820152a201612ca8565b612dbd612d2f828a8a613c10565b612dc8828689613c10565b6001600160a01b03909116808b52600260205260408b20549091359060ff1615612e90576103e88111612e785750906020602492604051938480926370a0823160e01b82523060048301525afa8015612e6d578a90612e37575b60019250612e308288613c4a565b5201612c81565b509060203d8111612e66575b612e4d81836139c3565b6020826000928101031261033b57509060019151612e22565b503d612e43565b6040513d8c823e3d90fd5b631051834f60e11b8b526004526103e860245260448afd5b6351104c5960e01b8b52600482905260248bfd5b63512509d360e11b8752600487fd5b6324d0d1fd60e01b8752600487fd5b63e2517d3f60e01b8652336004526000805160206147ee833981519152602452604486fd5b63f92ee8a960e01b8652600486fd5b60026001600160401b03919091161015905038612bb5565b503461033b578060031936011261033b576011546040516001600160a01b039091168152602090f35b503461033b578060031936011261033b576010546001600160a01b03163303612fef576000805160206147ae8339815191525460ff811615612fe05760ff19166000805160206147ae833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a280f35b638dfc202b60e01b8252600482fd5b6349db3bd360e01b8152600490fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361302661392e565b168152601683522054604051908152f35b503461033b57604036600319011261033b57613051613944565b336001600160a01b0382160361306d5761113e9060043561411a565b63334bd91960e11b8252600482fd5b503461033b57602036600319011261033b576020906040906001600160a01b036130a461392e565b168152600c83522054604051908152f35b503461033b57602036600319011261033b576020906040906001600160a01b036130dd61392e565b168152601783522054604051908152f35b503461033b57604036600319011261033b5761113e60043561310e613944565b9061311b61113482613b79565b6140d2565b503461033b5761312f36613969565b91909261313a613f12565b613142613f4e565b3381526009602052604081205443036135be57338152600a602052600360408220541015611f1057338152600a602052604081206131808154613b9a565b90555b6001600160a01b0382168082526002602052604082205490929060ff16613543575b828252600260205260ff604083205416156104665760ff6008541615613534578415610457578315611e6057828252600d602052604082205480861061351d5750828252600f6020526040822054801561350e578086116134f857508461320b91613f78565b670de0b6b3a76400008402848104670de0b6b3a7640000036134e4578282526003602052604082205461323d91613ab4565b90828152600560205260ff604082205416601281106134c4575b50828152600660205261327c612710613274604084205485613a8b565b048093613b6c565b938085106134ac575082815260076020528360408220541061348857828152600760205260408120548481106134795760008051602061482e8339815191526040826132c9888895613b6c565b8486526007602052808387205582519182526020820152a26001546040516318160ddd60e01b815290602090829060049082906001600160a01b03165afa908115611e0a578291613447575b5081546001600160a01b0316803b15611ca057826040518092633a52b90760e11b82528183816133498d3360048401613bc2565b03925af18015611cef57613432575b506001546040516318160ddd60e01b81529190602090839060049082906001600160a01b03165afa908115611cef5783916133fc575b6133989250613b6c565b8581036133e45750507f8caf04742286d017f9ac3924388e188c73e6e5094311c5e59a61a7ef86dda8bf611bcd6020956133d386338761404c565b604051918291339588429285613bdd565b635ab6e2db60e01b8252600486905260245260449150fd5b90506020823d60201161342a575b81613417602093836139c3565b810103126105fe5761339891519061338e565b3d915061340a565b9161344081600493946139c3565b9190613358565b90506020813d602011613471575b81613462602093836139c3565b810103126126d2575138613315565b3d9150613455565b6308aed4ef60e31b8252600482fd5b82815260076020526040812054635960d22160e01b82526004526024849052604490fd5b6371c4efed60e01b8252600485905260245260449150fd5b916134d760ff6117526134dd9495613ad4565b90613ab4565b9038613257565b634e487b7160e01b82526011600452602482fd5b625502a360e91b83526004869052602452604482fd5b636c6ff70d60e11b8352600483fd5b6361767b8560e01b83526004869052602452604482fd5b630df65d9f60e01b8252600482fd5b60405163313ce56760e01b815291939291602081600481865afa85918161359d575b506135795763105482c760e21b8552600485fd5b93919293838352600560205260ff806040852054169116908103611ec957506131a5565b6135b791925060203d6020116109c9576109ba81836139c3565b9038613565565b3381526009602052436040822055338152600a60205260016040822055613183565b503461033b57602036600319011261033b576020610f3c600435613b79565b503461033b57602036600319011261033b576020906040906001600160a01b0361362761392e565b168152600f83522054604051908152f35b503461033b57604036600319011261033b5761365261392e565b60105460243591906001600160a01b0316330361215a576001600160a01b031690811561214b5760406000805160206146ce8339815191529183855260126020528185205490848652601260205280838720558486526014602052828620438752602052828620548587526018602052838720558486526016602052438387205582519182526020820152a280f35b503461033b57602036600319011261033b576020906040906001600160a01b0361370961392e565b168152600683522054604051908152f35b503461033b578060031936011261033b576001546040516001600160a01b039091168152602090f35b503461033b57602036600319011261033b576020906040906001600160a01b0361376b61392e565b168152600d83522054604051908152f35b503461033b57602036600319011261033b5761379661395a565b6010546001600160a01b0316330361047957602060008051602061466e83398151915291151560ff196008541660ff821617600855604051908152a180f35b503461033b57602036600319011261033b5760043563ffffffff60e01b81168091036126d257602090635a05180f60e01b811490811561381b575b506040519015158152f35b637965db0b60e01b811491508115613835575b5082613810565b6301ffc9a760e01b1490508261382e565b503461033b57604036600319011261033b5761386061392e565b6001600160a01b0316808252600260205260408220546024359060ff161561177457670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561391a57916138bc60409383835260036020528483205490613ab4565b91808252600560205260ff8483205416601281106138f1575b5061172a84836127109361173295526006602052205484613a8b565b846117329361390f61271094966134d760ff61175261172a97613ad4565b9593509350506138d5565b634e487b7160e01b83526011600452602483fd5b600435906001600160a01b03821682036105fe57565b602435906001600160a01b03821682036105fe57565b6004359081151582036105fe57565b60609060031901126105fe576004356001600160a01b03811681036105fe57906024359060443590565b9181601f840112156105fe578235916001600160401b0383116105fe576020808501948460051b0101116105fe57565b601f909101601f19168101906001600160401b038211908210176139e657604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116139e657601f01601f191660200190565b919082519283825260005b848110613a43575050826000602080949584010152601f8019910116010190565b80602080928401015182828601015201613a22565b6084359060ff821682036105fe57565b60405190613a776040836139c3565b6005825264322e332e3360d81b6020830152565b81810292918115918404141715613a9e57565b634e487b7160e01b600052601160045260246000fd5b8115613abe570490565b634e487b7160e01b600052601260045260246000fd5b60ff166012039060ff8211613a9e57565b8015613b665760009060208110600116604e821060011617613b5e57600a916001915b60018111613b35575082600019048211613b2157500290565b634e487b7160e01b81526011600452602490fd5b92806000190481116134e45760018416613b55575b80029260011c613b08565b80920291613b4a565b9050600a0a90565b50600190565b91908203918211613a9e57565b60005260008051602061478e83398151915260205260016040600020015490565b6000198114613a9e5760010190565b908160209103126105fe575160ff811681036105fe5790565b6001600160a01b039091168152602081019190915260400190565b9094939260609260808301968352602083015260408201520152565b6001600160401b0381116139e65760051b60200190565b9190811015613c205760051b0190565b634e487b7160e01b600052603260045260246000fd5b356001600160a01b03811681036105fe5790565b8051821015613c205760209160051b010190565b6001600160a01b03168015613c9f57601080546001600160a01b0319811683179091556001600160a01b031660008051602061474e833981519152600080a3565b63e6c4247b60e01b60005260046000fd5b91908201809211613a9e57565b94919360e0969360ff929a99989561010088019b885260208801526040870152166060850152608084015260a083015260c08201520152565b6001600160a01b03811660008181526002602052604090205490919060ff16158015613de8575b8015613de0575b613dce5781600052600f6020526040600020548015908115613dd6575b50613dce57613d66926040918251948592839262f7fce960e01b845260048401613bc2565b0381305afa918215613dc257600092613d8e575b506000526007602052604060002054101590565b9091506040813d604011613dba575b81613daa604093836139c3565b810103126105fe57519038613d7a565b3d9150613d9d565b6040513d6000823e3d90fd5b505050600090565b9050831138613d41565b508215613d24565b5060ff6008541615613d1d565b6001546001600160a01b0391821691168103613e6a576020602491604051928380926370a0823160e01b82523060048301525afa908115613dc257600091613e3b575090565b90506020813d602011613e62575b81613e56602093836139c3565b810103126105fe575190565b3d9150613e49565b80600052600260205260ff60406000205416613e865750600090565b6040516370a0823160e01b815230600482015290602082602481845afa918215613dc257600092613ede575b506000526007602052604060002054808211600014613ed757613ed491613b6c565b90565b5050600090565b90916020823d602011613f0a575b81613ef9602093836139c3565b8101031261033b5750519038613eb2565b3d9150613eec565b60026000805160206147ce8339815191525414613f3d5760026000805160206147ce83398151915255565b633ee5aeb560e01b60005260046000fd5b60ff6000805160206147ae8339815191525416613f6757565b63d93c066560e01b60005260046000fd5b6001600160a01b0316600081815260136020526040902054801561404757816000526015602052604060002043600052602052613fbb6040600020549384613cb0565b92831061403657808260005260176020524360406000205414614018575b8311613ffc57506000526015602052604060002043600052602052604060002055565b925063029359d560e41b60005260045260245260445260646000fd5b5081600052601960205261403160406000205482613cb0565b613fd9565b63446c8cc960e01b60005260046000fd5b505050565b614081614086939261407360405194859263a9059cbb60e01b602085015260248401613bc2565b03601f1981018452836139c3565b6142ed565b565b600081815260008051602061478e8339815191526020908152604080832033845290915290205460ff16156140ba5750565b63e2517d3f60e01b6000523360045260245260446000fd5b6140dc8282614348565b91826140e757505090565b60009182526000805160206146ae8339815191526020526040909120614116916001600160a01b0316906144d0565b5090565b61412482826143ea565b918261412f57505090565b60009182526000805160206146ae8339815191526020526040909120614116916001600160a01b031690614539565b6001600160a01b03166000818152601260205260409020548015614047578160005260146020526040600020436000526020526141a16040600020549384613cb0565b928310614036578082600052601660205243604060002054146141fe575b83116141e257506000526014602052604060002043600052602052604060002055565b92506319a4e2a760e01b60005260045260245260445260646000fd5b5081600052601860205261421760406000205482613cb0565b6141bf565b6040516323b872dd60e01b60208201526001600160a01b039283166024820152929091166044830152606480830193909352918152614086916140816084836139c3565b60405163313ce56760e01b81529190602090839060049082906001600160a01b03165afa600092816142cc575b506142a357631eecbb6560e01b60005260046000fd5b60ff91821691168082036142b5575050565b631e43476360e11b60005260045260245260446000fd5b6142e691935060203d6020116109c9576109ba81836139c3565b913861428d565b906000602091828151910182855af115613dc2576000513d61433f57506001600160a01b0381163b155b61431e5750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b60011415614317565b600081815260008051602061478e833981519152602090815260408083206001600160a01b038616845290915290205460ff16613ed757600081815260008051602061478e833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b600081815260008051602061478e833981519152602090815260408083206001600160a01b038616845290915290205460ff1615613ed757600081815260008051602061478e833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b60ff60008051602061480e8339815191525460401c16156144a757565b631afcd79f60e31b60005260046000fd5b8054821015613c205760005260206000200190600090565b6001810190826000528160205260406000205415600014613dce578054600160401b8110156139e65761452461450d8260018794018555846144b8565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b9060018201918160005282602052604060002054801515600014614603576000198101818111613a9e578254600019810191908211613a9e578181036145cc575b505050805480156145b657600019019061459482826144b8565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b6145ec6145dc61450d93866144b8565b90549060031b1c928392866144b8565b90556000528360205260406000205538808061457a565b50505050600090565b90614632575080511561462157602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580614664575b614643575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561463b56fe2c0a5f5ab0ba371221bb3612c2d2f90d36566279309f526000c5b354efd1b0658c67aaac7f77de07240e5a9b36dfdccb2a89c438635abbb27a73142d2aa0f629c1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200048b07fab687f450848f1df8a96db08fef7840f53415f18fdc2ec8e9f810f0930c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d275027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc17dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846c4460507c21097c15f6883572ebd157a9ee4b1d989a312314e93afd9d2ecd494002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a006d129bd71f2401cbe77f49f546d7d5f58992faecfca6e51ba06b50b261e83331a164736f6c6343000822000a";
70219
70321
  var isSuperArgs = (xs) => xs.length > 1;
70220
- var SimplePSMV2__factory = class extends import_ethers29.ContractFactory {
70322
+ var SimplePSMV2__factory = class extends import_ethers30.ContractFactory {
70221
70323
  constructor(...args) {
70222
70324
  if (isSuperArgs(args)) {
70223
70325
  super(...args);
@@ -70237,10 +70339,10 @@ var SimplePSMV2__factory = class extends import_ethers29.ContractFactory {
70237
70339
  static bytecode = _bytecode;
70238
70340
  static abi = _abi;
70239
70341
  static createInterface() {
70240
- return new import_ethers29.Interface(_abi);
70342
+ return new import_ethers30.Interface(_abi);
70241
70343
  }
70242
70344
  static connect(address, runner) {
70243
- return new import_ethers29.Contract(address, _abi, runner);
70345
+ return new import_ethers30.Contract(address, _abi, runner);
70244
70346
  }
70245
70347
  };
70246
70348
  var _abi2 = [
@@ -71935,7 +72037,7 @@ var _abi2 = [
71935
72037
  ];
71936
72038
  var _bytecode2 = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161304c90816100f0823960805181818161114401526113290152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a714611ff7575080630d33f3c214611fd35780630f3f4a9414611f885780631459457a14611be257806318c38b8914611ad15780631d44454114611a005780632106764c146119d9578063248a9ca3146119b35780632ec22d4c146118f25780632f0647ce146118775780632f2ff15d14611846578063324207441461177257806336568abe1461172c578063392f1087146116f65780633f4ba83a146115fe5780633f5aadc91461158f5780634f1ef286146112ad57806352340363146111c45780635273b6f61461119b57806352d1902d14611131578063554c4f4b146110a1578063561b7f8a14610f755780635bc26aea14610ee85780635c975abb14610eb85780636289d18c14610e375780636711cc0b14610e1b5780636e852a7814610d1a5780637e35bf6e14610ce65780638343f67414610cb95780638456cb5914610bc35780638f33527f14610b895780639010d07c14610b3557806391d1485414610adb5780639b9d30c114610ab2578063a19af3f614610a01578063a217fddf146109e5578063a3246ad314610923578063a878086414610907578063ac3c0e30146107fa578063ad3cb1cc146107b3578063b3fad6381461070e578063c34e9c26146106f2578063c86deb31146106d6578063ca15c8731461069d578063d547741f14610665578063dd71d99a14610623578063e0922fa114610576578063efa9b4ae14610507578063f2f4eb26146104de578063f68e9553146104b5578063f94f67ab146103de578063fd437d391461029f5763ffa1ad741461026657600080fd5b3461029a57600036600319011261029a576102966102826121ed565b6040519182916020835260208301906121c8565b0390f35b600080fd5b3461029a57606036600319011261029a576102b861207a565b6102c0612064565b906102c961218f565b906102d2612795565b6001600160a01b0316338190036103ce5780600052600160205260406000209283549360ff8560e01c1660038110156103b8576001036103a75781600160209261033e877fc5d5c5bbf10444998e0ea6d4725e79027b574e1c14ec929279e8a9a95c6c6e919688612c43565b818060a01b038316828060a01b031982541617815561035d878261239f565b0180546001600160401b031916426001600160401b03908116919091179091556001600160a01b0391821660008181526002855260409081902087905551969091168652951693a4005b632437e77160e11b60005260046000fd5b634e487b7160e01b600052602160045260246000fd5b62fca64560e31b60005260046000fd5b3461029a57604036600319011261029a576004356103fa6120c9565b90610403612795565b63ffffffff600554169163ffffffff8116928084109081156104ac575b5061049b5760207f6b7727cc9c3df4a29acf0afe01594c1b7e845d20f40f4a14e4c292164a9ed8e191610452846127e0565b9161046a600863ffffffff845460a01c1617836122e3565b81546001600160e01b031660e09190911b6001600160e01b0319161790556040519485526001600160a01b031693a3005b634346c13160e01b60005260046000fd5b90501584610420565b3461029a57600036600319011261029a576020604051600080516020612fe08339815191528152f35b3461029a57600036600319011261029a576003546040516001600160a01b039091168152602090f35b3461029a57602036600319011261029a57600435610523612795565b61054561052f826127e0565b9190600163ffffffff825460a01c1617906122e3565b6001600160a01b0316907f812690e0a9dff5bf3add998111b8af5c8299608d859025bfe35662060ab4267d600080a3005b3461029a57602036600319011261029a576004356001600160401b0381169081810361029a576000546001600160a01b038116330361061257600160a01b600160e01b0319811660a092831b600160a01b600160e01b031617600055604080519190921c6001600160401b0316815260208101929092527f9c195448332abd01f716db873b329752ea02f19d33f7e311fb0daf082c4edd0391a1005b6349db3bd360e01b60005260046000fd5b3461029a57602036600319011261029a576001600160a01b0361064461207a565b166000526002602052602060018060a01b0360406000205416604051908152f35b3461029a57604036600319011261029a5761069b600435610684612064565b90610696610691826122c2565b6126bf565b612751565b005b3461029a57602036600319011261029a57600435600052600080516020612ee08339815191526020526020604060002054604051908152f35b3461029a57600036600319011261029a57602060405160088152f35b3461029a57600036600319011261029a57602060405160028152f35b3461029a57602036600319011261029a576000606060405161072f81612136565b828152826020820152826040820152015260043560005260046020526080604060002063ffffffff6040519161076483612136565b548160018060a01b038216938481528160208201818560a01c16815260606040840193838760c01c168552019460e01c8552604051968752511660208601525116604084015251166060820152f35b3461029a57600036600319011261029a5761029660408051906107d68183612151565b60058252640352e302e360dc1b6020830152519182916020835260208301906121c8565b3461029a57602036600319011261029a5761081361207a565b6000608060405161082381612105565b828152826020820152826040820152826060820152015260018060a01b03166000526001602052604060002060405161085b81612105565b81546001600160a01b038116825260a081901c6001600160401b03166020830190815292604083019160e01c60ff169060038210156103b857908252600101546001600160401b0380821660608501908152604092831c821660808601908152925194516001600160a01b03168552945116602084015290519260038410156103b857604083019390935291516001600160401b0390811660608301529151909116608082015260a090f35b3461029a57600036600319011261029a57602060405160018152f35b3461029a57602036600319011261029a57600435600052600080516020612ee083398151915260205260406000206040518060208354918281520190819360005260206000209060005b8181106109cf5750505081610983910382612151565b6040519182916020830190602084525180915260408301919060005b8181106109ad575050500390f35b82516001600160a01b031684528594506020938401939092019160010161099f565b825484526020909301926001928301920161096d565b3461029a57600036600319011261029a57602060405160008152f35b3461029a57604036600319011261029a57600435610a1d6120c9565b90610a26612795565b63ffffffff600554169163ffffffff811692808410908115610aa9575b5061049b5760207f1da95b87b4c773f68c1447ffc5644e41a8a8887d55065beb64852014cf7140be91610a96610a78856127e0565b9290610a91600463ffffffff835460a01c1617826122e3565b612210565b6040519485526001600160a01b031693a3005b90501584610a43565b3461029a57600036600319011261029a576020604051600080516020612f208339815191528152f35b3461029a57604036600319011261029a57610af4612064565b600435600052600080516020612fc083398151915260205260406000209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b3461029a57604036600319011261029a57600435600052600080516020612ee08339815191526020526020610b706024356040600020612d0c565b905460405160039290921b1c6001600160a01b03168152f35b3461029a57602036600319011261029a576001600160a01b03610baa61207a565b1660005260026020526020604060002054604051908152f35b3461029a57600036600319011261029a573360009081527f0ac8cc3d209806126662940717264973110c39045b305f6ba49613325a615e09602052604090205460ff1615610c9257610c13612795565b600160ff19600080516020613000833981519152541617600080516020613000833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a2005b63e2517d3f60e01b60005233600452600080516020612f2083398151915260245260446000fd5b3461029a57600036600319011261029a5760005460405160a09190911c6001600160401b03168152602090f35b3461029a57604036600319011261029a57610d0a610d02612064565b60043561236c565b906102966040519283928361209a565b3461029a57604036600319011261029a57610d3361207a565b336000908152600080516020612f60833981519152602052604090205460ff161580610e08575b6103ce576001600160a01b03166000818152600160205260409020805460e01c60ff1660038110156103b8576001036103a757805460ff60e01b198116600160e11b1782556001919091018054600160401b600160801b03191642604090811b600160401b600160801b0316919091179091555160243581526001600160a01b0390911691907fc0499cc07ed9d734deec6857802d3f0fa8d5afaf79a7008beb8ba7bef62a271b90602090a3005b50336001600160a01b0382161415610d5a565b3461029a57600036600319011261029a57602060405160048152f35b3461029a57602036600319011261029a57610e506120b6565b6000546001600160a01b031633036106125763ffffffff8116908115610ea757600080516020612fa083398151915291610ea263ffffffff926005549284198416176005556040519384931683612233565b0390a1005b6338f3377360e21b60005260046000fd5b3461029a57600036600319011261029a57602060ff60008051602061300083398151915254166040519015158152f35b3461029a57602036600319011261029a57610f0161207a565b6000546001600160a01b0381169033829003610612576001600160a01b038316928315610f64573b15610f53576001600160a01b03191682176000908155600080516020612f808339815191529080a3005b636f7c43f160e01b60005260046000fd5b63e6c4247b60e01b60005260046000fd5b3461029a57606036600319011261029a57610f8e61207a565b610f96612064565b610f9e61218f565b91610fa7612795565b6001600160a01b031690338290036103ce57816000526001602052604060002060ff815460e01c1660038110156103b857600114611090578160209161100f867ff223dc085722c94c84dcf67427e225799be616382a2a484d378f8921c69a20339587612c43565b80546001600160a01b0319166001600160a01b038316178155611032868261239f565b6001810180546001600160801b031916426001600160401b0390811691909117909155815460ff60e01b1916600160e01b179091556001600160a01b03919091166000818152600284526040908190208690555195909116855293a3005b639d2c8fdf60e01b60005260046000fd5b3461029a57602036600319011261029a576001600160a01b036110c261207a565b166000526001602052604060002060ff60008051602061300083398151915254161580611115575b602091816110fe575b506040519015158152f35b5460a01c6001600160401b031642109050826110f3565b5060ff815460e01c169060038210156103b857906001146110ea565b3461029a57600036600319011261029a577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316300361118a576020604051600080516020612f408339815191528152f35b63703e46dd60e11b60005260046000fd5b3461029a57600036600319011261029a576000546040516001600160a01b039091168152602090f35b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b03831692831590811561129e575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff161580611283575b611272578061124563fffffffe61124b935460a01c16826122e3565b8261269b565b7fa5ffbdba01b15df97334e34ad816b9986b6057a5ddc97aba93b7e8ccd21759ed600080a3005b630a606ec360e11b60005260046000fd5b5082331415611229565b6360eb6c2360e01b60005260046000fd5b6001915060a01c1615846111fd565b604036600319011261029a576112c161207a565b602435906001600160401b03821161029a573660238301121561029a578160040135906112ed82612174565b916112fb6040519384612151565b8083526020830193366024838301011161029a57816000926024602093018737840101526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630811490811561156c575b5061118a576000546001600160a01b03163303610612576001600160a01b038116928315610f6457813b1561155b5730841461154c57600080516020612f4083398151915254846113a36121ed565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f6113d9604051926040845260408401906121c8565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481895afa60009181611518575b506114295785634c9c8ce360e01b60005260045260246000fd5b9081600080516020612f408339815191528793036115045750833b156114ef576001600160a01b0319168117600080516020612f40833981519152557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28251156114d4576000809161069b945190845af43d156114cc573d916114af83612174565b926114bd6040519485612151565b83523d6000602085013e612e7e565b606091612e7e565b505050346114de57005b63b398979f60e01b60005260046000fd5b50634c9c8ce360e01b60005260045260246000fd5b632a87526960e21b60005260045260246000fd5b9091506020813d602011611544575b8161153460209383612151565b8101031261029a5751908761140f565b3d9150611527565b614e8d60eb1b60005260046000fd5b632e07c4bd60e11b60005260046000fd5b600080516020612f40833981519152546001600160a01b03161415905084611354565b3461029a57602036600319011261029a576004356115ab612795565b6115cd6115b7826127e0565b9190600263ffffffff825460a01c1617906122e3565b6001600160a01b0316907fc2713e691344add4705edc62a0ee5aede95ba66ad68f97316efef9cb50644edd600080a3005b3461029a57600036600319011261029a57336000908152600080516020612f60833981519152602052604090205460ff1615806116e1575b6116d0576000805160206130008339815191525460ff8116156116bf5760ff1916600080516020613000833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a2005b638dfc202b60e01b60005260046000fd5b63659a07b360e11b60005260046000fd5b506000546001600160a01b0316331415611636565b3461029a57604036600319011261029a5761029661171d611715612064565b600435612306565b604093919351938493846120dc565b3461029a57604036600319011261029a57611745612064565b336001600160a01b038216036117615761069b90600435612751565b63334bd91960e11b60005260046000fd5b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b038316928315908115611837575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff16158061182d575b61127257806117f363fffffff7611806935460a01c16826122e3565b80546001600160e01b031681558261269b565b7f054490ec6650e07db9b97a06ea31d44cebd44b390c9975a380055e1b4d3cac21600080a3005b50823314156117d7565b6008915060a01c1615846117ab565b3461029a57604036600319011261029a5761069b600435611865612064565b90611872610691826122c2565b612709565b3461029a57602036600319011261029a576004356118c161189782612629565b91906118ad63fffffffb825460a01c16826122e3565b805463ffffffff60c01b191681558361269b565b6001600160a01b0316907f09cb4ec44cdef8489412844b9682f87f7900758fa2bd7e039113e9125e538e0f600080a3005b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b0383169283159081156119a4575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff16158061199a575b611272578061124563fffffffd611973935460a01c16826122e3565b7fb390ab029eab314bd18190ebe73d7e5c1c336beaa5c83ac22578378dc9ccc405600080a3005b5082331415611957565b6002915060a01c16158461192b565b3461029a57602036600319011261029a5760206119d16004356122c2565b604051908152f35b3461029a57604036600319011261029a5761029661171d6119f8612064565b60043561224a565b3461029a57604036600319011261029a57600435611a1c6120c9565b63ffffffff600554169063ffffffff811691808310908115611ac8575b5061049b57611a4783612629565b909263ffffffff845460c01c16809260018060a01b03163314159182611abd575b5050611aac57611a98827e8a218591d4362499c38c38eb1c12e7a7cc97a9068818d1fe6046a42ba4a5ba94612210565b611aa760405192839283612233565b0390a2005b634e80a40760e11b60005260046000fd5b111590508186611a68565b90501584611a39565b3461029a57602036600319011261029a57611aea6120b6565b6000805160206130208339815191525460ff8160401c16908115611bca575b50611bb957600080516020613020833981519152805460026001600160401b0319821681179092556000546001600160481b031990911690911791906001600160a01b031633036106125763ffffffff168015610ea757604081600080516020612fa08339815191529263ffffffff196005541617600555815190600082526020820152a160008051602061302083398151915255600080516020612f00833981519152602060405160028152a1005b63f92ee8a960e01b60005260046000fd5b60026001600160401b03919091161015905082611b09565b3461029a5760a036600319011261029a57611bfb61207a565b611c03612064565b906044356001600160a01b03811680820361029a576064356001600160a01b0381169182820361029a576084356001600160a01b038116949085900361029a5760008051602061302083398151915254604081901c60ff161596906001600160401b031680159081611f80575b6001149081611f76575b159081611f6d575b50611bb95760008051602061302083398151915280546001600160401b031916600117905586611f48575b611cb5612acc565b611cbd612acc565b611cc5612acc565b611ccd612acc565b6001600160a01b038116908115610f64578315610f64578515610f64576001600160a01b038916988915610f64573b15610f5357858414611f375762aa36a746148015611f2c575b8015611f21575b1580611f0f575b610f5357611d32906000612afa565b9081611ec8575b5015611e0d57611d5790600080516020612fe0833981519152612afa565b9081611e73575b5015611e0d57611d7c90600080516020612f20833981519152612afa565b9081611e1e575b5015611e0d57600080546001600160a01b031916841781556040519390600080516020612f808339815191528180a38015610f6457803b15610f5357600380546001600160a01b031916919091179055611dd957005b600080516020613020833981519152805460ff60401b1916905560018152600080516020612f0083398151915290602090a1005b63cf5a8e3360e01b60005260046000fd5b600080516020612f20833981519152600052600080516020612ee0833981519152602052611e6c907ffff5b43478fa6840382eb63777e0da6941d320b940e3f70f0ea4780feff95827612d3a565b5084611d83565b600080516020612fe0833981519152600052600080516020612ee0833981519152602052611ec1907f32d31393d541a265984ec379cddd8b1fcbe5f2b0eb8ad81dddfead454f135eaa612d3a565b5086611d5e565b60008052600080516020612ee0833981519152602052611f08907f615f0f9e84155bea8cc509fe18befeb1baf65611e38a6ba60964480fb29dfd44612d3a565b5088611d39565b50823b1580611d235750843b15611d23565b50617a694614611d1c565b506105394614611d15565b638135316560e01b60005260046000fd5b600080516020613020833981519152805460ff60401b1916600160401b179055611cad565b90501589611c82565b303b159150611c7a565b889150611c70565b3461029a57604036600319011261029a57610296611fbc611fa7612064565b600435600052600460205260406000206123c8565b611fc581612090565b60405191818392158361209a565b3461029a57600036600319011261029a57602063ffffffff60055416604051908152f35b3461029a57602036600319011261029a576004359063ffffffff60e01b821680920361029a57602091635a05180f60e01b8114908115612039575b5015158152f35b637965db0b60e01b811491508115612053575b5083612032565b6301ffc9a760e01b1490508361204c565b602435906001600160a01b038216820361029a57565b600435906001600160a01b038216820361029a57565b600811156103b857565b9015158152604081019291906020906120b283612090565b0152565b6004359063ffffffff8216820361029a57565b6024359063ffffffff8216820361029a57565b91604091949363ffffffff916060850196151585526120fa81612090565b602085015216910152565b60a081019081106001600160401b0382111761212057604052565b634e487b7160e01b600052604160045260246000fd5b608081019081106001600160401b0382111761212057604052565b601f909101601f19168101906001600160401b0382119082101761212057604052565b6001600160401b03811161212057601f01601f191660200190565b604435906001600160401b038216820361029a57565b60005b8381106121b85750506000910152565b81810151838201526020016121a8565b906020916121e1815180928185528580860191016121a5565b601f01601f1916010190565b604051906121fc604083612151565b60058252640322e312e360dc1b6020830152565b805463ffffffff60c01b191660c09290921b63ffffffff60c01b16919091179055565b63ffffffff91821681529116602082015260400190565b600052600460205261226160406000209182612485565b61226a81612090565b806122b857505460e01c63ffffffff60055416811580156122b0575b6122a35780821061229c57505b60019160009190565b9050612293565b5050600090600390600090565b508015612286565b6000929091508290565b600052600080516020612fc083398151915260205260016040600020015490565b805463ffffffff60a01b191660a09290921b63ffffffff60a01b16919091179055565b919091600052600460205261232060406000209283612511565b9161232a83612090565b826123625763ffffffff9192505460c01c1663ffffffff60055416811580156122b0576122a35780821061229c575060019160009190565b5060009190600090565b90612383916000526004602052604060002061259d565b61238c81612090565b8061239a5750600190600090565b600091565b8054600160a01b600160e01b03191660a09290921b600160a01b600160e01b0316919091179055565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6002161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b600790565b5050600690565b5050600590565b505050600490565b5050600390565b505050600290565b5050600190565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6008161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6004161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6001161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b6000908152600460205260409020805490916001600160a01b03821691821590811561268c575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff161580612682575b61127257565b508133141561267c565b6004915060a01c161538612650565b905460a01c63ffffffff16156126ae5750565b600052600460205260006040812055565b6000818152600080516020612fc08339815191526020908152604080832033845290915290205460ff16156126f15750565b63e2517d3f60e01b6000523360045260245260446000fd5b6127138282612afa565b918261271e57505090565b6000918252600080516020612ee0833981519152602052604090912061274d916001600160a01b031690612d3a565b5090565b61275b8282612ba3565b918261276657505090565b6000918252600080516020612ee0833981519152602052604090912061274d916001600160a01b031690612dab565b60ff60008051602061300083398151915254166127ae57565b63d93c066560e01b60005260046000fd5b519064ffffffffff8216820361029a57565b519061ffff8216820361029a57565b8015612abb57600354604051638d34875560e01b8152600481018390529190600090839060249082906001600160a01b03165afa918215612aaf57600092612904575b5060808201516001600160a01b0316913383900361127257610120015161284981612090565b61285281612090565b600381149081156128ef575b81156128db575b506128ca5781600052600160205260ff60406000205460e01c1660038110156103b8576001036128b957600090815260046020526040902080546001600160a01b0319166001600160a01b03831617815591565b632e68d1d360e21b60005260046000fd5b63e9f6db8560e01b60005260046000fd5b600791506128e881612090565b1438612865565b90506128fa81612090565b600581149061285e565b90913d8082843e6129158184612151565b820191602081840312612a8f578051906001600160401b038211612a975701906101a082840312612a8c57604051926101a084016001600160401b03811185821017612a9b5760409081528351855260208085015190860152838101519085015260608301516001600160401b038111612a9757830181601f82011215612a97578051906129a282612174565b926129b06040519485612151565b82845260208383010111612a9357906129cf91602080850191016121a5565b606084015260808201516001600160a01b0381168103612a8f5760808401526129fa60a083016127bf565b60a0840152612a0b60c083016127bf565b60c0840152612a1c60e083016127d1565b60e0840152612a2e61010083016127bf565b610100840152610120820151906008821015612a8c5750612a7f9161018091610120850152612a6061014082016127bf565b610140850152612a7361016082016127d1565b610160850152016127bf565b6101808201529038612823565b80fd5b5080fd5b8380fd5b8280fd5b634e487b7160e01b83526041600452602483fd5b6040513d6000823e3d90fd5b637bb0b62160e01b60005260046000fd5b60ff6000805160206130208339815191525460401c1615612ae957565b631afcd79f60e31b60005260046000fd5b6000818152600080516020612fc0833981519152602090815260408083206001600160a01b038616845290915290205460ff16612b9c576000818152600080516020612fc0833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050600090565b6000818152600080516020612fc0833981519152602090815260408083206001600160a01b038616845290915290205460ff1615612b9c576000818152600080516020612fc0833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b158015612cfb575b610f64576001600160a01b0316600090815260026020526040902054612cea576001600160401b031642811115612cd95760005460a01c6001600160401b03168015159182612cae575b5050612c9d57565b63e774e7b560e01b60005260046000fd5b909150428103908111612cc357113880612c95565b634e487b7160e01b600052601160045260246000fd5b63efa7aefd60e01b60005260046000fd5b633b53f64f60e21b60005260046000fd5b506001600160a01b03811615612c4b565b8054821015612d245760005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b6001810190826000528160205260406000205415600014612da3578054600160401b81101561212057612d8e612d77826001879401855584612d0c565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b505050600090565b9060018201918160005282602052604060002054801515600014612e75576000198101818111612cc3578254600019810191908211612cc357818103612e3e575b50505080548015612e28576000190190612e068282612d0c565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b612e5e612e4e612d779386612d0c565b90549060031b1c92839286612d0c565b905560005283602052604060002055388080612dec565b50505050600090565b90612ea45750805115612e9357602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580612ed6575b612eb5575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b15612ead56fec1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d275027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc07966f2ab141347034724e9b2a472c2f77f5cd745aeba27cacba797b8fcb708617dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846cd37bc77615afefc793aa17d75d4249a9b517ba91b0e54a49c9c4a44b3d7e228302dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800edcc084d3dcd65a1f7f23c65c46722faca6953d28e43150a467cf43e5c309238cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a164736f6c6343000822000a";
71937
72039
  var isSuperArgs2 = (xs) => xs.length > 1;
71938
- var AgentDelegationRegistry__factory = class extends import_ethers30.ContractFactory {
72040
+ var AgentDelegationRegistry__factory = class extends import_ethers31.ContractFactory {
71939
72041
  constructor(...args) {
71940
72042
  if (isSuperArgs2(args)) {
71941
72043
  super(...args);
@@ -71955,10 +72057,10 @@ var AgentDelegationRegistry__factory = class extends import_ethers30.ContractFac
71955
72057
  static bytecode = _bytecode2;
71956
72058
  static abi = _abi2;
71957
72059
  static createInterface() {
71958
- return new import_ethers30.Interface(_abi2);
72060
+ return new import_ethers31.Interface(_abi2);
71959
72061
  }
71960
72062
  static connect(address, runner) {
71961
- return new import_ethers30.Contract(
72063
+ return new import_ethers31.Contract(
71962
72064
  address,
71963
72065
  _abi2,
71964
72066
  runner
@@ -71972,7 +72074,7 @@ var POSITION_DELEGATE_REGISTRY_ABI = [
71972
72074
  "event PositionDelegateUpdated(bytes32 indexed positionId, address indexed oldDelegate, address indexed newDelegate)"
71973
72075
  ];
71974
72076
  async function setPositionDelegate(positionId, delegate, signer, registryAddress) {
71975
- const registry = new import_ethers31.Contract(
72077
+ const registry = new import_ethers32.Contract(
71976
72078
  registryAddress,
71977
72079
  POSITION_DELEGATE_REGISTRY_ABI,
71978
72080
  signer
@@ -71980,7 +72082,7 @@ async function setPositionDelegate(positionId, delegate, signer, registryAddress
71980
72082
  return registry["setPositionDelegate"](positionId, delegate);
71981
72083
  }
71982
72084
  async function getPositionDelegate(positionId, provider, registryAddress) {
71983
- const registry = new import_ethers31.Contract(
72085
+ const registry = new import_ethers32.Contract(
71984
72086
  registryAddress,
71985
72087
  POSITION_DELEGATE_REGISTRY_ABI,
71986
72088
  provider
@@ -72103,7 +72205,7 @@ var SIGNABLE_FUNCTIONS2 = [
72103
72205
  // this too is client-only and never module-whitelisted.
72104
72206
  "function addAddress(string btcAddress) external"
72105
72207
  ];
72106
- var IFACE2 = new import_ethers33.ethers.Interface(SIGNABLE_FUNCTIONS2);
72208
+ var IFACE2 = new import_ethers34.ethers.Interface(SIGNABLE_FUNCTIONS2);
72107
72209
  function encodeSignable2(fn, args) {
72108
72210
  return IFACE2.encodeFunctionData(fn, args);
72109
72211
  }
@@ -72128,7 +72230,7 @@ function eqAddr2(a, b) {
72128
72230
  if (!a || !b)
72129
72231
  return false;
72130
72232
  try {
72131
- return import_ethers34.ethers.getAddress(a) === import_ethers34.ethers.getAddress(b);
72233
+ return import_ethers35.ethers.getAddress(a) === import_ethers35.ethers.getAddress(b);
72132
72234
  } catch {
72133
72235
  return false;
72134
72236
  }
@@ -72194,7 +72296,7 @@ function readValue2(tx2) {
72194
72296
  }
72195
72297
  function normalizePositionId2(id) {
72196
72298
  const hex = id.startsWith("0x") ? id : `0x${id}`;
72197
- return import_ethers34.ethers.zeroPadValue(hex, 32).toLowerCase();
72299
+ return import_ethers35.ethers.zeroPadValue(hex, 32).toLowerCase();
72198
72300
  }
72199
72301
  function requirePositionId(actual, expected) {
72200
72302
  const txPositionId = String(actual).toLowerCase();
@@ -72486,18 +72588,18 @@ function buildPsmRedeemTx2(p) {
72486
72588
  var PSM_READS_ABI = ["function supportedStablecoins(address) view returns (bool)"];
72487
72589
  var ERC20_READS_ABI = ["function allowance(address owner, address spender) view returns (uint256)"];
72488
72590
  function psmExchangeReadsFromProvider(provider, psmAddress) {
72489
- const psm = new import_ethers32.ethers.Contract(psmAddress, PSM_READS_ABI, provider);
72591
+ const psm = new import_ethers33.ethers.Contract(psmAddress, PSM_READS_ABI, provider);
72490
72592
  return {
72491
72593
  isStablecoinSupported: async (stablecoin) => await psm.getFunction("supportedStablecoins")(stablecoin),
72492
- allowance: async (token, owner, spender) => await new import_ethers32.ethers.Contract(token, ERC20_READS_ABI, provider).getFunction("allowance")(owner, spender)
72594
+ allowance: async (token, owner, spender) => await new import_ethers33.ethers.Contract(token, ERC20_READS_ABI, provider).getFunction("allowance")(owner, spender)
72493
72595
  };
72494
72596
  }
72495
72597
  var refuse = (direction, msg) => new TxValidationError2(msg, `PSM ${direction}`);
72496
72598
  function requireAddress(direction, label, value) {
72497
- if (!value || !import_ethers32.ethers.isAddress(value)) {
72599
+ if (!value || !import_ethers33.ethers.isAddress(value)) {
72498
72600
  throw refuse(direction, `${label} address is missing or invalid (${String(value)})`);
72499
72601
  }
72500
- return import_ethers32.ethers.getAddress(value);
72602
+ return import_ethers33.ethers.getAddress(value);
72501
72603
  }
72502
72604
  async function planPsmExchange(params) {
72503
72605
  const { direction, amountIn, minOut, vctx, reads } = params;
@@ -73062,7 +73164,7 @@ function contractErrorTable() {
73062
73164
  if (TABLE)
73063
73165
  return TABLE;
73064
73166
  const table2 = /* @__PURE__ */ new Map();
73065
- const iface = new import_ethers35.Interface(CONTRACT_ERROR_FRAGMENTS.map((e) => e.fragment));
73167
+ const iface = new import_ethers36.Interface(CONTRACT_ERROR_FRAGMENTS.map((e) => e.fragment));
73066
73168
  const contractsByName = new Map(
73067
73169
  CONTRACT_ERROR_FRAGMENTS.map((e) => [e.fragment.slice("error ".length, e.fragment.indexOf("(")), e.contracts])
73068
73170
  );
@@ -73155,7 +73257,7 @@ function decodeContractError(error) {
73155
73257
  const contract = entry.contracts.join(" | ");
73156
73258
  let args = [];
73157
73259
  try {
73158
- const decoded = new import_ethers35.Interface([entry.fragment]).decodeErrorResult(entry.fragment, errorData);
73260
+ const decoded = new import_ethers36.Interface([entry.fragment]).decodeErrorResult(entry.fragment, errorData);
73159
73261
  args = Array.from(decoded);
73160
73262
  } catch {
73161
73263
  args = [];
@@ -73714,7 +73816,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
73714
73816
  */
73715
73817
  constructor(config) {
73716
73818
  if (!config.provider && config.ethRpcUrl) {
73717
- config.provider = new import_ethers14.JsonRpcProvider(config.ethRpcUrl);
73819
+ config.provider = new import_ethers15.JsonRpcProvider(config.ethRpcUrl);
73718
73820
  }
73719
73821
  this.config = config;
73720
73822
  if (config.debug) {
@@ -74007,7 +74109,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
74007
74109
  const network = await config.provider.getNetwork();
74008
74110
  chainId = Number(network.chainId);
74009
74111
  } else if (config.ethRpcUrl) {
74010
- const tempProvider = new import_ethers14.JsonRpcProvider(
74112
+ const tempProvider = new import_ethers15.JsonRpcProvider(
74011
74113
  config.ethRpcUrl
74012
74114
  );
74013
74115
  const network = await tempProvider.getNetwork();
@@ -74553,7 +74655,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
74553
74655
  }
74554
74656
  const loanOps = this.loanOps();
74555
74657
  const protocolConfig = await loanOps.getProtocolConfig();
74556
- const requestAmountWei = (0, import_ethers14.parseEther)(
74658
+ const requestAmountWei = (0, import_ethers15.parseEther)(
74557
74659
  request.amount.toString()
74558
74660
  );
74559
74661
  const minLoanValueWei = BigInt(protocolConfig.minimumLoanValueWei);
@@ -74655,12 +74757,12 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
74655
74757
  );
74656
74758
  return {
74657
74759
  success: false,
74658
- error: `Amount ${request.amount} UCD plus the ${positionTerm.originationFeeBps / 100}% origination fee (${(0, import_ethers14.formatEther)(baseFeeWei)} UCD) would take this loan's debt to ${(0, import_ethers14.formatEther)(debtAfterWei)} UCD, above the protocol maximum of ${(0, import_ethers14.formatEther)(maxLoanValueWei)} UCD. The largest amount you can mint now is ${maxPrincipalUcd} UCD.`
74760
+ error: `Amount ${request.amount} UCD plus the ${positionTerm.originationFeeBps / 100}% origination fee (${(0, import_ethers15.formatEther)(baseFeeWei)} UCD) would take this loan's debt to ${(0, import_ethers15.formatEther)(debtAfterWei)} UCD, above the protocol maximum of ${(0, import_ethers15.formatEther)(maxLoanValueWei)} UCD. The largest amount you can mint now is ${maxPrincipalUcd} UCD.`
74659
74761
  };
74660
74762
  }
74661
74763
  if (this.config.debug) {
74662
74764
  log.info(
74663
- `\u2705 Fee-inclusive loan cap check passed: ${(0, import_ethers14.formatEther)(currentDebtWei + requestAmountWei + baseFeeWei)} UCD <= ${(0, import_ethers14.formatEther)(maxLoanValueWei)} UCD`,
74765
+ `\u2705 Fee-inclusive loan cap check passed: ${(0, import_ethers15.formatEther)(currentDebtWei + requestAmountWei + baseFeeWei)} UCD <= ${(0, import_ethers15.formatEther)(maxLoanValueWei)} UCD`,
74664
74766
  {}
74665
74767
  );
74666
74768
  }
@@ -74691,7 +74793,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
74691
74793
  pkpNftAddress,
74692
74794
  this.getChipotlePublicKeyFallback()
74693
74795
  );
74694
- pkpEthAddress = (0, import_ethers14.computeAddress)(pkpPublicKey);
74796
+ pkpEthAddress = (0, import_ethers15.computeAddress)(pkpPublicKey);
74695
74797
  pkpCache.set(request.positionId, {
74696
74798
  publicKey: pkpPublicKey,
74697
74799
  ethAddress: pkpEthAddress,
@@ -75034,8 +75136,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
75034
75136
  throw new Error(`Position not found: ${request.positionId}`);
75035
75137
  }
75036
75138
  const currentDebt = position.ucdDebt.toString();
75037
- const ucdDebtHash = (0, import_ethers14.keccak256)(import_ethers14.AbiCoder.defaultAbiCoder().encode(["uint256"], [currentDebt]));
75038
- const contractHash = (0, import_ethers14.keccak256)(import_ethers14.AbiCoder.defaultAbiCoder().encode(
75139
+ const ucdDebtHash = (0, import_ethers15.keccak256)(import_ethers15.AbiCoder.defaultAbiCoder().encode(["uint256"], [currentDebt]));
75140
+ const contractHash = (0, import_ethers15.keccak256)(import_ethers15.AbiCoder.defaultAbiCoder().encode(
75039
75141
  ["address", "address", "address", "address"],
75040
75142
  [
75041
75143
  positionManagerAddress,
@@ -75104,7 +75206,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
75104
75206
  const coreAbi = [
75105
75207
  "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, uint40 previousExpiryAt, uint16 totalTerm))"
75106
75208
  ];
75107
- const positionCore = new import_ethers14.Contract(
75209
+ const positionCore = new import_ethers15.Contract(
75108
75210
  coreAddress,
75109
75211
  coreAbi,
75110
75212
  this.getSignerOrThrow().provider
@@ -75112,8 +75214,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
75112
75214
  const currentPosition = await positionCore["getPositionDetails"](
75113
75215
  positionIdBytes32
75114
75216
  );
75115
- const currentDebtHash = (0, import_ethers14.keccak256)(
75116
- import_ethers14.AbiCoder.defaultAbiCoder().encode(
75217
+ const currentDebtHash = (0, import_ethers15.keccak256)(
75218
+ import_ethers15.AbiCoder.defaultAbiCoder().encode(
75117
75219
  ["uint256"],
75118
75220
  [currentPosition.ucdDebt]
75119
75221
  )
@@ -75160,7 +75262,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
75160
75262
  "function getCurrentQuantum() view returns (uint256)",
75161
75263
  "function isQuantumValid(bytes32,uint256) view returns (bool)"
75162
75264
  ];
75163
- const registry = new import_ethers14.Contract(
75265
+ const registry = new import_ethers15.Contract(
75164
75266
  registryAddress,
75165
75267
  registryAbi,
75166
75268
  this.getSignerOrThrow().provider
@@ -75276,7 +75378,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
75276
75378
  });
75277
75379
  }
75278
75380
  const signatureHexMint = finalSignature.startsWith("0x") ? finalSignature : "0x" + finalSignature;
75279
- const mintIface = new import_ethers14.Interface(positionManagerAbi);
75381
+ const mintIface = new import_ethers15.Interface(positionManagerAbi);
75280
75382
  const mintCalldata = mintIface.encodeFunctionData("mintUCD", [
75281
75383
  positionIdBytes32,
75282
75384
  validationResponse.mintAmount,
@@ -75312,7 +75414,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
75312
75414
  if (viewsAddress) {
75313
75415
  let diagnosis = null;
75314
75416
  try {
75315
- const views = new import_ethers14.Contract(
75417
+ const views = new import_ethers15.Contract(
75316
75418
  viewsAddress,
75317
75419
  [
75318
75420
  "function diagnoseMintUCD(bytes32,uint256,uint256,uint256,uint256,uint256,bytes32,bytes32,bytes32,uint256,bytes) view returns (string)"
@@ -75370,7 +75472,7 @@ MintGuardFailed(${guardCode}): ${guardMeaning}
75370
75472
  Lit mintAmount: ${validationResponse.mintAmount}
75371
75473
  Lit mintFee: ${validationResponse.mintFee}
75372
75474
  Lit newDebt: ${validationResponse.newDebt}
75373
- Protocol maximum: ${(0, import_ethers14.formatEther)(maxLoanValueWei)} UCD (fee-inclusive)`;
75475
+ Protocol maximum: ${(0, import_ethers15.formatEther)(maxLoanValueWei)} UCD (fee-inclusive)`;
75374
75476
  }
75375
75477
  const mintDebtDiagnostics = selector === "0xb9d419a7" || // DebtUpdateVerificationFailed()
75376
75478
  selector === "0xc7e20553" || // DebtUpdateVerificationFailedDetailed(...)
@@ -75441,7 +75543,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
75441
75543
  if (receipt.logs && receipt.logs.length > 0) {
75442
75544
  for (const receiptLog of receipt.logs) {
75443
75545
  if (receiptLog.topics && receiptLog.topics[0] === "0x08c379a0") {
75444
- const iface = new import_ethers14.Interface([
75546
+ const iface = new import_ethers15.Interface([
75445
75547
  "error Error(string)"
75446
75548
  ]);
75447
75549
  const decoded = iface.decodeErrorResult("Error", receiptLog.data);
@@ -75458,7 +75560,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
75458
75560
  const minimalAbi = [
75459
75561
  "event UCDMintedWithAuthorization(bytes32 indexed positionId, address indexed borrower, uint256 mintAmount, uint256 mintFee, uint256 newDebt, uint256 newCollateral, uint256 btcPrice, uint256 quantumTimestamp, bytes32 authorizedSpendsHash)"
75460
75562
  ];
75461
- const iface = new import_ethers14.Interface(minimalAbi);
75563
+ const iface = new import_ethers15.Interface(minimalAbi);
75462
75564
  for (const receiptLog of receipt.logs) {
75463
75565
  const parsed = (() => {
75464
75566
  const logIface = iface;
@@ -75626,7 +75728,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
75626
75728
  pkpNftAddress,
75627
75729
  this.getChipotlePublicKeyFallback()
75628
75730
  );
75629
- const pkpEthAddress = (0, import_ethers14.computeAddress)(pkpPublicKey);
75731
+ const pkpEthAddress = (0, import_ethers15.computeAddress)(pkpPublicKey);
75630
75732
  pkpData = {
75631
75733
  publicKey: pkpPublicKey,
75632
75734
  ethAddress: pkpEthAddress,
@@ -76024,7 +76126,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
76024
76126
  }
76025
76127
  const loanOpsForUcd = loanOpsForUcdResult.value;
76026
76128
  const ucdTokenAddress = await loanOpsForUcd.ucdToken();
76027
- const ucdToken = new import_ethers14.Contract(
76129
+ const ucdToken = new import_ethers15.Contract(
76028
76130
  ucdTokenAddress,
76029
76131
  [
76030
76132
  "function balanceOf(address) view returns (uint256)",
@@ -76040,9 +76142,9 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
76040
76142
  if (ucdBalance < debtWei) {
76041
76143
  return {
76042
76144
  success: false,
76043
- error: `Insufficient UCD balance for liquidation: ${(0, import_ethers14.formatEther)(
76145
+ error: `Insufficient UCD balance for liquidation: ${(0, import_ethers15.formatEther)(
76044
76146
  ucdBalance
76045
- )} UCD (need ${(0, import_ethers14.formatEther)(debtWei)} UCD)`,
76147
+ )} UCD (need ${(0, import_ethers15.formatEther)(debtWei)} UCD)`,
76046
76148
  positionId: request.positionId,
76047
76149
  wasLiquidated: false
76048
76150
  };
@@ -76051,7 +76153,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
76051
76153
  if (request.skipUcdApproval) {
76052
76154
  return {
76053
76155
  success: false,
76054
- error: `Insufficient UCD allowance for UCDController: need at least ${(0, import_ethers14.formatEther)(
76156
+ error: `Insufficient UCD allowance for UCDController: need at least ${(0, import_ethers15.formatEther)(
76055
76157
  debtWei
76056
76158
  )} UCD, or omit skipUcdApproval to let the SDK submit approve`,
76057
76159
  positionId: request.positionId,
@@ -76581,7 +76683,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
76581
76683
  if (typeof signatureBytes === "string" && signatureBytes.startsWith("{")) {
76582
76684
  try {
76583
76685
  const parsed = JSON.parse(signatureBytes);
76584
- signatureBytes = parsed.signature ?? (parsed.r && parsed.s && parsed.v ? import_ethers14.Signature.from({
76686
+ signatureBytes = parsed.signature ?? (parsed.r && parsed.s && parsed.v ? import_ethers15.Signature.from({
76585
76687
  r: parsed.r,
76586
76688
  s: parsed.s,
76587
76689
  v: parsed.v
@@ -76592,7 +76694,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
76592
76694
  if (!signatureBytes.startsWith("0x")) {
76593
76695
  signatureBytes = "0x" + signatureBytes;
76594
76696
  }
76595
- const extendIface = new import_ethers14.Interface([
76697
+ const extendIface = new import_ethers15.Interface([
76596
76698
  "function extendPosition(bytes32 positionId, uint256 selectedTerm, uint256 quantumTimestamp, uint256 btcPrice, uint256 availableBTCBalance, uint256 proRataRenewalFee, bytes calldata extensionValidatorSignature) external returns (bool)"
76597
76699
  ]);
76598
76700
  const extendCalldata = extendIface.encodeFunctionData("extendPosition", [
@@ -77147,7 +77249,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
77147
77249
  ` Converting payment amount: ${request.paymentAmount} (type: ${typeof request.paymentAmount})`
77148
77250
  );
77149
77251
  }
77150
- const paymentAmountWei = (0, import_ethers14.parseEther)(
77252
+ const paymentAmountWei = (0, import_ethers15.parseEther)(
77151
77253
  request.paymentAmount.toString()
77152
77254
  );
77153
77255
  if (this.config.debug) {
@@ -77214,7 +77316,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
77214
77316
  };
77215
77317
  }
77216
77318
  const ucdTokenAddress = await loanOps.ucdToken();
77217
- const ucdToken = new import_ethers14.Contract(
77319
+ const ucdToken = new import_ethers15.Contract(
77218
77320
  ucdTokenAddress,
77219
77321
  [
77220
77322
  "function balanceOf(address) view returns (uint256)",
@@ -77238,14 +77340,14 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
77238
77340
  ]);
77239
77341
  if (this.config.debug) {
77240
77342
  log.info(` UCD funds source: ${fundsSource}${isSelfRepay ? " (self)" : " (borrower; agent submitting)"}`);
77241
- log.info(` UCD Balance: ${(0, import_ethers14.formatEther)(balance)} UCD`);
77242
- log.info(` UCD Allowance: ${(0, import_ethers14.formatEther)(allowance)} UCD`);
77343
+ log.info(` UCD Balance: ${(0, import_ethers15.formatEther)(balance)} UCD`);
77344
+ log.info(` UCD Allowance: ${(0, import_ethers15.formatEther)(allowance)} UCD`);
77243
77345
  log.info(` Required: ${request.paymentAmount} UCD`);
77244
77346
  }
77245
77347
  if (balance < paymentAmountWei) {
77246
77348
  return {
77247
77349
  success: false,
77248
- error: `Insufficient UCD balance: ${(0, import_ethers14.formatEther)(
77350
+ error: `Insufficient UCD balance: ${(0, import_ethers15.formatEther)(
77249
77351
  balance
77250
77352
  )} UCD (need ${request.paymentAmount} UCD)${isSelfRepay ? "" : ` \u2014 borrower ${fundsSource} lacks funds`}`
77251
77353
  };
@@ -77254,7 +77356,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
77254
77356
  if (!isSelfRepay) {
77255
77357
  return {
77256
77358
  success: false,
77257
- error: `Borrower ${fundsSource} has insufficient UCD allowance to PositionManager (${(0, import_ethers14.formatEther)(allowance)} UCD, need ${request.paymentAmount}). The borrower must approve PositionManager before a delegated agent can repay.`
77359
+ error: `Borrower ${fundsSource} has insufficient UCD allowance to PositionManager (${(0, import_ethers15.formatEther)(allowance)} UCD, need ${request.paymentAmount}). The borrower must approve PositionManager before a delegated agent can repay.`
77258
77360
  };
77259
77361
  }
77260
77362
  if (this.config.debug) {
@@ -77523,7 +77625,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
77523
77625
  const paymentSigner = this.getSignerOrThrow();
77524
77626
  const paymentFrom = await paymentSigner.getAddress();
77525
77627
  const paymentProvider = contractManager.getProvider();
77526
- const paymentIface = new import_ethers14.Interface([
77628
+ const paymentIface = new import_ethers15.Interface([
77527
77629
  "function makePayment(bytes32 positionId, uint256 paymentAmount, uint256 quantumTimestamp, uint256 btcPrice, bytes calldata paymentValidatorSignature) external returns (bool)"
77528
77630
  ]);
77529
77631
  const paymentCalldata = paymentIface.encodeFunctionData("makePayment", [
@@ -77872,7 +77974,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
77872
77974
  const pkpId = position.pkpId;
77873
77975
  if (litValidatorAddr && pkpId) {
77874
77976
  try {
77875
- const litValidator = new import_ethers14.Contract(
77977
+ const litValidator = new import_ethers15.Contract(
77876
77978
  litValidatorAddr,
77877
77979
  ["function pkpOwners(bytes32) view returns (address)"],
77878
77980
  this.getProviderOrThrow()
@@ -77880,7 +77982,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
77880
77982
  const owner = await litValidator.pkpOwners(
77881
77983
  pkpId
77882
77984
  );
77883
- if (owner && owner !== import_ethers14.ZeroAddress) {
77985
+ if (owner && owner !== import_ethers15.ZeroAddress) {
77884
77986
  controller = owner;
77885
77987
  }
77886
77988
  } catch {
@@ -77932,7 +78034,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
77932
78034
  pkpNftAddress,
77933
78035
  this.getChipotlePublicKeyFallback()
77934
78036
  );
77935
- pkpEthAddress = (0, import_ethers14.computeAddress)(pkpPublicKey);
78037
+ pkpEthAddress = (0, import_ethers15.computeAddress)(pkpPublicKey);
77936
78038
  pkpCache.set(positionId, {
77937
78039
  publicKey: pkpPublicKey,
77938
78040
  ethAddress: pkpEthAddress,
@@ -78305,7 +78407,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
78305
78407
  utxoVout: withdrawalParams.utxoVout
78306
78408
  });
78307
78409
  }
78308
- const withdrawIface = new import_ethers14.Interface([
78410
+ const withdrawIface = new import_ethers15.Interface([
78309
78411
  "function withdrawBTC((bytes32 positionId, bytes32 actionHash, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, bytes32 contractBundleHash, string withdrawalAddress, uint256 totalDeduction, uint256 newCollateral, uint256 quantumTimestamp, uint256 btcPrice, string utxoTxid, uint32 utxoVout) params, bytes withdrawalValidatorSignature, bytes btcSpendAuthSignature) external returns (bool)"
78310
78412
  ]);
78311
78413
  const withdrawCalldata = withdrawIface.encodeFunctionData("withdrawBTC", [
@@ -78536,7 +78638,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
78536
78638
  }
78537
78639
  const pkpId = positionDetails.pkpId;
78538
78640
  const vaultAddress = positionDetails.vaultAddress;
78539
- if (!pkpId || pkpId === import_ethers14.ZeroHash) {
78641
+ if (!pkpId || pkpId === import_ethers15.ZeroHash) {
78540
78642
  return { success: false, error: "Position has no PKP" };
78541
78643
  }
78542
78644
  if (!vaultAddress) {
@@ -78556,7 +78658,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
78556
78658
  if (!publicKey) {
78557
78659
  return { success: false, error: "Failed to resolve PKP public key" };
78558
78660
  }
78559
- const chipotlePkpAddress = (0, import_ethers14.computeAddress)(publicKey);
78661
+ const chipotlePkpAddress = (0, import_ethers15.computeAddress)(publicKey);
78560
78662
  const chainName = LIT_ACTION_CHAIN_NAMES[chainId];
78561
78663
  if (!chainName) {
78562
78664
  return {
@@ -78940,7 +79042,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
78940
79042
  const btcSpendAuthorizerAbi = [
78941
79043
  "function getAuthorizedSpends(bytes32) view returns (tuple(string txid, uint32 vout, uint256 satoshis, string targetAddress, uint256 targetAmount, uint256 authorizedAt)[])"
78942
79044
  ];
78943
- const btcSpendAuthorizer = new import_ethers14.Contract(
79045
+ const btcSpendAuthorizer = new import_ethers15.Contract(
78944
79046
  btcSpendAuthorizerAddress,
78945
79047
  btcSpendAuthorizerAbi,
78946
79048
  this.getProviderOrThrow()
@@ -79026,7 +79128,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
79026
79128
  const abi = [
79027
79129
  "function getAuthorizedSpends(bytes32) view returns (tuple(string txid, uint32 vout, uint256 satoshis, string targetAddress, uint256 targetAmount, uint256 authorizedAt)[])"
79028
79130
  ];
79029
- const contract = new import_ethers14.Contract(
79131
+ const contract = new import_ethers15.Contract(
79030
79132
  btcSpendAuthorizerAddress,
79031
79133
  abi,
79032
79134
  this.getProviderOrThrow()
@@ -79040,7 +79142,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
79040
79142
  targetAddress: spend.targetAddress,
79041
79143
  targetAmount: Number(spend.targetAmount),
79042
79144
  authorizedAt: Number(spend.authorizedAt),
79043
- utxoKey: (0, import_ethers14.solidityPackedKeccak256)(
79145
+ utxoKey: (0, import_ethers15.solidityPackedKeccak256)(
79044
79146
  ["string", "uint32"],
79045
79147
  [spend.txid, Number(spend.vout)]
79046
79148
  )
@@ -79246,7 +79348,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
79246
79348
  error: attRes.error ?? attRes.reason ?? `LIT recovery attestation rejected${attRes.failedStep ? ` at step ${attRes.failedStep}` : ""}`
79247
79349
  };
79248
79350
  }
79249
- const btcSpendAuthorizer = new import_ethers14.Contract(
79351
+ const btcSpendAuthorizer = new import_ethers15.Contract(
79250
79352
  btcSpendAuthorizerAddress,
79251
79353
  [
79252
79354
  "function cancelStaleSpendWithProof(bytes32 positionId, bytes32 utxoKey, uint256 authorizedAt, string calldata invalidatorTxid, uint256 attestationTimestamp, bytes calldata litSignature) external"
@@ -79343,7 +79445,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
79343
79445
  const positionDetails = await this.getPositionDetailsView(
79344
79446
  params.positionId
79345
79447
  );
79346
- if (!positionDetails?.pkpId || positionDetails.pkpId === import_ethers14.ZeroHash) {
79448
+ if (!positionDetails?.pkpId || positionDetails.pkpId === import_ethers15.ZeroHash) {
79347
79449
  return { success: false, error: "Position has no PKP" };
79348
79450
  }
79349
79451
  const pkpCache = this.cacheManager.getCache("pkp-data", {
@@ -79360,7 +79462,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
79360
79462
  if (!publicKey) {
79361
79463
  return { success: false, error: "Failed to resolve PKP public key" };
79362
79464
  }
79363
- const chipotlePkpAddress = (0, import_ethers14.computeAddress)(publicKey);
79465
+ const chipotlePkpAddress = (0, import_ethers15.computeAddress)(publicKey);
79364
79466
  const dc = this.config.contractAddresses || {};
79365
79467
  const chainName = chainId === 1 ? "ethereum" : chainId === 11155111 ? "sepolia" : chainId === 1337 || chainId === 31337 ? "hardhat" : void 0;
79366
79468
  if (!chainName) {
@@ -80060,7 +80162,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
80060
80162
  *
80061
80163
  * Deliberately omits `minWithdrawRatioBps` — see {@link readLoanGrant}.
80062
80164
  */
80063
- static LOAN_GRANT_PREFIX_IFACE = new import_ethers14.Interface([
80165
+ static LOAN_GRANT_PREFIX_IFACE = new import_ethers15.Interface([
80064
80166
  "function getLoanGrant(bytes32 positionId) view returns (address borrower, uint32 scopeBits, uint32 minCollateralRatioBps)"
80065
80167
  ]);
80066
80168
  /**
@@ -80081,9 +80183,9 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
80081
80183
  to: registryAddress,
80082
80184
  data: iface.encodeFunctionData("getLoanGrant", [pid])
80083
80185
  });
80084
- if ((0, import_ethers14.getBytes)(data).length < 96) {
80186
+ if ((0, import_ethers15.getBytes)(data).length < 96) {
80085
80187
  throw new SDKError({
80086
- message: `AgentDelegationRegistry at ${registryAddress} returned ${(0, import_ethers14.getBytes)(data).length} bytes for getLoanGrant(bytes32) \u2014 expected at least 96. Wrong address, or a registry version this SDK does not support.`,
80188
+ message: `AgentDelegationRegistry at ${registryAddress} returned ${(0, import_ethers15.getBytes)(data).length} bytes for getLoanGrant(bytes32) \u2014 expected at least 96. Wrong address, or a registry version this SDK does not support.`,
80087
80189
  category: "CONTRACT",
80088
80190
  severity: "HIGH"
80089
80191
  /* HIGH */
@@ -80093,10 +80195,10 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
80093
80195
  "getLoanGrant",
80094
80196
  data
80095
80197
  );
80096
- const raw = (0, import_ethers14.getBytes)(data);
80198
+ const raw = (0, import_ethers15.getBytes)(data);
80097
80199
  const withdrawScopeSupported = raw.length >= 128;
80098
80200
  const minWithdrawRatioBps = withdrawScopeSupported ? Number(
80099
- import_ethers14.AbiCoder.defaultAbiCoder().decode(["uint32"], raw.slice(96, 128))[0]
80201
+ import_ethers15.AbiCoder.defaultAbiCoder().decode(["uint32"], raw.slice(96, 128))[0]
80100
80202
  ) : 0;
80101
80203
  return {
80102
80204
  borrower,
@@ -80261,7 +80363,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
80261
80363
  getPositionDelegate(pid, signer, pdrAddr),
80262
80364
  registry.agentOf(user).then((a) => a.agent)
80263
80365
  ]);
80264
- if (currentDelegate !== import_ethers14.ZeroAddress && currentDelegate.toLowerCase() === userAgent.toLowerCase()) {
80366
+ if (currentDelegate !== import_ethers15.ZeroAddress && currentDelegate.toLowerCase() === userAgent.toLowerCase()) {
80265
80367
  const clearTx = await setPositionDelegate(
80266
80368
  pid,
80267
80369
  "0x0000000000000000000000000000000000000000",
@@ -80658,7 +80760,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
80658
80760
  const maxUcdWhole = BigInt(result[3].toString());
80659
80761
  return success({
80660
80762
  liquidationThreshold: result[0].toString(),
80661
- minimumLoanValueUcd: (0, import_ethers14.formatUnits)(result[2], 18),
80763
+ minimumLoanValueUcd: (0, import_ethers15.formatUnits)(result[2], 18),
80662
80764
  minimumLoanValueWei: result[2].toString(),
80663
80765
  maxSingleLoanValueUcd: maxUcdWhole.toString(),
80664
80766
  maxSingleLoanValueWei: (maxUcdWhole * 10n ** 18n).toString()
@@ -80695,7 +80797,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
80695
80797
  const balanceWei = await provider.getBalance(address);
80696
80798
  return success({
80697
80799
  balanceWei: balanceWei.toString(),
80698
- balanceEth: (0, import_ethers14.formatEther)(balanceWei)
80800
+ balanceEth: (0, import_ethers15.formatEther)(balanceWei)
80699
80801
  });
80700
80802
  } catch (error) {
80701
80803
  return failure(new SDKError({
@@ -81104,7 +81206,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
81104
81206
  * Convert decimal position ID to bytes32 format
81105
81207
  */
81106
81208
  toBytes32(value) {
81107
- return (0, import_ethers14.zeroPadValue)((0, import_ethers14.toBeHex)(BigInt(value)), 32);
81209
+ return (0, import_ethers15.zeroPadValue)((0, import_ethers15.toBeHex)(BigInt(value)), 32);
81108
81210
  }
81109
81211
  /**
81110
81212
  * Check if an error indicates a technical failure vs business logic rejection
@@ -81145,7 +81247,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
81145
81247
  const coreModuleAbi = [
81146
81248
  "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, uint40 previousExpiryAt, uint16 totalTerm))"
81147
81249
  ];
81148
- const coreModule = new import_ethers14.Contract(
81250
+ const coreModule = new import_ethers15.Contract(
81149
81251
  coreModuleAddress,
81150
81252
  coreModuleAbi,
81151
81253
  provider
@@ -81212,7 +81314,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
81212
81314
  const corePositionAbi = [
81213
81315
  "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, uint40 previousExpiryAt, uint16 totalTerm))"
81214
81316
  ];
81215
- const corePositionContract = new import_ethers14.Contract(
81317
+ const corePositionContract = new import_ethers15.Contract(
81216
81318
  coreAddress,
81217
81319
  corePositionAbi,
81218
81320
  provider
@@ -81223,7 +81325,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
81223
81325
  positionIdBytes32
81224
81326
  );
81225
81327
  const positionIdFromCore = corePosition?.positionId || corePosition?.[0] || null;
81226
- if (positionIdFromCore && positionIdFromCore !== import_ethers14.ZeroHash && positionIdFromCore !== "0x0000000000000000000000000000000000000000000000000000000000000000") {
81328
+ if (positionIdFromCore && positionIdFromCore !== import_ethers15.ZeroHash && positionIdFromCore !== "0x0000000000000000000000000000000000000000000000000000000000000000") {
81227
81329
  if (this.config.debug) {
81228
81330
  log.info("Position exists in core contract", {
81229
81331
  positionId,
@@ -81291,7 +81393,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
81291
81393
  throw new Error("loanOperationsManager address not configured");
81292
81394
  }
81293
81395
  const runner = this.config.contractSigner || this.getProviderOrThrow();
81294
- const contract = new import_ethers14.Contract(
81396
+ const contract = new import_ethers15.Contract(
81295
81397
  addr.loanOperationsManager,
81296
81398
  [
81297
81399
  "function getProtocolConfig() external view returns (uint256 liquidationThreshold, uint256 minimumLoanValueUcd, uint256 minimumLoanValueWei, uint256 maxSingleLoanValueUcd)"
@@ -81304,7 +81406,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
81304
81406
  const maxUcdWhole = BigInt(result[3].toString());
81305
81407
  return {
81306
81408
  liquidationThreshold: result[0].toString(),
81307
- minimumLoanValueUcd: (0, import_ethers14.formatUnits)(result[2], 18),
81409
+ minimumLoanValueUcd: (0, import_ethers15.formatUnits)(result[2], 18),
81308
81410
  minimumLoanValueWei: result[2].toString(),
81309
81411
  maxSingleLoanValueUcd: maxUcdWhole.toString(),
81310
81412
  maxSingleLoanValueWei: (maxUcdWhole * 10n ** 18n).toString()
@@ -81322,8 +81424,8 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
81322
81424
  const MIN_REVEAL_DELAY = 60;
81323
81425
  const MAX_RANDOM_DELAY = 240;
81324
81426
  const entropyInput = positionId + quantumTimestamp.toString();
81325
- const hash = (0, import_ethers14.keccak256)(
81326
- (0, import_ethers14.toUtf8Bytes)(entropyInput)
81427
+ const hash = (0, import_ethers15.keccak256)(
81428
+ (0, import_ethers15.toUtf8Bytes)(entropyInput)
81327
81429
  );
81328
81430
  const randomValue = BigInt(hash);
81329
81431
  const randomDelay = Number(randomValue % BigInt(MAX_RANDOM_DELAY));
@@ -81348,12 +81450,12 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
81348
81450
  const rawPositionId = /^0x/i.test(params.positionId.trim()) ? params.positionId.trim().slice(2) : params.positionId.trim();
81349
81451
  const canonicalPositionId = "0x" + rawPositionId.padStart(64, "0").toLowerCase();
81350
81452
  const intentTimestamp = Math.floor(Date.now() / 1e3);
81351
- const intentActionHash = (0, import_ethers14.keccak256)((0, import_ethers14.toUtf8Bytes)("liquidate-position"));
81352
- const intentHash = (0, import_ethers14.solidityPackedKeccak256)(
81453
+ const intentActionHash = (0, import_ethers15.keccak256)((0, import_ethers15.toUtf8Bytes)("liquidate-position"));
81454
+ const intentHash = (0, import_ethers15.solidityPackedKeccak256)(
81353
81455
  ["bytes32", "uint256", "uint256", "address", "bytes32"],
81354
81456
  [canonicalPositionId, intentTimestamp, chainId, intentSigner, intentActionHash]
81355
81457
  );
81356
- const intentSignature = await signer.signMessage((0, import_ethers14.getBytes)(intentHash));
81458
+ const intentSignature = await signer.signMessage((0, import_ethers15.getBytes)(intentHash));
81357
81459
  const response = await fetch(endpoint, {
81358
81460
  method: "POST",
81359
81461
  headers: { "Content-Type": "application/json" },
@@ -81405,7 +81507,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
81405
81507
  const vrfSeedRaw = await lmResult.value["vrfSeeds"](positionId);
81406
81508
  const vrfSeed = BigInt(vrfSeedRaw.toString());
81407
81509
  if (vrfSeed !== 0n) {
81408
- const finalEntropy = (0, import_ethers14.solidityPackedKeccak256)(
81510
+ const finalEntropy = (0, import_ethers15.solidityPackedKeccak256)(
81409
81511
  ["uint256", "uint256", "bytes32"],
81410
81512
  [vrfSeed, BigInt(quantumTimestamp.toString()), positionId]
81411
81513
  );
@@ -81613,15 +81715,15 @@ var SUPPORTED_STABLECOINS = `
81613
81715
  }`;
81614
81716
 
81615
81717
  // src/boundary/upstream/real/psm-calls.ts
81616
- var import_ethers43 = require("ethers");
81718
+ var import_ethers44 = require("ethers");
81617
81719
 
81618
81720
  // node_modules/@gvnrdao/dh-sdk/dist/sign-guard.mjs
81619
- var import_ethers37 = require("ethers");
81620
81721
  var import_ethers38 = require("ethers");
81621
81722
  var import_ethers39 = require("ethers");
81622
81723
  var import_ethers40 = require("ethers");
81623
81724
  var import_ethers41 = require("ethers");
81624
81725
  var import_ethers42 = require("ethers");
81726
+ var import_ethers43 = require("ethers");
81625
81727
  var TxValidationError3 = class extends Error {
81626
81728
  /**
81627
81729
  * @param subject What is being refused. Defaults to the server-returned transaction the
@@ -81668,7 +81770,7 @@ var SIGNABLE_FUNCTIONS3 = [
81668
81770
  // this too is client-only and never module-whitelisted.
81669
81771
  "function addAddress(string btcAddress) external"
81670
81772
  ];
81671
- var IFACE3 = new import_ethers37.ethers.Interface(SIGNABLE_FUNCTIONS3);
81773
+ var IFACE3 = new import_ethers38.ethers.Interface(SIGNABLE_FUNCTIONS3);
81672
81774
  function encodeSignable3(fn, args) {
81673
81775
  return IFACE3.encodeFunctionData(fn, args);
81674
81776
  }
@@ -81698,10 +81800,10 @@ var DEFAULT_FEE_CEILING2 = {
81698
81800
  maxTxFeeWei: DEFAULT_MAX_TX_FEE_WEI2
81699
81801
  };
81700
81802
  function fmtEth2(wei) {
81701
- return `${import_ethers38.ethers.formatEther(wei)} ETH`;
81803
+ return `${import_ethers39.ethers.formatEther(wei)} ETH`;
81702
81804
  }
81703
81805
  function fmtGwei2(wei) {
81704
- return `${import_ethers38.ethers.formatUnits(wei, "gwei")} gwei`;
81806
+ return `${import_ethers39.ethers.formatUnits(wei, "gwei")} gwei`;
81705
81807
  }
81706
81808
  function worstCaseFeeWei2(gasLimit, maxFeePerGas) {
81707
81809
  if (gasLimit == null || maxFeePerGas == null)
@@ -81728,7 +81830,7 @@ function eqAddr3(a, b) {
81728
81830
  if (!a || !b)
81729
81831
  return false;
81730
81832
  try {
81731
- return import_ethers39.ethers.getAddress(a) === import_ethers39.ethers.getAddress(b);
81833
+ return import_ethers40.ethers.getAddress(a) === import_ethers40.ethers.getAddress(b);
81732
81834
  } catch {
81733
81835
  return false;
81734
81836
  }
@@ -81794,7 +81896,7 @@ function readValue3(tx2) {
81794
81896
  }
81795
81897
  function normalizePositionId3(id) {
81796
81898
  const hex = id.startsWith("0x") ? id : `0x${id}`;
81797
- return import_ethers39.ethers.zeroPadValue(hex, 32).toLowerCase();
81899
+ return import_ethers40.ethers.zeroPadValue(hex, 32).toLowerCase();
81798
81900
  }
81799
81901
  function requirePositionId2(actual, expected) {
81800
81902
  const txPositionId = String(actual).toLowerCase();
@@ -82089,18 +82191,18 @@ function buildPsmRedeemTx3(p) {
82089
82191
  var PSM_READS_ABI2 = ["function supportedStablecoins(address) view returns (bool)"];
82090
82192
  var ERC20_READS_ABI2 = ["function allowance(address owner, address spender) view returns (uint256)"];
82091
82193
  function psmExchangeReadsFromProvider2(provider, psmAddress) {
82092
- const psm = new import_ethers42.ethers.Contract(psmAddress, PSM_READS_ABI2, provider);
82194
+ const psm = new import_ethers43.ethers.Contract(psmAddress, PSM_READS_ABI2, provider);
82093
82195
  return {
82094
82196
  isStablecoinSupported: async (stablecoin) => await psm.getFunction("supportedStablecoins")(stablecoin),
82095
- allowance: async (token, owner, spender) => await new import_ethers42.ethers.Contract(token, ERC20_READS_ABI2, provider).getFunction("allowance")(owner, spender)
82197
+ allowance: async (token, owner, spender) => await new import_ethers43.ethers.Contract(token, ERC20_READS_ABI2, provider).getFunction("allowance")(owner, spender)
82096
82198
  };
82097
82199
  }
82098
82200
  var refuse2 = (direction, msg) => new TxValidationError3(msg, `PSM ${direction}`);
82099
82201
  function requireAddress2(direction, label, value) {
82100
- if (!value || !import_ethers42.ethers.isAddress(value)) {
82202
+ if (!value || !import_ethers43.ethers.isAddress(value)) {
82101
82203
  throw refuse2(direction, `${label} address is missing or invalid (${String(value)})`);
82102
82204
  }
82103
- return import_ethers42.ethers.getAddress(value);
82205
+ return import_ethers43.ethers.getAddress(value);
82104
82206
  }
82105
82207
  async function planPsmExchange2(params) {
82106
82208
  const { direction, amountIn, minOut, vctx, reads } = params;
@@ -82227,8 +82329,8 @@ var PsmCalls = class {
82227
82329
  constructor(deps) {
82228
82330
  this.deps = deps;
82229
82331
  const abi = [...PSM_VIEW_FRAGMENTS, ...PSM_ERROR_FRAGMENTS];
82230
- this.iface = new import_ethers43.ethers.Interface(abi);
82231
- this.psm = new import_ethers43.ethers.Contract(deps.psmAddress, abi, deps.provider);
82332
+ this.iface = new import_ethers44.ethers.Interface(abi);
82333
+ this.psm = new import_ethers44.ethers.Contract(deps.psmAddress, abi, deps.provider);
82232
82334
  }
82233
82335
  psm;
82234
82336
  iface;
@@ -82257,8 +82359,8 @@ var PsmCalls = class {
82257
82359
  });
82258
82360
  }
82259
82361
  return this.call(async () => {
82260
- const ucd = new import_ethers43.ethers.Contract(ucdToken, ERC20_FRAGMENTS, this.deps.provider);
82261
- const stable = new import_ethers43.ethers.Contract(this.deps.stablecoinAddress, ERC20_FRAGMENTS, this.deps.provider);
82362
+ const ucd = new import_ethers44.ethers.Contract(ucdToken, ERC20_FRAGMENTS, this.deps.provider);
82363
+ const stable = new import_ethers44.ethers.Contract(this.deps.stablecoinAddress, ERC20_FRAGMENTS, this.deps.provider);
82262
82364
  const [ucdWei, stablecoinUnits] = await Promise.all([ucd["balanceOf"](holder), stable["balanceOf"](holder)]);
82263
82365
  return { ucdWei: ucdWei.toString(), stablecoinUnits: stablecoinUnits.toString() };
82264
82366
  });
@@ -82376,7 +82478,7 @@ var PsmCalls = class {
82376
82478
  };
82377
82479
 
82378
82480
  // src/boundary/upstream/real/session.ts
82379
- var import_ethers44 = require("ethers");
82481
+ var import_ethers45 = require("ethers");
82380
82482
  var REFRESH_LEEWAY_SEC = 30;
82381
82483
  var LOGIN_TYPES_WITH_AUDIENCE3 = {
82382
82484
  DiamondHands: [
@@ -82424,7 +82526,7 @@ var LitOpsSession = class {
82424
82526
  const message2 = {
82425
82527
  address: this.wallet.address,
82426
82528
  issuedAt: Math.floor(Date.now() / 1e3),
82427
- nonce: "0x" + Buffer.from(import_ethers44.ethers.randomBytes(32)).toString("hex"),
82529
+ nonce: "0x" + Buffer.from(import_ethers45.ethers.randomBytes(32)).toString("hex"),
82428
82530
  audience: this.serviceEndpoint
82429
82531
  };
82430
82532
  const signature = await this.wallet.signTypedData(
@@ -82466,7 +82568,7 @@ function decodeJwtExp(token) {
82466
82568
  }
82467
82569
 
82468
82570
  // src/boundary/upstream/real/write-ops.ts
82469
- var import_ethers46 = require("ethers");
82571
+ var import_ethers47 = require("ethers");
82470
82572
 
82471
82573
  // src/signer/types.ts
82472
82574
  var OperationDeclined = class extends Error {
@@ -82476,7 +82578,7 @@ var OperationDeclined = class extends Error {
82476
82578
  init_tx_validator();
82477
82579
 
82478
82580
  // src/boundary/upstream/shared/external-bridge/page-crypto.ts
82479
- var import_ethers45 = require("ethers");
82581
+ var import_ethers46 = require("ethers");
82480
82582
  var PERSONAL_SIGN_LAYOUTS = {
82481
82583
  "dh-op-envelope-v1": {
82482
82584
  types: ["bytes32", "uint256", "uint256", "uint256", "bytes32"],
@@ -82497,9 +82599,9 @@ function hashForLayout(layout, fields) {
82497
82599
  const values = def.fieldOrder.map((name) => {
82498
82600
  const raw = fields[name];
82499
82601
  if (raw === void 0) throw new Error(`page-crypto: layout "${layout}" missing field "${name}"`);
82500
- return hashUtf8.has(name) ? import_ethers45.ethers.keccak256(import_ethers45.ethers.toUtf8Bytes(raw)) : raw;
82602
+ return hashUtf8.has(name) ? import_ethers46.ethers.keccak256(import_ethers46.ethers.toUtf8Bytes(raw)) : raw;
82501
82603
  });
82502
- return import_ethers45.ethers.solidityPackedKeccak256(def.types, values);
82604
+ return import_ethers46.ethers.solidityPackedKeccak256(def.types, values);
82503
82605
  }
82504
82606
  var PAGE_CRYPTO_JS = `"use strict";
82505
82607
  (function () {
@@ -82742,7 +82844,7 @@ function mcpExpected(leg) {
82742
82844
  }
82743
82845
  var OP_LAYOUT = "dh-op-envelope-v1";
82744
82846
  function randomNonceHex() {
82745
- return "0x" + Buffer.from(import_ethers46.ethers.randomBytes(16)).toString("hex");
82847
+ return "0x" + Buffer.from(import_ethers47.ethers.randomBytes(16)).toString("hex");
82746
82848
  }
82747
82849
  async function postJson(url2, body, headers) {
82748
82850
  const res = await fetch(url2, {
@@ -82803,7 +82905,7 @@ function buildWriteOps(deps) {
82803
82905
  return {
82804
82906
  to: String(tx2["to"] ?? ""),
82805
82907
  data: String(tx2["data"] ?? "0x"),
82806
- value: tx2["value"] != null ? import_ethers46.ethers.toBeHex(BigInt(String(tx2["value"]))) : "0x0",
82908
+ value: tx2["value"] != null ? import_ethers47.ethers.toBeHex(BigInt(String(tx2["value"]))) : "0x0",
82807
82909
  chainId: tx2["chainId"] != null ? Number(tx2["chainId"]) : chainId
82808
82910
  };
82809
82911
  }
@@ -82969,7 +83071,7 @@ function buildWriteOps(deps) {
82969
83071
  mintedUcdWei: minted,
82970
83072
  feeUcdWei: mintFee,
82971
83073
  echoedAmountUcdWei: minted,
82972
- authorization: auth(action, `mint ${import_ethers46.ethers.formatEther(amountWei)} UCD against ${p.positionId}`, r.value.digest)
83074
+ authorization: auth(action, `mint ${import_ethers47.ethers.formatEther(amountWei)} UCD against ${p.positionId}`, r.value.digest)
82973
83075
  },
82974
83076
  { id: SOURCE5, kind: "lit-ops", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }
82975
83077
  );
@@ -83010,7 +83112,7 @@ function buildWriteOps(deps) {
83010
83112
  txRef: { kind: "eth-tx", id: r.value.txHash },
83011
83113
  paidUcdWei: paid,
83012
83114
  echoedAmountUcdWei: paid,
83013
- authorization: auth(action, `repay ${import_ethers46.ethers.formatEther(amountWei)} UCD on ${p.positionId}`, r.value.digest)
83115
+ authorization: auth(action, `repay ${import_ethers47.ethers.formatEther(amountWei)} UCD on ${p.positionId}`, r.value.digest)
83014
83116
  },
83015
83117
  { id: SOURCE5, kind: "lit-ops", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }
83016
83118
  );
@@ -83273,7 +83375,7 @@ function buildWriteOps(deps) {
83273
83375
  }
83274
83376
 
83275
83377
  // src/signer/eoa-dh.ts
83276
- var import_ethers47 = require("ethers");
83378
+ var import_ethers48 = require("ethers");
83277
83379
  var EoaDHSigner = class {
83278
83380
  constructor(wallet, broadcast, clock = Date.now) {
83279
83381
  this.wallet = wallet;
@@ -83290,7 +83392,7 @@ var EoaDHSigner = class {
83290
83392
  async signAuthorization(spec) {
83291
83393
  const quantumTs = nextQuantumTimestamp(this.clock());
83292
83394
  const { fields, hashHex } = spec.stamp(quantumTs);
83293
- const signature = await this.wallet.signMessage(import_ethers47.ethers.getBytes(hashHex));
83395
+ const signature = await this.wallet.signMessage(import_ethers48.ethers.getBytes(hashHex));
83294
83396
  return { signature, quantumTs, fields };
83295
83397
  }
83296
83398
  async wrapInnerTx(innerTx) {
@@ -83308,10 +83410,10 @@ var EoaDHSigner = class {
83308
83410
 
83309
83411
  // src/signer/external-eoa.ts
83310
83412
  var import_node_crypto8 = require("crypto");
83311
- var import_ethers49 = require("ethers");
83413
+ var import_ethers50 = require("ethers");
83312
83414
 
83313
83415
  // src/boundary/upstream/shared/external-bridge/verify-landed-tx.ts
83314
- var import_ethers48 = require("ethers");
83416
+ var import_ethers49 = require("ethers");
83315
83417
  function eq2(a, b) {
83316
83418
  return a.toLowerCase() === b.toLowerCase();
83317
83419
  }
@@ -83334,7 +83436,7 @@ function compareLandedTx(landed, approved, borrower) {
83334
83436
  return { status: "verified", from: landed.from, hash: landed.hash };
83335
83437
  }
83336
83438
  function verifyRawSignedTx(rawSignedTx, approved, borrower) {
83337
- const parsed = import_ethers48.ethers.Transaction.from(rawSignedTx);
83439
+ const parsed = import_ethers49.ethers.Transaction.from(rawSignedTx);
83338
83440
  if (!parsed.from || !parsed.to || !parsed.hash) {
83339
83441
  return { status: "mismatch", hash: parsed.hash ?? "0x", reason: "the returned raw transaction is unsigned or malformed" };
83340
83442
  }
@@ -83372,7 +83474,7 @@ async function gasHintAcrossBlocks(provider, from, tx2, action) {
83372
83474
  for (let attempt = 0; attempt < 4; attempt++) {
83373
83475
  try {
83374
83476
  const est = await provider.estimateGas({ from, to: tx2.to, data: tx2.data, value: BigInt(tx2.value) });
83375
- return import_ethers49.ethers.toBeHex(est * 15n / 10n);
83477
+ return import_ethers50.ethers.toBeHex(est * 15n / 10n);
83376
83478
  } catch (e) {
83377
83479
  lastErr = e;
83378
83480
  await new Promise((r) => setTimeout(r, 13e3));
@@ -83422,7 +83524,7 @@ var ExternalEoaDHSigner = class {
83422
83524
  throw new OperationDeclined(`the ${spec.action} authorization was not signed: ${describeOutcome(outcome)}`);
83423
83525
  }
83424
83526
  const finalHash = spec.stamp(used.quantumTs).hashHex;
83425
- const recovered = import_ethers49.ethers.verifyMessage(import_ethers49.ethers.getBytes(finalHash), outcome.signature);
83527
+ const recovered = import_ethers50.ethers.verifyMessage(import_ethers50.ethers.getBytes(finalHash), outcome.signature);
83426
83528
  if (recovered.toLowerCase() !== this.deps.borrower.toLowerCase()) {
83427
83529
  throw new Error(`the ${spec.action} authorization was signed by ${recovered}, not the borrower ${this.deps.borrower}`);
83428
83530
  }
@@ -83433,7 +83535,7 @@ var ExternalEoaDHSigner = class {
83433
83535
  }
83434
83536
  async submitValidatedTx(outerTx, ctx) {
83435
83537
  const approved = toApprovedTx(outerTx, this.deps.chainId);
83436
- const gas = outerTx.gasLimit != null ? import_ethers49.ethers.toBeHex(BigInt(String(outerTx.gasLimit))) : await gasHintAcrossBlocks(this.deps.provider, this.deps.borrower, approved, ctx.action);
83538
+ const gas = outerTx.gasLimit != null ? import_ethers50.ethers.toBeHex(BigInt(String(outerTx.gasLimit))) : await gasHintAcrossBlocks(this.deps.provider, this.deps.borrower, approved, ctx.action);
83437
83539
  const outcome = await this.deps.bridge.requestSignature({
83438
83540
  id: (0, import_node_crypto8.randomUUID)(),
83439
83541
  kind: "transaction",
@@ -83467,7 +83569,7 @@ var ExternalEoaDHSigner = class {
83467
83569
  return new BridgeEthersSigner(this.deps);
83468
83570
  }
83469
83571
  };
83470
- var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers49.ethers.AbstractSigner {
83572
+ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers50.ethers.AbstractSigner {
83471
83573
  constructor(deps) {
83472
83574
  super(deps.provider);
83473
83575
  this.deps = deps;
@@ -83478,13 +83580,13 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers49.ether
83478
83580
  return this.deps.borrower;
83479
83581
  }
83480
83582
  async signMessage(message2) {
83481
- const bytes = typeof message2 === "string" ? import_ethers49.ethers.toUtf8Bytes(message2) : message2;
83583
+ const bytes = typeof message2 === "string" ? import_ethers50.ethers.toUtf8Bytes(message2) : message2;
83482
83584
  if (bytes.length !== 32) {
83483
83585
  throw new Error(
83484
83586
  `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.`
83485
83587
  );
83486
83588
  }
83487
- const hashHex = import_ethers49.ethers.hexlify(bytes).toLowerCase();
83589
+ const hashHex = import_ethers50.ethers.hexlify(bytes).toLowerCase();
83488
83590
  const nowMs = (this.deps.clock ?? Date.now)();
83489
83591
  const expiresAtSec = nextQuantumTimestamp(nowMs);
83490
83592
  const secondsLeft = Math.max(0, expiresAtSec - Math.floor(nowMs / 1e3));
@@ -83514,7 +83616,7 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers49.ether
83514
83616
  if (outcome.status !== "approved" || !outcome.signature) {
83515
83617
  throw new OperationDeclined(`the btc-withdrawal authorization was not signed: ${describeOutcome(outcome)}`);
83516
83618
  }
83517
- const recovered = import_ethers49.ethers.verifyMessage(bytes, outcome.signature);
83619
+ const recovered = import_ethers50.ethers.verifyMessage(bytes, outcome.signature);
83518
83620
  if (recovered.toLowerCase() !== this.deps.borrower.toLowerCase()) {
83519
83621
  throw new Error(`the btc-withdrawal authorization was signed by ${recovered}, not the borrower ${this.deps.borrower}`);
83520
83622
  }
@@ -83548,11 +83650,11 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers49.ether
83548
83650
  const approved = {
83549
83651
  to: tx2.to,
83550
83652
  data: tx2.data,
83551
- value: tx2.value != null ? import_ethers49.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
83653
+ value: tx2.value != null ? import_ethers50.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
83552
83654
  chainId: tx2.chainId != null ? Number(tx2.chainId) : this.deps.chainId
83553
83655
  };
83554
83656
  const card = cardForTx(approved);
83555
- 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));
83657
+ const gas = tx2.gasLimit != null ? import_ethers50.ethers.toBeHex(BigInt(String(tx2.gasLimit))) : await gasHintAcrossBlocks(this.deps.provider, this.deps.borrower, approved, describeFn(approved.data));
83556
83658
  const outcome = await this.deps.bridge.requestSignature({
83557
83659
  id: (0, import_node_crypto8.randomUUID)(),
83558
83660
  kind: "transaction",
@@ -83594,7 +83696,7 @@ function toApprovedTx(tx2, fallbackChainId) {
83594
83696
  return {
83595
83697
  to: tx2.to,
83596
83698
  data: tx2.data,
83597
- value: tx2.value != null ? import_ethers49.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
83699
+ value: tx2.value != null ? import_ethers50.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
83598
83700
  chainId: tx2.chainId != null ? Number(tx2.chainId) : fallbackChainId
83599
83701
  };
83600
83702
  }
@@ -83638,7 +83740,9 @@ var MIN_CONFIRMATIONS = { mainnet: 6, sepolia: 1 };
83638
83740
  var RealUpstreamPlugin = class {
83639
83741
  constructor(config, wallet, runtime) {
83640
83742
  this.config = config;
83641
- this.provider = new import_ethers50.ethers.JsonRpcProvider(config.rpcUrl, config.chainId);
83743
+ const rpc = new import_ethers51.ethers.FetchRequest(config.rpcUrl);
83744
+ if (config.rpcDrpcKey !== void 0) rpc.setHeader("Drpc-Key", config.rpcDrpcKey);
83745
+ this.provider = new import_ethers51.ethers.JsonRpcProvider(rpc, config.chainId);
83642
83746
  this.wallet = wallet ?? null;
83643
83747
  this.runtime = runtime ?? null;
83644
83748
  this.session = wallet ? new LitOpsSession(wallet.connect(this.provider), config.serviceEndpoint, config.chainId) : null;
@@ -83945,14 +84049,14 @@ var RealUpstreamPlugin = class {
83945
84049
  if (!pkpValidation) {
83946
84050
  throw new Error(`the SDK's ${this.config.network} deployment table has no PKPValidation address \u2014 cannot verify validator version ${version2}.`);
83947
84051
  }
83948
- const registry = new import_ethers50.ethers.Contract(pkpValidation, ["function validatorForVersion(uint256) view returns (address)"], this.provider);
84052
+ const registry = new import_ethers51.ethers.Contract(pkpValidation, ["function validatorForVersion(uint256) view returns (address)"], this.provider);
83949
84053
  let validator;
83950
84054
  try {
83951
84055
  validator = await registry.validatorForVersion(version2);
83952
84056
  } catch (e) {
83953
84057
  throw new Error(`could not verify validator version ${version2} on-chain (PKPValidation ${pkpValidation}): ${e.message}`);
83954
84058
  }
83955
- if (validator === import_ethers50.ethers.ZeroAddress) {
84059
+ if (validator === import_ethers51.ethers.ZeroAddress) {
83956
84060
  throw new Error(
83957
84061
  `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.`
83958
84062
  );
@@ -84242,7 +84346,7 @@ var RealUpstreamPlugin = class {
84242
84346
  );
84243
84347
  if (!r.ok) return r;
84244
84348
  const raw = r.value.data.supportedStablecoins ?? [];
84245
- const bad = raw.find((x) => !import_ethers50.ethers.isAddress(String(x.address)) || !Number.isFinite(Number(x.decimals)));
84349
+ const bad = raw.find((x) => !import_ethers51.ethers.isAddress(String(x.address)) || !Number.isFinite(Number(x.decimals)));
84246
84350
  if (bad) {
84247
84351
  return {
84248
84352
  ok: false,
@@ -84325,7 +84429,7 @@ var RealUpstreamPlugin = class {
84325
84429
  };
84326
84430
  }
84327
84431
  const symbol = raw.toLowerCase();
84328
- if (import_ethers50.ethers.isAddress(raw)) return this.psmCallsFor(symbol);
84432
+ if (import_ethers51.ethers.isAddress(raw)) return this.psmCallsFor(symbol);
84329
84433
  const verified = await this.verifiedStablecoins();
84330
84434
  if (!verified.ok) return { ok: false, failure: verified.failure };
84331
84435
  const hits = verified.rows.filter((r) => r.symbol.toLowerCase() === symbol);
@@ -84363,7 +84467,7 @@ var RealUpstreamPlugin = class {
84363
84467
  * chain, then sign.
84364
84468
  */
84365
84469
  async psmCallsFor(stablecoinAddress) {
84366
- if (!import_ethers50.ethers.isAddress(stablecoinAddress)) {
84470
+ if (!import_ethers51.ethers.isAddress(stablecoinAddress)) {
84367
84471
  throw new Error(`psmCallsFor requires a resolved 0x address, got '${stablecoinAddress}' \u2014 resolve through psmCallsForChoice`);
84368
84472
  }
84369
84473
  const key = stablecoinAddress.toLowerCase();
@@ -84383,9 +84487,9 @@ var RealUpstreamPlugin = class {
84383
84487
  let supported;
84384
84488
  let symbol;
84385
84489
  try {
84386
- const psm = new import_ethers50.ethers.Contract(psmAddress, ["function supportedStablecoins(address) view returns (bool)"], this.provider);
84490
+ const psm = new import_ethers51.ethers.Contract(psmAddress, ["function supportedStablecoins(address) view returns (bool)"], this.provider);
84387
84491
  supported = await psm["supportedStablecoins"](key);
84388
- const erc20 = new import_ethers50.ethers.Contract(key, ["function symbol() view returns (string)"], this.provider);
84492
+ const erc20 = new import_ethers51.ethers.Contract(key, ["function symbol() view returns (string)"], this.provider);
84389
84493
  symbol = await erc20["symbol"]();
84390
84494
  } catch (e) {
84391
84495
  return { ok: false, failure: { kind: "unavailable", source: "chain-rpc", message: `PSM stablecoin check failed for ${key}: ${e.message}` } };
@@ -84579,8 +84683,9 @@ var RealUpstreamPlugin = class {
84579
84683
  }
84580
84684
  /** Chain read → mapped value, failures typed. F-PUB-5 (protocol 106): the SPECIFIC
84581
84685
  * thrown cause is rendered — a blanket rewrite to a generic message masked the
84582
- * deliberate `readPendingWithdrawals` gap as an RPC outage. No secrets transit here
84583
- * (provider errors carry method/params, never keys). */
84686
+ * deliberate `readPendingWithdrawals` gap as an RPC outage. Provider errors DO carry
84687
+ * the request URL (ethers' `info.requestUrl`); the server's URL holds no key (it is in
84688
+ * the `Drpc-Key` header) and failureToError redacts every URL regardless. */
84584
84689
  async chainRead(fn) {
84585
84690
  try {
84586
84691
  return upOk(await fn(), this.src("chain-rpc"));
@@ -84598,7 +84703,7 @@ var RealUpstreamPlugin = class {
84598
84703
  const pm = this.contracts["PositionManager"];
84599
84704
  if (!pm) return false;
84600
84705
  try {
84601
- const c = new import_ethers50.ethers.Contract(pm, PAUSABLE_ABI, this.provider);
84706
+ const c = new import_ethers51.ethers.Contract(pm, PAUSABLE_ABI, this.provider);
84602
84707
  return Boolean(await c["paused"]());
84603
84708
  } catch {
84604
84709
  return false;
@@ -84607,16 +84712,16 @@ var RealUpstreamPlugin = class {
84607
84712
  async readPositionDetails(id) {
84608
84713
  const core = this.contracts["PositionManagerCoreModule"] ?? this.contracts["PositionManager"];
84609
84714
  if (!core) throw new Error(`no PositionManager address for network ${this.config.network}`);
84610
- const c = new import_ethers50.ethers.Contract(core, POSITION_DETAILS_ABI, this.provider);
84715
+ const c = new import_ethers51.ethers.Contract(core, POSITION_DETAILS_ABI, this.provider);
84611
84716
  let d;
84612
84717
  try {
84613
- d = await c["getPositionDetails"](import_ethers50.ethers.zeroPadValue(id, 32));
84718
+ d = await c["getPositionDetails"](import_ethers51.ethers.zeroPadValue(id, 32));
84614
84719
  } catch (e) {
84615
84720
  if (e.code === "CALL_EXCEPTION") return null;
84616
84721
  throw e;
84617
84722
  }
84618
84723
  const borrower = String(d["borrower"]);
84619
- if (borrower === import_ethers50.ethers.ZeroAddress) return null;
84724
+ if (borrower === import_ethers51.ethers.ZeroAddress) return null;
84620
84725
  return {
84621
84726
  positionId: String(d["positionId"]),
84622
84727
  pkpId: String(d["pkpId"]),
@@ -84641,7 +84746,7 @@ var RealUpstreamPlugin = class {
84641
84746
  var fs4 = __toESM(require("fs"));
84642
84747
  var http3 = __toESM(require("http"));
84643
84748
  var import_node_crypto9 = require("crypto");
84644
- var import_ethers51 = require("ethers");
84749
+ var import_ethers52 = require("ethers");
84645
84750
 
84646
84751
  // src/boundary/upstream/shared/external-bridge/approval-page.ts
84647
84752
  function renderApprovalPage(sessionId, nonce) {
@@ -84692,7 +84797,7 @@ ${houseHeader("Diamond Hands \xB7 signature approval")}
84692
84797
  <button id="wc-connect" class="btn-secondary">Use a mobile wallet instead (WalletConnect)</button>
84693
84798
  <div id="wc-qr" class="qr-plate hidden"></div>
84694
84799
  <div id="wc-uri" class="card hidden"></div>
84695
- <div id="wc-hint" class="status hidden">Scan the QR with your wallet app (or open the app \u2192 WalletConnect \u2192 paste the pairing code). Approvals then happen on your phone.</div>
84800
+ <div id="wc-hint" class="status hidden">Scan the QR with your wallet app (or open the app \u2192 WalletConnect \u2192 paste the pairing code). Your wallet first asks you to sign a short statement proving the wallet is yours \u2014 it moves no funds. Approvals then happen on your phone.</div>
84696
84801
  </div>
84697
84802
  </div>
84698
84803
  </main>
@@ -85039,7 +85144,7 @@ document.getElementById("wc-connect").onclick = async () => {
85039
85144
  qrEl.classList.remove("hidden");
85040
85145
  }
85041
85146
  document.getElementById("wc-hint").classList.remove("hidden");
85042
- showStatus("Scan the QR (or paste the code) in your mobile wallet \u2014 it becomes the signing wallet.");
85147
+ showIdleStatus("Scan the QR (or paste the code) in your mobile wallet, then sign the short statement it shows (it proves the wallet is yours and moves no funds) \u2014 it then becomes the signing wallet.");
85043
85148
  };
85044
85149
 
85045
85150
  listen();
@@ -85123,7 +85228,6 @@ document.getElementById("generate").onclick = () => submit(true);
85123
85228
 
85124
85229
  // src/boundary/upstream/shared/external-bridge/bridge.ts
85125
85230
  var MAX_SESSIONS = 16;
85126
- var MAX_PENDING_PAIRINGS = 64;
85127
85231
  function presenceStatement(origin2, chainId, nonce) {
85128
85232
  return [
85129
85233
  "Diamond Hands approval page",
@@ -85133,6 +85237,13 @@ function presenceStatement(origin2, chainId, nonce) {
85133
85237
  `Session nonce: ${nonce}`
85134
85238
  ].join("\n");
85135
85239
  }
85240
+ function recoverPresenceSigner(statement, signature) {
85241
+ try {
85242
+ return import_ethers52.ethers.verifyMessage(statement, signature);
85243
+ } catch {
85244
+ return null;
85245
+ }
85246
+ }
85136
85247
  var DEFAULT_EXPIRY_MS = 5 * 60 * 1e3;
85137
85248
  var DEFAULT_ATTACH_GRACE_MS = 60 * 1e3;
85138
85249
  var DEFAULT_HOSTED_ATTACH_GRACE_MS = 180 * 1e3;
@@ -85182,6 +85293,10 @@ var SignatureBridge = class {
85182
85293
  * "most recent asker" guess let a second session claim the credit for a QR the user's
85183
85294
  * phone scanned (Sentinel 2 PoC-B). */
85184
85295
  pairingOwners = /* @__PURE__ */ new Map();
85296
+ /** The page session the ADMITTED WalletConnect session's proof was made for — the one page
85297
+ * credited with `wcPaired`. The credit lasts exactly as long as that session: it moves when
85298
+ * another proven session replaces it and ends when the wallet disconnects. */
85299
+ wcCreditedSession = null;
85185
85300
  keystoreUnlock;
85186
85301
  unlockToken = null;
85187
85302
  unlockSession = null;
@@ -85670,46 +85785,16 @@ var SignatureBridge = class {
85670
85785
  const { WcTransport: WcTransport2 } = await Promise.resolve().then(() => (init_wc_transport(), wc_transport_exports));
85671
85786
  return WcTransport2.create(cfg);
85672
85787
  });
85673
- this.wcTransport = await factory2(this.wcConfig);
85674
- this.wcTransport.onSession((info) => {
85675
- const refusal = info ? this.accountRefusal(info.account) : null;
85676
- if (info && refusal) {
85677
- if (!this.wcActive) {
85678
- this.rebuildSharedWallet();
85679
- this.demoteWcEntries();
85680
- }
85681
- process.stderr.write(`[bridge] WalletConnect session refused \u2014 ${refusal}
85682
- `);
85683
- return false;
85684
- }
85685
- this.wcActive = info !== null;
85686
- this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
85687
- if (info?.pairingId) {
85688
- const owner = this.pairingOwners.get(info.pairingId);
85689
- this.pairingOwners.delete(info.pairingId);
85690
- const paired = owner ? this.sessions.get(owner) : void 0;
85691
- if (paired) paired.wcPaired = true;
85692
- }
85693
- if (info === null) {
85694
- for (const entry of this.pending.values()) {
85695
- if (!entry.settled && !entry.collect) {
85696
- this.settle(entry, {
85697
- status: "invalidated",
85698
- reason: entry.dispatched && entry.request.kind === "transaction" ? "the WalletConnect session disconnected after being asked to send this transaction \u2014 it may have broadcast. Check the chain (or your wallet's activity) before retrying, or you may pay twice." : "the WalletConnect session disconnected"
85699
- });
85700
- }
85701
- }
85702
- }
85703
- });
85788
+ const transport = await factory2(this.wcConfig);
85789
+ this.wcTransport = transport;
85790
+ transport.onSession((info) => info === null ? this.onWcDisconnect() : this.admitWcSession(info, transport));
85704
85791
  }
85705
85792
  const { uri, pairingId } = await this.wcTransport.createPairing();
85706
85793
  if (pairingId) {
85707
- this.pairingOwners.set(pairingId, askingSession);
85708
- while (this.pairingOwners.size > MAX_PENDING_PAIRINGS) {
85709
- const oldest = this.pairingOwners.keys().next();
85710
- if (oldest.done) break;
85711
- this.pairingOwners.delete(oldest.value);
85794
+ for (const [pending, owner] of this.pairingOwners) {
85795
+ if (owner === askingSession || !this.sessions.has(owner)) this.pairingOwners.delete(pending);
85712
85796
  }
85797
+ this.pairingOwners.set(pairingId, askingSession);
85713
85798
  }
85714
85799
  const { default: qrcode } = await import("qrcode-generator");
85715
85800
  const qr = qrcode(0, "M");
@@ -85810,12 +85895,7 @@ var SignatureBridge = class {
85810
85895
  return;
85811
85896
  }
85812
85897
  const statement = presenceStatement(this.publicOrigin(), chainId, session.presenceNonce);
85813
- let recovered = null;
85814
- try {
85815
- recovered = import_ethers51.ethers.verifyMessage(statement, signature);
85816
- } catch {
85817
- recovered = null;
85818
- }
85898
+ const recovered = recoverPresenceSigner(statement, signature);
85819
85899
  if (recovered === null || recovered.toLowerCase() !== account.toLowerCase()) {
85820
85900
  this.deny(
85821
85901
  res,
@@ -85906,6 +85986,100 @@ var SignatureBridge = class {
85906
85986
  * Those entries instead fail fast at the per-entry grace, since `attachedFor` now reads
85907
85987
  * false for them, and `unattendedReason` says plainly that the phone may already have
85908
85988
  * acted. */
85989
+ /**
85990
+ * C-47, the THIRD door: a wallet announced a WalletConnect session. `requestSignature`
85991
+ * PREFERS the WalletConnect wallet over the approval page (see the `wcActive` branch there),
85992
+ * so an account admitted here does not merely become the candidate — it becomes the SIGNER,
85993
+ * and the page that showed its QR becomes the page that sees every card.
85994
+ *
85995
+ * The account a WalletConnect session carries is the wallet's own UNSIGNED claim — the
85996
+ * protocol validates its format, never its ownership. Admitting on that claim let anyone
85997
+ * holding the approval link answer their own QR with a scripted wallet claiming the user's
85998
+ * public address: it took the signer seat, its page saw every card, and an extension-only
85999
+ * user's ceremonies were routed to it (Sentinel 2 PoC-D). So this door now asks for the same
86000
+ * proof `hello` does: the wallet signs the presence statement of the page whose QR it
86001
+ * answered, and the signature must recover to the account it claims.
86002
+ *
86003
+ * Resolves `false` to refuse — the transport then keeps what it held and drops the wallet. If
86004
+ * the wallet declines the proof (or the request fails) the promise rejects and the transport
86005
+ * ends the session unadopted; nothing here is adopted before the proof checks out.
86006
+ */
86007
+ async admitWcSession(info, transport) {
86008
+ const refusal = this.accountRefusal(info.account);
86009
+ if (refusal) return this.refuseWcSession(refusal);
86010
+ const ownerId = info.pairingId ? this.pairingOwners.get(info.pairingId) : void 0;
86011
+ if (info.pairingId) this.pairingOwners.delete(info.pairingId);
86012
+ const owner = ownerId ? this.sessions.get(ownerId) : void 0;
86013
+ if (!ownerId || !owner) {
86014
+ return this.refuseWcSession(
86015
+ "the wallet answered no QR code that an open approval page of this bridge showed \u2014 open the approval page and scan the QR code it shows"
86016
+ );
86017
+ }
86018
+ if (!info.prove || !info.live) {
86019
+ return this.refuseWcSession(
86020
+ "this WalletConnect transport cannot ask the wallet to prove its account (or report whether its session is still live), so no session can be admitted"
86021
+ );
86022
+ }
86023
+ const statement = presenceStatement(this.publicOrigin(), info.chainId, owner.presenceNonce);
86024
+ const signature = await info.prove(statement);
86025
+ const recovered = recoverPresenceSigner(statement, signature);
86026
+ if (recovered === null || recovered.toLowerCase() !== info.account.toLowerCase()) {
86027
+ return this.refuseWcSession(
86028
+ `the wallet claimed ${info.account} but ${recovered === null ? "returned no valid signature" : `signed with ${recovered}`} for the approval page's presence statement \u2014 an address alone proves nothing`
86029
+ );
86030
+ }
86031
+ if (this.wcTransport !== transport) {
86032
+ return this.refuseWcSession("the bridge's WalletConnect connection was replaced while the wallet was proving its account");
86033
+ }
86034
+ if (!info.live()) {
86035
+ return this.refuseWcSession("the wallet's WalletConnect session ended (or the relay failed) while it was proving its account \u2014 scan the QR again");
86036
+ }
86037
+ const lateRefusal = this.accountRefusal(info.account);
86038
+ if (lateRefusal) return this.refuseWcSession(lateRefusal);
86039
+ const page = this.sessions.get(ownerId);
86040
+ if (!page || page.refused) {
86041
+ return this.refuseWcSession("the approval page that showed this QR code closed while the wallet was proving its account \u2014 reopen it and scan again");
86042
+ }
86043
+ if (this.wcCreditedSession !== null && this.wcCreditedSession !== ownerId) {
86044
+ const previous = this.sessions.get(this.wcCreditedSession);
86045
+ if (previous) previous.wcPaired = false;
86046
+ }
86047
+ this.wcActive = true;
86048
+ this.wallet = { account: info.account, chainId: info.chainId };
86049
+ page.wcPaired = true;
86050
+ page.provenAccount = info.account;
86051
+ this.wcCreditedSession = ownerId;
86052
+ this.replayPending(page);
86053
+ return true;
86054
+ }
86055
+ /** Refuse a WalletConnect session — see `admitWcSession`. */
86056
+ refuseWcSession(reason) {
86057
+ if (!this.wcActive) {
86058
+ this.rebuildSharedWallet();
86059
+ this.demoteWcEntries();
86060
+ }
86061
+ process.stderr.write(`[bridge] WalletConnect session refused \u2014 ${reason}
86062
+ `);
86063
+ return false;
86064
+ }
86065
+ /** The admitted WalletConnect wallet went away. */
86066
+ onWcDisconnect() {
86067
+ this.wcActive = false;
86068
+ this.wallet = null;
86069
+ for (const entry of this.pending.values()) {
86070
+ if (!entry.settled && !entry.collect) {
86071
+ this.settle(entry, {
86072
+ status: "invalidated",
86073
+ reason: entry.dispatched && entry.request.kind === "transaction" ? "the WalletConnect session disconnected after being asked to send this transaction \u2014 it may have broadcast. Check the chain (or your wallet's activity) before retrying, or you may pay twice." : "the WalletConnect session disconnected"
86074
+ });
86075
+ }
86076
+ }
86077
+ if (this.wcCreditedSession !== null) {
86078
+ const credited = this.sessions.get(this.wcCreditedSession);
86079
+ if (credited) credited.wcPaired = false;
86080
+ this.wcCreditedSession = null;
86081
+ }
86082
+ }
85909
86083
  demoteWcEntries() {
85910
86084
  for (const entry of this.pending.values()) {
85911
86085
  if (entry.settled || entry.owner !== "wc" || entry.dispatched) continue;
@@ -86389,7 +86563,10 @@ async function createRealBoundary(config, wallet, overrides) {
86389
86563
  const chainName = config.network === "mainnet" ? "Ethereum Mainnet" : "Sepolia";
86390
86564
  const bridge = new SignatureBridge({
86391
86565
  ...config.bridgeUrlFile ? { urlFile: config.bridgeUrlFile } : {},
86392
- network: { chainId: config.chainId, chainName, rpcUrl: config.rpcUrl },
86566
+ // The page's wallet_addEthereumChain gets the PUBLIC proxy, never config.rpcUrl: the
86567
+ // server's endpoint is a server credential, and the page would save it into the
86568
+ // user's wallet.
86569
+ network: { chainId: config.chainId, chainName, rpcUrl: publicRpcUrl(config.chainId) },
86393
86570
  ...config.wcProjectId ? { wc: { projectId: config.wcProjectId, chainId: config.chainId } } : {},
86394
86571
  // Plan 17 E2 (SVC-OPS-08): the HOSTED tier caps ceremonies at concurrent-1 per
86395
86572
  // tenant — one bridge per tenant world, so the bridge cap IS the tenant cap. The
@@ -86414,7 +86591,7 @@ async function createRealBoundary(config, wallet, overrides) {
86414
86591
  const manager = new SignerManager({
86415
86592
  persistence: overrides?.signerPersistence?.(config.network) ?? fileSignerPersistence(stateFile),
86416
86593
  initialMode,
86417
- ...overrides?.boundBorrower ? { authenticatedBorrower: import_ethers52.ethers.getAddress(overrides.boundBorrower) } : {},
86594
+ ...overrides?.boundBorrower ? { authenticatedBorrower: import_ethers53.ethers.getAddress(overrides.boundBorrower) } : {},
86418
86595
  candidate: () => bridge.walletState()?.account ?? null,
86419
86596
  pendingCeremonies: () => bridge.pendingCount(),
86420
86597
  keystore
@@ -86510,8 +86687,8 @@ async function buildBoundary(configResult, overrides) {
86510
86687
  );
86511
86688
  }
86512
86689
  try {
86513
- const decrypted = await import_ethers53.ethers.Wallet.fromEncryptedJson(keystoreJson, config.keystorePassword);
86514
- if (!(decrypted instanceof import_ethers53.ethers.Wallet)) {
86690
+ const decrypted = await import_ethers54.ethers.Wallet.fromEncryptedJson(keystoreJson, config.keystorePassword);
86691
+ if (!(decrypted instanceof import_ethers54.ethers.Wallet)) {
86515
86692
  return bootError("DH_KEYSTORE_PATH did not decrypt to an EOA wallet keystore.", ["DH_KEYSTORE_PATH"]);
86516
86693
  }
86517
86694
  wallet = decrypted;
@@ -86991,7 +87168,7 @@ on the real adapter and the mock.
86991
87168
  **The walkthrough:**
86992
87169
  1. \`signer_setup\` action \`use\`, mode \`external\`. The approval page auto-opens in the
86993
87170
  desktop browser; ${approvalPageLocation(d)}
86994
- 2. On the page: connect the browser extension${d.walletConnect ? ", or \u2014 for a mobile wallet \u2014 scan the\n WalletConnect QR code or paste the pairing code. KEEP THAT APPROVAL PAGE OPEN \u2014 the one\n whose QR you scanned: while a phone wallet is connected it is the READ-ONLY reader for\n every ceremony \u2014 it shows the full card, the phone shows only what a wallet can render,\n and you approve or decline in the phone. (Cancel still works from the page.) With no\n such page open, the phone is NOT asked to sign the opaque 32-byte hashes (loan and withdrawal\n envelopes) \u2014 those refuse, because a wallet shows them as a bare hash. Plain transactions and\n typed-data are not gated: the wallet decodes those itself." : ". " + phoneWalletOffer(d) + "."}
87171
+ 2. On the page: connect the browser extension${d.walletConnect ? ", or \u2014 for a mobile wallet \u2014 scan the\n WalletConnect QR code or paste the pairing code, then sign the short statement the wallet\n shows: it proves the wallet holds the address it reports, approves nothing and moves no\n funds, and without it the phone is not accepted. The proof needs an ordinary wallet account\n (EOA): a smart-contract or smart-account wallet cannot produce it, so it cannot connect\n here. KEEP THAT APPROVAL PAGE OPEN \u2014 the one\n whose QR you scanned: while a phone wallet is connected it is the READ-ONLY reader for\n every ceremony \u2014 it shows the full card, the phone shows only what a wallet can render,\n and you approve or decline in the phone. (Cancel still works from the page.) With no\n such page open, the phone is NOT asked to sign the opaque 32-byte hashes (loan and withdrawal\n envelopes) \u2014 those refuse, because a wallet shows them as a bare hash. Plain transactions and\n typed-data are not gated: the wallet decodes those itself." : ". " + phoneWalletOffer(d) + "."}
86995
87172
  3. For authenticated reads before any write: \`signer_setup\` action \`connect\` runs the
86996
87173
  login ceremony explicitly (one typed-data signature in the wallet).
86997
87174
  4. The FIRST verified signature binds that wallet address as the borrower \u2014 it persists
@@ -87650,7 +87827,7 @@ var import_mcp2 = require("@modelcontextprotocol/sdk/server/mcp.js");
87650
87827
 
87651
87828
  // src/tools/loan.ts
87652
87829
  var import_zod = require("zod");
87653
- var import_ethers54 = require("ethers");
87830
+ var import_ethers55 = require("ethers");
87654
87831
 
87655
87832
  // src/util/format.ts
87656
87833
  function bigintReplacer(_key, value) {
@@ -87838,7 +88015,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
87838
88015
  const b = getB();
87839
88016
  if (!b.ok) return renderError(b.error);
87840
88017
  return renderEnvelope(
87841
- await b.boundary.mintUcd({ positionId, amountUcdWei: (0, import_ethers54.parseEther)(amountUcd.toString()).toString() })
88018
+ await b.boundary.mintUcd({ positionId, amountUcdWei: (0, import_ethers55.parseEther)(amountUcd.toString()).toString() })
87842
88019
  );
87843
88020
  })
87844
88021
  );
@@ -87876,7 +88053,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
87876
88053
  if (BigInt(detail.data.debtUcdWei) === 0n) return validationFailed("the position has no outstanding debt");
87877
88054
  amountUcdWei = detail.data.debtUcdWei;
87878
88055
  } else {
87879
- amountUcdWei = (0, import_ethers54.parseEther)(amountUcd.toString()).toString();
88056
+ amountUcdWei = (0, import_ethers55.parseEther)(amountUcd.toString()).toString();
87880
88057
  }
87881
88058
  return renderEnvelope(await b.boundary.repayUcd({ positionId, amountUcdWei }));
87882
88059
  })
@@ -88479,7 +88656,7 @@ function registerMockControlTool(server, control, chainId = 1337) {
88479
88656
 
88480
88657
  // src/tools/signer.ts
88481
88658
  var import_zod6 = require("zod");
88482
- var import_ethers55 = require("ethers");
88659
+ var import_ethers56 = require("ethers");
88483
88660
  var MODES = ["external", "keystore", "safe", "safe-module", "mock-simulated"];
88484
88661
  var ACTIONS2 = ["status", "use", "reset-borrower", "unlock-keystore", "connect", "disconnect"];
88485
88662
  var EXTERNAL_ONLY_MODES = ["external"];
@@ -88521,7 +88698,7 @@ function registerSignerTool(server, getRuntime, opts) {
88521
88698
  if (mode !== void 0 && !offeredModes.includes(mode)) {
88522
88699
  return validationFailed(looksSecretShaped(mode) ? SECRET_REFUSAL : `mode '${mode}' is not one of: ${offeredModes.join(" | ")}`);
88523
88700
  }
88524
- if (safeAddress !== void 0 && !import_ethers55.ethers.isAddress(safeAddress)) {
88701
+ if (safeAddress !== void 0 && !import_ethers56.ethers.isAddress(safeAddress)) {
88525
88702
  return validationFailed(looksSecretShaped(safeAddress) ? SECRET_REFUSAL : `'${safeAddress}' is not a valid Safe address`);
88526
88703
  }
88527
88704
  if (action === "status") {