@gvnrdao/dh-sdk 0.0.166 → 0.0.205

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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -5
  3. package/browser/dist/397.browser.js +1 -1
  4. package/browser/dist/833.browser.js +1 -1
  5. package/browser/dist/browser.js +1 -13
  6. package/browser/dist/browser.js.LICENSE.txt +1 -70
  7. package/browser/dist/index.d.ts +3 -4
  8. package/browser/dist/index.d.ts.map +1 -1
  9. package/browser/dist/index.js +4 -3
  10. package/dist/constants/chunks/contract-abis.d.ts +7 -0
  11. package/dist/constants/chunks/deployment-addresses.d.ts +68 -0
  12. package/dist/constants/chunks/encrypted-provider-params.d.ts +21 -0
  13. package/dist/constants/chunks/environment.browser.d.ts +45 -0
  14. package/dist/constants/chunks/environment.d.ts +57 -0
  15. package/dist/constants/chunks/network-configs.d.ts +65 -0
  16. package/dist/constants/chunks/sdk-config.d.ts +33 -0
  17. package/dist/constants/chunks/sdk-limits.d.ts +66 -0
  18. package/dist/constants/index.d.ts +15 -0
  19. package/dist/graphs/client.d.ts +19 -0
  20. package/dist/graphs/diamond-hands.d.ts +248 -0
  21. package/dist/index.d.ts +47 -7391
  22. package/dist/index.js +4525 -16860
  23. package/dist/index.mjs +4489 -16801
  24. package/dist/interfaces/chunks/btc.i.d.ts +36 -0
  25. package/dist/interfaces/chunks/config.i.d.ts +250 -0
  26. package/dist/interfaces/chunks/contract-interactions.i.d.ts +64 -0
  27. package/dist/interfaces/chunks/contract-types.i.d.ts +165 -0
  28. package/dist/interfaces/chunks/lit-actions-results.i.d.ts +165 -0
  29. package/dist/interfaces/chunks/lit-actions.i.d.ts +98 -0
  30. package/dist/interfaces/chunks/loan-operations.i.d.ts +332 -0
  31. package/dist/interfaces/chunks/pkp-integration.i.d.ts +87 -0
  32. package/dist/interfaces/chunks/position-query.i.d.ts +76 -0
  33. package/dist/interfaces/chunks/requests.i.d.ts +55 -0
  34. package/dist/interfaces/chunks/ucd-minting.i.d.ts +34 -0
  35. package/dist/interfaces/chunks/utility.i.d.ts +64 -0
  36. package/dist/interfaces/index.d.ts +17 -0
  37. package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +223 -0
  38. package/dist/modules/cache/cache-manager.module.d.ts +92 -0
  39. package/dist/modules/contract/contract-manager.module.d.ts +136 -0
  40. package/dist/modules/diamond-hands-sdk.d.ts +669 -0
  41. package/dist/modules/loan/loan-creator.module.d.ts +143 -0
  42. package/dist/modules/loan/loan-query.module.d.ts +206 -0
  43. package/dist/modules/mock/mock-token-manager.module.d.ts +83 -0
  44. package/dist/modules/pkp/pkp-manager.module.d.ts +136 -0
  45. package/dist/protocol/protocol-pause.d.ts +19 -0
  46. package/dist/server.d.ts +17 -0
  47. package/dist/server.js +285 -0
  48. package/dist/server.mjs +242 -0
  49. package/dist/types/authorization-params.d.ts +160 -0
  50. package/dist/types/branded/domain-values.d.ts +138 -0
  51. package/dist/types/branded/ids.d.ts +23 -0
  52. package/dist/types/event-types.d.ts +235 -0
  53. package/dist/types/graph-dtos.d.ts +228 -0
  54. package/dist/types/loanStatus.d.ts +10 -0
  55. package/dist/types/result.d.ts +120 -0
  56. package/dist/utils/bitcoin-address-cache.utils.d.ts +87 -0
  57. package/dist/utils/bitcoin-provider.utils.d.ts +48 -0
  58. package/dist/utils/bitcoin-signature.d.ts +20 -0
  59. package/dist/utils/chunks/bitcoin-utils.d.ts +75 -0
  60. package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +24 -0
  61. package/dist/utils/error-handler.d.ts +106 -0
  62. package/dist/utils/ethers-interop.utils.d.ts +146 -0
  63. package/dist/utils/extend-authorization.utils.d.ts +61 -0
  64. package/dist/utils/lit-signature.utils.d.ts +6 -0
  65. package/dist/utils/logger.utils.d.ts +142 -0
  66. package/dist/utils/mint-authorization.utils.d.ts +224 -0
  67. package/dist/utils/quantum-timing.d.ts +75 -0
  68. package/dist/utils/signature-tempering.utils.d.ts +31 -0
  69. package/dist/utils/telegram-messaging.utils.d.ts +188 -0
  70. package/package.json +43 -22
  71. package/dist/index.d.mts +0 -7392
