@gvnrdao/dh-sdk 0.0.288 → 0.0.289
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/browser/dist/833.browser.js +1 -1
- package/browser/dist/browser.js +1 -1
- package/browser/dist/browser.js.LICENSE.txt +5 -10
- package/dist/constants/chunks/contract-abis.d.ts +20 -0
- package/dist/constants/chunks/deployment-addresses.d.ts +79 -0
- package/dist/constants/chunks/encrypted-provider-params.d.ts +21 -0
- package/dist/constants/chunks/environment.browser.d.ts +44 -0
- package/dist/constants/chunks/environment.d.ts +57 -0
- package/dist/constants/chunks/network-configs.d.ts +72 -0
- package/dist/constants/chunks/sdk-config.d.ts +33 -0
- package/dist/constants/chunks/sdk-limits.d.ts +66 -0
- package/dist/constants/index.d.ts +15 -0
- package/dist/contracts/typechain-contracts/common.d.ts +50 -0
- package/dist/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.d.ts +1996 -0
- package/dist/contracts/typechain-contracts/src/psm/SimplePSMV2.d.ts +1198 -0
- package/dist/deployments.js +21 -45
- package/dist/deployments.mjs +21 -45
- package/dist/graphs/client.d.ts +22 -0
- package/dist/graphs/diamond-hands.d.ts +259 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +1123 -628
- package/dist/index.mjs +1123 -628
- package/dist/interfaces/chunks/btc.i.d.ts +36 -0
- package/dist/interfaces/chunks/config.i.d.ts +270 -0
- package/dist/interfaces/chunks/contract-interactions.i.d.ts +64 -0
- package/dist/interfaces/chunks/contract-types.i.d.ts +171 -0
- package/dist/interfaces/chunks/lit-actions-results.i.d.ts +165 -0
- package/dist/interfaces/chunks/lit-actions.i.d.ts +98 -0
- package/dist/interfaces/chunks/loan-operations.i.d.ts +331 -0
- package/dist/interfaces/chunks/pkp-integration.i.d.ts +87 -0
- package/dist/interfaces/chunks/position-query.i.d.ts +76 -0
- package/dist/interfaces/chunks/requests.i.d.ts +55 -0
- package/dist/interfaces/chunks/ucd-minting.i.d.ts +34 -0
- package/dist/interfaces/chunks/utility.i.d.ts +64 -0
- package/dist/interfaces/index.d.ts +17 -0
- package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +254 -0
- package/dist/modules/cache/cache-manager.module.d.ts +259 -0
- package/dist/modules/contract/contract-manager.module.d.ts +152 -0
- package/dist/modules/diamond-hands-sdk.d.ts +969 -0
- package/dist/modules/loan/loan-creator.module.d.ts +132 -0
- package/dist/modules/loan/loan-query.module.d.ts +204 -0
- package/dist/modules/mock/mock-token-manager.module.d.ts +83 -0
- package/dist/modules/pkp/pkp-manager.module.d.ts +136 -0
- package/dist/modules/withdrawal-address/withdrawal-address.module.d.ts +78 -0
- package/dist/protocol/protocol-pause.d.ts +19 -0
- package/dist/server.d.ts +17 -0
- package/dist/types/authorization-params.d.ts +160 -0
- package/dist/types/branded/domain-values.d.ts +138 -0
- package/dist/types/branded/ids.d.ts +23 -0
- package/dist/types/event-types.d.ts +261 -0
- package/dist/types/graph-dtos.d.ts +228 -0
- package/dist/types/loanStatus.d.ts +10 -0
- package/dist/types/protocol-event-types.d.ts +99 -0
- package/dist/types/result.d.ts +120 -0
- package/dist/utils/address-conversion.utils.d.ts +51 -0
- package/dist/utils/bitcoin-address-cache.utils.d.ts +87 -0
- package/dist/utils/bitcoin-provider.utils.d.ts +84 -0
- package/dist/utils/btc-withdrawal-message.d.ts +60 -0
- package/dist/utils/chunks/bitcoin-utils.d.ts +85 -0
- package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +33 -0
- package/dist/utils/eip712-login.d.ts +34 -0
- package/dist/utils/error-handler.d.ts +106 -0
- package/dist/utils/ethers-interop.utils.d.ts +146 -0
- package/dist/utils/extend-authorization.utils.d.ts +61 -0
- package/dist/utils/lit-signature.utils.d.ts +6 -0
- package/dist/utils/logger.utils.d.ts +142 -0
- package/dist/utils/mint-authorization.utils.d.ts +248 -0
- package/dist/utils/position-delegate.utils.d.ts +41 -0
- package/dist/utils/quantum-timing.d.ts +75 -0
- package/dist/utils/server-session.d.ts +50 -0
- package/dist/utils/service-endpoint-policy.d.ts +16 -0
- package/dist/utils/signature-tempering.utils.d.ts +34 -0
- package/dist/utils/telegram-messaging.utils.d.ts +188 -0
- package/package.json +1 -1
- package/browser/dist/397.browser.js +0 -2
- package/browser/dist/397.browser.js.LICENSE.txt +0 -1
package/dist/deployments.js
CHANGED
|
@@ -428,68 +428,44 @@ var MAINNET_CONTRACTS = {
|
|
|
428
428
|
var LOCALHOST_DEPLOYMENT = {
|
|
429
429
|
network: "localhost",
|
|
430
430
|
chainId: 31337,
|
|
431
|
-
timestamp: "2026-
|
|
431
|
+
timestamp: "2026-03-23T15:33:34.068Z",
|
|
432
432
|
deployer: "",
|
|
433
433
|
contracts: {
|
|
434
|
-
MessageHashBuilder: "
|
|
435
|
-
UpgradeValidator: "
|
|
434
|
+
MessageHashBuilder: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
435
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
436
436
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
437
437
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
438
|
-
PositionManagerCoreModule: "
|
|
439
|
-
TermManagerModule: "
|
|
440
|
-
LoanOperationsManagerModule: "
|
|
438
|
+
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
439
|
+
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
440
|
+
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
441
441
|
BTCSpendAuthorizer: "0x59b670e9fA9D0A427751Af201D676719a970857b",
|
|
442
442
|
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
443
443
|
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
444
|
-
CircuitBreakerModule: "
|
|
444
|
+
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
445
445
|
AdminModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
446
|
-
PositionManagerViews: "
|
|
447
|
-
PositionManager: "
|
|
448
|
-
OperationAuthorizationRegistry: "
|
|
449
|
-
PKPValidation: "
|
|
450
|
-
},
|
|
451
|
-
latestEnv: {
|
|
452
|
-
UCD_TOKEN: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
453
|
-
UCD_CONTROLLER: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
454
|
-
POSITION_MANAGER: "0xf5059a5D33d5853360D16C683c16e67980206f36",
|
|
455
|
-
PKP_VALIDATION_REGISTRY: "0xc0F115A19107322cFBf1cDBC7ea011C19EbDB4F8",
|
|
456
|
-
PKP_VALIDATION_CID_V1: "0x122052091400dec1612605e0b92f973e7dd35c2d0c05e2d39c2168e158ceaa9beac7",
|
|
457
|
-
PKP_VALIDATION_CID_V3: "0x122052091400dec1612605e0b92f973e7dd35c2d0c05e2d39c2168e158ceaa9beac7",
|
|
458
|
-
PKP_ETH_ADDRESS: "0x9eE56687F7a984D5DF7aB79330271a619ef56DdD",
|
|
459
|
-
OPERATION_AUTHORIZATION_REGISTRY: "0xF8e31cb472bc70500f08Cd84917E5A1912Ec8397",
|
|
460
|
-
UCD_MINT_VALIDATOR_ADDRESS: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
|
|
461
|
-
UCD_MINT_VALIDATOR_VERSION: 1,
|
|
462
|
-
BTC_WITHDRAWAL_VALIDATOR_ADDRESS: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
|
|
463
|
-
BTC_WITHDRAWAL_VALIDATOR_VERSION: 1,
|
|
464
|
-
UPDATE_BALANCE_VALIDATOR_ADDRESS: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
|
|
465
|
-
UPDATE_BALANCE_VALIDATOR_VERSION: 1,
|
|
466
|
-
PROCESS_PAYMENT_VALIDATOR_ADDRESS: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
|
|
467
|
-
PROCESS_PAYMENT_VALIDATOR_VERSION: 1,
|
|
468
|
-
EXTEND_POSITION_VALIDATOR_ADDRESS: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
|
|
469
|
-
EXTEND_POSITION_VALIDATOR_VERSION: 1,
|
|
470
|
-
POSITION_MANAGER_CORE_MODULE: "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0",
|
|
471
|
-
LOAN_OPERATIONS_MANAGER_MODULE: "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c",
|
|
472
|
-
TERM_MANAGER_MODULE: "0x9A676e781A523b5d0C0e43731313A708CB607508",
|
|
473
|
-
COMMUNITY_MANAGER_MODULE: ""
|
|
446
|
+
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
447
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
448
|
+
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
449
|
+
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
474
450
|
}
|
|
475
451
|
};
|
|
476
452
|
var LOCALHOST_CONTRACTS = {
|
|
477
|
-
MessageHashBuilder: "
|
|
478
|
-
UpgradeValidator: "
|
|
453
|
+
MessageHashBuilder: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
454
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
479
455
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
480
456
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
481
|
-
PositionManagerCoreModule: "
|
|
482
|
-
TermManagerModule: "
|
|
483
|
-
LoanOperationsManagerModule: "
|
|
457
|
+
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
458
|
+
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
459
|
+
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
484
460
|
BTCSpendAuthorizer: "0x59b670e9fA9D0A427751Af201D676719a970857b",
|
|
485
461
|
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
486
462
|
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
487
|
-
CircuitBreakerModule: "
|
|
463
|
+
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
488
464
|
AdminModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
489
|
-
PositionManagerViews: "
|
|
490
|
-
PositionManager: "
|
|
491
|
-
OperationAuthorizationRegistry: "
|
|
492
|
-
PKPValidation: "
|
|
465
|
+
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
466
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
467
|
+
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
468
|
+
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
493
469
|
};
|
|
494
470
|
var ALL_DEPLOYMENTS = {
|
|
495
471
|
sepolia: SEPOLIA_DEPLOYMENT,
|
package/dist/deployments.mjs
CHANGED
|
@@ -395,68 +395,44 @@ var MAINNET_CONTRACTS = {
|
|
|
395
395
|
var LOCALHOST_DEPLOYMENT = {
|
|
396
396
|
network: "localhost",
|
|
397
397
|
chainId: 31337,
|
|
398
|
-
timestamp: "2026-
|
|
398
|
+
timestamp: "2026-03-23T15:33:34.068Z",
|
|
399
399
|
deployer: "",
|
|
400
400
|
contracts: {
|
|
401
|
-
MessageHashBuilder: "
|
|
402
|
-
UpgradeValidator: "
|
|
401
|
+
MessageHashBuilder: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
402
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
403
403
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
404
404
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
405
|
-
PositionManagerCoreModule: "
|
|
406
|
-
TermManagerModule: "
|
|
407
|
-
LoanOperationsManagerModule: "
|
|
405
|
+
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
406
|
+
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
407
|
+
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
408
408
|
BTCSpendAuthorizer: "0x59b670e9fA9D0A427751Af201D676719a970857b",
|
|
409
409
|
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
410
410
|
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
411
|
-
CircuitBreakerModule: "
|
|
411
|
+
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
412
412
|
AdminModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
413
|
-
PositionManagerViews: "
|
|
414
|
-
PositionManager: "
|
|
415
|
-
OperationAuthorizationRegistry: "
|
|
416
|
-
PKPValidation: "
|
|
417
|
-
},
|
|
418
|
-
latestEnv: {
|
|
419
|
-
UCD_TOKEN: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
420
|
-
UCD_CONTROLLER: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
421
|
-
POSITION_MANAGER: "0xf5059a5D33d5853360D16C683c16e67980206f36",
|
|
422
|
-
PKP_VALIDATION_REGISTRY: "0xc0F115A19107322cFBf1cDBC7ea011C19EbDB4F8",
|
|
423
|
-
PKP_VALIDATION_CID_V1: "0x122052091400dec1612605e0b92f973e7dd35c2d0c05e2d39c2168e158ceaa9beac7",
|
|
424
|
-
PKP_VALIDATION_CID_V3: "0x122052091400dec1612605e0b92f973e7dd35c2d0c05e2d39c2168e158ceaa9beac7",
|
|
425
|
-
PKP_ETH_ADDRESS: "0x9eE56687F7a984D5DF7aB79330271a619ef56DdD",
|
|
426
|
-
OPERATION_AUTHORIZATION_REGISTRY: "0xF8e31cb472bc70500f08Cd84917E5A1912Ec8397",
|
|
427
|
-
UCD_MINT_VALIDATOR_ADDRESS: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
|
|
428
|
-
UCD_MINT_VALIDATOR_VERSION: 1,
|
|
429
|
-
BTC_WITHDRAWAL_VALIDATOR_ADDRESS: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
|
|
430
|
-
BTC_WITHDRAWAL_VALIDATOR_VERSION: 1,
|
|
431
|
-
UPDATE_BALANCE_VALIDATOR_ADDRESS: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
|
|
432
|
-
UPDATE_BALANCE_VALIDATOR_VERSION: 1,
|
|
433
|
-
PROCESS_PAYMENT_VALIDATOR_ADDRESS: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
|
|
434
|
-
PROCESS_PAYMENT_VALIDATOR_VERSION: 1,
|
|
435
|
-
EXTEND_POSITION_VALIDATOR_ADDRESS: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
|
|
436
|
-
EXTEND_POSITION_VALIDATOR_VERSION: 1,
|
|
437
|
-
POSITION_MANAGER_CORE_MODULE: "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0",
|
|
438
|
-
LOAN_OPERATIONS_MANAGER_MODULE: "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c",
|
|
439
|
-
TERM_MANAGER_MODULE: "0x9A676e781A523b5d0C0e43731313A708CB607508",
|
|
440
|
-
COMMUNITY_MANAGER_MODULE: ""
|
|
413
|
+
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
414
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
415
|
+
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
416
|
+
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
441
417
|
}
|
|
442
418
|
};
|
|
443
419
|
var LOCALHOST_CONTRACTS = {
|
|
444
|
-
MessageHashBuilder: "
|
|
445
|
-
UpgradeValidator: "
|
|
420
|
+
MessageHashBuilder: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
|
|
421
|
+
UpgradeValidator: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
446
422
|
UCDToken: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
447
423
|
UCDController: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
448
|
-
PositionManagerCoreModule: "
|
|
449
|
-
TermManagerModule: "
|
|
450
|
-
LoanOperationsManagerModule: "
|
|
424
|
+
PositionManagerCoreModule: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
425
|
+
TermManagerModule: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
426
|
+
LoanOperationsManagerModule: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
|
|
451
427
|
BTCSpendAuthorizer: "0x59b670e9fA9D0A427751Af201D676719a970857b",
|
|
452
428
|
CollateralManagerModule: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
|
|
453
429
|
LiquidationManagerModule: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
454
|
-
CircuitBreakerModule: "
|
|
430
|
+
CircuitBreakerModule: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
455
431
|
AdminModule: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
456
|
-
PositionManagerViews: "
|
|
457
|
-
PositionManager: "
|
|
458
|
-
OperationAuthorizationRegistry: "
|
|
459
|
-
PKPValidation: "
|
|
432
|
+
PositionManagerViews: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
|
|
433
|
+
PositionManager: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
|
|
434
|
+
OperationAuthorizationRegistry: "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0",
|
|
435
|
+
PKPValidation: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
|
|
460
436
|
};
|
|
461
437
|
var ALL_DEPLOYMENTS = {
|
|
462
438
|
sepolia: SEPOLIA_DEPLOYMENT,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface GraphClientConfig {
|
|
2
|
+
endpoint: string;
|
|
3
|
+
requestTimeoutMs?: number;
|
|
4
|
+
maxRetries?: number;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
/** Optional async supplier for per-request headers (e.g. session JWT). */
|
|
7
|
+
getHeaders?: () => Promise<Record<string, string>>;
|
|
8
|
+
}
|
|
9
|
+
export declare class GraphClient {
|
|
10
|
+
private endpoint;
|
|
11
|
+
private requestTimeoutMs;
|
|
12
|
+
private maxRetries;
|
|
13
|
+
private headers?;
|
|
14
|
+
private getHeadersFn?;
|
|
15
|
+
constructor(config: GraphClientConfig);
|
|
16
|
+
execute<T>(query: string, variables?: Record<string, any>): Promise<T>;
|
|
17
|
+
paginate<TItem>(query: string, variables: Record<string, any>, select: (page: any) => TItem[], options?: {
|
|
18
|
+
pageSize?: number;
|
|
19
|
+
maxPages?: number;
|
|
20
|
+
}): Promise<TItem[]>;
|
|
21
|
+
private backoff;
|
|
22
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import type { ProtocolEventsFilter, ProtocolEventsResult } from "../types/protocol-event-types";
|
|
2
|
+
import type { LoanData } from "../interfaces";
|
|
3
|
+
import type { GraphPositionWithBorrowerDTO } from "../types/graph-dtos";
|
|
4
|
+
import type { LoanEvents, LoanEventsFilter } from "../types/event-types";
|
|
5
|
+
import type { BitcoinOperations, EnrichedBitcoinBalance } from "../modules/bitcoin/bitcoin-operations.module";
|
|
6
|
+
export interface DiamondHandsGraphConfig {
|
|
7
|
+
endpoint: string;
|
|
8
|
+
requestTimeoutMs?: number;
|
|
9
|
+
maxRetries?: number;
|
|
10
|
+
defaultPageSize?: number;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
/** Optional async supplier for per-request headers (e.g. session JWT). */
|
|
13
|
+
getHeaders?: () => Promise<Record<string, string>>;
|
|
14
|
+
}
|
|
15
|
+
export interface UserData {
|
|
16
|
+
id: string;
|
|
17
|
+
positions: LoanData[];
|
|
18
|
+
totalBorrowed: string;
|
|
19
|
+
totalRepaid: string;
|
|
20
|
+
activePositions: string;
|
|
21
|
+
firstInteractionTimestamp: string;
|
|
22
|
+
lastInteractionTimestamp: string;
|
|
23
|
+
}
|
|
24
|
+
export interface LoanTermData {
|
|
25
|
+
id: string;
|
|
26
|
+
months: string;
|
|
27
|
+
mintFeeBps?: string;
|
|
28
|
+
extensionFeeBps?: string;
|
|
29
|
+
isValid?: boolean;
|
|
30
|
+
createdAt?: string;
|
|
31
|
+
createdAtBlock?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface PSMConfigurationData {
|
|
34
|
+
id: string;
|
|
35
|
+
version: string;
|
|
36
|
+
redeemEnabled: boolean;
|
|
37
|
+
totalSwapVolume: string;
|
|
38
|
+
totalRedeemVolume: string;
|
|
39
|
+
supportedStablecoinsCount: string;
|
|
40
|
+
lastUpdated: string;
|
|
41
|
+
}
|
|
42
|
+
export interface SupportedStablecoinData {
|
|
43
|
+
id: string;
|
|
44
|
+
address: string;
|
|
45
|
+
isSupported: boolean;
|
|
46
|
+
exchangeRate: string;
|
|
47
|
+
entryFee: string;
|
|
48
|
+
exitFee: string;
|
|
49
|
+
reserves: string;
|
|
50
|
+
decimals: string;
|
|
51
|
+
totalSwapVolume: string;
|
|
52
|
+
totalRedeemVolume: string;
|
|
53
|
+
swapCount: string;
|
|
54
|
+
redeemCount: string;
|
|
55
|
+
addedAt: string;
|
|
56
|
+
lastUpdated: string;
|
|
57
|
+
}
|
|
58
|
+
export interface PSMTransactionData {
|
|
59
|
+
id: string;
|
|
60
|
+
type: string;
|
|
61
|
+
user: string;
|
|
62
|
+
stablecoin: SupportedStablecoinData;
|
|
63
|
+
stablecoinAmount: string;
|
|
64
|
+
ucdAmount: string;
|
|
65
|
+
fee: string;
|
|
66
|
+
effectiveRate: string;
|
|
67
|
+
timestamp: string;
|
|
68
|
+
blockNumber: string;
|
|
69
|
+
transactionHash: string;
|
|
70
|
+
}
|
|
71
|
+
export interface UserRateLimitData {
|
|
72
|
+
id: string;
|
|
73
|
+
user: string;
|
|
74
|
+
stablecoin: SupportedStablecoinData;
|
|
75
|
+
lastOperationBlock: string;
|
|
76
|
+
operationCount: string;
|
|
77
|
+
isCurrentlyLimited: boolean;
|
|
78
|
+
nextResetBlock: string;
|
|
79
|
+
lastUpdated: string;
|
|
80
|
+
}
|
|
81
|
+
export declare class DiamondHandsGraph {
|
|
82
|
+
private client;
|
|
83
|
+
private defaultPageSize;
|
|
84
|
+
private bitcoinOps?;
|
|
85
|
+
constructor(config: DiamondHandsGraphConfig, bitcoinOps?: BitcoinOperations);
|
|
86
|
+
/**
|
|
87
|
+
* Transform graph position data to LoanData interface
|
|
88
|
+
* Converts flat graph structure to nested LoanData structure
|
|
89
|
+
*/
|
|
90
|
+
private transformGraphPositionToLoanData;
|
|
91
|
+
/**
|
|
92
|
+
* Helper: Get total count by paginating through all results
|
|
93
|
+
* The Graph has a hard limit of 1000 items per query, so we need to paginate
|
|
94
|
+
*
|
|
95
|
+
* NOTE: This implementation fetches minimal data (just IDs) for counting.
|
|
96
|
+
* The Graph protocol does not currently support count-only aggregation queries,
|
|
97
|
+
* so this batching approach is optimal for total count determination.
|
|
98
|
+
* Future optimization: If The Graph adds support for aggregate functions
|
|
99
|
+
* (e.g., `positions_aggregate { count }`), this should be updated.
|
|
100
|
+
*
|
|
101
|
+
* @param entityName The GraphQL entity name (e.g., "positions", "users")
|
|
102
|
+
* @param whereClause Optional GraphQL where clause (e.g., "{ borrower: $borrower }")
|
|
103
|
+
* @param variables Optional variables for the where clause
|
|
104
|
+
* @returns Total count of items
|
|
105
|
+
*/
|
|
106
|
+
private getTotalCountPaginated;
|
|
107
|
+
/**
|
|
108
|
+
* Get user positions from subgraph
|
|
109
|
+
*/
|
|
110
|
+
getUserPositions(userAddress: string, first?: number, skip?: number, orderBy?: string, orderDirection?: string): Promise<{
|
|
111
|
+
positions: LoanData[];
|
|
112
|
+
total: number;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Get user positions with enriched Bitcoin balance data
|
|
116
|
+
*
|
|
117
|
+
* Same as getUserPositions but queries actual BTC balance from Bitcoin network
|
|
118
|
+
* for each vault address in parallel.
|
|
119
|
+
*
|
|
120
|
+
* @param userAddress - User's Ethereum address
|
|
121
|
+
* @param first - Optional: max number of positions to return (default: 10)
|
|
122
|
+
* @param skip - Optional: number of positions to skip (default: 0)
|
|
123
|
+
* @param orderBy - Optional: field to order by (default: "createdAt")
|
|
124
|
+
* @param orderDirection - Optional: asc or desc (default: "desc" - most recent first)
|
|
125
|
+
* @returns Positions with actual BTC balances from Bitcoin network
|
|
126
|
+
*/
|
|
127
|
+
getUserPositionsWithBtc(userAddress: string, first?: number, skip?: number, orderBy?: string, orderDirection?: "asc" | "desc"): Promise<{
|
|
128
|
+
positions: (LoanData & {
|
|
129
|
+
btcBalance?: EnrichedBitcoinBalance;
|
|
130
|
+
})[];
|
|
131
|
+
total: number;
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* Get position by PKP ID from subgraph
|
|
135
|
+
*/
|
|
136
|
+
getPositionByPKP(pkpId: string): Promise<LoanData | null>;
|
|
137
|
+
/**
|
|
138
|
+
* Get detailed position data by PKP ID from subgraph
|
|
139
|
+
*/
|
|
140
|
+
getDetailedPositionByPkpId(pkpId: string): Promise<any | null>;
|
|
141
|
+
/**
|
|
142
|
+
* Get detailed position data by position ID from subgraph
|
|
143
|
+
*/
|
|
144
|
+
getDetailedPositionById(positionId: string): Promise<GraphPositionWithBorrowerDTO | null>;
|
|
145
|
+
/**
|
|
146
|
+
* Get all positions with pagination
|
|
147
|
+
*/
|
|
148
|
+
getAllPositions(options?: {
|
|
149
|
+
pageSize?: number;
|
|
150
|
+
maxPages?: number;
|
|
151
|
+
}): Promise<LoanData[]>;
|
|
152
|
+
/**
|
|
153
|
+
* Get all positions directly (simple query with pagination support)
|
|
154
|
+
*/
|
|
155
|
+
getPositions(first?: number, orderBy?: string, orderDirection?: "asc" | "desc", skip?: number, includeTotalCount?: boolean): Promise<{
|
|
156
|
+
positions: LoanData[];
|
|
157
|
+
total: number;
|
|
158
|
+
}>;
|
|
159
|
+
/**
|
|
160
|
+
* Get positions filtered by an array of statuses
|
|
161
|
+
*/
|
|
162
|
+
getPositionsByStatus(statuses: string[], first?: number, orderBy?: string, orderDirection?: "asc" | "desc", skip?: number): Promise<{
|
|
163
|
+
positions: LoanData[];
|
|
164
|
+
total: number;
|
|
165
|
+
}>;
|
|
166
|
+
/**
|
|
167
|
+
* Get active positions only
|
|
168
|
+
*/
|
|
169
|
+
getActivePositions(options?: {
|
|
170
|
+
pageSize?: number;
|
|
171
|
+
maxPages?: number;
|
|
172
|
+
}): Promise<LoanData[]>;
|
|
173
|
+
/**
|
|
174
|
+
* Get protocol statistics
|
|
175
|
+
*/
|
|
176
|
+
getProtocolStats(): Promise<{
|
|
177
|
+
totalValueLocked: string;
|
|
178
|
+
totalBorrowed: string;
|
|
179
|
+
totalRepaid: string;
|
|
180
|
+
totalLiquidated: string;
|
|
181
|
+
totalPositions: string;
|
|
182
|
+
activePositions: string;
|
|
183
|
+
totalUsers: string;
|
|
184
|
+
} | null>;
|
|
185
|
+
/**
|
|
186
|
+
* Health check for subgraph
|
|
187
|
+
*/
|
|
188
|
+
healthCheck(): Promise<{
|
|
189
|
+
isHealthy: boolean;
|
|
190
|
+
latestBlock?: string;
|
|
191
|
+
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Get all configured loan terms (from subgraph)
|
|
194
|
+
* Note: If the subgraph does not seed default terms from the contract, this may return an empty array.
|
|
195
|
+
*/
|
|
196
|
+
getLoanTerms(options?: {
|
|
197
|
+
first?: number;
|
|
198
|
+
skip?: number;
|
|
199
|
+
}): Promise<LoanTermData[]>;
|
|
200
|
+
/**
|
|
201
|
+
* Get a single loan term by months (from subgraph)
|
|
202
|
+
* Typical id is the months as string, e.g., "12".
|
|
203
|
+
*/
|
|
204
|
+
getLoanTerm(months: number | string): Promise<LoanTermData | null>;
|
|
205
|
+
/**
|
|
206
|
+
* Get PSM configuration from subgraph
|
|
207
|
+
*/
|
|
208
|
+
getPSMConfiguration(): Promise<PSMConfigurationData | null>;
|
|
209
|
+
/**
|
|
210
|
+
* Get all supported stablecoins from subgraph
|
|
211
|
+
*/
|
|
212
|
+
getSupportedStablecoins(onlySupported?: boolean): Promise<SupportedStablecoinData[]>;
|
|
213
|
+
/**
|
|
214
|
+
* Get stablecoin details by address
|
|
215
|
+
*/
|
|
216
|
+
getStablecoinDetails(address: string): Promise<SupportedStablecoinData | null>;
|
|
217
|
+
/**
|
|
218
|
+
* Get user rate limit status for a specific stablecoin
|
|
219
|
+
*/
|
|
220
|
+
getUserRateLimit(userAddress: string, stablecoinAddress: string): Promise<UserRateLimitData | null>;
|
|
221
|
+
/**
|
|
222
|
+
* Get PSM transactions with filters
|
|
223
|
+
*/
|
|
224
|
+
getPSMTransactions(filters?: {
|
|
225
|
+
user?: string;
|
|
226
|
+
stablecoin?: string;
|
|
227
|
+
type?: "SWAP" | "REDEEM";
|
|
228
|
+
first?: number;
|
|
229
|
+
skip?: number;
|
|
230
|
+
}): Promise<PSMTransactionData[]>;
|
|
231
|
+
/**
|
|
232
|
+
* Get PSM analytics for a date range
|
|
233
|
+
*/
|
|
234
|
+
getPSMDailyMetrics(startDate?: string, endDate?: string, first?: number): Promise<any[]>;
|
|
235
|
+
/**
|
|
236
|
+
* Get all events for a specific loan position
|
|
237
|
+
*
|
|
238
|
+
* Returns a comprehensive event history including:
|
|
239
|
+
* - Payments (full repayments, partial payments, extension fees)
|
|
240
|
+
* - Status updates with reasons
|
|
241
|
+
* - Liquidation event (if liquidated)
|
|
242
|
+
* - UCD mint events
|
|
243
|
+
* - Community fee distributions
|
|
244
|
+
*
|
|
245
|
+
* @param positionId - The position ID to query events for
|
|
246
|
+
* @param filter - Optional filters to apply
|
|
247
|
+
* @returns Complete event history for the position
|
|
248
|
+
*/
|
|
249
|
+
getLoanEvents(positionId: string, filter?: LoanEventsFilter): Promise<LoanEvents>;
|
|
250
|
+
/**
|
|
251
|
+
* Retrieve events across the full protocol, optionally narrowed to a position.
|
|
252
|
+
* Returns a merged, sorted discriminated-union timeline suitable for explorers.
|
|
253
|
+
*
|
|
254
|
+
* Protocol-global admin events (circuit breaker, term fees, etc.) are included
|
|
255
|
+
* by default; pass `kinds` to restrict.
|
|
256
|
+
*/
|
|
257
|
+
getAllEvents(filter?: ProtocolEventsFilter): Promise<ProtocolEventsResult>;
|
|
258
|
+
}
|
|
259
|
+
export type DiamondHandsGraphClient = DiamondHandsGraph;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diamond Hands SDK Package
|
|
3
|
+
* Diamond Hands Protocol - SDK Operations
|
|
4
|
+
*
|
|
5
|
+
* Provides high-level interface for Diamond Hands Protocol operations supporting:
|
|
6
|
+
* - Loan creation with PKP integration
|
|
7
|
+
* - Smart contract interactions
|
|
8
|
+
* - LIT Protocol operations
|
|
9
|
+
* - Bitcoin custody and operations
|
|
10
|
+
*
|
|
11
|
+
* Version 2.0 - Complete rewrite with full type safety
|
|
12
|
+
*/
|
|
13
|
+
export { DiamondHandsSDK } from './modules/diamond-hands-sdk';
|
|
14
|
+
export { DiamondHandsSDK as default } from './modules/diamond-hands-sdk';
|
|
15
|
+
export type { UCD, Satoshis, Wei, BPS, UnixTimestamp, BlockNumber, } from './types/branded/domain-values';
|
|
16
|
+
export { UCDConversions, SatoshisConversions, WeiConversions, BPSConversions, } from './types/branded/domain-values';
|
|
17
|
+
export type { Result, Success, Failure, } from './types/result';
|
|
18
|
+
export { success, failure, isSuccess, isFailure, unwrap, unwrapOr, map, mapError, andThen, firstSuccess, collectSuccesses, collectFailures, combine, tryCatch, tryCatchAsync, toPromise, fromPromise, match, } from './types/result';
|
|
19
|
+
export type { AuthorizationParams, CreateLoanAuthParams, MintUCDAuthParams, WithdrawBTCAuthParams, RepayDebtAuthParams, ExtendTermAuthParams, ClosePositionAuthParams, } from './types/authorization-params';
|
|
20
|
+
export { isCreateLoanAuth, isMintUCDAuth, isWithdrawBTCAuth, isRepayDebtAuth, isExtendTermAuth, isClosePositionAuth, AuthParamsValidation, } from './types/authorization-params';
|
|
21
|
+
export { ContractManager, createContractManager, } from './modules/contract/contract-manager.module';
|
|
22
|
+
export type { ContractManagerConfig, ManagedContracts, } from './modules/contract/contract-manager.module';
|
|
23
|
+
export { LRUCache, CacheManager, createCacheManager, } from './modules/cache/cache-manager.module';
|
|
24
|
+
export type { CacheConfig, CacheStats, } from './modules/cache/cache-manager.module';
|
|
25
|
+
export { PKPManager, createPKPManager, } from './modules/pkp/pkp-manager.module';
|
|
26
|
+
export type { PKPManagerConfig, } from './modules/pkp/pkp-manager.module';
|
|
27
|
+
export { LoanCreator, createLoanCreator, } from './modules/loan/loan-creator.module';
|
|
28
|
+
export type { LoanCreatorConfig, LoanCreationAudit, } from './modules/loan/loan-creator.module';
|
|
29
|
+
export { LoanQuery, createLoanQuery, } from './modules/loan/loan-query.module';
|
|
30
|
+
export type { LoanQueryConfig, LoanQueryFilters, PaginationParams, } from './modules/loan/loan-query.module';
|
|
31
|
+
export { WithdrawalAddressModule, createWithdrawalAddressModule, } from './modules/withdrawal-address/withdrawal-address.module';
|
|
32
|
+
export type { WithdrawalAddressModuleConfig, WithdrawalAddressEntry, } from './modules/withdrawal-address/withdrawal-address.module';
|
|
33
|
+
export { BitcoinOperations, createBitcoinOperations, } from './modules/bitcoin/bitcoin-operations.module';
|
|
34
|
+
export type { BitcoinOperationsConfig, BitcoinNetwork, EnrichedBitcoinBalance, } from './modules/bitcoin/bitcoin-operations.module';
|
|
35
|
+
export { MockTokenManager, createMockTokenManager, } from './modules/mock/mock-token-manager.module';
|
|
36
|
+
export type { SupportedStablecoinData } from './graphs/diamond-hands';
|
|
37
|
+
export type { MockTokenManagerConfig, MockTokenTransactionResult, } from './modules/mock/mock-token-manager.module';
|
|
38
|
+
export { validateSDKConfig, validateServiceModeConfig, validateStandaloneModeConfig, isServiceModeConfig, isStandaloneModeConfig, } from './interfaces/chunks/config.i';
|
|
39
|
+
export { assertSafeServiceEndpoint } from './utils/service-endpoint-policy';
|
|
40
|
+
export { DEFAULT_LIT_NETWORK, VALID_LIT_NETWORKS, SDK_DEFAULTS, } from './constants/chunks/sdk-config';
|
|
41
|
+
export { ALL_CONTRACTS, ALL_DEPLOYMENTS, getContractsByNetwork, getDeploymentByNetwork, LOCALHOST_CONTRACTS, SEPOLIA_CONTRACTS, } from './constants/chunks/deployment-addresses';
|
|
42
|
+
export type { DeploymentContracts, DeploymentData, DeploymentLatestEnv, } from './constants/chunks/deployment-addresses';
|
|
43
|
+
export type { CreateLoanRequest, CreateLoanResult, LoanData, LoanDataDetail, PaginatedLoansResponse, PKPValidationData, BitcoinAddresses, } from './interfaces/chunks/loan-operations.i';
|
|
44
|
+
export type { DiamondHandsSDKConfig, SDKMode, ContractAddresses, BitcoinProviderConfig, } from './interfaces/chunks/config.i';
|
|
45
|
+
export type { PKPData, PKPCreationRequest, PKPCreationResult, PKPValidationResult, } from './interfaces/chunks/pkp-integration.i';
|
|
46
|
+
export type { AuthorizationRequest, AuthorizationResult, BTCDepositRequest, BTCDepositResult, } from './interfaces/chunks/requests.i';
|
|
47
|
+
export { LoanStatus } from './types/loanStatus';
|
|
48
|
+
export type { LoanEvents, LoanEventsFilter, PositionCreatedEvent, PaymentEvent, StatusUpdateEvent, LiquidationEvent, UCDMintEvent, WithdrawalEvent, RenewalEvent, OperationFailureEvent, MintRequestEvent, BurnRequestEvent, CollateralContractEvent, } from './types/event-types';
|
|
49
|
+
export { PaymentType, PositionStatus, isValidPositionStatus, isValidPaymentType, numericToPositionStatus, EventHelpers, } from './types/event-types';
|
|
50
|
+
export type { ProtocolEvent, ProtocolEventsFilter, ProtocolEventsResult, } from './types/protocol-event-types';
|
|
51
|
+
export { fetchProtocolPauseStatus, assertProtocolNotPaused, } from './protocol/protocol-pause';
|
|
52
|
+
export type { ProtocolPauseStatus, ProtocolPauseKey, } from './protocol/protocol-pause';
|
|
53
|
+
export { SDKError, ErrorCategory, ErrorSeverity } from './utils/error-handler';
|
|
54
|
+
export { setPositionDelegate, getPositionDelegate } from './utils/position-delegate.utils';
|
|
55
|
+
export { buildBtcExecuteEnvelope, } from './utils/btc-withdrawal-message';
|
|
56
|
+
export type { BtcExecuteSignParams, BtcExecuteSignedEnvelope, } from './utils/btc-withdrawal-message';
|