@vesper85/strategy-sdk 0.1.0

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.
@@ -0,0 +1,54 @@
1
+ import type { ISigner, SignerConfig } from './types';
2
+ /**
3
+ * Signer class that supports multiple signing modes:
4
+ * - 'osiris': Signs via Osiris Hub API (requires OAuth token and connection)
5
+ * - 'privateKey': Signs directly with a private key (EVM chains)
6
+ *
7
+ * @example Osiris mode
8
+ * ```typescript
9
+ * const signer = new Signer({
10
+ * mode: 'osiris',
11
+ * config: {
12
+ * hubBaseUrl: 'https://api.osirislabs.xyz/v1',
13
+ * accessToken: 'your-oauth-token',
14
+ * connectionId: 'wallet-connection-id'
15
+ * }
16
+ * });
17
+ * ```
18
+ *
19
+ * @example Private Key mode
20
+ * ```typescript
21
+ * const signer = new Signer({
22
+ * mode: 'privateKey',
23
+ * config: {
24
+ * privateKey: '0x...',
25
+ * chain: 'evm:eip155:1' // optional, defaults to mainnet
26
+ * }
27
+ * });
28
+ * ```
29
+ */
30
+ export declare class Signer implements ISigner {
31
+ private impl;
32
+ constructor(config: SignerConfig);
33
+ /**
34
+ * Get the wallet address (only available for privateKey mode)
35
+ */
36
+ getAddress(): string | undefined;
37
+ /**
38
+ * Sign a transaction via Osiris Hub
39
+ */
40
+ signTransaction(transaction: string | any, chain: string, walletAddress: string): Promise<string>;
41
+ /**
42
+ * Sign typed data (EIP-712 for EVM) via Osiris Hub
43
+ */
44
+ signTypedData(typedData: any, chain: string, walletAddress: string): Promise<string>;
45
+ /**
46
+ * Sign a message via Osiris Hub
47
+ */
48
+ signMessage(message: string | Uint8Array, chain: string, walletAddress: string): Promise<string>;
49
+ getPrivateKey(): string | undefined;
50
+ }
51
+ export { OsirisSigner } from './osiris-signer';
52
+ export { PrivateKeySigner } from './privatekey-signer';
53
+ export type { ISigner, SignerConfig, OsirisSignerConfig, PrivateKeySignerConfig } from './types';
54
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,29 @@
1
+ import type { ISigner } from './types';
2
+ import type { OsirisSignerConfig } from './types';
3
+ /**
4
+ * Osiris signer implementation using the Osiris Hub API
5
+ * Signs transactions through the hub's wallet signing endpoint
6
+ */
7
+ export declare class OsirisSigner implements ISigner {
8
+ private hubBaseUrl;
9
+ private accessToken;
10
+ private connectionId;
11
+ constructor(config: OsirisSignerConfig);
12
+ /**
13
+ * Sign a transaction via Osiris Hub API
14
+ * @param walletAddress - Required wallet address for signing
15
+ */
16
+ signTransaction(transaction: string | any, chain: string, walletAddress: string): Promise<string>;
17
+ /**
18
+ * Sign typed data (EIP-712) via Osiris Hub API
19
+ * @param walletAddress - Required wallet address for signing
20
+ */
21
+ signTypedData(typedData: any, chain: string, walletAddress: string): Promise<string>;
22
+ /**
23
+ * Sign a message via Osiris Hub API
24
+ * @param walletAddress - Required wallet address for signing
25
+ */
26
+ signMessage(message: string | Uint8Array, chain: string, walletAddress: string): Promise<string>;
27
+ getPrivateKey(): string | undefined;
28
+ }
29
+ //# sourceMappingURL=osiris-signer.d.ts.map
@@ -0,0 +1,41 @@
1
+ import type { ISigner, PrivateKeySignerConfig } from './types';
2
+ /**
3
+ * Private key signer implementation for EVM chains
4
+ * Signs transactions directly using a private key
5
+ */
6
+ export declare class PrivateKeySigner implements ISigner {
7
+ private account;
8
+ private defaultChain;
9
+ private clientCache;
10
+ private privateKey;
11
+ constructor(config: PrivateKeySignerConfig);
12
+ /**
13
+ * Get the wallet address derived from the private key
14
+ */
15
+ getAddress(): string;
16
+ /**
17
+ * Get the private key (needed for CLOB client initialization)
18
+ * @returns The private key with 0x prefix
19
+ */
20
+ getPrivateKey(): string;
21
+ /**
22
+ * Get or create a wallet client for the specified chain
23
+ */
24
+ private getClient;
25
+ /**
26
+ * Sign a transaction with the private key
27
+ * @param walletAddress - Ignored for private key signer (uses derived address)
28
+ */
29
+ signTransaction(transaction: string | any, chain: string, _walletAddress: string): Promise<string>;
30
+ /**
31
+ * Sign typed data (EIP-712) with the private key
32
+ * @param walletAddress - Ignored for private key signer (uses derived address)
33
+ */
34
+ signTypedData(typedData: any, chain: string, _walletAddress: string): Promise<string>;
35
+ /**
36
+ * Sign a message with the private key
37
+ * @param walletAddress - Ignored for private key signer (uses derived address)
38
+ */
39
+ signMessage(message: string | Uint8Array, chain: string, _walletAddress: string): Promise<string>;
40
+ }
41
+ //# sourceMappingURL=privatekey-signer.d.ts.map
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Signer method types
3
+ */
4
+ export type SignerMethod = 'signTransaction' | 'signTypedData' | 'signMessage';
5
+ /**
6
+ * Signer interface for Osiris Hub-based signing
7
+ */
8
+ export interface ISigner {
9
+ /**
10
+ * Sign a transaction via Osiris Hub
11
+ * @param transaction - Serialized transaction or transaction object
12
+ * @param chain - Chain identifier (e.g., 'evm:eip155:1' or 'solana:mainnet')
13
+ * @param walletAddress - Wallet address (required)
14
+ * @returns Signed transaction as hex string
15
+ */
16
+ signTransaction(transaction: string | any, chain: string, walletAddress: string): Promise<string>;
17
+ /**
18
+ * Sign typed data (EIP-712 for EVM) via Osiris Hub
19
+ * @param typedData - Typed data object
20
+ * @param chain - Chain identifier
21
+ * @param walletAddress - Wallet address (required)
22
+ * @returns Signature as hex string
23
+ */
24
+ signTypedData(typedData: any, chain: string, walletAddress: string): Promise<string>;
25
+ /**
26
+ * Sign a message via Osiris Hub
27
+ * @param message - Message to sign (string or bytes)
28
+ * @param chain - Chain identifier
29
+ * @param walletAddress - Wallet address (required)
30
+ * @returns Signature as hex string
31
+ */
32
+ signMessage(message: string | Uint8Array, chain: string, walletAddress: string): Promise<string>;
33
+ getPrivateKey(): string | undefined;
34
+ }
35
+ /**
36
+ * Configuration for Osiris signer mode
37
+ */
38
+ export interface OsirisSignerConfig {
39
+ hubBaseUrl: string;
40
+ accessToken: string;
41
+ connectionId: string;
42
+ }
43
+ /**
44
+ * Configuration for Private Key signer mode
45
+ */
46
+ export interface PrivateKeySignerConfig {
47
+ /** Private key (with or without 0x prefix) */
48
+ privateKey: string;
49
+ /** Default chain identifier (e.g., 'evm:eip155:1') */
50
+ chain?: string;
51
+ }
52
+ /**
53
+ * Signer configuration - supports Osiris Hub or Private Key modes
54
+ */
55
+ export type SignerConfig = {
56
+ mode: 'osiris';
57
+ config: OsirisSignerConfig;
58
+ } | {
59
+ mode: 'privateKey';
60
+ config: PrivateKeySignerConfig;
61
+ };
62
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,17 @@
1
+ import type { OsirisState } from "../types/osiris";
2
+ /**
3
+ * In-memory state manager for standalone strategy execution
4
+ * Perfect for testing and development
5
+ */
6
+ export declare class MemoryStateManager implements OsirisState {
7
+ private storage;
8
+ get(key: string): Promise<any>;
9
+ set(key: string, value: any): Promise<void>;
10
+ delete(key: string): Promise<void>;
11
+ clear(): Promise<void>;
12
+ /**
13
+ * Get all keys (useful for debugging)
14
+ */
15
+ getAllKeys(): string[];
16
+ }
17
+ //# sourceMappingURL=memory-state.d.ts.map
@@ -0,0 +1,20 @@
1
+ import type { OsirisState } from "../types/osiris";
2
+ import type { Logger } from "../utils/logger";
3
+ /**
4
+ * Redis-based state manager for persistent state across strategy executions
5
+ * Requires a Redis connection
6
+ */
7
+ export declare class RedisStateManager implements OsirisState {
8
+ private client;
9
+ private strategyId;
10
+ private logger;
11
+ constructor(redisUrl: string, strategyId: string, logger: Logger);
12
+ connect(): Promise<void>;
13
+ disconnect(): Promise<void>;
14
+ private getKey;
15
+ get(key: string): Promise<any>;
16
+ set(key: string, value: any): Promise<void>;
17
+ delete(key: string): Promise<void>;
18
+ clear(): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=redis-state.d.ts.map
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Event types for event-based strategy execution
3
+ */
4
+ /**
5
+ * Supported event types
6
+ */
7
+ export type EventType = 'price' | 'orderbook' | 'time' | 'trade' | 'fill' | 'liquidation' | 'custom';
8
+ /**
9
+ * Conditions for filtering events
10
+ */
11
+ export interface EventConditions {
12
+ /** Trigger when price goes above this value */
13
+ priceAbove?: number;
14
+ /** Trigger when price goes below this value */
15
+ priceBelow?: number;
16
+ /** Trigger on percentage price change */
17
+ priceChangePercent?: number;
18
+ /** Cron expression for scheduled events (e.g., "0 * * * *" for hourly) */
19
+ cron?: string;
20
+ /** Interval in milliseconds for recurring events */
21
+ interval?: number;
22
+ /** Trigger when spread percentage is above this value */
23
+ spreadAbove?: number;
24
+ /** Trigger when spread percentage is below this value */
25
+ spreadBelow?: number;
26
+ /** Trigger when volume exceeds this value */
27
+ volumeAbove?: number;
28
+ [key: string]: any;
29
+ }
30
+ /**
31
+ * Event subscription configuration
32
+ * Defines what events a strategy wants to receive
33
+ */
34
+ export interface EventSubscription {
35
+ /** Type of event to subscribe to */
36
+ type: EventType;
37
+ /** Market/asset identifier (e.g., token ID, trading pair like "BTC-USD") */
38
+ market?: string;
39
+ /** Optional filter conditions */
40
+ conditions?: EventConditions;
41
+ /** Optional custom channel name for the event source */
42
+ channel?: string;
43
+ }
44
+ /**
45
+ * Data payload for strategy events
46
+ */
47
+ export interface EventData {
48
+ /** Current price */
49
+ price?: number;
50
+ /** Previous price (before the change) */
51
+ previousPrice?: number;
52
+ /** Percentage change from previous price */
53
+ changePercent?: number;
54
+ /** Best bid price */
55
+ bestBid?: number;
56
+ /** Best ask price */
57
+ bestAsk?: number;
58
+ /** Spread percentage */
59
+ spread?: number;
60
+ /** Bid depth */
61
+ bidDepth?: number;
62
+ /** Ask depth */
63
+ askDepth?: number;
64
+ /** Trade side */
65
+ side?: 'buy' | 'sell';
66
+ /** Trade size */
67
+ size?: number;
68
+ /** Trade/order ID */
69
+ tradeId?: string;
70
+ /** Order ID (for fills) */
71
+ orderId?: string;
72
+ /** Trading volume */
73
+ volume?: number;
74
+ raw?: any;
75
+ [key: string]: any;
76
+ }
77
+ /**
78
+ * Strategy event passed to onEvent handler
79
+ */
80
+ export interface StrategyEvent {
81
+ /** Event type */
82
+ type: EventType;
83
+ /** Timestamp when event occurred (Unix milliseconds) */
84
+ timestamp: number;
85
+ /** Market/asset this event relates to */
86
+ market?: string;
87
+ /** Event-specific data payload */
88
+ data: EventData;
89
+ }
90
+ /**
91
+ * WebSocket message types for event source protocol
92
+ */
93
+ export interface EventSourceSubscribeMessage {
94
+ action: 'subscribe';
95
+ subscriptions: EventSubscription[];
96
+ }
97
+ export interface EventSourceUnsubscribeMessage {
98
+ action: 'unsubscribe';
99
+ subscriptions: EventSubscription[];
100
+ }
101
+ export type EventSourceMessage = EventSourceSubscribeMessage | EventSourceUnsubscribeMessage;
102
+ //# sourceMappingURL=event-types.d.ts.map