@gvnrdao/dh-sdk 0.0.314 → 0.0.316

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/index.mjs CHANGED
@@ -95,8 +95,8 @@ var init_deployment_addresses = __esm({
95
95
  FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
96
96
  BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
97
97
  CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
98
- AgentDelegationRegistry: "0xA6040Ee7c52220634C6cC565885d6956C95Faaf5",
99
- DHAgentDelegate: "0x3Ea189b22Db147A7c79fF3FD8AaDfA8B0Bd0f4FB"
98
+ AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
99
+ DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF"
100
100
  },
101
101
  upgraded: {
102
102
  PositionManager: {
@@ -361,9 +361,9 @@ var init_deployment_addresses = __esm({
361
361
  BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_IMPL: "0xFF270BC4470dBA80430Bd1a3a66EB691599354fA",
362
362
  CARRY_AGENT_REGISTRY: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
363
363
  CARRY_AGENT_REGISTRY_IMPL: "0x1b11a3D5e46F3672E643c997f0d569DFf0b64a01",
364
- AGENT_DELEGATION_REGISTRY: "0xA6040Ee7c52220634C6cC565885d6956C95Faaf5",
365
- AGENT_DELEGATION_REGISTRY_IMPL: "0x4cCB77306A1EE0F1F686EeF83B66eD8796E6dd90",
366
- DH_AGENT_DELEGATE: "0x3Ea189b22Db147A7c79fF3FD8AaDfA8B0Bd0f4FB"
364
+ AGENT_DELEGATION_REGISTRY: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
365
+ AGENT_DELEGATION_REGISTRY_IMPL: "0x80C47350274513688e348D02506477A96B4afCCb",
366
+ DH_AGENT_DELEGATE: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF"
367
367
  }
368
368
  };
369
369
  SEPOLIA_CONTRACTS = {
@@ -393,8 +393,8 @@ var init_deployment_addresses = __esm({
393
393
  FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
394
394
  BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
395
395
  CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
396
- AgentDelegationRegistry: "0xA6040Ee7c52220634C6cC565885d6956C95Faaf5",
397
- DHAgentDelegate: "0x3Ea189b22Db147A7c79fF3FD8AaDfA8B0Bd0f4FB"
396
+ AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
397
+ DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF"
398
398
  };
399
399
  MAINNET_DEPLOYMENT = {
400
400
  network: "mainnet",
@@ -9099,6 +9099,23 @@ function createPKPManager(config) {
9099
9099
  // src/modules/loan/loan-creator.module.ts
9100
9100
  import { Contract as Contract3, Interface as Interface2, zeroPadValue as zeroPadValue4, toBeHex, SigningKey } from "ethers";
9101
9101
  var import_dh_lit_actions = __toESM(require_pkg_src());
9102
+
9103
+ // src/utils/contract-wallet.utils.ts
9104
+ var contractWalletCache = /* @__PURE__ */ new Map();
9105
+ async function isContractWallet(provider, address) {
9106
+ const { chainId } = await provider.getNetwork();
9107
+ const cacheKey = `${chainId}:${address.toLowerCase()}`;
9108
+ const cached = contractWalletCache.get(cacheKey);
9109
+ if (cached !== void 0)
9110
+ return cached;
9111
+ const code = await provider.getCode(address);
9112
+ const isContract = code !== "0x";
9113
+ contractWalletCache.set(cacheKey, isContract);
9114
+ return isContract;
9115
+ }
9116
+
9117
+ // src/modules/loan/loan-creator.module.ts
9118
+ var CONTRACT_WALLET_POLL_INTERVAL_MS = 4e3;
9102
9119
  var LoanCreator = class {
9103
9120
  config;
9104
9121
  transactionTimeoutMs;
@@ -9322,6 +9339,11 @@ var LoanCreator = class {
9322
9339
  validatorSignature: validatorSignature.substring(0, 20) + "..."
9323
9340
  });
9324
9341
  }
9342
+ this.config.onPkpCreated?.({
9343
+ tokenId: pkpData.tokenId,
9344
+ ethAddress: pkpData.ethAddress,
9345
+ publicKey: pkpData.publicKey
9346
+ });
9325
9347
  const addressesResult = await this.deriveBitcoinAddresses(
9326
9348
  pkpData.publicKey
9327
9349
  );
@@ -9494,6 +9516,12 @@ var LoanCreator = class {
9494
9516
  error: encErr instanceof Error ? encErr.message : String(encErr)
9495
9517
  });
9496
9518
  }
9519
+ const provider = this.config.contractManager.getProvider();
9520
+ const senderIsContractWallet = await isContractWallet(
9521
+ provider,
9522
+ await signerResult.value.getAddress()
9523
+ );
9524
+ const searchFromBlock = senderIsContractWallet ? await provider.getBlockNumber() : 0;
9497
9525
  const tx = await positionManager.createPosition(
9498
9526
  pkpIdBytes32,
9499
9527
  validatorSignature,
@@ -9515,19 +9543,20 @@ var LoanCreator = class {
9515
9543
  }
9516
9544
  if (this.config.debug) {
9517
9545
  log.info("\u23F3 Waiting for transaction confirmation", {
9518
- hash: tx.hash
9546
+ // For a contract wallet this is the wallet's own id, not an L1 hash — which is
9547
+ // exactly why the confirmation below does not wait on it.
9548
+ hash: tx.hash,
9549
+ senderIsContractWallet,
9550
+ searchFromBlock: senderIsContractWallet ? searchFromBlock : void 0
9519
9551
  });
9520
9552
  }
9521
9553
  const confirmations = await this.createPositionConfirmations();
9522
- const receipt = await Promise.race([
9523
- tx.wait(confirmations),
9524
- new Promise(
9525
- (_, reject) => setTimeout(
9526
- () => reject(new Error("Transaction confirmation timeout")),
9527
- this.transactionTimeoutMs
9528
- )
9529
- )
9530
- ]);
9554
+ const receipt = senderIsContractWallet ? await this.awaitPositionCreatedByPkpId(
9555
+ positionManager,
9556
+ pkpIdBytes32,
9557
+ searchFromBlock,
9558
+ confirmations
9559
+ ) : await this.awaitReceiptByHash(tx, confirmations);
9531
9560
  if (!receipt)
9532
9561
  throw new Error("Transaction was not mined (receipt is null)");
9533
9562
  if (this.config.debug && receipt.logs) {
@@ -9661,6 +9690,81 @@ var LoanCreator = class {
9661
9690
  }
9662
9691
  return 3;
9663
9692
  }
9693
+ /**
9694
+ * EOA path: the returned hash is the L1 hash, so `tx.wait` is exact.
9695
+ *
9696
+ * The timer is cleared on settle — an uncleared one keeps the process alive for the
9697
+ * full timeout after a fast confirmation, which in Node holds the event loop open.
9698
+ */
9699
+ async awaitReceiptByHash(tx, confirmations) {
9700
+ let timer;
9701
+ try {
9702
+ return await Promise.race([
9703
+ tx.wait(confirmations),
9704
+ new Promise((_, reject) => {
9705
+ timer = setTimeout(
9706
+ () => reject(new Error("Transaction confirmation timeout")),
9707
+ this.transactionTimeoutMs
9708
+ );
9709
+ })
9710
+ ]);
9711
+ } finally {
9712
+ if (timer)
9713
+ clearTimeout(timer);
9714
+ }
9715
+ }
9716
+ /**
9717
+ * Contract-wallet path: find this position by its `PositionCreated` log.
9718
+ *
9719
+ * `pkpId` is minted fresh per attempt and is the event's second indexed argument, so a
9720
+ * topic filter on it identifies exactly this position without reference to any transaction
9721
+ * hash. The filter deliberately leaves topic0 unconstrained: two `PositionCreated` ABIs are
9722
+ * in circulation (see `extractPositionId`) and matching on the freshly-minted pkpId alone,
9723
+ * scoped to this contract and to blocks at or after the send, is already unambiguous.
9724
+ *
9725
+ * The same confirmation depth as the EOA path is applied to the log's block, for the reason
9726
+ * given at the call site: `positionId` does not survive a reorg unchanged.
9727
+ */
9728
+ async awaitPositionCreatedByPkpId(positionManager, pkpIdBytes32, fromBlock, confirmations) {
9729
+ const provider = this.config.contractManager.getProvider();
9730
+ const contractAddress = await positionManager.getAddress();
9731
+ const deadline = Date.now() + this.transactionTimeoutMs;
9732
+ while (Date.now() < deadline) {
9733
+ const logs = await provider.getLogs({
9734
+ address: contractAddress,
9735
+ topics: [null, null, pkpIdBytes32],
9736
+ fromBlock,
9737
+ toBlock: "latest"
9738
+ });
9739
+ if (logs.length > 1) {
9740
+ throw new Error(
9741
+ `Expected at most one PositionCreated log for pkpId ${pkpIdBytes32}, found ${logs.length}`
9742
+ );
9743
+ }
9744
+ const positionLog = logs[0];
9745
+ if (positionLog) {
9746
+ const head = await provider.getBlockNumber();
9747
+ const depth = head - positionLog.blockNumber + 1;
9748
+ if (depth >= confirmations) {
9749
+ const receipt = await provider.getTransactionReceipt(
9750
+ positionLog.transactionHash
9751
+ );
9752
+ if (!receipt) {
9753
+ throw new Error(
9754
+ `PositionCreated log for pkpId ${pkpIdBytes32} has no receipt at ${positionLog.transactionHash} \u2014 the block was reorged out mid-confirmation.`
9755
+ );
9756
+ }
9757
+ return receipt;
9758
+ }
9759
+ }
9760
+ await new Promise(
9761
+ (resolve) => setTimeout(resolve, CONTRACT_WALLET_POLL_INTERVAL_MS)
9762
+ );
9763
+ }
9764
+ throw new Error(
9765
+ `Timed out after ${this.transactionTimeoutMs}ms waiting for the PositionCreated log for pkpId ${pkpIdBytes32}. The wallet may not have executed the transaction yet; the position must be rediscovered by pkpId before it is used.`
9766
+ );
9767
+ }
9664
9768
  /**
9665
9769
  * Re-read the receipt after confirmations and re-derive `positionId`, so a reorg
9666
9770
  * cannot leave the caller holding an id that never survived to the canonical chain.
@@ -16281,11 +16385,6 @@ var _abi2 = [
16281
16385
  name: "NotAdminModule",
16282
16386
  type: "error"
16283
16387
  },
16284
- {
16285
- inputs: [],
16286
- name: "NotAuthorizedConsumer",
16287
- type: "error"
16288
- },
16289
16388
  {
16290
16389
  inputs: [],
16291
16390
  name: "NotBorrowerOrRegistrar",
@@ -16318,7 +16417,12 @@ var _abi2 = [
16318
16417
  },
16319
16418
  {
16320
16419
  inputs: [],
16321
- name: "RenewalCapReached",
16420
+ name: "RegistrarAndPauserMustDiffer",
16421
+ type: "error"
16422
+ },
16423
+ {
16424
+ inputs: [],
16425
+ name: "RegistrarMayOnlyRaiseFloor",
16322
16426
  type: "error"
16323
16427
  },
16324
16428
  {
@@ -16476,25 +16580,6 @@ var _abi2 = [
16476
16580
  name: "AgentRotated",
16477
16581
  type: "event"
16478
16582
  },
16479
- {
16480
- anonymous: false,
16481
- inputs: [
16482
- {
16483
- indexed: true,
16484
- internalType: "address",
16485
- name: "previous",
16486
- type: "address"
16487
- },
16488
- {
16489
- indexed: true,
16490
- internalType: "address",
16491
- name: "next",
16492
- type: "address"
16493
- }
16494
- ],
16495
- name: "AuthorizedConsumerUpdated",
16496
- type: "event"
16497
- },
16498
16583
  {
16499
16584
  anonymous: false,
16500
16585
  inputs: [
@@ -16572,18 +16657,6 @@ var _abi2 = [
16572
16657
  internalType: "address",
16573
16658
  name: "borrower",
16574
16659
  type: "address"
16575
- },
16576
- {
16577
- indexed: false,
16578
- internalType: "uint32",
16579
- name: "maxRenewals",
16580
- type: "uint32"
16581
- },
16582
- {
16583
- indexed: false,
16584
- internalType: "uint40",
16585
- name: "maxEndTimestamp",
16586
- type: "uint40"
16587
16660
  }
16588
16661
  ],
16589
16662
  name: "AutoRenewEnabled",
@@ -16766,25 +16839,6 @@ var _abi2 = [
16766
16839
  name: "Paused",
16767
16840
  type: "event"
16768
16841
  },
16769
- {
16770
- anonymous: false,
16771
- inputs: [
16772
- {
16773
- indexed: true,
16774
- internalType: "bytes32",
16775
- name: "positionId",
16776
- type: "bytes32"
16777
- },
16778
- {
16779
- indexed: false,
16780
- internalType: "uint32",
16781
- name: "renewalsUsed",
16782
- type: "uint32"
16783
- }
16784
- ],
16785
- name: "RenewalRecorded",
16786
- type: "event"
16787
- },
16788
16842
  {
16789
16843
  anonymous: false,
16790
16844
  inputs: [
@@ -17062,19 +17116,6 @@ var _abi2 = [
17062
17116
  stateMutability: "view",
17063
17117
  type: "function"
17064
17118
  },
17065
- {
17066
- inputs: [],
17067
- name: "authorizedConsumer",
17068
- outputs: [
17069
- {
17070
- internalType: "address",
17071
- name: "",
17072
- type: "address"
17073
- }
17074
- ],
17075
- stateMutability: "view",
17076
- type: "function"
17077
- },
17078
17119
  {
17079
17120
  inputs: [
17080
17121
  {
@@ -17243,16 +17284,6 @@ var _abi2 = [
17243
17284
  internalType: "bytes32",
17244
17285
  name: "positionId",
17245
17286
  type: "bytes32"
17246
- },
17247
- {
17248
- internalType: "uint32",
17249
- name: "maxRenewals",
17250
- type: "uint32"
17251
- },
17252
- {
17253
- internalType: "uint40",
17254
- name: "maxEndTimestamp",
17255
- type: "uint40"
17256
17287
  }
17257
17288
  ],
17258
17289
  name: "enableAutoRenew",
@@ -17295,21 +17326,6 @@ var _abi2 = [
17295
17326
  name: "scopeBits",
17296
17327
  type: "uint32"
17297
17328
  },
17298
- {
17299
- internalType: "uint32",
17300
- name: "maxRenewals",
17301
- type: "uint32"
17302
- },
17303
- {
17304
- internalType: "uint32",
17305
- name: "renewalsUsed",
17306
- type: "uint32"
17307
- },
17308
- {
17309
- internalType: "uint40",
17310
- name: "maxEndTimestamp",
17311
- type: "uint40"
17312
- },
17313
17329
  {
17314
17330
  internalType: "uint32",
17315
17331
  name: "minCollateralRatioBps",
@@ -17577,19 +17593,6 @@ var _abi2 = [
17577
17593
  stateMutability: "view",
17578
17594
  type: "function"
17579
17595
  },
17580
- {
17581
- inputs: [
17582
- {
17583
- internalType: "bytes32",
17584
- name: "positionId",
17585
- type: "bytes32"
17586
- }
17587
- ],
17588
- name: "recordRenewal",
17589
- outputs: [],
17590
- stateMutability: "nonpayable",
17591
- type: "function"
17592
- },
17593
17596
  {
17594
17597
  inputs: [
17595
17598
  {
@@ -17716,19 +17719,6 @@ var _abi2 = [
17716
17719
  stateMutability: "nonpayable",
17717
17720
  type: "function"
17718
17721
  },
17719
- {
17720
- inputs: [
17721
- {
17722
- internalType: "address",
17723
- name: "consumer",
17724
- type: "address"
17725
- }
17726
- ],
17727
- name: "setAuthorizedConsumer",
17728
- outputs: [],
17729
- stateMutability: "nonpayable",
17730
- type: "function"
17731
- },
17732
17722
  {
17733
17723
  inputs: [
17734
17724
  {
@@ -17824,7 +17814,7 @@ var _abi2 = [
17824
17814
  type: "function"
17825
17815
  }
17826
17816
  ];
17827
- var _bytecode2 = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161308690816100f0823960805181818161121b015261140e0152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a7146120b4575080630d33f3c2146120905780630f3f4a94146120445780631459457a14611cfd578063188787e814611c2b57806318c38b8914611b1a5780631b02993114611aa65780631d44454114611a0b578063248a9ca3146119e55780632ec22d4c1461191c5780632f0647ce1461189d5780632f2ff15d1461186c57806336568abe14611826578063392f1087146117db5780633f4ba83a146116e35780633f5aadc9146116745780634f1ef28614611392578063523403631461129b5780635273b6f61461127257806352d1902d14611208578063554c4f4b14611178578063561b7f8a146110145780635bc26aea14610f875780635c975abb14610f575780636289d18c14610ed65780636711cc0b14610eba5780636e852a7814610da95780637e35bf6e14610d755780638343f67414610d485780638456cb5914610c525780638f33527f14610c185780639010d07c14610bc457806391d1485414610b6a5780639b9d30c114610b41578063a19af3f614610a7c578063a217fddf14610a60578063a3246ad31461099e578063a878086414610982578063ac3c0e3014610875578063ad3cb1cc1461082e578063b3fad6381461074b578063c34e9c261461072f578063c6fbbb87146105dd578063ca15c873146105a4578063d547741f1461056c578063dd71d99a1461052a578063e0922fa11461047d578063e187828314610454578063f2f4eb261461042b578063f68e955314610402578063fd437d39146102945763ffa1ad741461025b57600080fd5b3461028f57600036600319011261028f5761028b610277612282565b60405191829160208352602083019061225d565b0390f35b600080fd5b3461028f57606036600319011261028f576102ad612137565b6102b5612121565b906102be612224565b336000908152600080516020612f9a833981519152602052604090205490919060ff16156103db576001600160a01b031660008181526001602052604090208054939060e085901c60ff1660038110156103c5576001036103b45781600160209261034b877fc5d5c5bbf10444998e0ea6d4725e79027b574e1c14ec929279e8a9a95c6c6e919688612c79565b818060a01b038316828060a01b031982541617815561036a878261243b565b0180546001600160401b031916426001600160401b03908116919091179091556001600160a01b0391821660008181526002855260409081902087905551969091168652951693a4005b632437e77160e11b60005260046000fd5b634e487b7160e01b600052602160045260246000fd5b63e2517d3f60e01b6000523360045260008051602061301a83398151915260245260446000fd5b3461028f57600036600319011261028f57602060405160008051602061301a8339815191528152f35b3461028f57600036600319011261028f576003546040516001600160a01b039091168152602090f35b3461028f57600036600319011261028f576004546040516001600160a01b039091168152602090f35b3461028f57602036600319011261028f576004356001600160401b0381169081810361028f576000546001600160a01b038116330361051957600160a01b600160e01b0319811660a092831b600160a01b600160e01b031617600055604080519190921c6001600160401b0316815260208101929092527f9c195448332abd01f716db873b329752ea02f19d33f7e311fb0daf082c4edd0391a1005b6349db3bd360e01b60005260046000fd5b3461028f57602036600319011261028f576001600160a01b0361054b612137565b166000526002602052602060018060a01b0360406000205416604051908152f35b3461028f57604036600319011261028f576105a260043561058b612121565b9061059d61059882612302565b612a2c565b612abe565b005b3461028f57602036600319011261028f57600435600052600080516020612f1a8339815191526020526020604060002054604051908152f35b3461028f57602036600319011261028f5760043560018060a01b036004541633141580610708575b6106f757600081815260056020526040902080546001600160a01b038116156106e65760018160a01c16156106e65763ffffffff8160c01c1680151590816106d8575b506106c75760e01c6001019063ffffffff82116106b15780546001600160e01b031660e083901b6001600160e01b03191617905560405163ffffffff90911681527f859a3b34c0d733a1033c6089d4d18643a0705b707970a0d0d79c84423f089da190602090a2005b634e487b7160e01b600052601160045260246000fd5b638a6ea6bf60e01b60005260046000fd5b90508160e01c101584610648565b6360eb6c2360e01b60005260046000fd5b634b95b20b60e11b60005260046000fd5b50336000908152600080516020612f9a833981519152602052604090205460ff1615610605565b3461028f57600036600319011261028f57602060405160028152f35b3461028f57602036600319011261028f57600060a060405161076c816121cb565b8281528260208201528260408201528260608201528260808201520152600435600052600560205260c0604060002063ffffffff604051916107ad836121cb565b64ffffffffff8154938360018060a01b03861695868352816020840195818360a01c168752816001604087019282868e1c168452606088019560e01c86520154978160a060808901988a8c168a52019960281c1689526040519a8b52511660208a0152511660408801525116606086015251166080840152511660a0820152f35b3461028f57600036600319011261028f5761028b604080519061085181836121e6565b60058252640352e302e360dc1b60208301525191829160208352602083019061225d565b3461028f57602036600319011261028f5761088e612137565b6000608060405161089e8161219a565b828152826020820152826040820152826060820152015260018060a01b0316600052600160205260406000206040516108d68161219a565b81546001600160a01b038116825260a081901c6001600160401b03166020830190815292604083019160e01c60ff169060038210156103c557908252600101546001600160401b0380821660608501908152604092831c821660808601908152925194516001600160a01b03168552945116602084015290519260038410156103c557604083019390935291516001600160401b0390811660608301529151909116608082015260a090f35b3461028f57600036600319011261028f57602060405160018152f35b3461028f57602036600319011261028f57600435600052600080516020612f1a83398151915260205260406000206040518060208354918281520190819360005260206000209060005b818110610a4a57505050816109fe9103826121e6565b6040519182916020830190602084525180915260408301919060005b818110610a28575050500390f35b82516001600160a01b0316845285945060209384019390920191600101610a1a565b82548452602090930192600192830192016109e8565b3461028f57600036600319011261028f57602060405160008152f35b3461028f57604036600319011261028f57600435610a98612174565b90610aa1612639565b63ffffffff600654169163ffffffff811692808410908115610b38575b50610b275760206001610b147f1da95b87b4c773f68c1447ffc5644e41a8a8887d55065beb64852014cf7140be93610af586612684565b9390610b0e600463ffffffff835460a01c1617826122a5565b016122c8565b6040519485526001600160a01b031693a3005b634346c13160e01b60005260046000fd5b90501584610abe565b3461028f57600036600319011261028f576020604051600080516020612f5a8339815191528152f35b3461028f57604036600319011261028f57610b83612121565b600435600052600080516020612ffa83398151915260205260406000209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b3461028f57604036600319011261028f57600435600052600080516020612f1a8339815191526020526020610bff6024356040600020612d46565b905460405160039290921b1c6001600160a01b03168152f35b3461028f57602036600319011261028f576001600160a01b03610c39612137565b1660005260026020526020604060002054604051908152f35b3461028f57600036600319011261028f573360009081527f0ac8cc3d209806126662940717264973110c39045b305f6ba49613325a615e09602052604090205460ff1615610d2157610ca2612639565b600160ff1960008051602061303a83398151915254161760008051602061303a833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a2005b63e2517d3f60e01b60005233600452600080516020612f5a83398151915260245260446000fd5b3461028f57600036600319011261028f5760005460405160a09190911c6001600160401b03168152602090f35b3461028f57604036600319011261028f57610d99610d91612121565b6004356123a5565b9061028b6040519283928361215a565b3461028f57604036600319011261028f57610dc2612137565b336000908152600080516020612f9a833981519152602052604090205460ff161580610ea7575b610e97576001600160a01b03166000818152600160205260409020805460e01c60ff1660038110156103c5576001036103b457805460ff60e01b198116600160e11b1782556001919091018054600160401b600160801b03191642604090811b600160401b600160801b0316919091179091555160243581526001600160a01b0390911691907fc0499cc07ed9d734deec6857802d3f0fa8d5afaf79a7008beb8ba7bef62a271b90602090a3005b62fca64560e31b60005260046000fd5b50336001600160a01b0382161415610de9565b3461028f57600036600319011261028f57602060405160048152f35b3461028f57602036600319011261028f57610eef612187565b6000546001600160a01b031633036105195763ffffffff8116908115610f4657600080516020612fda83398151915291610f4163ffffffff9260065492841984161760065560405193849316836122eb565b0390a1005b6338f3377360e21b60005260046000fd5b3461028f57600036600319011261028f57602060ff60008051602061303a83398151915254166040519015158152f35b3461028f57602036600319011261028f57610fa0612137565b6000546001600160a01b0381169033829003610519576001600160a01b038316928315611003573b15610ff2576001600160a01b03191682176000908155600080516020612fba8339815191529080a3005b636f7c43f160e01b60005260046000fd5b63e6c4247b60e01b60005260046000fd5b3461028f57606036600319011261028f5761102d612137565b611035612121565b61103d612224565b91611046612639565b336000908152600080516020612f9a833981519152602052604090205460ff161580611165575b610e97576001600160a01b03166000818152600160205260409020805491929160e01c60ff1660038110156103c55760011461115457816020916110d3867ff223dc085722c94c84dcf67427e225799be616382a2a484d378f8921c69a20339587612c79565b80546001600160a01b0319166001600160a01b0383161781556110f6868261243b565b6001810180546001600160801b031916426001600160401b0390811691909117909155815460ff60e01b1916600160e01b179091556001600160a01b03919091166000818152600284526040908190208690555195909116855293a3005b639d2c8fdf60e01b60005260046000fd5b50336001600160a01b038216141561106d565b3461028f57602036600319011261028f576001600160a01b03611199612137565b166000526001602052604060002060ff60008051602061303a833981519152541615806111ec575b602091816111d5575b506040519015158152f35b5460a01c6001600160401b031642109050826111ca565b5060ff815460e01c169060038210156103c557906001146111c1565b3461028f57600036600319011261028f577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163003611261576020604051600080516020612f7a8339815191528152f35b63703e46dd60e11b60005260046000fd5b3461028f57600036600319011261028f576000546040516001600160a01b039091168152602090f35b3461028f57602036600319011261028f57600435600081815260056020526040902080546001600160a01b0381169291908315908115611383575b506106e657336000908152600080516020612f9a833981519152602052604090205460ff161580611379575b611368578061131e63fffffffe611341935460a01c16826122a5565b80546001600160c01b0316815560018101805464ffffffffff1916905582612a02565b7fa5ffbdba01b15df97334e34ad816b9986b6057a5ddc97aba93b7e8ccd21759ed600080a3005b630a606ec360e11b60005260046000fd5b5082331415611302565b6001915060a01c1615846112d6565b604036600319011261028f576113a6612137565b602435906001600160401b03821161028f573660238301121561028f578160040135906113d282612209565b916113e060405193846121e6565b8083526020830193366024838301011161028f57816000926024602093018737840101526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016308114908115611651575b50611261576000546001600160a01b03163303610519576001600160a01b03811692831561100357813b156116405730841461163157600080516020612f7a8339815191525484611488612282565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f6114be6040519260408452604084019061225d565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481895afa600091816115fd575b5061150e5785634c9c8ce360e01b60005260045260246000fd5b9081600080516020612f7a8339815191528793036115e95750833b156115d4576001600160a01b0319168117600080516020612f7a833981519152557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28251156115b957600080916105a2945190845af43d156115b1573d9161159483612209565b926115a260405194856121e6565b83523d6000602085013e612eb8565b606091612eb8565b505050346115c357005b63b398979f60e01b60005260046000fd5b50634c9c8ce360e01b60005260045260246000fd5b632a87526960e21b60005260045260246000fd5b9091506020813d602011611629575b81611619602093836121e6565b8101031261028f575190876114f4565b3d915061160c565b614e8d60eb1b60005260046000fd5b632e07c4bd60e11b60005260046000fd5b600080516020612f7a833981519152546001600160a01b03161415905084611439565b3461028f57602036600319011261028f57600435611690612639565b6116b261169c82612684565b9190600263ffffffff825460a01c1617906122a5565b6001600160a01b0316907fc2713e691344add4705edc62a0ee5aede95ba66ad68f97316efef9cb50644edd600080a3005b3461028f57600036600319011261028f57336000908152600080516020612f9a833981519152602052604090205460ff1615806117c6575b6117b55760008051602061303a8339815191525460ff8116156117a45760ff191660008051602061303a833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a2005b638dfc202b60e01b60005260046000fd5b63659a07b360e11b60005260046000fd5b506000546001600160a01b031633141561171b565b3461028f57604036600319011261028f57606061181e63ffffffff611809611801612121565b600435612323565b9193906040519415158552602085019061214d565b166040820152f35b3461028f57604036600319011261028f5761183f612121565b336001600160a01b0382160361185b576105a290600435612abe565b63334bd91960e11b60005260046000fd5b3461028f57604036600319011261028f576105a260043561188b612121565b9061189861059882612302565b612a76565b3461028f57602036600319011261028f576004356118eb6118bd82612990565b91906118d363fffffffb825460a01c16826122a5565b60018101805463ffffffff60281b1916905583612a02565b6001600160a01b0316907f09cb4ec44cdef8489412844b9682f87f7900758fa2bd7e039113e9125e538e0f600080a3005b3461028f57602036600319011261028f57600435600081815260056020526040902080546001600160a01b03811692919083159081156119d6575b506106e657336000908152600080516020612f9a833981519152602052604090205460ff1615806119cc575b611368578061199f63fffffffd6119a5935460a01c16826122a5565b82612a02565b7fb390ab029eab314bd18190ebe73d7e5c1c336beaa5c83ac22578378dc9ccc405600080a3005b5082331415611983565b6002915060a01c161584611957565b3461028f57602036600319011261028f576020611a03600435612302565b604051908152f35b3461028f57604036600319011261028f57600435611a27612174565b63ffffffff600654168063ffffffff831610908115611a9d575b50610b27577e8a218591d4362499c38c38eb1c12e7a7cc97a9068818d1fe6046a42ba4a5ba906001611a7284612990565b5001611a898263ffffffff835460281c16926122c8565b611a98604051928392836122eb565b0390a2005b90501583611a41565b3461028f57602036600319011261028f57611abf612137565b6000546001600160a01b0316330361051957600480546001600160a01b039283166001600160a01b0319821681179092559091167f8556037c5648b2d5b51736f07a8fa4d099812ef06abf79a5731be619b111e4d4600080a3005b3461028f57602036600319011261028f57611b33612187565b60008051602061305a8339815191525460ff8160401c16908115611c13575b50611c025760008051602061305a833981519152805460026001600160401b0319821681179092556000546001600160481b031990911690911791906001600160a01b031633036105195763ffffffff168015610f4657604081600080516020612fda8339815191529263ffffffff196006541617600655815190600082526020820152a160008051602061305a83398151915255600080516020612f3a833981519152602060405160028152a1005b63f92ee8a960e01b60005260046000fd5b60026001600160401b03919091161015905082611b52565b3461028f57606036600319011261028f57600435611c47612174565b9060443564ffffffffff811680910361028f57604060017ef8e9f2101420b089a9228a3e9fa546f669754196824e19ec1adab7cab1f2e992611c87612639565b611c9085612684565b9290611ca88263ffffffff835460a01c1617826122a5565b805463ffffffff60c01b60c08a901b1663ffffffff60c01b199091161760e083901b83900316815501805464ffffffffff191682179055825163ffffffff909616865260208601526001600160a01b031693a3005b3461028f5760a036600319011261028f57611d16612137565b611d1e612121565b906044356001600160a01b03811680820361028f576064356001600160a01b0381169182820361028f576084356001600160a01b038116949085900361028f5760008051602061305a83398151915254604081901c60ff161596906001600160401b03168015908161203c575b6001149081612032575b159081612029575b50611c025760008051602061305a83398151915280546001600160401b031916600117905586612004575b611dd0612b02565b611dd8612b02565b611de0612b02565b611de8612b02565b6001600160a01b038116908115611003578315611003578515611003576001600160a01b038916988915611003573b15610ff257611e27906000612b30565b9081611fbd575b5015611f0257611e4c9060008051602061301a833981519152612b30565b9081611f68575b5015611f0257611e7190600080516020612f5a833981519152612b30565b9081611f13575b5015611f0257600080546001600160a01b031916841781556040519390600080516020612fba8339815191528180a3801561100357803b15610ff257600380546001600160a01b031916919091179055611ece57005b60008051602061305a833981519152805460ff60401b1916905560018152600080516020612f3a83398151915290602090a1005b63cf5a8e3360e01b60005260046000fd5b600080516020612f5a833981519152600052600080516020612f1a833981519152602052611f61907ffff5b43478fa6840382eb63777e0da6941d320b940e3f70f0ea4780feff95827612d74565b5084611e78565b60008051602061301a833981519152600052600080516020612f1a833981519152602052611fb6907f32d31393d541a265984ec379cddd8b1fcbe5f2b0eb8ad81dddfead454f135eaa612d74565b5086611e53565b60008052600080516020612f1a833981519152602052611ffd907f615f0f9e84155bea8cc509fe18befeb1baf65611e38a6ba60964480fb29dfd44612d74565b5088611e2e565b60008051602061305a833981519152805460ff60401b1916600160401b179055611dc8565b90501589611d9d565b303b159150611d95565b889150611d8b565b3461028f57604036600319011261028f57612075612060612121565b60043560005260056020526040600020612464565b600a8110156103c55761028b9060405191818392158361215a565b3461028f57600036600319011261028f57602063ffffffff60065416604051908152f35b3461028f57602036600319011261028f576004359063ffffffff60e01b821680920361028f57602091635a05180f60e01b81149081156120f6575b5015158152f35b637965db0b60e01b811491508115612110575b50836120ef565b6301ffc9a760e01b14905083612109565b602435906001600160a01b038216820361028f57565b600435906001600160a01b038216820361028f57565b90600a8210156103c55752565b9015158152604081019291612172916020019061214d565b565b6024359063ffffffff8216820361028f57565b6004359063ffffffff8216820361028f57565b60a081019081106001600160401b038211176121b557604052565b634e487b7160e01b600052604160045260246000fd5b60c081019081106001600160401b038211176121b557604052565b601f909101601f19168101906001600160401b038211908210176121b557604052565b6001600160401b0381116121b557601f01601f191660200190565b604435906001600160401b038216820361028f57565b60005b83811061224d5750506000910152565b818101518382015260200161223d565b906020916122768151809281855285808601910161223a565b601f01601f1916010190565b604051906122916040836121e6565b6005825264312e312e3160d81b6020830152565b805463ffffffff60a01b191660a09290921b63ffffffff60a01b16919091179055565b805463ffffffff60281b191660289290921b63ffffffff60281b16919091179055565b63ffffffff91821681529116602082015260400190565b600052600080516020612ffa83398151915260205260016040600020015490565b600052600560205261233a60406000209182612521565b600a8110156103c5578061239b5750600163ffffffff91015460281c1663ffffffff6006541681158015612393575b6123865780821061237f57505b60019160009190565b9050612376565b5050600090600390600090565b508015612369565b6000929091508290565b60005260056020526123bc604060002091826125ad565b600a8110156103c557806124335750805463ffffffff8160c01c168015159182612425575b505061241c576001015464ffffffffff168015159081612411575b5061240957600190600090565b600090600990565b9050421015386123fc565b50600090600890565b60e01c1015905038806123e1565b600092909150565b8054600160a01b600160e01b03191660a09290921b600160a01b600160e01b0316919091179055565b60ff60008051602061303a833981519152541661251a57546001600160a01b0381169081156125125760a01c6002161561250b5760005260016020526040600020549060ff8260e01c1660038110156103c5578015612503576002146124fc574260a083901c6001600160401b031611156124f5576001600160a01b039081169116036124f057600090565b600790565b5050600690565b5050600590565b505050600490565b5050600390565b505050600290565b5050600190565b60ff60008051602061303a833981519152541661251a57546001600160a01b0381169081156125125760a01c6004161561250b5760005260016020526040600020549060ff8260e01c1660038110156103c5578015612503576002146124fc574260a083901c6001600160401b031611156124f5576001600160a01b039081169116036124f057600090565b60ff60008051602061303a833981519152541661251a57546001600160a01b0381169081156125125760a01c6001161561250b5760005260016020526040600020549060ff8260e01c1660038110156103c5578015612503576002146124fc574260a083901c6001600160401b031611156124f5576001600160a01b039081169116036124f057600090565b60ff60008051602061303a833981519152541661265257565b63d93c066560e01b60005260046000fd5b519064ffffffffff8216820361028f57565b519061ffff8216820361028f57565b801561297f57600354604051638d34875560e01b8152600481018390529190600090839060249082906001600160a01b03165afa918215612973576000926127c8575b506080820151336000908152600080516020612f9a83398151915260205260409020546001600160a01b03909116929060ff1615806127be575b61136857610120015160088110156103c5576003811490600082156127b0575b821561279f575b505061278e5781600052600160205260ff60406000205460e01c1660038110156103c55760010361277d57600090815260056020526040902080546001600160a01b0319166001600160a01b03831617815591565b632e68d1d360e21b60005260046000fd5b63e9f6db8560e01b60005260046000fd5b9091506103c5576007143880612728565b506005811491506000612721565b5082331415612701565b90913d8082843e6127d981846121e6565b820191602081840312612953578051906001600160401b03821161295b5701906101a08284031261295057604051926101a084016001600160401b0381118582101761295f5760409081528351855260208085015190860152838101519085015260608301516001600160401b03811161295b57830181601f8201121561295b5780519061286682612209565b9261287460405194856121e6565b828452602083830101116129575790612893916020808501910161223a565b606084015260808201516001600160a01b03811681036129535760808401526128be60a08301612663565b60a08401526128cf60c08301612663565b60c08401526128e060e08301612675565b60e08401526128f26101008301612663565b610100840152610120820151906008821015612950575061294391610180916101208501526129246101408201612663565b6101408501526129376101608201612675565b61016085015201612663565b61018082015290386126c7565b80fd5b5080fd5b8380fd5b8280fd5b634e487b7160e01b83526041600452602483fd5b6040513d6000823e3d90fd5b637bb0b62160e01b60005260046000fd5b6000908152600560205260409020805490916001600160a01b0382169182159081156129f3575b506106e657336000908152600080516020612f9a833981519152602052604090205460ff1615806129e9575b61136857565b50813314156129e3565b6004915060a01c1615386129b7565b905460a01c63ffffffff1615612a155750565b600052600560205260006001604082208281550155565b6000818152600080516020612ffa8339815191526020908152604080832033845290915290205460ff1615612a5e5750565b63e2517d3f60e01b6000523360045260245260446000fd5b612a808282612b30565b9182612a8b57505090565b6000918252600080516020612f1a8339815191526020526040909120612aba916001600160a01b031690612d74565b5090565b612ac88282612bd9565b9182612ad357505090565b6000918252600080516020612f1a8339815191526020526040909120612aba916001600160a01b031690612de5565b60ff60008051602061305a8339815191525460401c1615612b1f57565b631afcd79f60e31b60005260046000fd5b6000818152600080516020612ffa833981519152602090815260408083206001600160a01b038616845290915290205460ff16612bd2576000818152600080516020612ffa833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050600090565b6000818152600080516020612ffa833981519152602090815260408083206001600160a01b038616845290915290205460ff1615612bd2576000818152600080516020612ffa833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b9081158015612d35575b611003576001600160a01b0316600090815260026020526040902054801515919082612d2a575b5050612d19576001600160401b031642811115612d085760005460a01c6001600160401b03168015159182612cf3575b5050612ce257565b63e774e7b560e01b60005260046000fd5b9091504281039081116106b157113880612cda565b63efa7aefd60e01b60005260046000fd5b633b53f64f60e21b60005260046000fd5b141590503880612caa565b506001600160a01b03811615612c83565b8054821015612d5e5760005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b6001810190826000528160205260406000205415600014612ddd578054600160401b8110156121b557612dc8612db1826001879401855584612d46565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b505050600090565b9060018201918160005282602052604060002054801515600014612eaf5760001981018181116106b15782546000198101919082116106b157818103612e78575b50505080548015612e62576000190190612e408282612d46565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b612e98612e88612db19386612d46565b90549060031b1c92839286612d46565b905560005283602052604060002055388080612e26565b50505050600090565b90612ede5750805115612ecd57602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580612f10575b612eef575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b15612ee756fec1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d275027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc07966f2ab141347034724e9b2a472c2f77f5cd745aeba27cacba797b8fcb708617dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846cd37bc77615afefc793aa17d75d4249a9b517ba91b0e54a49c9c4a44b3d7e228302dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800edcc084d3dcd65a1f7f23c65c46722faca6953d28e43150a467cf43e5c309238cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a164736f6c6343000822000a";
17817
+ var _bytecode2 = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b604051612d3290816100f0823960805181818161101d01526112020152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a714611dec575080630d33f3c214611dc85780630f3f4a9414611d7d5780631459457a146119d757806318c38b89146118c65780631d444541146117f5578063248a9ca3146117cf5780632ec22d4c1461170e5780632f0647ce146116935780632f2ff15d1461166257806336568abe1461161c578063392f1087146115cf5780633f4ba83a146114d75780633f5aadc9146114685780634f1ef28614611186578063523403631461109d5780635273b6f61461107457806352d1902d1461100a578063554c4f4b14610f7a578063561b7f8a14610e4e5780635bc26aea14610dc15780635c975abb14610d915780636289d18c14610d105780636711cc0b14610cf45780636e852a7814610bf35780637e35bf6e14610bbf5780638343f67414610b925780638456cb5914610a9c5780638f33527f14610a625780639010d07c14610a0e57806391d14854146109b45780639b9d30c11461098b578063a19af3f6146108c9578063a217fddf146108ad578063a3246ad3146107eb578063a8780864146107cf578063ac3c0e30146106c2578063ad3cb1cc1461067b578063b3fad638146105ef578063c34e9c26146105d3578063ca15c8731461059a578063d547741f14610562578063dd71d99a14610520578063e0922fa114610473578063efa9b4ae14610404578063f2f4eb26146103db578063f68e9553146103b2578063fd437d39146102735763ffa1ad741461023a57600080fd5b3461026e57600036600319011261026e5761026a610256611fb9565b604051918291602083526020830190611f94565b0390f35b600080fd5b3461026e57606036600319011261026e5761028c611e6f565b610294611e59565b9061029d611f5b565b906102a661247b565b6001600160a01b0316338190036103a25780600052600160205260406000209283549360ff8560e01c16600381101561038c5760010361037b57816001602092610312877fc5d5c5bbf10444998e0ea6d4725e79027b574e1c14ec929279e8a9a95c6c6e919688612929565b818060a01b038316828060a01b03198254161781556103318782612111565b0180546001600160401b031916426001600160401b03908116919091179091556001600160a01b0391821660008181526002855260409081902087905551969091168652951693a4005b632437e77160e11b60005260046000fd5b634e487b7160e01b600052602160045260246000fd5b62fca64560e31b60005260046000fd5b3461026e57600036600319011261026e576020604051600080516020612cc68339815191528152f35b3461026e57600036600319011261026e576003546040516001600160a01b039091168152602090f35b3461026e57602036600319011261026e5760043561042061247b565b61044261042c826124c6565b9190600163ffffffff825460a01c161790612037565b6001600160a01b0316907f812690e0a9dff5bf3add998111b8af5c8299608d859025bfe35662060ab4267d600080a3005b3461026e57602036600319011261026e576004356001600160401b0381169081810361026e576000546001600160a01b038116330361050f57600160a01b600160e01b0319811660a092831b600160a01b600160e01b031617600055604080519190921c6001600160401b0316815260208101929092527f9c195448332abd01f716db873b329752ea02f19d33f7e311fb0daf082c4edd0391a1005b6349db3bd360e01b60005260046000fd5b3461026e57602036600319011261026e576001600160a01b03610541611e6f565b166000526002602052602060018060a01b0360406000205416604051908152f35b3461026e57604036600319011261026e57610598600435610581611e59565b9061059361058e82612016565b6123a5565b612437565b005b3461026e57602036600319011261026e57600435600052600080516020612bc68339815191526020526020604060002054604051908152f35b3461026e57600036600319011261026e57602060405160028152f35b3461026e57602036600319011261026e5760006040805161060f81611f02565b828152826020820152015260043560005260046020526060604060002063ffffffff6040519161063e83611f02565b548160018060a01b038216938481528160406020830192828660a01c168452019360c01c1683526040519485525116602084015251166040820152f35b3461026e57600036600319011261026e5761026a604080519061069e8183611f1d565b60058252640352e302e360dc1b602083015251918291602083526020830190611f94565b3461026e57602036600319011261026e576106db611e6f565b600060806040516106eb81611ed1565b828152826020820152826040820152826060820152015260018060a01b03166000526001602052604060002060405161072381611ed1565b81546001600160a01b038116825260a081901c6001600160401b03166020830190815292604083019160e01c60ff1690600382101561038c57908252600101546001600160401b0380821660608501908152604092831c821660808601908152925194516001600160a01b031685529451166020840152905192600384101561038c57604083019390935291516001600160401b0390811660608301529151909116608082015260a090f35b3461026e57600036600319011261026e57602060405160018152f35b3461026e57602036600319011261026e57600435600052600080516020612bc683398151915260205260406000206040518060208354918281520190819360005260206000209060005b818110610897575050508161084b910382611f1d565b6040519182916020830190602084525180915260408301919060005b818110610875575050500390f35b82516001600160a01b0316845285945060209384019390920191600101610867565b8254845260209093019260019283019201610835565b3461026e57600036600319011261026e57602060405160008152f35b3461026e57604036600319011261026e576004356108e5611ebe565b906108ee61247b565b63ffffffff600554169163ffffffff811692808410908115610982575b506109715760207f1da95b87b4c773f68c1447ffc5644e41a8a8887d55065beb64852014cf7140be9161095e610940856124c6565b9290610959600463ffffffff835460a01c161782612037565b611fdc565b6040519485526001600160a01b031693a3005b634346c13160e01b60005260046000fd5b9050158461090b565b3461026e57600036600319011261026e576020604051600080516020612c068339815191528152f35b3461026e57604036600319011261026e576109cd611e59565b600435600052600080516020612ca683398151915260205260406000209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b3461026e57604036600319011261026e57600435600052600080516020612bc68339815191526020526020610a4960243560406000206129f2565b905460405160039290921b1c6001600160a01b03168152f35b3461026e57602036600319011261026e576001600160a01b03610a83611e6f565b1660005260026020526020604060002054604051908152f35b3461026e57600036600319011261026e573360009081527f0ac8cc3d209806126662940717264973110c39045b305f6ba49613325a615e09602052604090205460ff1615610b6b57610aec61247b565b600160ff19600080516020612ce6833981519152541617600080516020612ce6833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a2005b63e2517d3f60e01b60005233600452600080516020612c0683398151915260245260446000fd5b3461026e57600036600319011261026e5760005460405160a09190911c6001600160401b03168152602090f35b3461026e57604036600319011261026e57610be3610bdb611e59565b6004356120de565b9061026a60405192839283611e8f565b3461026e57604036600319011261026e57610c0c611e6f565b336000908152600080516020612c46833981519152602052604090205460ff161580610ce1575b6103a2576001600160a01b03166000818152600160205260409020805460e01c60ff16600381101561038c5760010361037b57805460ff60e01b198116600160e11b1782556001919091018054600160401b600160801b03191642604090811b600160401b600160801b0316919091179091555160243581526001600160a01b0390911691907fc0499cc07ed9d734deec6857802d3f0fa8d5afaf79a7008beb8ba7bef62a271b90602090a3005b50336001600160a01b0382161415610c33565b3461026e57600036600319011261026e57602060405160048152f35b3461026e57602036600319011261026e57610d29611eab565b6000546001600160a01b0316330361050f5763ffffffff8116908115610d8057600080516020612c8683398151915291610d7b63ffffffff926005549284198416176005556040519384931683611fff565b0390a1005b6338f3377360e21b60005260046000fd5b3461026e57600036600319011261026e57602060ff600080516020612ce683398151915254166040519015158152f35b3461026e57602036600319011261026e57610dda611e6f565b6000546001600160a01b038116903382900361050f576001600160a01b038316928315610e3d573b15610e2c576001600160a01b03191682176000908155600080516020612c668339815191529080a3005b636f7c43f160e01b60005260046000fd5b63e6c4247b60e01b60005260046000fd5b3461026e57606036600319011261026e57610e67611e6f565b610e6f611e59565b610e77611f5b565b91610e8061247b565b6001600160a01b031690338290036103a257816000526001602052604060002060ff815460e01c16600381101561038c57600114610f695781602091610ee8867ff223dc085722c94c84dcf67427e225799be616382a2a484d378f8921c69a20339587612929565b80546001600160a01b0319166001600160a01b038316178155610f0b8682612111565b6001810180546001600160801b031916426001600160401b0390811691909117909155815460ff60e01b1916600160e01b179091556001600160a01b03919091166000818152600284526040908190208690555195909116855293a3005b639d2c8fdf60e01b60005260046000fd5b3461026e57602036600319011261026e576001600160a01b03610f9b611e6f565b166000526001602052604060002060ff600080516020612ce683398151915254161580610fee575b60209181610fd7575b506040519015158152f35b5460a01c6001600160401b03164210905082610fcc565b5060ff815460e01c1690600382101561038c5790600114610fc3565b3461026e57600036600319011261026e577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163003611063576020604051600080516020612c268339815191528152f35b63703e46dd60e11b60005260046000fd5b3461026e57600036600319011261026e576000546040516001600160a01b039091168152602090f35b3461026e57602036600319011261026e57600435604060008281526004602052209081549160018060a01b038316928315908115611177575b5061116657336000908152600080516020612c46833981519152602052604090205460ff16158061115c575b61114b578061111e63fffffffe611124935460a01c1682612037565b82612381565b7fa5ffbdba01b15df97334e34ad816b9986b6057a5ddc97aba93b7e8ccd21759ed600080a3005b630a606ec360e11b60005260046000fd5b5082331415611102565b6360eb6c2360e01b60005260046000fd5b6001915060a01c1615846110d6565b604036600319011261026e5761119a611e6f565b602435906001600160401b03821161026e573660238301121561026e578160040135906111c682611f40565b916111d46040519384611f1d565b8083526020830193366024838301011161026e57816000926024602093018737840101526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016308114908115611445575b50611063576000546001600160a01b0316330361050f576001600160a01b038116928315610e3d57813b156114345730841461142557600080516020612c26833981519152548461127c611fb9565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f6112b260405192604084526040840190611f94565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481895afa600091816113f1575b506113025785634c9c8ce360e01b60005260045260246000fd5b9081600080516020612c268339815191528793036113dd5750833b156113c8576001600160a01b0319168117600080516020612c26833981519152557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28251156113ad5760008091610598945190845af43d156113a5573d9161138883611f40565b926113966040519485611f1d565b83523d6000602085013e612b64565b606091612b64565b505050346113b757005b63b398979f60e01b60005260046000fd5b50634c9c8ce360e01b60005260045260246000fd5b632a87526960e21b60005260045260246000fd5b9091506020813d60201161141d575b8161140d60209383611f1d565b8101031261026e575190876112e8565b3d9150611400565b614e8d60eb1b60005260046000fd5b632e07c4bd60e11b60005260046000fd5b600080516020612c26833981519152546001600160a01b0316141590508461122d565b3461026e57602036600319011261026e5760043561148461247b565b6114a6611490826124c6565b9190600263ffffffff825460a01c161790612037565b6001600160a01b0316907fc2713e691344add4705edc62a0ee5aede95ba66ad68f97316efef9cb50644edd600080a3005b3461026e57600036600319011261026e57336000908152600080516020612c46833981519152602052604090205460ff1615806115ba575b6115a957600080516020612ce68339815191525460ff8116156115985760ff1916600080516020612ce6833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a2005b638dfc202b60e01b60005260046000fd5b63659a07b360e11b60005260046000fd5b506000546001600160a01b031633141561150f565b3461026e57604036600319011261026e57606063ffffffff6115fa6115f2611e59565b60043561205a565b90604093929351931515845261160f81611e85565b6020840152166040820152f35b3461026e57604036600319011261026e57611635611e59565b336001600160a01b038216036116515761059890600435612437565b63334bd91960e11b60005260046000fd5b3461026e57604036600319011261026e57610598600435611681611e59565b9061168e61058e82612016565b6123ef565b3461026e57602036600319011261026e576004356116dd6116b38261230f565b91906116c963fffffffb825460a01c1682612037565b805463ffffffff60c01b1916815583612381565b6001600160a01b0316907f09cb4ec44cdef8489412844b9682f87f7900758fa2bd7e039113e9125e538e0f600080a3005b3461026e57602036600319011261026e57600435604060008281526004602052209081549160018060a01b0383169283159081156117c0575b5061116657336000908152600080516020612c46833981519152602052604090205460ff1615806117b6575b61114b578061111e63fffffffd61178f935460a01c1682612037565b7fb390ab029eab314bd18190ebe73d7e5c1c336beaa5c83ac22578378dc9ccc405600080a3005b5082331415611773565b6002915060a01c161584611747565b3461026e57602036600319011261026e5760206117ed600435612016565b604051908152f35b3461026e57604036600319011261026e57600435611811611ebe565b63ffffffff600554169063ffffffff8116918083109081156118bd575b506109715761183c8361230f565b909263ffffffff845460c01c16809260018060a01b031633141591826118b2575b50506118a15761188d827e8a218591d4362499c38c38eb1c12e7a7cc97a9068818d1fe6046a42ba4a5ba94611fdc565b61189c60405192839283611fff565b0390a2005b634e80a40760e11b60005260046000fd5b11159050818661185d565b9050158461182e565b3461026e57602036600319011261026e576118df611eab565b600080516020612d068339815191525460ff8160401c169081156119bf575b506119ae57600080516020612d06833981519152805460026001600160401b0319821681179092556000546001600160481b031990911690911791906001600160a01b0316330361050f5763ffffffff168015610d8057604081600080516020612c868339815191529263ffffffff196005541617600555815190600082526020820152a1600080516020612d0683398151915255600080516020612be6833981519152602060405160028152a1005b63f92ee8a960e01b60005260046000fd5b60026001600160401b039190911610159050826118fe565b3461026e5760a036600319011261026e576119f0611e6f565b6119f8611e59565b906044356001600160a01b03811680820361026e576064356001600160a01b0381169182820361026e576084356001600160a01b038116949085900361026e57600080516020612d0683398151915254604081901c60ff161596906001600160401b031680159081611d75575b6001149081611d6b575b159081611d62575b506119ae57600080516020612d0683398151915280546001600160401b031916600117905586611d3d575b611aaa6127b2565b611ab26127b2565b611aba6127b2565b611ac26127b2565b6001600160a01b038116908115610e3d578315610e3d578515610e3d576001600160a01b038916988915610e3d573b15610e2c57858414611d2c5762aa36a746148015611d21575b8015611d16575b1580611d04575b610e2c57611b279060006127e0565b9081611cbd575b5015611c0257611b4c90600080516020612cc68339815191526127e0565b9081611c68575b5015611c0257611b7190600080516020612c068339815191526127e0565b9081611c13575b5015611c0257600080546001600160a01b031916841781556040519390600080516020612c668339815191528180a38015610e3d57803b15610e2c57600380546001600160a01b031916919091179055611bce57005b600080516020612d06833981519152805460ff60401b1916905560018152600080516020612be683398151915290602090a1005b63cf5a8e3360e01b60005260046000fd5b600080516020612c06833981519152600052600080516020612bc6833981519152602052611c61907ffff5b43478fa6840382eb63777e0da6941d320b940e3f70f0ea4780feff95827612a20565b5084611b78565b600080516020612cc6833981519152600052600080516020612bc6833981519152602052611cb6907f32d31393d541a265984ec379cddd8b1fcbe5f2b0eb8ad81dddfead454f135eaa612a20565b5086611b53565b60008052600080516020612bc6833981519152602052611cfd907f615f0f9e84155bea8cc509fe18befeb1baf65611e38a6ba60964480fb29dfd44612a20565b5088611b2e565b50823b1580611b185750843b15611b18565b50617a694614611b11565b506105394614611b0a565b638135316560e01b60005260046000fd5b600080516020612d06833981519152805460ff60401b1916600160401b179055611aa2565b90501589611a77565b303b159150611a6f565b889150611a65565b3461026e57604036600319011261026e5761026a611db1611d9c611e59565b6004356000526004602052604060002061213a565b611dba81611e85565b604051918183921583611e8f565b3461026e57600036600319011261026e57602063ffffffff60055416604051908152f35b3461026e57602036600319011261026e576004359063ffffffff60e01b821680920361026e57602091635a05180f60e01b8114908115611e2e575b5015158152f35b637965db0b60e01b811491508115611e48575b5083611e27565b6301ffc9a760e01b14905083611e41565b602435906001600160a01b038216820361026e57565b600435906001600160a01b038216820361026e57565b6008111561038c57565b901515815260408101929190602090611ea783611e85565b0152565b6004359063ffffffff8216820361026e57565b6024359063ffffffff8216820361026e57565b60a081019081106001600160401b03821117611eec57604052565b634e487b7160e01b600052604160045260246000fd5b606081019081106001600160401b03821117611eec57604052565b601f909101601f19168101906001600160401b03821190821017611eec57604052565b6001600160401b038111611eec57601f01601f191660200190565b604435906001600160401b038216820361026e57565b60005b838110611f845750506000910152565b8181015183820152602001611f74565b90602091611fad81518092818552858086019101611f71565b601f01601f1916010190565b60405190611fc8604083611f1d565b60058252640322e302e360dc1b6020830152565b805463ffffffff60c01b191660c09290921b63ffffffff60c01b16919091179055565b63ffffffff91821681529116602082015260400190565b600052600080516020612ca683398151915260205260016040600020015490565b805463ffffffff60a01b191660a09290921b63ffffffff60a01b16919091179055565b9190916000526004602052612074604060002092836121f7565b9161207e83611e85565b826120d45763ffffffff9192505460c01c1663ffffffff60055416811580156120cc575b6120bf578082106120b857505b60019160009190565b90506120af565b5050600090600390600090565b5080156120a2565b5060009190600090565b906120f59160005260046020526040600020612283565b6120fe81611e85565b8061210c5750600190600090565b600091565b8054600160a01b600160e01b03191660a09290921b600160a01b600160e01b0316919091179055565b60ff600080516020612ce683398151915254166121f057546001600160a01b0381169081156121e85760a01c600216156121e15760005260016020526040600020549060ff8260e01c16600381101561038c5780156121d9576002146121d2574260a083901c6001600160401b031611156121cb576001600160a01b039081169116036121c657600090565b600790565b5050600690565b5050600590565b505050600490565b5050600390565b505050600290565b5050600190565b60ff600080516020612ce683398151915254166121f057546001600160a01b0381169081156121e85760a01c600416156121e15760005260016020526040600020549060ff8260e01c16600381101561038c5780156121d9576002146121d2574260a083901c6001600160401b031611156121cb576001600160a01b039081169116036121c657600090565b60ff600080516020612ce683398151915254166121f057546001600160a01b0381169081156121e85760a01c600116156121e15760005260016020526040600020549060ff8260e01c16600381101561038c5780156121d9576002146121d2574260a083901c6001600160401b031611156121cb576001600160a01b039081169116036121c657600090565b6000908152600460205260409020805490916001600160a01b038216918215908115612372575b5061116657336000908152600080516020612c46833981519152602052604090205460ff161580612368575b61114b57565b5081331415612362565b6004915060a01c161538612336565b905460a01c63ffffffff16156123945750565b600052600460205260006040812055565b6000818152600080516020612ca68339815191526020908152604080832033845290915290205460ff16156123d75750565b63e2517d3f60e01b6000523360045260245260446000fd5b6123f982826127e0565b918261240457505090565b6000918252600080516020612bc68339815191526020526040909120612433916001600160a01b031690612a20565b5090565b6124418282612889565b918261244c57505090565b6000918252600080516020612bc68339815191526020526040909120612433916001600160a01b031690612a91565b60ff600080516020612ce6833981519152541661249457565b63d93c066560e01b60005260046000fd5b519064ffffffffff8216820361026e57565b519061ffff8216820361026e57565b80156127a157600354604051638d34875560e01b8152600481018390529190600090839060249082906001600160a01b03165afa918215612795576000926125ea575b5060808201516001600160a01b0316913383900361114b57610120015161252f81611e85565b61253881611e85565b600381149081156125d5575b81156125c1575b506125b05781600052600160205260ff60406000205460e01c16600381101561038c5760010361259f57600090815260046020526040902080546001600160a01b0319166001600160a01b03831617815591565b632e68d1d360e21b60005260046000fd5b63e9f6db8560e01b60005260046000fd5b600791506125ce81611e85565b143861254b565b90506125e081611e85565b6005811490612544565b90913d8082843e6125fb8184611f1d565b820191602081840312612775578051906001600160401b03821161277d5701906101a08284031261277257604051926101a084016001600160401b038111858210176127815760409081528351855260208085015190860152838101519085015260608301516001600160401b03811161277d57830181601f8201121561277d5780519061268882611f40565b926126966040519485611f1d565b8284526020838301011161277957906126b59160208085019101611f71565b606084015260808201516001600160a01b03811681036127755760808401526126e060a083016124a5565b60a08401526126f160c083016124a5565b60c084015261270260e083016124b7565b60e084015261271461010083016124a5565b6101008401526101208201519060088210156127725750612765916101809161012085015261274661014082016124a5565b61014085015261275961016082016124b7565b610160850152016124a5565b6101808201529038612509565b80fd5b5080fd5b8380fd5b8280fd5b634e487b7160e01b83526041600452602483fd5b6040513d6000823e3d90fd5b637bb0b62160e01b60005260046000fd5b60ff600080516020612d068339815191525460401c16156127cf57565b631afcd79f60e31b60005260046000fd5b6000818152600080516020612ca6833981519152602090815260408083206001600160a01b038616845290915290205460ff16612882576000818152600080516020612ca6833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050600090565b6000818152600080516020612ca6833981519152602090815260408083206001600160a01b038616845290915290205460ff1615612882576000818152600080516020612ca6833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b1580156129e1575b610e3d576001600160a01b03166000908152600260205260409020546129d0576001600160401b0316428111156129bf5760005460a01c6001600160401b03168015159182612994575b505061298357565b63e774e7b560e01b60005260046000fd5b9091504281039081116129a95711388061297b565b634e487b7160e01b600052601160045260246000fd5b63efa7aefd60e01b60005260046000fd5b633b53f64f60e21b60005260046000fd5b506001600160a01b03811615612931565b8054821015612a0a5760005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b6001810190826000528160205260406000205415600014612a89578054600160401b811015611eec57612a74612a5d8260018794018555846129f2565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b505050600090565b9060018201918160005282602052604060002054801515600014612b5b5760001981018181116129a95782546000198101919082116129a957818103612b24575b50505080548015612b0e576000190190612aec82826129f2565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b612b44612b34612a5d93866129f2565b90549060031b1c928392866129f2565b905560005283602052604060002055388080612ad2565b50505050600090565b90612b8a5750805115612b7957602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580612bbc575b612b9b575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b15612b9356fec1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d275027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc07966f2ab141347034724e9b2a472c2f77f5cd745aeba27cacba797b8fcb708617dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846cd37bc77615afefc793aa17d75d4249a9b517ba91b0e54a49c9c4a44b3d7e228302dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800edcc084d3dcd65a1f7f23c65c46722faca6953d28e43150a467cf43e5c309238cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a164736f6c6343000822000a";
17828
17818
  var isSuperArgs2 = (xs) => xs.length > 1;
17829
17819
  var AgentDelegationRegistry__factory = class extends ContractFactory2 {
17830
17820
  constructor(...args) {
@@ -18701,7 +18691,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
18701
18691
  litNetwork: config.litNetwork,
18702
18692
  loanCreationValidatorVersion: config.validators?.loanCreation ?? 1,
18703
18693
  ethRpcUrl: config.ethRpcUrl,
18704
- temperSignaturesTest: config.temperSignaturesTest
18694
+ temperSignaturesTest: config.temperSignaturesTest,
18695
+ onPkpCreated: config.onPkpCreated
18705
18696
  });
18706
18697
  if (!loanCreatorResult.success) {
18707
18698
  throw new Error(
@@ -24565,8 +24556,6 @@ Message: ${causeMessage}${quantumContext}${mintDebtDiagnostics}`
24565
24556
  return {
24566
24557
  enabled,
24567
24558
  borrower: grant.borrower,
24568
- maxRenewals: Number(grant.maxRenewals),
24569
- renewalsUsed: Number(grant.renewalsUsed),
24570
24559
  agentActive,
24571
24560
  canRenew
24572
24561
  };
@@ -24611,11 +24600,7 @@ Message: ${causeMessage}${quantumContext}${mintDebtDiagnostics}`
24611
24600
  const delTx = await setPositionDelegate(pid, agentAddress, signer, pdrAddr);
24612
24601
  await delTx.wait();
24613
24602
  }
24614
- const tx = await registry.enableAutoRenew(
24615
- pid,
24616
- options?.maxRenewals ?? 0,
24617
- options?.maxEndTimestamp ?? 0
24618
- );
24603
+ const tx = await registry.enableAutoRenew(pid);
24619
24604
  const receipt = await tx.wait();
24620
24605
  return { hash: tx.hash, blockNumber: receipt?.blockNumber ?? 0, agentAddress };
24621
24606
  }
@@ -102,6 +102,24 @@ interface BaseSDKConfig {
102
102
  * contract wallet can leave that request open for minutes.
103
103
  */
104
104
  onSessionSignatureResolved?: (ok: boolean) => void;
105
+ /**
106
+ * Fires during loan creation the moment the PKP has been minted and validated,
107
+ * before the `createPosition` transaction is submitted.
108
+ *
109
+ * The PKP is minted fresh per attempt, so `tokenId` is a unique, send-independent
110
+ * handle on the position that transaction is about to create — it is the only
111
+ * identifier a caller can hold *before* a hash exists. UIs use it to recognise
112
+ * their own position in an indexed feed without depending on the transaction
113
+ * hash, which a contract wallet does not return in a usable form.
114
+ *
115
+ * Note `tokenId` is a decimal string; the on-chain and subgraph `pkpId` is the
116
+ * same value as 32-byte hex. Normalise before comparing.
117
+ */
118
+ onPkpCreated?: (pkp: {
119
+ tokenId: string;
120
+ ethAddress: string;
121
+ publicKey: string;
122
+ }) => void;
105
123
  ethRpcUrl?: string;
106
124
  chainId?: number;
107
125
  networkOverride?: {
@@ -896,8 +896,6 @@ export declare class DiamondHandsSDK {
896
896
  getAutoRenewStatus(positionId: string, user?: string): Promise<{
897
897
  enabled: boolean;
898
898
  borrower: string;
899
- maxRenewals: number;
900
- renewalsUsed: number;
901
899
  agentActive: boolean | null;
902
900
  canRenew: {
903
901
  ok: boolean;
@@ -910,8 +908,11 @@ export declare class DiamondHandsSDK {
910
908
  * registers it, then records the position's renew grant. Borrower-signed.
911
909
  */
912
910
  enableAutoRenew(positionId: string, options?: {
913
- maxRenewals?: number;
914
- maxEndTimestamp?: number;
911
+ /**
912
+ * Agent lifetime in seconds (default 90 days). This is the ONLY bound on the delegation:
913
+ * the registry has no per-grant renewal cap or end date — auto-renew lives exactly as long
914
+ * as the agent does. For "auto-renew until date X", pass X - now.
915
+ */
915
916
  agentValiditySeconds?: number;
916
917
  }): Promise<{
917
918
  hash: string;
@@ -61,6 +61,15 @@ export interface LoanCreatorConfig {
61
61
  ethRpcUrl?: string;
62
62
  /** Security testing: Temper signatures to test contract validation */
63
63
  temperSignaturesTest?: boolean;
64
+ /**
65
+ * Fires once the PKP is minted and validated, before `createPosition` is submitted.
66
+ * See `SDKConfig.onPkpCreated` for why this exists and for the tokenId encoding caveat.
67
+ */
68
+ onPkpCreated?: (pkp: {
69
+ tokenId: string;
70
+ ethAddress: string;
71
+ publicKey: string;
72
+ }) => void;
64
73
  }
65
74
  /**
66
75
  * Loan creation audit trail
@@ -133,6 +142,26 @@ export declare class LoanCreator {
133
142
  * Override with `createPositionConfirmations` when a chain needs more.
134
143
  */
135
144
  private createPositionConfirmations;
145
+ /**
146
+ * EOA path: the returned hash is the L1 hash, so `tx.wait` is exact.
147
+ *
148
+ * The timer is cleared on settle — an uncleared one keeps the process alive for the
149
+ * full timeout after a fast confirmation, which in Node holds the event loop open.
150
+ */
151
+ private awaitReceiptByHash;
152
+ /**
153
+ * Contract-wallet path: find this position by its `PositionCreated` log.
154
+ *
155
+ * `pkpId` is minted fresh per attempt and is the event's second indexed argument, so a
156
+ * topic filter on it identifies exactly this position without reference to any transaction
157
+ * hash. The filter deliberately leaves topic0 unconstrained: two `PositionCreated` ABIs are
158
+ * in circulation (see `extractPositionId`) and matching on the freshly-minted pkpId alone,
159
+ * scoped to this contract and to blocks at or after the send, is already unambiguous.
160
+ *
161
+ * The same confirmation depth as the EOA path is applied to the log's block, for the reason
162
+ * given at the call site: `positionId` does not survive a reorg unchanged.
163
+ */
164
+ private awaitPositionCreatedByPkpId;
136
165
  /**
137
166
  * Re-read the receipt after confirmations and re-derive `positionId`, so a reorg
138
167
  * cannot leave the caller holding an id that never survived to the canonical chain.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Contract-wallet detection.
3
+ *
4
+ * A Safe (or any smart-account) returns its OWN transaction identifier from
5
+ * `eth_sendTransaction` — the safeTxHash — not an L1 transaction hash. Anything that
6
+ * waits on that identifier waits forever, because it never lands on chain. Callers
7
+ * that need to confirm a transaction must therefore know which kind of sender they
8
+ * are dealing with and confirm by some other means.
9
+ *
10
+ * Contract-ness is settled by asking the chain for code at the address, which is the
11
+ * same test the servers use for the EIP-1271 path — not the wallet name, which is
12
+ * whatever the connector chose to call itself.
13
+ */
14
+ import type { Provider } from "ethers";
15
+ /**
16
+ * True when `address` has code on the chain behind `provider`.
17
+ *
18
+ * Deliberately propagates provider errors rather than assuming EOA: a failed `getCode`
19
+ * means the provider is unreachable, and guessing "EOA" there would send the caller
20
+ * back into a wait that cannot complete.
21
+ */
22
+ export declare function isContractWallet(provider: Provider, address: string): Promise<boolean>;
23
+ /** Test seam — clears memoised detections. */
24
+ export declare function resetContractWalletCache(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gvnrdao/dh-sdk",
3
- "version": "0.0.314",
3
+ "version": "0.0.316",
4
4
  "description": "TypeScript SDK for Diamond Hands Protocol - Bitcoin-backed lending with LIT Protocol PKPs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",