@gvnrdao/dh-sdk 0.0.312 → 0.0.313

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.
@@ -37,6 +37,10 @@ export interface ContractAddresses {
37
37
  positionDelegateRegistry?: string;
38
38
  /** BitcoinWithdrawalAddressRegistry proxy; per-wallet allowlist that gates borrower-initiated BTC withdrawal destinations (24h time-lock). */
39
39
  bitcoinWithdrawalAddressRegistry?: string;
40
+ /** AgentDelegationRegistry proxy; protocol agent-delegation policy layer (MVP: auto-renew). Sepolia only. */
41
+ agentDelegationRegistry?: string;
42
+ /** DHAgentDelegate; EIP-7702 execution adapter (Gate 2) the borrower EOA delegates to. Sepolia only. */
43
+ dhAgentDelegate?: string;
40
44
  mockUsdcToken?: string;
41
45
  mockUsdcOwner?: string;
42
46
  mockUsdtToken?: string;
@@ -887,6 +887,42 @@ export declare class DiamondHandsSDK {
887
887
  * @param options - Override timeout/interval for this call
888
888
  * @throws if timeout is reached before subgraph catches up
889
889
  */
890
+ /** Guard: the AgentDelegationRegistry MVP is deployed on Sepolia only. */
891
+ private assertAgentDelegationSepolia;
892
+ /**
893
+ * Read a position's auto-renew delegation state (used to drive the Enable/Disable toggle).
894
+ * Pure view — no signer required.
895
+ */
896
+ getAutoRenewStatus(positionId: string, user?: string): Promise<{
897
+ enabled: boolean;
898
+ borrower: string;
899
+ maxRenewals: number;
900
+ renewalsUsed: number;
901
+ agentActive: boolean | null;
902
+ canRenew: {
903
+ ok: boolean;
904
+ reason: number;
905
+ } | null;
906
+ }>;
907
+ /**
908
+ * Enable auto-renew delegation for a position. Orchestrates the first-time setup: if the
909
+ * borrower has no active agent, mints a fresh per-user agent PKP (via lit-ops-server) and
910
+ * registers it, then records the position's renew grant. Borrower-signed.
911
+ */
912
+ enableAutoRenew(positionId: string, options?: {
913
+ maxRenewals?: number;
914
+ maxEndTimestamp?: number;
915
+ agentValiditySeconds?: number;
916
+ }): Promise<{
917
+ hash: string;
918
+ blockNumber: number;
919
+ agentAddress?: string;
920
+ }>;
921
+ /** Disable auto-renew delegation for a position (clears the grant). Borrower-signed. */
922
+ disableAutoRenew(positionId: string): Promise<{
923
+ hash: string;
924
+ blockNumber: number;
925
+ }>;
890
926
  /**
891
927
  * Get Bitcoin balance for an address
892
928
  *
@@ -46,6 +46,15 @@ export interface LoanCreatorConfig {
46
46
  debug?: boolean;
47
47
  /** Transaction timeout (ms) */
48
48
  transactionTimeoutMs?: number;
49
+ /**
50
+ * Confirmations to wait for before trusting the `positionId` read from a
51
+ * createPosition receipt. Defaults to 1 on local chains and 3 elsewhere.
52
+ *
53
+ * `positionId` is derived on-chain from `block.timestamp` and a global counter, so a
54
+ * reorg re-executes the same transaction into a different id. Raise this on chains
55
+ * with deep reorgs; it trades loan-creation latency for id stability.
56
+ */
57
+ createPositionConfirmations?: number;
49
58
  /** Validator version for loan creation (createPosition) - REQUIRED */
50
59
  loanCreationValidatorVersion: number;
51
60
  /** EVM JSON-RPC URL for service-mode PKP flow (forwards to lit-ops-server) */
@@ -117,6 +126,23 @@ export declare class LoanCreator {
117
126
  * Step 3: Submit loan creation transaction
118
127
  */
119
128
  private submitLoanCreation;
129
+ /**
130
+ * Confirmation depth to wait for before trusting `positionId` from a receipt.
131
+ *
132
+ * Deeper is safer but slower, so local chains (instant mining, no reorgs) stay at 1.
133
+ * Override with `createPositionConfirmations` when a chain needs more.
134
+ */
135
+ private createPositionConfirmations;
136
+ /**
137
+ * Re-read the receipt after confirmations and re-derive `positionId`, so a reorg
138
+ * cannot leave the caller holding an id that never survived to the canonical chain.
139
+ *
140
+ * Returns the authoritative id. If the re-read disagrees with what was first
141
+ * extracted, the fresh value wins and the divergence is logged loudly — silently
142
+ * returning a phantom id is how this surfaced as a `PositionNotFound()` hundreds of
143
+ * lines downstream, long after the real cause.
144
+ */
145
+ private confirmPositionId;
120
146
  /**
121
147
  * Extract position ID from transaction receipt
122
148
  */
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Agent-delegation service helpers (auto-renew MVP).
3
+ *
4
+ * Kept separate from the generic `PKPManager` so that module stays focused on PKP lifecycle —
5
+ * this file owns the feature-specific orchestration (the lit-ops-server mint-agent endpoint).
6
+ */
7
+ /**
8
+ * Mint a fresh per-user AGENT PKP via lit-ops-server and return its Ethereum address, to be
9
+ * registered as the renewal agent in `AgentDelegationRegistry`. Each call yields a unique
10
+ * address (satisfies the registry's AR-1 non-reuse). Throws on failure.
11
+ *
12
+ * @param serviceEndpoint lit-ops-server base URL (the SDK's `serviceEndpoint`).
13
+ * @param authHeader Optional async/sync provider of auth headers (the SDK's session token).
14
+ * @param timeoutMs Request timeout (default 30s).
15
+ */
16
+ export declare function mintAgentPkp(params: {
17
+ serviceEndpoint: string;
18
+ authHeader?: () => Promise<Record<string, string>> | Record<string, string>;
19
+ timeoutMs?: number;
20
+ }): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gvnrdao/dh-sdk",
3
- "version": "0.0.312",
3
+ "version": "0.0.313",
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",
@@ -82,8 +82,8 @@
82
82
  },
83
83
  "sideEffects": false,
84
84
  "dependencies": {
85
- "@gvnrdao/dh-lit-actions": "^0.0.316",
86
- "@gvnrdao/dh-lit-ops": "^0.0.307",
85
+ "@gvnrdao/dh-lit-actions": "^0.0.317",
86
+ "@gvnrdao/dh-lit-ops": "^0.0.308",
87
87
  "@noble/hashes": "^1.5.0",
88
88
  "axios": "^1.17.0",
89
89
  "bech32": "^2.0.0",