@@ -1,28 +1,3 @@
1
- /*!
2
- * Ensure correct constructor
3
- */
4
-
5
- /*!
6
- * Inherit from Error.prototype
7
- */
8
-
9
- /*!
10
- * Primary Exports
11
- */
12
-
13
- /*!
14
- * Return a function that will copy properties from
15
- * one object to another excluding any originally
16
- * listed. Returned function will create a new `{}`.
17
- *
18
- * @param {String} excluded properties ...
19
- * @return {Function}
20
- */
21
-
22
- /*!
23
- * Statically set name
24
- */
25
-
26
1
  /*!
27
2
  * The buffer module from node.js, for the browser.
28
3
  *
@@ -30,54 +5,14 @@
30
5
  * @license MIT
31
6
  */
32
7
 
33
- /*!
34
- * assertion-error
35
- * Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
36
- * MIT Licensed
37
- */
38
-
39
- /*!
40
- * depd
41
- * Copyright(c) 2015 Douglas Christopher Wilson
42
- * MIT Licensed
43
- */
44
-
45
- /*! *****************************************************************************
46
- Copyright (c) Microsoft Corporation.
47
-
48
- Permission to use, copy, modify, and/or distribute this software for any
49
- purpose with or without fee is hereby granted.
50
-
51
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
52
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
53
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
54
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
55
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
56
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
57
- PERFORMANCE OF THIS SOFTWARE.
58
- ***************************************************************************** */
59
-
60
- /*! Axios v1.13.3 Copyright (c) 2026 Matt Zabriskie and contributors */
61
-
62
- /*! Axios v1.13.4 Copyright (c) 2026 Matt Zabriskie and contributors */
8
+ /*! Axios v1.15.2 Copyright (c) 2026 Matt Zabriskie and contributors */
63
9
 
64
10
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
65
11
 
66
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
67
-
68
12
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
69
13
 
70
14
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
71
15
 
72
- /**
73
- * @license
74
- * Lodash <https://lodash.com/>
75
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
76
- * Released under MIT license <https://lodash.com/license>
77
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
78
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
79
- */
80
-
81
16
  /**
82
17
  * [js-sha3]{@link https://github.com/emn178/js-sha3}
83
18
  *
@@ -86,7 +21,3 @@ PERFORMANCE OF THIS SOFTWARE.
86
21
  * @copyright Chen, Yi-Cyuan 2015-2018
87
22
  * @license MIT
88
23
  */
89
-
90
- //! stable.js 0.1.8, https://github.com/Two-Screen/stable
91
-
92
- //! © 2018 Angry Bytes and contributors. MIT licensed.
@@ -1,9 +1,8 @@
1
- import * as SDKModule from "../dist/index.js";
2
- export declare const DiamondHandsSDK: typeof SDKModule.DiamondHandsSDK;
1
+ export declare const DiamondHandsSDK: any;
3
2
  export type CreateLoanRequest = any;
4
3
  export type CreateLoanResult = any;
5
4
  export type DiamondHandsSDKConfig = any;
6
- export * from "../dist/index.js";
7
- declare const _default: typeof SDKModule.DiamondHandsSDK;
5
+ export declare const AuthParamsValidation: any, BPSConversions: any, BitcoinOperations: any, CacheManager: any, ContractManager: any, SDKClass: any, ErrorCategory: any, ErrorSeverity: any, EventHelpers: any, LoanCreator: any, LoanQuery: any, LoanStatus: any, PaymentType: any, PositionStatus: any, SDKError: any, SatoshisConversions: any, UCDConversions: any, WeiConversions: any, createBitcoinOperations: any, createCacheManager: any, createContractManager: any, createLoanCreator: any, createLoanQuery: any, createPKPManager: any, failure: any, success: any, tryCatch: any, tryCatchAsync: any, unwrap: any, unwrapOr: any, validateSDKConfig: any;
6
+ declare const _default: any;
8
7
  export default _default;
