n8n-nodes-lighter 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.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # n8n-nodes-lighter
2
+
3
+ This is an n8n community node for **Lighter (zkLighter)** - a high-performance perpetuals DEX built on a zero-knowledge rollup on Ethereum.
4
+
5
+ [Lighter](https://lighter.xyz) | [API Documentation](https://apidocs.lighter.xyz) | [n8n Community Nodes Documentation](https://docs.n8n.io/integrations/community-nodes/)
6
+
7
+ ## Features
8
+
9
+ ### Lighter Node (REST API)
10
+ - **Account Operations**: Get account info, positions, PnL, liquidations, funding data
11
+ - **Market Operations**: Order books, exchange stats, funding rates
12
+ - **Order Operations**: Active/inactive orders, order history export
13
+ - **Trade Operations**: Recent trades, trade history
14
+ - **Transaction Operations**: Transaction details, deposit/withdraw/transfer history
15
+ - **System Operations**: Status, info, announcements
16
+
17
+ ### Lighter Trigger (WebSocket)
18
+ Real-time data streaming via WebSocket:
19
+ - Order book updates (50ms intervals)
20
+ - Market statistics
21
+ - Trade feed
22
+ - Account positions, orders, trades
23
+ - Notifications (liquidations, deleveraging)
24
+ - Blockchain height updates
25
+
26
+ ## Installation
27
+
28
+ ### Community Nodes (Recommended)
29
+ 1. Go to **Settings > Community Nodes** in n8n
30
+ 2. Select **Install**
31
+ 3. Enter `n8n-nodes-lighter`
32
+ 4. Click **Install**
33
+
34
+ ### Manual Installation
35
+ ```bash
36
+ cd ~/.n8n/nodes
37
+ npm install n8n-nodes-lighter
38
+ ```
39
+
40
+ ## Credentials
41
+
42
+ To use this node, you need to set up Lighter API credentials:
43
+
44
+ 1. **Environment**: Choose between Mainnet or Testnet
45
+ 2. **Account Index**: Your Lighter account index (find it using `accountsByL1Address` endpoint)
46
+ 3. **API Key Index**: Your API key index (3-254, indices 0-2 are reserved)
47
+ 4. **API Private Key**: Your API private key for signing transactions
48
+ 5. **Auth Token** (Optional): Pre-generated auth token for authenticated endpoints
49
+
50
+ ### Getting Your Credentials
51
+
52
+ 1. Visit [Lighter](https://app.lighter.xyz) and connect your wallet
53
+ 2. Create an API key using the Python or Go SDK
54
+ 3. Find your account index using the `accountsByL1Address` endpoint
55
+
56
+ Example using Python SDK:
57
+ ```python
58
+ import lighter
59
+
60
+ client = lighter.SignerClient(
61
+ url="https://mainnet.zklighter.elliot.ai",
62
+ api_private_keys={3: "your_private_key"},
63
+ account_index=YOUR_ACCOUNT_INDEX
64
+ )
65
+
66
+ # Generate auth token (max 8 hours)
67
+ auth, err = client.create_auth_token_with_expiry(3600)
68
+ ```
69
+
70
+ ## Usage Examples
71
+
72
+ ### Get Account Information
73
+ 1. Add the **Lighter** node to your workflow
74
+ 2. Select **Resource**: Account
75
+ 3. Select **Operation**: Get Account
76
+ 4. Choose **Query By**: Account Index or L1 Address
77
+ 5. Enter the account index or address
78
+
79
+ ### Subscribe to Order Book Updates
80
+ 1. Add the **Lighter Trigger** node
81
+ 2. Select **Channel**: Order Book
82
+ 3. Enter the **Market Index** (0 = ETH-USD)
83
+ 4. The trigger will emit events on every orderbook update
84
+
85
+ ### Get Recent Trades
86
+ 1. Add the **Lighter** node
87
+ 2. Select **Resource**: Trade
88
+ 3. Select **Operation**: Get Recent Trades
89
+ 4. Enter **Market Index** and **Limit**
90
+
91
+ ## API Reference
92
+
93
+ ### Markets
94
+ | Index | Symbol |
95
+ |-------|--------|
96
+ | 0 | ETH-USD |
97
+ | 1 | BTC-USD |
98
+ | 2 | SOL-USD |
99
+ | ... | ... |
100
+
101
+ Use the `Get Order Books` operation to retrieve all available markets.
102
+
103
+ ### Rate Limits
104
+ - **Standard Account**: 60 weighted requests/minute
105
+ - **Premium Account**: 24,000 weighted requests/minute
106
+ - **WebSocket**: 100 connections, 1000 subscriptions total
107
+
108
+ ## Resources
109
+
110
+ - [Lighter Documentation](https://docs.lighter.xyz)
111
+ - [API Documentation](https://apidocs.lighter.xyz)
112
+ - [Python SDK](https://github.com/elliottech/lighter-python)
113
+ - [Go SDK](https://github.com/elliottech/lighter-go)
114
+
115
+ ## License
116
+
117
+ [MIT](LICENSE.md)
118
+
119
+ ## Contributing
120
+
121
+ Contributions are welcome! Please feel free to submit a Pull Request.
@@ -0,0 +1,9 @@
1
+ import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class LighterApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ authenticate: IAuthenticateGeneric;
8
+ test: ICredentialTestRequest;
9
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LighterApi = void 0;
4
+ class LighterApi {
5
+ constructor() {
6
+ this.name = 'lighterApi';
7
+ this.displayName = 'Lighter API';
8
+ this.documentationUrl = 'https://apidocs.lighter.xyz/docs/get-started-for-programmers-1';
9
+ this.properties = [
10
+ {
11
+ displayName: 'Environment',
12
+ name: 'environment',
13
+ type: 'options',
14
+ default: 'mainnet',
15
+ options: [
16
+ {
17
+ name: 'Mainnet',
18
+ value: 'mainnet',
19
+ },
20
+ {
21
+ name: 'Testnet',
22
+ value: 'testnet',
23
+ },
24
+ ],
25
+ description: 'Select the Lighter network environment',
26
+ },
27
+ {
28
+ displayName: 'Account Index',
29
+ name: 'accountIndex',
30
+ type: 'number',
31
+ default: 0,
32
+ required: true,
33
+ description: 'Your Lighter account index. Find it using the accountsByL1Address endpoint.',
34
+ },
35
+ {
36
+ displayName: 'API Key Index',
37
+ name: 'apiKeyIndex',
38
+ type: 'number',
39
+ default: 3,
40
+ required: true,
41
+ description: 'The API key index (3-254). Indices 0-2 are reserved for desktop/mobile apps.',
42
+ },
43
+ {
44
+ displayName: 'API Private Key',
45
+ name: 'apiPrivateKey',
46
+ type: 'string',
47
+ typeOptions: {
48
+ password: true,
49
+ },
50
+ default: '',
51
+ required: true,
52
+ description: 'Your Lighter API private key for signing transactions',
53
+ },
54
+ {
55
+ displayName: 'Auth Token',
56
+ name: 'authToken',
57
+ type: 'string',
58
+ typeOptions: {
59
+ password: true,
60
+ },
61
+ default: '',
62
+ description: 'Pre-generated auth token for API requests. If empty, public endpoints will be used.',
63
+ hint: 'Generate using the SDK: client.create_auth_token_with_expiry()',
64
+ },
65
+ {
66
+ displayName: 'L1 Address (Optional)',
67
+ name: 'l1Address',
68
+ type: 'string',
69
+ default: '',
70
+ description: 'Your Ethereum L1 address (optional, for convenience)',
71
+ },
72
+ ];
73
+ this.authenticate = {
74
+ type: 'generic',
75
+ properties: {
76
+ headers: {
77
+ Authorization: '={{$credentials.authToken}}',
78
+ },
79
+ },
80
+ };
81
+ this.test = {
82
+ request: {
83
+ baseURL: '={{$credentials.environment === "mainnet" ? "https://mainnet.zklighter.elliot.ai" : "https://testnet.zklighter.elliot.ai"}}',
84
+ url: '/api/v1/status',
85
+ method: 'GET',
86
+ },
87
+ };
88
+ }
89
+ }
90
+ exports.LighterApi = LighterApi;
91
+ //# sourceMappingURL=LighterApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LighterApi.credentials.js","sourceRoot":"","sources":["../../credentials/LighterApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,UAAU;IAAvB;QACC,SAAI,GAAG,YAAY,CAAC;QACpB,gBAAW,GAAG,aAAa,CAAC;QAC5B,qBAAgB,GAAG,gEAAgE,CAAC;QACpF,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,aAAa;gBAC1B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,SAAS;gBAClB,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,SAAS;qBAChB;oBACD;wBACC,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,SAAS;qBAChB;iBACD;gBACD,WAAW,EAAE,wCAAwC;aACrD;YACD;gBACC,WAAW,EAAE,eAAe;gBAC5B,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,CAAC;gBACV,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,6EAA6E;aAC1F;YACD;gBACC,WAAW,EAAE,eAAe;gBAC5B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,CAAC;gBACV,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,8EAA8E;aAC3F;YACD;gBACC,WAAW,EAAE,iBAAiB;gBAC9B,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,uDAAuD;aACpE;YACD;gBACC,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,qFAAqF;gBAClG,IAAI,EAAE,gEAAgE;aACtE;YACD;gBACC,WAAW,EAAE,uBAAuB;gBACpC,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,sDAAsD;aACnE;SACD,CAAC;QAEF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,aAAa,EAAE,6BAA6B;iBAC5C;aACD;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,6HAA6H;gBACtI,GAAG,EAAE,gBAAgB;gBACrB,MAAM,EAAE,KAAK;aACb;SACD,CAAC;IACH,CAAC;CAAA;AArFD,gCAqFC"}
@@ -0,0 +1,5 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class Lighter implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }