@gvnrdao/dh-sdk 0.0.1
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/README.md +77 -0
- package/dist/browser.d.ts +14 -0
- package/dist/browser.js +36 -0
- package/dist/constants/chunks/contract-abis.d.ts +6 -0
- package/dist/constants/chunks/contract-abis.js +39 -0
- package/dist/constants/chunks/environment.browser.d.ts +40 -0
- package/dist/constants/chunks/environment.browser.js +111 -0
- package/dist/constants/chunks/environment.d.ts +40 -0
- package/dist/constants/chunks/environment.js +146 -0
- package/dist/constants/chunks/sdk-config.d.ts +27 -0
- package/dist/constants/chunks/sdk-config.js +34 -0
- package/dist/constants/index.d.ts +9 -0
- package/dist/constants/index.js +28 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +50 -0
- package/dist/interfaces/chunks/IBTCProof.d.ts +32 -0
- package/dist/interfaces/chunks/IBTCProof.js +2 -0
- package/dist/interfaces/chunks/SDKTypes.d.ts +2 -0
- package/dist/interfaces/chunks/SDKTypes.js +19 -0
- package/dist/interfaces/chunks/btc.i.d.ts +36 -0
- package/dist/interfaces/chunks/btc.i.js +5 -0
- package/dist/interfaces/chunks/config.i.d.ts +45 -0
- package/dist/interfaces/chunks/config.i.js +5 -0
- package/dist/interfaces/chunks/contract-interactions.i.d.ts +66 -0
- package/dist/interfaces/chunks/contract-interactions.i.js +5 -0
- package/dist/interfaces/chunks/lit-actions.d.ts +27 -0
- package/dist/interfaces/chunks/lit-actions.i.d.ts +44 -0
- package/dist/interfaces/chunks/lit-actions.i.js +5 -0
- package/dist/interfaces/chunks/lit-actions.js +2 -0
- package/dist/interfaces/chunks/loan-operations.d.ts +56 -0
- package/dist/interfaces/chunks/loan-operations.i.d.ts +85 -0
- package/dist/interfaces/chunks/loan-operations.i.js +5 -0
- package/dist/interfaces/chunks/loan-operations.js +2 -0
- package/dist/interfaces/chunks/pkp-integration.i.d.ts +88 -0
- package/dist/interfaces/chunks/pkp-integration.i.js +5 -0
- package/dist/interfaces/chunks/requests.i.d.ts +28 -0
- package/dist/interfaces/chunks/requests.i.js +5 -0
- package/dist/interfaces/chunks/ucd-minting.i.d.ts +34 -0
- package/dist/interfaces/chunks/ucd-minting.i.js +5 -0
- package/dist/interfaces/chunks/utility.i.d.ts +64 -0
- package/dist/interfaces/chunks/utility.i.js +5 -0
- package/dist/interfaces/index.d.ts +15 -0
- package/dist/interfaces/index.js +40 -0
- package/dist/modules/contract-interaction-manager.module.d.ts +86 -0
- package/dist/modules/contract-interaction-manager.module.js +136 -0
- package/dist/modules/diamond-hands-sdk.module.d.ts +109 -0
- package/dist/modules/diamond-hands-sdk.module.js +773 -0
- package/dist/modules/loan-operations-manager.module.d.ts +92 -0
- package/dist/modules/loan-operations-manager.module.js +171 -0
- package/dist/modules/pkp-integration-manager.module.d.ts +86 -0
- package/dist/modules/pkp-integration-manager.module.js +62 -0
- package/dist/types/loanStatus.d.ts +10 -0
- package/dist/types/loanStatus.js +16 -0
- package/dist/utils/chunks/bitcoin-utils.d.ts +51 -0
- package/dist/utils/chunks/bitcoin-utils.js +135 -0
- package/dist/utils/chunks/environment-utils.d.ts +11 -0
- package/dist/utils/chunks/environment-utils.js +21 -0
- package/dist/utils/chunks/pkp-utils.d.ts +19 -0
- package/dist/utils/chunks/pkp-utils.js +44 -0
- package/dist/utils/chunks/validation-utils.d.ts +30 -0
- package/dist/utils/chunks/validation-utils.js +58 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.js +39 -0
- package/package.json +74 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility Type Interfaces
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Generic Result Interface
|
|
6
|
+
*/
|
|
7
|
+
export interface Result<T = any> {
|
|
8
|
+
success: boolean;
|
|
9
|
+
error?: string;
|
|
10
|
+
data?: T;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Pagination Interface
|
|
14
|
+
*/
|
|
15
|
+
export interface Pagination {
|
|
16
|
+
page: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
total?: number;
|
|
19
|
+
hasNext?: boolean;
|
|
20
|
+
hasPrev?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Paginated Result Interface
|
|
24
|
+
*/
|
|
25
|
+
export interface PaginatedResult<T = any> extends Result<T[]> {
|
|
26
|
+
pagination?: Pagination;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Audit Trail Interface
|
|
30
|
+
*/
|
|
31
|
+
export interface AuditTrail {
|
|
32
|
+
operation: string;
|
|
33
|
+
timestamp: number;
|
|
34
|
+
duration?: number;
|
|
35
|
+
success: boolean;
|
|
36
|
+
error?: string;
|
|
37
|
+
metadata?: Record<string, any>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Debug Information Interface
|
|
41
|
+
*/
|
|
42
|
+
export interface DebugInfo {
|
|
43
|
+
logs: string[];
|
|
44
|
+
metrics?: {
|
|
45
|
+
startTime: number;
|
|
46
|
+
endTime: number;
|
|
47
|
+
duration: number;
|
|
48
|
+
};
|
|
49
|
+
networkCalls?: {
|
|
50
|
+
url: string;
|
|
51
|
+
method: string;
|
|
52
|
+
duration: number;
|
|
53
|
+
success: boolean;
|
|
54
|
+
}[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Retry Configuration Interface
|
|
58
|
+
*/
|
|
59
|
+
export interface RetryConfig {
|
|
60
|
+
maxAttempts: number;
|
|
61
|
+
delay: number;
|
|
62
|
+
backoffMultiplier?: number;
|
|
63
|
+
maxDelay?: number;
|
|
64
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diamond Hands SDK Interfaces
|
|
3
|
+
* All TypeScript interfaces and types used in the SDK package
|
|
4
|
+
*
|
|
5
|
+
* Following the golden source pattern with organized chunks
|
|
6
|
+
*/
|
|
7
|
+
export * from "./chunks/config.i";
|
|
8
|
+
export * from "./chunks/loan-operations.i";
|
|
9
|
+
export * from "./chunks/pkp-integration.i";
|
|
10
|
+
export * from "./chunks/contract-interactions.i";
|
|
11
|
+
export * from "./chunks/utility.i";
|
|
12
|
+
export * from "./chunks/btc.i";
|
|
13
|
+
export * from "./chunks/lit-actions.i";
|
|
14
|
+
export * from "./chunks/ucd-minting.i";
|
|
15
|
+
export * from "./chunks/requests.i";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Diamond Hands SDK Interfaces
|
|
4
|
+
* All TypeScript interfaces and types used in the SDK package
|
|
5
|
+
*
|
|
6
|
+
* Following the golden source pattern with organized chunks
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
// Configuration Types
|
|
24
|
+
__exportStar(require("./chunks/config.i"), exports);
|
|
25
|
+
// Loan Operation Types
|
|
26
|
+
__exportStar(require("./chunks/loan-operations.i"), exports);
|
|
27
|
+
// PKP Integration Types
|
|
28
|
+
__exportStar(require("./chunks/pkp-integration.i"), exports);
|
|
29
|
+
// Contract Interaction Types
|
|
30
|
+
__exportStar(require("./chunks/contract-interactions.i"), exports);
|
|
31
|
+
// Utility Types
|
|
32
|
+
__exportStar(require("./chunks/utility.i"), exports);
|
|
33
|
+
// Bitcoin Types
|
|
34
|
+
__exportStar(require("./chunks/btc.i"), exports);
|
|
35
|
+
// LIT Action Types (for compatibility with lit-ops)
|
|
36
|
+
__exportStar(require("./chunks/lit-actions.i"), exports);
|
|
37
|
+
// UCD Minting Types
|
|
38
|
+
__exportStar(require("./chunks/ucd-minting.i"), exports);
|
|
39
|
+
// Request/Response Types
|
|
40
|
+
__exportStar(require("./chunks/requests.i"), exports);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract Interaction Manager Module
|
|
3
|
+
* Handles all smart contract interactions for Diamond Hands Protocol
|
|
4
|
+
*/
|
|
5
|
+
import { ethers as ethers5 } from "ethers";
|
|
6
|
+
/**
|
|
7
|
+
* Contract Transaction Result Interface
|
|
8
|
+
*/
|
|
9
|
+
export interface ContractTransactionResult {
|
|
10
|
+
success: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
transactionHash?: string;
|
|
13
|
+
receipt?: ethers5.providers.TransactionReceipt;
|
|
14
|
+
gasUsed?: string;
|
|
15
|
+
events?: any[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Position Details Interface
|
|
19
|
+
*/
|
|
20
|
+
export interface PositionDetails {
|
|
21
|
+
positionId: string;
|
|
22
|
+
pkpId: string;
|
|
23
|
+
borrower: string;
|
|
24
|
+
btcAmount: string;
|
|
25
|
+
ucdDebt: string;
|
|
26
|
+
createdAt: number;
|
|
27
|
+
lastUpdated: number;
|
|
28
|
+
isActive: boolean;
|
|
29
|
+
collateralRatio: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Contract Call Options Interface
|
|
33
|
+
*/
|
|
34
|
+
export interface ContractCallOptions {
|
|
35
|
+
gasLimit?: number;
|
|
36
|
+
gasPrice?: string;
|
|
37
|
+
value?: string;
|
|
38
|
+
timeout?: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for Contract Interaction Manager
|
|
42
|
+
*/
|
|
43
|
+
export interface ContractManagerConfig {
|
|
44
|
+
provider: ethers5.providers.JsonRpcProvider;
|
|
45
|
+
contractAddresses: {
|
|
46
|
+
positionManager: string;
|
|
47
|
+
ucdToken: string;
|
|
48
|
+
litActionValidator: string;
|
|
49
|
+
priceFeedConsumer: string;
|
|
50
|
+
};
|
|
51
|
+
debug?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Contract Interaction Manager Class
|
|
55
|
+
* Manages all smart contract interactions
|
|
56
|
+
*/
|
|
57
|
+
export declare class ContractInteractionManager {
|
|
58
|
+
private config;
|
|
59
|
+
private positionManagerContract;
|
|
60
|
+
private initialized;
|
|
61
|
+
constructor(config: ContractManagerConfig);
|
|
62
|
+
/**
|
|
63
|
+
* Initialize the contract manager
|
|
64
|
+
*/
|
|
65
|
+
initialize(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Create position in smart contract
|
|
68
|
+
*/
|
|
69
|
+
createPosition(pkpId: string, amount: string, validatorSignature: string, signer: ethers5.Wallet, options?: ContractCallOptions): Promise<ContractTransactionResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Get position details
|
|
72
|
+
*/
|
|
73
|
+
getPositionDetails(positionId: string): Promise<PositionDetails | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Get Position Manager contract instance
|
|
76
|
+
*/
|
|
77
|
+
getPositionManagerContract(): ethers5.Contract;
|
|
78
|
+
/**
|
|
79
|
+
* Cleanup manager resources
|
|
80
|
+
*/
|
|
81
|
+
destroy(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Verify contracts are deployed
|
|
84
|
+
*/
|
|
85
|
+
private _verifyContracts;
|
|
86
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Contract Interaction Manager Module
|
|
4
|
+
* Handles all smart contract interactions for Diamond Hands Protocol
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ContractInteractionManager = void 0;
|
|
8
|
+
const ethers_1 = require("ethers");
|
|
9
|
+
const contract_abis_1 = require("../constants/chunks/contract-abis");
|
|
10
|
+
/**
|
|
11
|
+
* Contract Interaction Manager Class
|
|
12
|
+
* Manages all smart contract interactions
|
|
13
|
+
*/
|
|
14
|
+
class ContractInteractionManager {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.initialized = false;
|
|
17
|
+
this.config = config;
|
|
18
|
+
// Initialize Position Manager contract
|
|
19
|
+
this.positionManagerContract = new ethers_1.ethers.Contract(config.contractAddresses.positionManager, contract_abis_1.POSITION_MANAGER_ABI, config.provider);
|
|
20
|
+
if (this.config.debug) {
|
|
21
|
+
console.log("🔗 Contract Interaction Manager initialized");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the contract manager
|
|
26
|
+
*/
|
|
27
|
+
async initialize() {
|
|
28
|
+
if (this.initialized)
|
|
29
|
+
return;
|
|
30
|
+
if (this.config.debug) {
|
|
31
|
+
console.log("🚀 Initializing Contract Interaction Manager...");
|
|
32
|
+
}
|
|
33
|
+
// Verify contracts are deployed
|
|
34
|
+
await this._verifyContracts();
|
|
35
|
+
this.initialized = true;
|
|
36
|
+
if (this.config.debug) {
|
|
37
|
+
console.log("✅ Contract Interaction Manager initialized");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create position in smart contract
|
|
42
|
+
*/
|
|
43
|
+
async createPosition(pkpId, amount, validatorSignature, signer, options = {}) {
|
|
44
|
+
try {
|
|
45
|
+
if (this.config.debug) {
|
|
46
|
+
console.log("📝 Creating position in smart contract");
|
|
47
|
+
console.log(` PKP ID: ${pkpId}`);
|
|
48
|
+
console.log(` Amount: ${amount}`);
|
|
49
|
+
}
|
|
50
|
+
const contract = this.positionManagerContract.connect(signer);
|
|
51
|
+
// Convert PKP ID to bytes32 (ethers v5 compatible)
|
|
52
|
+
const pkpIdBytes32 = ethers_1.ethers.utils.hexZeroPad(pkpId, 32);
|
|
53
|
+
const tx = await contract.createPosition(pkpIdBytes32, amount, validatorSignature, {
|
|
54
|
+
gasLimit: options.gasLimit,
|
|
55
|
+
gasPrice: options.gasPrice,
|
|
56
|
+
value: options.value,
|
|
57
|
+
});
|
|
58
|
+
const receipt = await tx.wait();
|
|
59
|
+
if (this.config.debug) {
|
|
60
|
+
console.log("✅ Position created successfully");
|
|
61
|
+
console.log(` Transaction Hash: ${receipt.hash}`);
|
|
62
|
+
console.log(` Gas Used: ${receipt.gasUsed?.toString()}`);
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
66
|
+
transactionHash: receipt.hash,
|
|
67
|
+
receipt: receipt,
|
|
68
|
+
gasUsed: receipt.gasUsed?.toString(),
|
|
69
|
+
events: receipt.logs,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
74
|
+
if (this.config.debug) {
|
|
75
|
+
console.error("❌ Position creation failed:", errorMessage);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
success: false,
|
|
79
|
+
error: errorMessage,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get position details
|
|
85
|
+
*/
|
|
86
|
+
async getPositionDetails(positionId) {
|
|
87
|
+
try {
|
|
88
|
+
const position = await this.positionManagerContract.getPositionDetails(positionId);
|
|
89
|
+
return {
|
|
90
|
+
positionId: position.positionId,
|
|
91
|
+
pkpId: position.pkpId,
|
|
92
|
+
borrower: position.borrower,
|
|
93
|
+
btcAmount: position.btcAmount.toString(),
|
|
94
|
+
ucdDebt: position.ucdDebt.toString(),
|
|
95
|
+
createdAt: position.createdAt.toNumber(),
|
|
96
|
+
lastUpdated: position.lastUpdated.toNumber(),
|
|
97
|
+
isActive: position.isActive,
|
|
98
|
+
collateralRatio: position.collateralRatio.toString(),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (this.config.debug) {
|
|
103
|
+
console.error("Failed to get position details:", error);
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get Position Manager contract instance
|
|
110
|
+
*/
|
|
111
|
+
getPositionManagerContract() {
|
|
112
|
+
return this.positionManagerContract;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Cleanup manager resources
|
|
116
|
+
*/
|
|
117
|
+
async destroy() {
|
|
118
|
+
this.initialized = false;
|
|
119
|
+
if (this.config.debug) {
|
|
120
|
+
console.log("🧹 Contract Interaction Manager cleanup complete");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Verify contracts are deployed
|
|
125
|
+
*/
|
|
126
|
+
async _verifyContracts() {
|
|
127
|
+
const positionManagerCode = await this.config.provider.getCode(this.config.contractAddresses.positionManager);
|
|
128
|
+
if (positionManagerCode === "0x") {
|
|
129
|
+
throw new Error("Position Manager contract not found at specified address");
|
|
130
|
+
}
|
|
131
|
+
if (this.config.debug) {
|
|
132
|
+
console.log("✅ All contracts verified and accessible");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.ContractInteractionManager = ContractInteractionManager;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { CreateLoanRequest, CreateLoanResult, DiamondHandsSDKConfig, LiquidationRequest, LoanData, LoansQuery, UCDMintRequest } from "../interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Core Diamond Hands SDK Module
|
|
4
|
+
*
|
|
5
|
+
* This is the main SDK class that provides a high-level interface for Diamond Hands Protocol operations.
|
|
6
|
+
* It supports two operation modes:
|
|
7
|
+
* - Standalone: User provides signer and network, SDK creates PKPs directly via LIT Protocol
|
|
8
|
+
* - Service: SDK calls lit-ops-server backend which handles LIT Protocol operations
|
|
9
|
+
*
|
|
10
|
+
* Default behavior (if mode not specified):
|
|
11
|
+
* - Mode: "service"
|
|
12
|
+
* - Service endpoint: "http://localhost:3001"
|
|
13
|
+
*/
|
|
14
|
+
export declare class DiamondHandsSDK {
|
|
15
|
+
private litOps;
|
|
16
|
+
private config;
|
|
17
|
+
private provider;
|
|
18
|
+
private initialized;
|
|
19
|
+
private mode;
|
|
20
|
+
private serviceEndpoint;
|
|
21
|
+
constructor(config: DiamondHandsSDKConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Validate configuration based on the selected mode
|
|
24
|
+
*/
|
|
25
|
+
private validateConfig;
|
|
26
|
+
/**
|
|
27
|
+
* Initialize the SDK with required dependencies
|
|
28
|
+
*/
|
|
29
|
+
initialize(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a new Diamond Hands loan by:
|
|
32
|
+
* 1. Creating and validating a PKP (via standalone LitOps or service endpoint)
|
|
33
|
+
* 2. Extracting the validator signature from PKP creation result
|
|
34
|
+
* 3. Funding the contract wallet if needed
|
|
35
|
+
* 4. Calling the smart contract createPosition method with PKP validator signature
|
|
36
|
+
*/
|
|
37
|
+
createLoan(request: CreateLoanRequest): Promise<CreateLoanResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Create loan in standalone mode - uses LitOps directly
|
|
40
|
+
*/
|
|
41
|
+
private createLoanStandalone;
|
|
42
|
+
/**
|
|
43
|
+
* Create loan in service mode - calls lit-ops-server
|
|
44
|
+
*/
|
|
45
|
+
private createLoanService;
|
|
46
|
+
/**
|
|
47
|
+
* Setup contract wallet for Ethereum transactions
|
|
48
|
+
*/
|
|
49
|
+
private setupContractWallet;
|
|
50
|
+
/**
|
|
51
|
+
* Create PKP with retry logic for LIT Protocol network issues
|
|
52
|
+
*/
|
|
53
|
+
private createPKPWithRetry;
|
|
54
|
+
/**
|
|
55
|
+
* Process loan creation after PKP is created - handle signature extraction and contract calls
|
|
56
|
+
*/
|
|
57
|
+
private processLoanCreation;
|
|
58
|
+
/**
|
|
59
|
+
* Get single loan by vault address
|
|
60
|
+
*/
|
|
61
|
+
getLoan(vaultAddress: string): Promise<LoanData | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Get loans by various criteria
|
|
64
|
+
*/
|
|
65
|
+
getLoans(query: LoansQuery): Promise<LoanData[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Get all positions for a user
|
|
68
|
+
*/
|
|
69
|
+
getUserPositions(userAddress: string): Promise<LoanData[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Get position details by PKP ID
|
|
72
|
+
*/
|
|
73
|
+
getPositionByPKP(pkpId: string): Promise<LoanData | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Get PKP loan parameters (amount, collateral ratio, term) directly by PKP ID
|
|
76
|
+
* This uses the optimized storage for quick access to core loan parameters
|
|
77
|
+
*/
|
|
78
|
+
getPKPLoanParams(pkpId: string): Promise<{
|
|
79
|
+
amount: number;
|
|
80
|
+
requestedCollateralRatio: number;
|
|
81
|
+
selectedTerm: number;
|
|
82
|
+
} | null>;
|
|
83
|
+
/**
|
|
84
|
+
* Get complete PKP position data by PKP ID
|
|
85
|
+
* This provides all stored PKP position information in one call
|
|
86
|
+
*/
|
|
87
|
+
getPKPPositionData(pkpId: string): Promise<{
|
|
88
|
+
positionId: string;
|
|
89
|
+
borrower: string;
|
|
90
|
+
amount: number;
|
|
91
|
+
requestedCollateralRatio: number;
|
|
92
|
+
selectedTerm: number;
|
|
93
|
+
createdAt: number;
|
|
94
|
+
isActive: boolean;
|
|
95
|
+
} | null>;
|
|
96
|
+
/**
|
|
97
|
+
* Request UCD minting for a loan
|
|
98
|
+
*/
|
|
99
|
+
requestMintUCD(request: UCDMintRequest): Promise<boolean>;
|
|
100
|
+
/**
|
|
101
|
+
* Request loan liquidation
|
|
102
|
+
*/
|
|
103
|
+
requestLiquidation(request: LiquidationRequest): Promise<boolean>;
|
|
104
|
+
/**
|
|
105
|
+
* Cleanup SDK resources
|
|
106
|
+
*/
|
|
107
|
+
destroy(): Promise<void>;
|
|
108
|
+
private ensureInitialized;
|
|
109
|
+
}
|