9
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAY9C,eAAO,MAAM,eAAe,kCAA4B,CAAC;AAoCzD,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACpC,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACnC,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAOxC,cAAc,kBAAkB,CAAC;;AAOjC,wBAAyC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,eAAe,KAA4B,CAAC;AAgCzD,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACpC,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACnC,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAQxC,eAAO,MACL,oBAAoB,OACpB,cAAc,OACd,iBAAiB,OACjB,YAAY,OACZ,eAAe,OACE,QAAQ,OACzB,aAAa,OACb,aAAa,OACb,YAAY,OACZ,WAAW,OACX,SAAS,OACT,UAAU,OACV,WAAW,OACX,cAAc,OACd,QAAQ,OACR,mBAAmB,OACnB,cAAc,OACd,cAAc,OACd,uBAAuB,OACvB,kBAAkB,OAClB,qBAAqB,OACrB,iBAAiB,OACjB,eAAe,OACf,gBAAgB,OAChB,OAAO,OACP,OAAO,OACP,QAAQ,OACR,aAAa,OACb,MAAM,OACN,QAAQ,OACR,iBAAiB,KACN,CAAC;;AAOd,wBAAyC"}
@@ -1,8 +1,8 @@
1
1
  // Browser ESM entry point for Diamond Hands SDK
2
2
  // Converts CommonJS exports to ES module imports for browser compatibility
3
3
  // Uses the proven wrapper pattern from test-app/src/lib/lit-ops-wrapper.ts
4
- // Import from the original built SDK
5
- import * as SDKModule from "../dist/index.js";
4
+ // Import from the original built SDK (CommonJS module)
5
+ const SDKModule = require("../dist/index.js");
6
6
  // Import lit-ops and lit-actions (using the wrapper pattern)
7
7
  // TODO: Re-enable when these modules have proper ES module builds
8
8
  // import * as LitOpsModule from "../../lit-ops/dist/index.js";
@@ -16,7 +16,8 @@ export const DiamondHandsSDK = SDKModule.DiamondHandsSDK;
16
16
  // RE-EXPORT CORE SDK ONLY
17
17
  // ========================================
18
18
  // Re-export core SDK exports only to avoid conflicts
19
- export * from "../dist/index.js";
19
+ // Note: CommonJS module, so we export specific items
20
+ export const { AuthParamsValidation, BPSConversions, BitcoinOperations, CacheManager, ContractManager, DiamondHandsSDK: SDKClass, ErrorCategory, ErrorSeverity, EventHelpers, LoanCreator, LoanQuery, LoanStatus, PaymentType, PositionStatus, SDKError, SatoshisConversions, UCDConversions, WeiConversions, createBitcoinOperations, createCacheManager, createContractManager, createLoanCreator, createLoanQuery, createPKPManager, failure, success, tryCatch, tryCatchAsync, unwrap, unwrapOr, validateSDKConfig, } = SDKModule;
20
21
  // ========================================
21
22
  // DEFAULT EXPORT
