@gvnrdao/dh-lit-actions 0.0.112 → 0.0.192
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-liquidation-validator.action.js +1 -0
- package/dist/admin-liquidation-validator.hash +1 -0
- package/dist/admin-liquidation-validator.meta.json +9 -0
- package/dist/always-signer.action.js +1 -0
- package/dist/always-signer.hash +1 -0
- package/dist/always-signer.meta.json +9 -0
- package/dist/authorization-dummy-b.action.js +1 -0
- package/dist/authorization-dummy-b.hash +1 -0
- package/dist/authorization-dummy-b.meta.json +9 -0
- package/dist/authorization-dummy.action.js +1 -0
- package/dist/authorization-dummy.hash +1 -0
- package/dist/authorization-dummy.meta.json +9 -0
- package/dist/btc-transaction-signer.action.js +1 -0
- package/dist/btc-transaction-signer.hash +1 -0
- package/dist/btc-transaction-signer.meta.json +9 -0
- package/dist/btc-withdrawal.action.js +1 -0
- package/dist/btc-withdrawal.hash +1 -0
- package/dist/btc-withdrawal.meta.json +9 -0
- package/dist/extend-position-validator.action.js +1 -0
- package/dist/extend-position-validator.hash +1 -0
- package/dist/extend-position-validator.meta.json +9 -0
- package/dist/liquidation-validator.action.js +1 -0
- package/dist/liquidation-validator.hash +1 -0
- package/dist/liquidation-validator.meta.json +9 -0
- package/dist/loan-vault-btc-balance.action.js +1 -0
- package/dist/loan-vault-btc-balance.hash +1 -0
- package/dist/loan-vault-btc-balance.meta.json +9 -0
- package/dist/pkp-validator-datil.action.js +1 -0
- package/dist/pkp-validator-datil.hash +1 -0
- package/dist/pkp-validator-datil.meta.json +9 -0
- package/dist/price-oracle.action.js +1 -0
- package/dist/price-oracle.hash +1 -0
- package/dist/price-oracle.meta.json +9 -0
- package/dist/process-payment-sign-only.action.js +1 -0
- package/dist/process-payment-sign-only.hash +1 -0
- package/dist/process-payment-sign-only.meta.json +9 -0
- package/dist/process-payment-validator.action.js +1 -0
- package/dist/process-payment-validator.hash +1 -0
- package/dist/process-payment-validator.meta.json +9 -0
- package/dist/ucd-mint-validator.action.js +1 -0
- package/dist/ucd-mint-validator.hash +1 -0
- package/dist/ucd-mint-validator.meta.json +9 -0
- package/package.json +4 -2
- package/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.d.ts.map +1 -1
- package/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js +127 -108
- package/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.js.map +1 -1
- package/pkg-dist/pkg-src/executors/chunks/price-oracle-executor.d.ts +47 -0
- package/pkg-dist/pkg-src/executors/chunks/price-oracle-executor.d.ts.map +1 -0
- package/pkg-dist/pkg-src/executors/chunks/price-oracle-executor.js +77 -0
- package/pkg-dist/pkg-src/executors/chunks/price-oracle-executor.js.map +1 -0
- package/pkg-dist/pkg-src/executors/index.d.ts +39 -0
- package/pkg-dist/pkg-src/executors/index.d.ts.map +1 -1
- package/pkg-dist/pkg-src/executors/index.js +41 -1
- package/pkg-dist/pkg-src/executors/index.js.map +1 -1
- package/pkg-dist/pkg-src/utils/chunks/cid-utils.d.ts.map +1 -1
- package/pkg-dist/pkg-src/utils/chunks/cid-utils.js +0 -5
- package/pkg-dist/pkg-src/utils/chunks/cid-utils.js.map +1 -1
- package/pkg-dist/src/constants/chunks/quantum-time.d.ts +5 -5
- package/pkg-dist/src/constants/chunks/quantum-time.js +5 -5
- package/pkg-dist/src/interfaces/chunks/vault-balance.i.d.ts +0 -1
- package/pkg-dist/src/interfaces/chunks/vault-balance.i.d.ts.map +1 -1
- package/pkg-dist/src/modules/bitcoin-data-provider.module.d.ts +7 -6
- package/pkg-dist/src/modules/bitcoin-data-provider.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/bitcoin-data-provider.module.js +93 -97
- package/pkg-dist/src/modules/bitcoin-data-provider.module.js.map +1 -1
- package/pkg-dist/src/modules/business-rules-math.module.d.ts +2 -0
- package/pkg-dist/src/modules/business-rules-math.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/business-rules-math.module.js +9 -2
- package/pkg-dist/src/modules/business-rules-math.module.js.map +1 -1
- package/pkg-dist/src/modules/lit-action-logger.module.d.ts +55 -0
- package/pkg-dist/src/modules/lit-action-logger.module.d.ts.map +1 -0
- package/pkg-dist/src/modules/lit-action-logger.module.js +184 -0
- package/pkg-dist/src/modules/lit-action-logger.module.js.map +1 -0
- package/pkg-dist/src/modules/price-oracle.module.d.ts +41 -3
- package/pkg-dist/src/modules/price-oracle.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/price-oracle.module.js +265 -122
- package/pkg-dist/src/modules/price-oracle.module.js.map +1 -1
- package/pkg-dist/src/modules/protocol-parameters.module.d.ts +10 -0
- package/pkg-dist/src/modules/protocol-parameters.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/protocol-parameters.module.js +49 -2
- package/pkg-dist/src/modules/protocol-parameters.module.js.map +1 -1
- package/pkg-dist/src/modules/quantum-time.module.d.ts +1 -1
- package/pkg-dist/src/modules/quantum-time.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/quantum-time.module.js +18 -9
- package/pkg-dist/src/modules/quantum-time.module.js.map +1 -1
- package/pkg-dist/src/modules/vault-balance.module.d.ts +37 -3
- package/pkg-dist/src/modules/vault-balance.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/vault-balance.module.js +116 -63
- package/pkg-dist/src/modules/vault-balance.module.js.map +1 -1
- package/pkg-dist/src/modules/vault-snapshot.d.ts +5 -3
- package/pkg-dist/src/modules/vault-snapshot.d.ts.map +1 -1
- package/pkg-dist/src/modules/vault-snapshot.js +9 -6
- package/pkg-dist/src/modules/vault-snapshot.js.map +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LIT Action Logger Module
|
|
3
|
+
*
|
|
4
|
+
* Centralized logging and timing infrastructure for LIT Actions.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Opt-in debugging via globalThis.debugAction flag
|
|
8
|
+
* - Execution ID for multi-node correlation
|
|
9
|
+
* - Step timing with automatic elapsed/remaining calculation
|
|
10
|
+
* - Timeout warnings (30s LIT Protocol limit)
|
|
11
|
+
* - Node context detection
|
|
12
|
+
* - Final execution summary
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const logger = LitActionLogger.create();
|
|
17
|
+
* logger.stepStart('1', 'Fetching vault snapshot');
|
|
18
|
+
* // ... do work ...
|
|
19
|
+
* logger.stepEnd('1');
|
|
20
|
+
* logger.summary();
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Debug mode enabled when globalThis.debugAction === true
|
|
24
|
+
*
|
|
25
|
+
* Performance: When disabled (99% of cases), returns a no-op stub that does nothing.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Interface for LIT Action Logger
|
|
29
|
+
*/
|
|
30
|
+
interface ILitActionLogger {
|
|
31
|
+
stepStart(stepId: string, description: string): void;
|
|
32
|
+
stepEnd(stepId: string, warnThresholdMs?: number): void;
|
|
33
|
+
log(stepId: string, message: string): void;
|
|
34
|
+
warn(stepId: string, message: string): void;
|
|
35
|
+
error(stepId: string, message: string): void;
|
|
36
|
+
getElapsed(): number;
|
|
37
|
+
getRemaining(): number;
|
|
38
|
+
summary(): void;
|
|
39
|
+
getExecutionId(): string;
|
|
40
|
+
isDebugEnabled(): boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* LIT Action Logger factory
|
|
44
|
+
*/
|
|
45
|
+
export declare class LitActionLogger {
|
|
46
|
+
/**
|
|
47
|
+
* Create logger instance
|
|
48
|
+
* Returns NoOpLogger when disabled (99% case), DebugLogger when enabled
|
|
49
|
+
* @param actionName - Name of the LIT Action (for logging context)
|
|
50
|
+
* @param debugAction - Optional override for globalThis.debugAction
|
|
51
|
+
*/
|
|
52
|
+
static create(actionName?: string, debugAction?: boolean): ILitActionLogger;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=lit-action-logger.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit-action-logger.module.d.ts","sourceRoot":"","sources":["../../../src/modules/lit-action-logger.module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AA2BH;;GAEG;AACH,UAAU,gBAAgB;IACxB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACrD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxD,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,UAAU,IAAI,MAAM,CAAC;IACrB,YAAY,IAAI,MAAM,CAAC;IACvB,OAAO,IAAI,IAAI,CAAC;IAChB,cAAc,IAAI,MAAM,CAAC;IACzB,cAAc,IAAI,OAAO,CAAC;CAC3B;AAsKD;;GAEG;AACH,qBAAa,eAAe;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CACX,UAAU,GAAE,MAAqB,EACjC,WAAW,CAAC,EAAE,OAAO,GACpB,gBAAgB;CAWpB"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LIT Action Logger Module
|
|
4
|
+
*
|
|
5
|
+
* Centralized logging and timing infrastructure for LIT Actions.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Opt-in debugging via globalThis.debugAction flag
|
|
9
|
+
* - Execution ID for multi-node correlation
|
|
10
|
+
* - Step timing with automatic elapsed/remaining calculation
|
|
11
|
+
* - Timeout warnings (30s LIT Protocol limit)
|
|
12
|
+
* - Node context detection
|
|
13
|
+
* - Final execution summary
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const logger = LitActionLogger.create();
|
|
18
|
+
* logger.stepStart('1', 'Fetching vault snapshot');
|
|
19
|
+
* // ... do work ...
|
|
20
|
+
* logger.stepEnd('1');
|
|
21
|
+
* logger.summary();
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Debug mode enabled when globalThis.debugAction === true
|
|
25
|
+
*
|
|
26
|
+
* Performance: When disabled (99% of cases), returns a no-op stub that does nothing.
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.LitActionLogger = void 0;
|
|
30
|
+
/**
|
|
31
|
+
* No-op logger stub for when debugging is disabled
|
|
32
|
+
* Zero overhead - all methods are empty
|
|
33
|
+
*/
|
|
34
|
+
class NoOpLogger {
|
|
35
|
+
stepStart(_stepId, _description) { }
|
|
36
|
+
stepEnd(_stepId, _warnThresholdMs) { }
|
|
37
|
+
log(_stepId, _message) { }
|
|
38
|
+
warn(_stepId, _message) { }
|
|
39
|
+
error(_stepId, _message) { }
|
|
40
|
+
getElapsed() {
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
getRemaining() {
|
|
44
|
+
return 30000;
|
|
45
|
+
}
|
|
46
|
+
summary() { }
|
|
47
|
+
getExecutionId() {
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
isDebugEnabled() {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Full logger implementation for when debugging is enabled
|
|
56
|
+
*/
|
|
57
|
+
class DebugLogger {
|
|
58
|
+
constructor(actionName) {
|
|
59
|
+
this.stepStartTimes = new Map();
|
|
60
|
+
this.stepDurations = new Map();
|
|
61
|
+
this.TIMEOUT_MS = 30000; // 30 seconds LIT Action timeout
|
|
62
|
+
this.actionName = actionName;
|
|
63
|
+
this.executionStartTime = Date.now();
|
|
64
|
+
// Generate unique execution ID for multi-node correlation
|
|
65
|
+
const timestamp = Date.now();
|
|
66
|
+
const random = Math.random().toString(36).substring(2, 9);
|
|
67
|
+
this.executionId = `exec_${timestamp}_${random}`;
|
|
68
|
+
this.logHeader();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Log action header with execution context
|
|
72
|
+
*/
|
|
73
|
+
logHeader() {
|
|
74
|
+
console.log(`[${this.actionName}] ========================================`);
|
|
75
|
+
console.log(`[${this.actionName}] Execution started`);
|
|
76
|
+
console.log(`[${this.actionName}] Execution ID: ${this.executionId}`);
|
|
77
|
+
// Detect if running in LIT node context vs browser
|
|
78
|
+
const isLitNode = typeof globalThis.litNodeContext !== "undefined";
|
|
79
|
+
if (isLitNode) {
|
|
80
|
+
console.log(`[${this.actionName}] Context: LIT Node`);
|
|
81
|
+
console.log(`[${this.actionName}] Node: ${globalThis.litNodeContext?.nodeAddress || "unknown"}`);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
console.log(`[${this.actionName}] Context: Browser/Test`);
|
|
85
|
+
}
|
|
86
|
+
console.log(`[${this.actionName}] ========================================`);
|
|
87
|
+
}
|
|
88
|
+
stepStart(stepId, description) {
|
|
89
|
+
this.stepStartTimes.set(stepId, Date.now());
|
|
90
|
+
const elapsed = Date.now() - this.executionStartTime;
|
|
91
|
+
const remaining = this.TIMEOUT_MS - elapsed;
|
|
92
|
+
console.log(`[Step ${stepId}] ${description}...`);
|
|
93
|
+
console.log(`[Step ${stepId}] Elapsed: ${elapsed}ms | Remaining: ${remaining}ms`);
|
|
94
|
+
}
|
|
95
|
+
stepEnd(stepId, warnThresholdMs = 5000) {
|
|
96
|
+
const startTime = this.stepStartTimes.get(stepId);
|
|
97
|
+
if (!startTime) {
|
|
98
|
+
console.warn(`[Step ${stepId}] ⚠️ stepEnd called without matching stepStart`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const duration = Date.now() - startTime;
|
|
102
|
+
this.stepDurations.set(stepId, duration);
|
|
103
|
+
console.log(`[Step ${stepId}] Duration: ${duration}ms`);
|
|
104
|
+
// Warn if step took longer than threshold
|
|
105
|
+
if (duration > warnThresholdMs) {
|
|
106
|
+
console.warn(`⚠️ [Step ${stepId}] Took ${duration}ms (> ${warnThresholdMs}ms threshold)`);
|
|
107
|
+
}
|
|
108
|
+
// Warn if approaching timeout
|
|
109
|
+
const elapsed = Date.now() - this.executionStartTime;
|
|
110
|
+
const remaining = this.TIMEOUT_MS - elapsed;
|
|
111
|
+
if (remaining < 5000) {
|
|
112
|
+
console.warn(`⚠️ [Step ${stepId}] Time remaining: ${remaining}ms (approaching timeout)`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
log(stepId, message) {
|
|
116
|
+
console.log(`[Step ${stepId}] ${message}`);
|
|
117
|
+
}
|
|
118
|
+
warn(stepId, message) {
|
|
119
|
+
console.warn(`⚠️ [Step ${stepId}] ${message}`);
|
|
120
|
+
}
|
|
121
|
+
error(stepId, message) {
|
|
122
|
+
console.error(`❌ [Step ${stepId}] ${message}`);
|
|
123
|
+
}
|
|
124
|
+
getElapsed() {
|
|
125
|
+
return Date.now() - this.executionStartTime;
|
|
126
|
+
}
|
|
127
|
+
getRemaining() {
|
|
128
|
+
return this.TIMEOUT_MS - this.getElapsed();
|
|
129
|
+
}
|
|
130
|
+
summary() {
|
|
131
|
+
const totalDuration = Date.now() - this.executionStartTime;
|
|
132
|
+
const remaining = this.TIMEOUT_MS - totalDuration;
|
|
133
|
+
console.log(`[${this.actionName}] ========================================`);
|
|
134
|
+
console.log(`[${this.actionName}] Execution Summary`);
|
|
135
|
+
console.log(`[${this.actionName}] Execution ID: ${this.executionId}`);
|
|
136
|
+
console.log(`[${this.actionName}] Total time: ${(totalDuration / 1000).toFixed(2)}s`);
|
|
137
|
+
console.log(`[${this.actionName}] Time remaining: ${remaining}ms`);
|
|
138
|
+
// Log step timing breakdown
|
|
139
|
+
if (this.stepDurations.size > 0) {
|
|
140
|
+
console.log(`[${this.actionName}] Step breakdown:`);
|
|
141
|
+
for (const [stepId, duration] of this.stepDurations.entries()) {
|
|
142
|
+
const percent = ((duration / totalDuration) * 100).toFixed(1);
|
|
143
|
+
console.log(`[${this.actionName}] Step ${stepId}: ${duration}ms (${percent}%)`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Warnings for slow execution
|
|
147
|
+
if (totalDuration > 20000) {
|
|
148
|
+
console.warn(`⚠️ [${this.actionName}] Slow execution: ${(totalDuration / 1000).toFixed(2)}s (${remaining}ms remaining)`);
|
|
149
|
+
}
|
|
150
|
+
if (remaining < 5000) {
|
|
151
|
+
console.warn(`⚠️ [${this.actionName}] CRITICAL: Only ${remaining}ms remaining before timeout!`);
|
|
152
|
+
}
|
|
153
|
+
console.log(`[${this.actionName}] ========================================`);
|
|
154
|
+
}
|
|
155
|
+
getExecutionId() {
|
|
156
|
+
return this.executionId;
|
|
157
|
+
}
|
|
158
|
+
isDebugEnabled() {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* LIT Action Logger factory
|
|
164
|
+
*/
|
|
165
|
+
class LitActionLogger {
|
|
166
|
+
/**
|
|
167
|
+
* Create logger instance
|
|
168
|
+
* Returns NoOpLogger when disabled (99% case), DebugLogger when enabled
|
|
169
|
+
* @param actionName - Name of the LIT Action (for logging context)
|
|
170
|
+
* @param debugAction - Optional override for globalThis.debugAction
|
|
171
|
+
*/
|
|
172
|
+
static create(actionName = "LIT Action", debugAction) {
|
|
173
|
+
const debugEnabled = debugAction ?? globalThis.debugAction ?? false;
|
|
174
|
+
if (debugEnabled) {
|
|
175
|
+
return new DebugLogger(actionName);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
// Return lightweight no-op stub - zero overhead for 99% of executions
|
|
179
|
+
return new NoOpLogger();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.LitActionLogger = LitActionLogger;
|
|
184
|
+
//# sourceMappingURL=lit-action-logger.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit-action-logger.module.js","sourceRoot":"","sources":["../../../src/modules/lit-action-logger.module.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAEH;;;GAGG;AACH,MAAM,UAAU;IACd,SAAS,CAAC,OAAe,EAAE,YAAoB,IAAS,CAAC;IACzD,OAAO,CAAC,OAAe,EAAE,gBAAyB,IAAS,CAAC;IAC5D,GAAG,CAAC,OAAe,EAAE,QAAgB,IAAS,CAAC;IAC/C,IAAI,CAAC,OAAe,EAAE,QAAgB,IAAS,CAAC;IAChD,KAAK,CAAC,OAAe,EAAE,QAAgB,IAAS,CAAC;IACjD,UAAU;QACR,OAAO,CAAC,CAAC;IACX,CAAC;IACD,YAAY;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,KAAU,CAAC;IAClB,cAAc;QACZ,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,cAAc;QACZ,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAkBD;;GAEG;AACH,MAAM,WAAW;IAQf,YAAY,UAAkB;QALtB,mBAAc,GAAwB,IAAI,GAAG,EAAE,CAAC;QAChD,kBAAa,GAAwB,IAAI,GAAG,EAAE,CAAC;QACtC,eAAU,GAAG,KAAK,CAAC,CAAC,gCAAgC;QAInE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAErC,0DAA0D;QAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,C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interfaces/chunks/price-oracle.i";
|
|
2
2
|
export declare class PriceOracleModule implements IPriceOracle {
|
|
3
3
|
private sources;
|
|
4
|
+
private mode?;
|
|
4
5
|
constructor(priceProvidersOrConfig?: Array<{
|
|
5
6
|
name: string;
|
|
6
7
|
apiKey?: string;
|
|
7
|
-
|
|
8
|
+
apiSecret?: string;
|
|
9
|
+
}> | any, legacySources?: PriceSourceConfig[], mode?: "dev" | "prod");
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
11
|
+
* Validate provider count based on mode
|
|
12
|
+
* - Production: Requires at least 3 providers for consensus
|
|
13
|
+
* - Development: Allows as few as 1 provider for testing
|
|
14
|
+
*/
|
|
15
|
+
private validateProviderCount;
|
|
16
|
+
/**
|
|
17
|
+
* Build price sources from config
|
|
18
|
+
* All providers are treated equally - no special priority for any provider
|
|
10
19
|
*/
|
|
11
20
|
private buildSources;
|
|
12
21
|
/**
|
|
13
22
|
* Create CryptoCompare price source
|
|
23
|
+
* Requires API key for access
|
|
14
24
|
*/
|
|
15
25
|
private createCryptoCompareSource;
|
|
26
|
+
/**
|
|
27
|
+
* Create shared fetch helper with timeout
|
|
28
|
+
* LIT runtime rejects custom User-Agent headers
|
|
29
|
+
*/
|
|
30
|
+
private createFetchJson;
|
|
31
|
+
/**
|
|
32
|
+
* Get default free providers (no API keys required)
|
|
33
|
+
*/
|
|
16
34
|
private getDefaultSources;
|
|
35
|
+
/**
|
|
36
|
+
* Create CoinGecko price source
|
|
37
|
+
*/
|
|
38
|
+
private createCoinGeckoSource;
|
|
39
|
+
/**
|
|
40
|
+
* Create Binance price source
|
|
41
|
+
*/
|
|
42
|
+
private createBinanceSource;
|
|
43
|
+
/**
|
|
44
|
+
* Create Coinbase price source
|
|
45
|
+
*/
|
|
46
|
+
private createCoinbaseSource;
|
|
17
47
|
/**
|
|
18
48
|
* Get BTC price in USD with 8 decimals
|
|
19
|
-
*
|
|
49
|
+
*
|
|
50
|
+
* CRITICAL OPTIMIZATION: Queries all sources in parallel with Promise.race()
|
|
51
|
+
* This prevents timeout when multiple sources fail sequentially.
|
|
52
|
+
*
|
|
53
|
+
* Master's Wisdom: "The fastest path to truth is asking all at once"
|
|
54
|
+
* - All sources queried simultaneously
|
|
55
|
+
* - First successful response wins
|
|
56
|
+
* - No waiting for slow/failed providers
|
|
57
|
+
* - Total time = fastest provider, not sum of all attempts
|
|
20
58
|
*/
|
|
21
59
|
getBTCPrice(): Promise<bigint>;
|
|
22
60
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price-oracle.module.d.ts","sourceRoot":"","sources":["../../../src/modules/price-oracle.module.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,iBAAiB,EAClB,MAAM,qCAAqC,CAAC;AAM7C,qBAAa,iBAAkB,YAAW,YAAY;IACpD,OAAO,CAAC,OAAO,CAAsB;
|
|
1
|
+
{"version":3,"file":"price-oracle.module.d.ts","sourceRoot":"","sources":["../../../src/modules/price-oracle.module.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,iBAAiB,EAClB,MAAM,qCAAqC,CAAC;AAM7C,qBAAa,iBAAkB,YAAW,YAAY;IACpD,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,IAAI,CAAC,CAAiB;gBAG5B,sBAAsB,CAAC,EACnB,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAC5D,GAAG,EACP,aAAa,CAAC,EAAE,iBAAiB,EAAE,EACnC,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM;IAuBvB;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAgB7B;;;OAGG;IACH,OAAO,CAAC,YAAY;IAwDpB;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IA6DjC;;;OAGG;IACH,OAAO,CAAC,eAAe;IAoBvB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA+B7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAoC3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAiC5B;;;;;;;;;;;OAWG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IA+JpC;;;;;;;;;;;;;;;OAeG;IACG,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CA+G9C"}
|