@steerprotocol/data-connector-loader 5.0.0-next.6 → 5.0.0-next.7
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 +14 -0
- package/lib/esm/execution/executionApp.d.ts +6 -4
- package/lib/esm/execution/executionApp.js +15 -4
- package/lib/esm/execution/executionBase.d.ts +1 -1
- package/lib/execution/executionApp.d.ts +6 -4
- package/lib/execution/executionApp.js +15 -4
- package/lib/execution/executionBase.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,6 +48,20 @@ a fresh temporary directory while reusing npm's download cache.
|
|
|
48
48
|
## Block-pinned strategy execution (recommended)
|
|
49
49
|
|
|
50
50
|
Supply a resolved `SmartPoolExecutionContext` to `ExecutionApp.executeWithContext`.
|
|
51
|
+
Strategy entrypoints return the exact string `"continue"` when no action is needed,
|
|
52
|
+
or the decoded JSON result. Their generic `T` describes the complete JSON result
|
|
53
|
+
(an action object or array), and the return type is `Promise<T | "continue">`.
|
|
54
|
+
All other non-JSON output is rejected as `StrategyExecutionError`.
|
|
55
|
+
|
|
56
|
+
The offline `strategyWasm.integration.test.ts` suite runs retained Liquid Arc and
|
|
57
|
+
Static Stable binaries through the loader, covering both `continue` and JSON
|
|
58
|
+
actions with supplied contexts. It checks binary hashes and runs with `npm test`
|
|
59
|
+
in CI. To run just these cases:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
npm test -- --runInBand strategyWasm.integration.test.ts
|
|
63
|
+
```
|
|
64
|
+
|
|
51
65
|
For connectors, pass an `ExecutionContext` to `DataConnectorExecution.executeWithContext`.
|
|
52
66
|
`SmartPoolExecutionContext` extends `ExecutionContext`, so the same resolved
|
|
53
67
|
context can be used for both. Both contexts include the chain ID for comparison
|
|
@@ -41,18 +41,20 @@ export declare class ExecutionApp extends ExecutionBase {
|
|
|
41
41
|
sentioApiKey: string;
|
|
42
42
|
config: ExecutionAppConfig;
|
|
43
43
|
constructor(config: ExecutionAppConfig);
|
|
44
|
-
execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<
|
|
44
|
+
execute<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
|
|
45
45
|
/**
|
|
46
46
|
* Executes a strategy against a supplied execution context.
|
|
47
47
|
* This is the recommended API for new consumers. It intentionally bypasses
|
|
48
48
|
* all legacy vault, pool, subgraph, clock, and block-estimation reads.
|
|
49
49
|
*/
|
|
50
|
-
executeWithContext<T>(options: ExecuteWithContextOptions): Promise<
|
|
50
|
+
executeWithContext<T = unknown>(options: ExecuteWithContextOptions): Promise<T | "continue">;
|
|
51
|
+
/** T is the complete decoded JSON result. Only the exact sentinel skips JSON decoding. */
|
|
52
|
+
private parseStrategyResult;
|
|
51
53
|
private parseVaultConfig;
|
|
52
54
|
private validateExecutionContext;
|
|
53
55
|
private redactError;
|
|
54
|
-
executeStabilityVault<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<
|
|
55
|
-
executeDynamicJobs<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, _job: JobDetails, rpc?: RpcAccess, forceDeposit?: boolean): Promise<
|
|
56
|
+
executeStabilityVault<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
|
|
57
|
+
executeDynamicJobs<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, _job: JobDetails, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
|
|
56
58
|
private getSmartPoolExecutionContext;
|
|
57
59
|
private getPoolCurrentTick;
|
|
58
60
|
private getTickSpacing;
|
|
@@ -484,7 +484,7 @@ export class ExecutionApp extends ExecutionBase {
|
|
|
484
484
|
}, forceDeposit);
|
|
485
485
|
_data = _data.map((element) => JSON.stringify(element));
|
|
486
486
|
const result = await dataConnector.executeBundle(_data);
|
|
487
|
-
return
|
|
487
|
+
return this.parseStrategyResult(result);
|
|
488
488
|
}
|
|
489
489
|
/**
|
|
490
490
|
* Executes a strategy against a supplied execution context.
|
|
@@ -509,7 +509,7 @@ export class ExecutionApp extends ExecutionBase {
|
|
|
509
509
|
await dataConnector.loadSync();
|
|
510
510
|
dataConnector.initializeStrategyWithContext(executionContext, options.forceDeposit);
|
|
511
511
|
const result = await dataConnector.executeBundle(options.data.map((item) => JSON.stringify(item)));
|
|
512
|
-
return
|
|
512
|
+
return this.parseStrategyResult(result);
|
|
513
513
|
}
|
|
514
514
|
catch (error) {
|
|
515
515
|
if (error instanceof ExecutionContextError)
|
|
@@ -517,6 +517,17 @@ export class ExecutionApp extends ExecutionBase {
|
|
|
517
517
|
throw new StrategyExecutionError(this.redactError(error));
|
|
518
518
|
}
|
|
519
519
|
}
|
|
520
|
+
/** T is the complete decoded JSON result. Only the exact sentinel skips JSON decoding. */
|
|
521
|
+
parseStrategyResult(result) {
|
|
522
|
+
if (result === "continue")
|
|
523
|
+
return result;
|
|
524
|
+
try {
|
|
525
|
+
return JSON.parse(result);
|
|
526
|
+
}
|
|
527
|
+
catch (error) {
|
|
528
|
+
throw new StrategyExecutionError(this.redactError(error));
|
|
529
|
+
}
|
|
530
|
+
}
|
|
520
531
|
parseVaultConfig(vaultConfig) {
|
|
521
532
|
try {
|
|
522
533
|
return JSON.parse(vaultConfig);
|
|
@@ -601,7 +612,7 @@ export class ExecutionApp extends ExecutionBase {
|
|
|
601
612
|
}, forceDeposit);
|
|
602
613
|
_data = _data.map((element) => JSON.stringify(element));
|
|
603
614
|
const result = await dataConnector.executeDynamicJobBundle(_data);
|
|
604
|
-
return
|
|
615
|
+
return this.parseStrategyResult(result);
|
|
605
616
|
}
|
|
606
617
|
async executeDynamicJobs(_wasmFile, _vaultConfig, _data, _job, rpc, forceDeposit) {
|
|
607
618
|
const dataConnector = new DataConnector({
|
|
@@ -625,7 +636,7 @@ export class ExecutionApp extends ExecutionBase {
|
|
|
625
636
|
}, forceDeposit);
|
|
626
637
|
_data = _data.map((element) => JSON.stringify(element));
|
|
627
638
|
const result = await dataConnector.executeDynamicJobBundle(_data);
|
|
628
|
-
return
|
|
639
|
+
return this.parseStrategyResult(result);
|
|
629
640
|
}
|
|
630
641
|
async getSmartPoolExecutionContext(currentExecutionContext, dataConnector, vaultConfig) {
|
|
631
642
|
const smartPoolExecutionContext = {};
|
|
@@ -7,7 +7,7 @@ export declare class ExecutionBase {
|
|
|
7
7
|
protected delay(ms: number): Promise<void>;
|
|
8
8
|
protected log(...args: Array<any>): void;
|
|
9
9
|
protected getExecutionContext(dataConnector: DataConnector, vaultConfig: VaultConfigPayload): Promise<ExecutionContext>;
|
|
10
|
-
execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess): Promise<Array<T
|
|
10
|
+
execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess): Promise<T | Array<T> | "continue">;
|
|
11
11
|
protected getDataConnectorVersion(dataConnector: DataConnector): Promise<number>;
|
|
12
12
|
getAverageBlockTime(provider: PublicClient, blockCount?: number): Promise<number>;
|
|
13
13
|
getBlockNumberFromAvgBlockTime(provider: PublicClient, targetTimestamp: number, avgBlockTime: number): Promise<number>;
|
|
@@ -41,18 +41,20 @@ export declare class ExecutionApp extends ExecutionBase {
|
|
|
41
41
|
sentioApiKey: string;
|
|
42
42
|
config: ExecutionAppConfig;
|
|
43
43
|
constructor(config: ExecutionAppConfig);
|
|
44
|
-
execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<
|
|
44
|
+
execute<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
|
|
45
45
|
/**
|
|
46
46
|
* Executes a strategy against a supplied execution context.
|
|
47
47
|
* This is the recommended API for new consumers. It intentionally bypasses
|
|
48
48
|
* all legacy vault, pool, subgraph, clock, and block-estimation reads.
|
|
49
49
|
*/
|
|
50
|
-
executeWithContext<T>(options: ExecuteWithContextOptions): Promise<
|
|
50
|
+
executeWithContext<T = unknown>(options: ExecuteWithContextOptions): Promise<T | "continue">;
|
|
51
|
+
/** T is the complete decoded JSON result. Only the exact sentinel skips JSON decoding. */
|
|
52
|
+
private parseStrategyResult;
|
|
51
53
|
private parseVaultConfig;
|
|
52
54
|
private validateExecutionContext;
|
|
53
55
|
private redactError;
|
|
54
|
-
executeStabilityVault<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<
|
|
55
|
-
executeDynamicJobs<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, _job: JobDetails, rpc?: RpcAccess, forceDeposit?: boolean): Promise<
|
|
56
|
+
executeStabilityVault<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
|
|
57
|
+
executeDynamicJobs<T = unknown>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, _job: JobDetails, rpc?: RpcAccess, forceDeposit?: boolean): Promise<T | "continue">;
|
|
56
58
|
private getSmartPoolExecutionContext;
|
|
57
59
|
private getPoolCurrentTick;
|
|
58
60
|
private getTickSpacing;
|
|
@@ -495,7 +495,7 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
|
|
|
495
495
|
dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), smartPoolExecutionContext), forceDeposit);
|
|
496
496
|
_data = _data.map((element) => JSON.stringify(element));
|
|
497
497
|
const result = yield dataConnector.executeBundle(_data);
|
|
498
|
-
return
|
|
498
|
+
return this.parseStrategyResult(result);
|
|
499
499
|
});
|
|
500
500
|
}
|
|
501
501
|
/**
|
|
@@ -517,7 +517,7 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
|
|
|
517
517
|
yield dataConnector.loadSync();
|
|
518
518
|
dataConnector.initializeStrategyWithContext(executionContext, options.forceDeposit);
|
|
519
519
|
const result = yield dataConnector.executeBundle(options.data.map((item) => JSON.stringify(item)));
|
|
520
|
-
return
|
|
520
|
+
return this.parseStrategyResult(result);
|
|
521
521
|
}
|
|
522
522
|
catch (error) {
|
|
523
523
|
if (error instanceof types_js_1.ExecutionContextError)
|
|
@@ -526,6 +526,17 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
|
|
|
526
526
|
}
|
|
527
527
|
});
|
|
528
528
|
}
|
|
529
|
+
/** T is the complete decoded JSON result. Only the exact sentinel skips JSON decoding. */
|
|
530
|
+
parseStrategyResult(result) {
|
|
531
|
+
if (result === "continue")
|
|
532
|
+
return result;
|
|
533
|
+
try {
|
|
534
|
+
return JSON.parse(result);
|
|
535
|
+
}
|
|
536
|
+
catch (error) {
|
|
537
|
+
throw new types_js_1.StrategyExecutionError(this.redactError(error));
|
|
538
|
+
}
|
|
539
|
+
}
|
|
529
540
|
parseVaultConfig(vaultConfig) {
|
|
530
541
|
try {
|
|
531
542
|
return JSON.parse(vaultConfig);
|
|
@@ -609,7 +620,7 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
|
|
|
609
620
|
dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), dynamicJobExecutionContext), forceDeposit);
|
|
610
621
|
_data = _data.map((element) => JSON.stringify(element));
|
|
611
622
|
const result = yield dataConnector.executeDynamicJobBundle(_data);
|
|
612
|
-
return
|
|
623
|
+
return this.parseStrategyResult(result);
|
|
613
624
|
});
|
|
614
625
|
}
|
|
615
626
|
executeDynamicJobs(_wasmFile, _vaultConfig, _data, _job, rpc, forceDeposit) {
|
|
@@ -632,7 +643,7 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
|
|
|
632
643
|
dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), dynamicJobExecutionContext), forceDeposit);
|
|
633
644
|
_data = _data.map((element) => JSON.stringify(element));
|
|
634
645
|
const result = yield dataConnector.executeDynamicJobBundle(_data);
|
|
635
|
-
return
|
|
646
|
+
return this.parseStrategyResult(result);
|
|
636
647
|
});
|
|
637
648
|
}
|
|
638
649
|
getSmartPoolExecutionContext(currentExecutionContext, dataConnector, vaultConfig) {
|
|
@@ -7,7 +7,7 @@ export declare class ExecutionBase {
|
|
|
7
7
|
protected delay(ms: number): Promise<void>;
|
|
8
8
|
protected log(...args: Array<any>): void;
|
|
9
9
|
protected getExecutionContext(dataConnector: DataConnector, vaultConfig: VaultConfigPayload): Promise<ExecutionContext>;
|
|
10
|
-
execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess): Promise<Array<T
|
|
10
|
+
execute<T>(_wasmFile: string | ArrayBuffer, _vaultConfig: string, _data: Array<any>, rpc?: RpcAccess): Promise<T | Array<T> | "continue">;
|
|
11
11
|
protected getDataConnectorVersion(dataConnector: DataConnector): Promise<number>;
|
|
12
12
|
getAverageBlockTime(provider: PublicClient, blockCount?: number): Promise<number>;
|
|
13
13
|
getBlockNumberFromAvgBlockTime(provider: PublicClient, targetTimestamp: number, avgBlockTime: number): Promise<number>;
|