22
23
  // ========================================
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Smart Contract ABIs
3
+ */
4
+ export declare const POSITION_MANAGER_ABI: readonly ["function createPosition(bytes32 pkpId, bytes calldata validatorSignature, address borrower, string calldata vaultAddress, uint256 selectedTermMonths) external returns (bool)", "function getPositionById(bytes32 positionId) external view returns (tuple(bytes32 positionId, bytes32 pkpId, uint256 ucdDebt, string vaultAddress, address borrower, uint40 createdAt, uint40 lastUpdated, uint16 selectedTerm, uint40 expiryAt, uint8 status))", "function getUserPositions(address user) external view returns (bytes32[] memory)", "function calculateCollateralRatio(bytes32 positionId) external view returns (uint256)", "function hasRole(bytes32 role, address account) external view returns (bool)", "function ADMIN_ROLE() external view returns (bytes32)", "function paused() external view returns (bool)", "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)", "function repayPosition(bytes32 positionId, uint256 repaymentAmount) external returns (bool)", "function makePayment(bytes32 positionId, uint256 paymentAmount, uint256 quantumTimestamp, uint256 btcPrice, bytes calldata paymentValidatorSignature) external returns (bool)", "function withdrawBTC(bytes32 positionId, string withdrawalAddress, uint256 networkFee) external returns (bool)", "function extendPosition(bytes32 positionId, uint256 selectedTerm, uint256 quantumTimestamp, uint256 btcPrice, uint256 availableBTCBalance, bytes calldata extensionValidatorSignature) external returns (bool)", "function liquidatePosition(bytes32 positionId) external returns (bool)", "function commitLiquidation(bytes32 positionId, bytes32 commitHash) external", "function revealAndLiquidate(bytes32 positionId, uint256 nonce, uint256 deadline) external returns (bool)", "function getExpiredLoanLiquidationThreshold(bytes32 positionId) external view returns (uint256)", "function isExpiredLoanLiquidatable(bytes32 positionId, uint256 collateralValue, uint256 debtAmount) external view returns (bool)", "event PositionCreated(bytes32 indexed positionId, bytes32 indexed pkpId, address indexed borrower, uint256 requestedCollateralRatio, uint256 selectedTerm, uint256 expiryAt)", "event UCDMinted(bytes32 indexed positionId, uint256 amount, bytes proof)", "event PositionLiquidated(bytes32 indexed positionId, address indexed liquidator, uint256 collateralRatio, uint256 debtRepaid, uint256 collateralValue, bool wasExpired, uint256 timestamp)", "event CollateralRatioUpdated(bytes32 indexed positionId, uint256 oldRatio, uint256 newRatio)", "event PositionUpdated(bytes32 indexed positionId, uint256 oldDebt, uint256 newDebt)"];
5
+ export declare const UCD_TOKEN_ABI: readonly ["function balanceOf(address account) external view returns (uint256)", "function transfer(address to, uint256 amount) external returns (bool)", "function approve(address spender, uint256 amount) external returns (bool)", "function allowance(address owner, address spender) external view returns (uint256)", "function mint(address to, uint256 amount) external", "function burn(uint256 amount) external", "function burnFrom(address account, uint256 amount) external", "event Transfer(address indexed from, address indexed to, uint256 value)", "event Approval(address indexed owner, address indexed spender, uint256 value)"];
6
+ export declare const PRICE_FEED_CONSUMER_ABI: readonly ["function getCurrentPrice() external view returns (uint256)", "function isPriceStale() external view returns (bool)", "function updatePrice() external", "event PriceUpdated(uint256 indexed price, uint256 timestamp)"];
7
+ export declare const PSM_ABI: readonly ["function swap(address stablecoin, uint256 amountIn, uint256 minUcdOut) external returns (uint256 ucdAmount)", "function addSupportedStablecoin(address stablecoin, uint256 exchangeRate, uint256 entryFeeBps, uint256 exitFeeBps, uint8 decimals, uint256 minSwapAmount, uint256 minRedeemAmount) external", "function updateSupportedStablecoin(address stablecoin, uint256 exchangeRate, uint256 entryFeeBps, uint256 exitFeeBps, uint8 decimals, uint256 minSwapAmount, uint256 minRedeemAmount) external", "function removeSupportedStablecoin(address stablecoin) external", "function withdrawStablecoin(address stablecoin, uint256 amount) external", "function pause() external", "function unpause() external", "function redeem(address stablecoin, uint256 ucdAmount, uint256 minStablecoinOut) external returns (uint256 stablecoinAmount)", "function setExitFee(address stablecoin, uint256 fee) external", "function setEntryFee(address stablecoin, uint256 fee) external", "function setExchangeRate(address stablecoin, uint256 rate) external", "function setRedeemEnabled(bool enabled) external", "function addReserves(address stablecoin, uint256 amount) external", "function syncReserves(address stablecoin) external", "function forceSyncReserves(address stablecoin) external", "function getRedemptionQuote(address stablecoin, uint256 ucdAmount) external view returns (uint256 stablecoinOut, uint256 exitFee)", "function getAvailableReserves(address stablecoin) external view returns (uint256)", "function canRedeem(address stablecoin, uint256 ucdAmount) external view returns (bool)", "function version() external pure returns (string memory)", "function supportedStablecoins(address) external view returns (bool)", "function exchangeRates(address) external view returns (uint256)", "function fees(address) external view returns (uint256)", "function exitFees(address) external view returns (uint256)", "function reserves(address) external view returns (uint256)", "function redeemEnabled() external view returns (bool)", "function stablecoinDecimals(address) external view returns (uint8)", "function lastOperationBlock(address) external view returns (uint256)", "function operationCount(address) external view returns (uint256)", "function BASIS_POINTS() external view returns (uint256)", "function EXCHANGE_RATE_SCALE() external view returns (uint256)", "function MAX_EXIT_FEE() external view returns (uint256)", "function MAX_RESERVE_DRIFT() external view returns (uint256)", "event Swap(address indexed user, address indexed stablecoin, uint256 stablecoinAmount, uint256 ucdAmount, uint256 fee, uint256 timestamp)", "event Redeem(address indexed user, address indexed stablecoin, uint256 ucdAmount, uint256 stablecoinAmount, uint256 exitFee, uint256 timestamp)", "event StablecoinAdded(address indexed stablecoin, uint256 exchangeRate, uint256 fee)", "event StablecoinRemoved(address indexed stablecoin)", "event ReserveUpdated(address indexed stablecoin, uint256 oldReserve, uint256 newReserve)", "event ExitFeeUpdated(address indexed stablecoin, uint256 oldFee, uint256 newFee)", "event EntryFeeUpdated(address indexed stablecoin, uint256 oldFee, uint256 newFee)", "event ExchangeRateUpdated(address indexed stablecoin, uint256 oldRate, uint256 newRate)"];
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Auto-generated deployment addresses
3
+ * Generated by scripts/sync-deployments.js
4
+ * Do not edit manually - this file is overwritten during build
5
+ */
6
+ export interface DeploymentLatestEnv {
7
+ [key: string]: string | number | undefined;
8
+ }
9
+ export interface DeploymentContracts {
10
+ PositionManagerProxy?: string;
11
+ PositionManager?: string;
12
+ PositionManagerCoreModule?: string;
13
+ PositionManagerViews?: string;
14
+ SimplePSMV2?: string;
15
+ LoanOperationsManagerModule?: string;
16
+ BTCSpendAuthorizer?: string;
17
+ TermManagerModule?: string;
18
+ CircuitBreakerModule?: string;
19
+ LiquidationManagerModule?: string;
20
+ CollateralManagerModule?: string;
21
+ AdminModule?: string;
22
+ UCDToken?: string;
23
+ UCDController?: string;
24
+ UCDMintingRewards?: string;
25
+ UpgradeValidator?: string;
26
+ BTCProofValidator?: string;
27
+ LITActionValidator?: string;
28
+ BitcoinProviderRegistry?: string;
29
+ PriceFeedConsumer?: string;
30
+ OperationAuthorizationRegistry?: string;
31
+ PKPValidation?: string;
32
+ EmergencyStorageUpdate?: string;
33
+ mockUsdcToken?: string;
34
+ mockUsdcOwner?: string;
35
+ mockUsdtToken?: string;
36
+ mockUsdtOwner?: string;
37
+ [key: string]: string | undefined;
38
+ }
39
+ export interface DeploymentData {
40
+ network: string;
41
+ chainId?: number;
42
+ timestamp: string;
43
+ deployer: string;
44
+ contracts: DeploymentContracts;
45
+ /** Flat assignments from contracts/deployments/full-{network}-latest.env (proxies, impls, validators, etc.) */
46
+ latestEnv?: DeploymentLatestEnv;
47
+ [key: string]: any;
48
+ }
49
+ export declare const SEPOLIA_DEPLOYMENT: DeploymentData;
50
+ export declare const SEPOLIA_CONTRACTS: DeploymentContracts;
51
+ export declare const LOCALHOST_DEPLOYMENT: DeploymentData;
52
+ export declare const LOCALHOST_CONTRACTS: DeploymentContracts;
53
+ export declare const ALL_DEPLOYMENTS: {
54
+ readonly sepolia: DeploymentData;
55
+ readonly localhost: DeploymentData;
56
+ };
57
+ export declare const ALL_CONTRACTS: {
58
+ readonly sepolia: DeploymentContracts;
59
+ readonly localhost: DeploymentContracts;
60
+ };
61
+ /**
62
+ * Get deployment data by network name
63
+ */
64
+ export declare function getDeploymentByNetwork(network: string): DeploymentData | null;
65
+ /**
66
+ * Get contract addresses by network name
67
+ */
68
+ export declare function getContractsByNetwork(network: string): DeploymentContracts | null;
@@ -0,0 +1,21 @@
1
+ export type EncryptedPriceProvider = {
2
+ name: string;
3
+ pkpId: string;
4
+ apiKey: string;
5
+ apiSecret?: string;
6
+ };
7
+ type RegistryProvider = {
8
+ name: string;
9
+ pkpId: string;
10
+ apiKeyEncrypted: string;
11
+ apiSecretEncrypted?: string;
12
+ version: number;
13
+ updatedAt: string;
14
+ };
15
+ type EncryptedParamsRegistry = {
16
+ network: string;
17
+ providers: RegistryProvider[];
18
+ };
19
+ export declare function loadEncryptedProviderRegistry(registryPath?: string): EncryptedParamsRegistry;
20
+ export declare function getEncryptedPriceProviders(providerNames?: string[], registryPath?: string): EncryptedPriceProvider[];
21
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Environment Configuration for Diamond Hands SDK - Browser Version
3
+ * Browser-compatible environment handling without Node.js dependencies
4
+ */
5
+ import { LitNetwork } from "@gvnrdao/dh-lit-ops";
6
+ /** SDK environment label — mirrors `LIT_NETWORK` for supported networks. */
7
+ export type EnvironmentName = "chipotle";
8
+ export interface SDKConfig {
9
+ environment: EnvironmentName;
10
+ litNetwork: LitNetwork;
11
+ realLitTesting: boolean;
12
+ debugMode: boolean;
13
+ runRealIntegrationTests: boolean;
14
+ litRelayUrl?: string;
15
+ ethRpcUrl: string;
16
+ polygonRpcUrl: string;
17
+ pkpMintPrivateKey?: string;
18
+ }
19
+ /**
20
+ * Resolved Lit network from `LIT_NETWORK` / `VITE_LIT_NETWORK` (default: production **chipotle**).
21
+ */
22
+ export declare function resolveLitNetworkFromEnv(): LitNetwork;
23
+ /**
24
+ * SDK environment label derived from `LIT_NETWORK` (default **chipotle**).
25
+ */
26
+ export declare function getCurrentEnvironment(): EnvironmentName;
27
+ /**
28
+ * Load and validate SDK configuration from environment
29
+ */
30
+ export declare function loadSDKConfig(): SDKConfig;
31
+ /**
32
+ * Get LIT Network configuration
33
+ */
34
+ export declare function getLitNetworkConfig(networkName: LitNetwork): LitNetwork;
35
+ /**
36
+ * Environment-aware console logging
37
+ */
38
+ export declare function envLog(message: string, ...args: any[]): void;
39
+ /**
40
+ * Validate SDK environment requirements
41
+ */
42
+ export declare function validateSDKEnvironment(requirements: {
43
+ requiresRealLitTesting?: boolean;
44
+ requiresPrivateKey?: boolean;
45
+ }): SDKConfig;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Environment Configuration for Diamond Hands SDK (Node only)
3
+ *
4
+ * Loads and validates environment variables with multi-path `.env` discovery.
5
+ * Used for server-side flows that may read `PKP_MINT_PRIVATE_KEY`.
6
+ *
7
+ * **Do not import this file from browser-oriented modules.** Import via
8
+ * `@gvnrdao/dh-sdk/server` only. Shared / client code should use `environment.browser`.
9
+ *
10
+ * **Observability:** With `DEBUG_SDK=true`, logs once which `.env` paths were attempted
11
+ * and which existing files were merged (later overrides earlier).
12
+ *
13
+ * **Strict merge checks:** Detecting conflicting definitions of the same variable across
14
+ * multiple `.env` files is not implemented; reserved for a future CI-gated workflow once
15
+ * the repo has automated SDK checks in CI.
16
+ */
17
+ import { LitNetwork } from "@gvnrdao/dh-lit-ops";
18
+ /** SDK environment label — mirrors `LIT_NETWORK` for supported networks. */
19
+ export type EnvironmentName = "chipotle";
20
+ export interface SDKConfig {
21
+ environment: EnvironmentName;
22
+ litNetwork: LitNetwork;
23
+ realLitTesting: boolean;
24
+ debugMode: boolean;
25
+ runRealIntegrationTests: boolean;
26
+ litRelayUrl?: string;
27
+ ethRpcUrl: string;
28
+ polygonRpcUrl: string;
29
+ pkpMintPrivateKey?: string;
30
+ }
31
+ /**
32
+ * Resolved Lit network from `LIT_NETWORK` (default: production **chipotle**).
33
+ */
34
+ export declare function resolveLitNetworkFromEnv(): LitNetwork;
35
+ /**
36
+ * SDK environment label derived from `LIT_NETWORK` (default **chipotle**).
37
+ */
38
+ export declare function getCurrentEnvironment(): EnvironmentName;
39
+ /**
40
+ * Load and validate SDK configuration from environment
41
+ */
42
+ export declare function loadSDKConfig(): SDKConfig;
43
+ /**
44
+ * Get LIT Network configuration
45
+ */
46
+ export declare function getLitNetworkConfig(networkName: LitNetwork): LitNetwork;
47
+ /**
48
+ * Environment-aware console logging
49
+ */
50
+ export declare function envLog(message: string, ...args: any[]): void;
51
+ /**
52
+ * Validate SDK environment requirements
53
+ */
54
+ export declare function validateSDKEnvironment(requirements: {
55
+ requiresRealLitTesting?: boolean;
56
+ requiresPrivateKey?: boolean;
57
+ }): SDKConfig;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Network Configuration Constants
3
+ * Automatically loads contract addresses from deployment files
4
+ * Browser-friendly implementation with silent fallbacks
5
+ */
6
+ /**
7
+ * Network Configuration Interface
8
+ */
9
+ export interface NetworkConfig {
10
+ mode: "service" | "standalone";
11
+ serviceEndpoint: string;
12
+ chainId: number;
13
+ name: string;
14
+ rpcUrls: string[];
15
+ contractAddresses: {
16
+ positionManager: string;
17
+ positionManagerCore?: string;
18
+ positionManagerViews?: string;
19
+ simplePsmV2?: string;
20
+ loanOperationsManager?: string;
21
+ termManager?: string;
22
+ circuitBreaker?: string;
23
+ liquidationManager?: string;
24
+ ucdToken: string;
25
+ ucdController?: string;
26
+ priceFeedConsumer: string;
27
+ operationAuthorizationRegistry?: string;
28
+ btcSpendAuthorizer?: string;
29
+ bitcoinProviderRegistry?: string;
30
+ mockUsdcToken?: string;
31
+ mockUsdtToken?: string;
32
+ mockUsdcOwner?: string;
33
+ };
34
+ subgraphs: {
35
+ diamondHandsUrl?: string;
36
+ tokenGvnrUrl?: string;
37
+ };
38
+ litNetwork: string;
39
+ validatorVersion?: number;
40
+ debug: boolean;
41
+ }
42
+ /**
43
+ * Network Configuration Registry
44
+ */
45
+ export declare const NETWORK_CONFIGS: Record<number, NetworkConfig>;
46
+ /**
47
+ * Get network configuration by chain ID
48
+ */
49
+ export declare function getNetworkConfig(chainId: number): NetworkConfig | null;
50
+ /**
51
+ * Get network configuration by human-readable name (e.g., "sepolia")
52
+ */
53
+ export declare function getNetworkConfigByName(name: string): NetworkConfig | null;
54
+ /**
55
+ * Get all supported network configurations
56
+ */
57
+ export declare function getAllNetworkConfigs(): NetworkConfig[];
58
+ /**
59
+ * Check if a network is supported
60
+ */
61
+ export declare function isNetworkSupported(chainId: number): boolean;
62
+ /**
63
+ * Default network fallbacks
64
+ */
65
+ export declare const DEFAULT_NETWORK_CONFIG: Partial<NetworkConfig>;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * SDK Configuration Constants
3
+ */
4
+ import type { LitNetwork } from "@gvnrdao/dh-lit-ops";
5
+ export declare const DEFAULT_NETWORKS: {
6
+ readonly ETHEREUM_MAINNET: "https://eth-mainnet.g.alchemy.com/v2/";
7
+ readonly ETHEREUM_SEPOLIA: "https://eth-sepolia.g.alchemy.com/v2/";
8
+ readonly POLYGON_MAINNET: "https://polygon-mainnet.g.alchemy.com/v2/";
9
+ readonly LOCAL_HARDHAT: "http://localhost:8545";
10
+ };
11
+ export declare const DEFAULT_LIT_NETWORKS: {
12
+ readonly CHIPOTLE: "chipotle";
13
+ };
14
+ /**
15
+ * Default Lit network when `LIT_NETWORK` is unset or config omits `litNetwork`.
16
+ */
17
+ export declare const DEFAULT_LIT_NETWORK: "chipotle";
18
+ /** Supported Lit Protocol networks for this SDK (Chipotle). */
19
+ export declare const VALID_LIT_NETWORKS: readonly LitNetwork[];
20
+ export declare const SDK_DEFAULTS: {
21
+ readonly SESSION_EXPIRATION_MINUTES: 60;
22
+ readonly TRANSACTION_TIMEOUT_MS: 30000;
23
+ readonly RETRY_ATTEMPTS: 3;
24
+ readonly DEBUG: false;
25
+ };
26
+ export declare const SDK_ERROR_MESSAGES: {
27
+ readonly NOT_INITIALIZED: "SDK not initialized. Call initialize() first.";
28
+ readonly INVALID_CONFIG: "Invalid SDK configuration provided.";
29
+ readonly NETWORK_ERROR: "Network connection error occurred.";
30
+ readonly TRANSACTION_FAILED: "Transaction failed to execute.";
31
+ readonly PKP_CREATION_FAILED: "PKP creation failed.";
32
+ readonly SIGNATURE_INVALID: "Invalid signature provided.";
33
+ };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * SDK Limits and Configuration Constants
3
+ * Centralized constants for magic numbers used throughout the SDK
4
+ */
5
+ /**
6
+ * Maximum batch size for The Graph queries
7
+ * The Graph has a hard limit of 1000 items per query
8
+ */
9
+ export declare const THE_GRAPH_MAX_BATCH_SIZE = 1000;
10
+ /**
11
+ * Maximum rows per page for pagination
12
+ * Prevents excessive memory usage and query timeouts
13
+ */
14
+ export declare const MAX_PAGINATION_ROWS = 1000;
15
+ /**
16
+ * Default rows per page for pagination
17
+ */
18
+ export declare const DEFAULT_PAGINATION_ROWS = 10;
19
+ /**
20
+ * Default maximum number of retries for failed operations
21
+ */
22
+ export declare const DEFAULT_MAX_RETRIES = 3;
23
+ /**
24
+ * Default operation timeout in milliseconds
25
+ */
26
+ export declare const DEFAULT_OPERATION_TIMEOUT_MS = 30000;
27
+ /**
28
+ * Default PKP address cache size
29
+ */
30
+ export declare const DEFAULT_PKP_CACHE_SIZE = 500;
31
+ /**
32
+ * Default PKP address cache TTL in milliseconds
33
+ */
34
+ export declare const DEFAULT_PKP_CACHE_TTL_MS = 300000;
35
+ /**
36
+ * Default balance cache size
37
+ */
38
+ export declare const DEFAULT_BALANCE_CACHE_SIZE = 1000;
39
+ /**
40
+ * Default balance cache TTL in milliseconds
41
+ */
42
+ export declare const DEFAULT_BALANCE_CACHE_TTL_MS = 60000;
43
+ /**
44
+ * Default cache cleanup interval in milliseconds
45
+ */
46
+ export declare const DEFAULT_CACHE_CLEANUP_INTERVAL_MS = 300000;
47
+ /**
48
+ * Default number of blocks for PSM rate limit reset period
49
+ */
50
+ export declare const PSM_RATE_LIMIT_RESET_BLOCKS = 100;
51
+ /**
52
+ * Maximum operations per PSM rate limit window
53
+ */
54
+ export declare const PSM_MAX_OPERATIONS_PER_WINDOW = 10;
55
+ /**
56
+ * Default maximum concurrent operations
57
+ */
58
+ export declare const DEFAULT_CONCURRENCY_LIMIT = 10;
59
+ /**
60
+ * Default Bitcoin provider consensus mode
61
+ */
62
+ export declare const DEFAULT_BITCOIN_CONSENSUS_MODE: "majority";
63
+ /**
64
+ * Minimum number of Bitcoin providers for consensus
65
+ */
66
+ export declare const MIN_BITCOIN_PROVIDERS_FOR_CONSENSUS = 2;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Diamond Hands SDK Constants
3
+ * All constants used in the SDK package
4
+ *
5
+ * Following the golden source pattern with organized chunks
6
+ *
7
+ * **Environment:** This barrel exports **browser-safe** `environment.browser` only.
8
+ * For Node-only config including `PKP_MINT_PRIVATE_KEY` / dotenv paths, use
9
+ * `@gvnrdao/dh-sdk/server` (see `src/server.ts`).
10
+ */
11
+ export * from "./chunks/sdk-config";
12
+ export * from "./chunks/network-configs";
13
+ export * from "./chunks/environment.browser";
14
+ export * from "./chunks/contract-abis";
15
+ export * from "./chunks/sdk-limits";
@@ -0,0 +1,19 @@
1
+ export interface GraphClientConfig {
2
+ endpoint: string;
3
+ requestTimeoutMs?: number;
4
+ maxRetries?: number;
5
+ headers?: Record<string, string>;
6
+ }
7
+ export declare class GraphClient {
8
+ private endpoint;
9
+ private requestTimeoutMs;
10
+ private maxRetries;
11
+ private headers?;
12
+ constructor(config: GraphClientConfig);
13
+ execute<T>(query: string, variables?: Record<string, any>): Promise<T>;
14
+ paginate<TItem>(query: string, variables: Record<string, any>, select: (page: any) => TItem[], options?: {
15
+ pageSize?: number;
16
+ maxPages?: number;
17
+ }): Promise<TItem[]>;
18
+ private backoff;
19
+ }