n3-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.
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ <a id="readme-top"></a>
2
+
3
+ [![Contributors][contributors-shield]][contributors-url]
4
+ [![Forks][forks-shield]][forks-url]
5
+ [![Stargazers][stars-shield]][stars-url]
6
+ [![Issues][issues-shield]][issues-url]
7
+ [![MIT License][license-shield]][license-url]
8
+ [![LinkedIn][linkedin-shield]][linkedin-url]
9
+
10
+ <br />
11
+ <div align="center">
12
+ <a href="https://n3.exchange">
13
+ <img src="images/logo.png" alt="Logo" width="80" height="80">
14
+ </a>
15
+
16
+ <h3 align="center">N3 SDK</h3>
17
+
18
+ <p align="center">
19
+ A modern, type-safe, and modular SDK for the N3 Network — a privacy-preserving trading and liquidity layer.
20
+ <br />
21
+ <a href="https://docs.n3.exchange"><strong>Explore the Docs »</strong></a>
22
+ <br />
23
+ <br />
24
+ <a href="https://github.com/n3labs/n3-sdk">View Demo</a>
25
+ ·
26
+ <a href="https://github.com/n3labs/n3-sdk/issues/new?labels=bug&template=bug-report.md">Report Bug</a>
27
+ ·
28
+ <a href="https://github.com/n3labs/n3-sdk/issues/new?labels=enhancement&template=feature-request.md">Request Feature</a>
29
+ </p>
30
+ </div>
31
+
32
+ <details>
33
+ <summary>Table of Contents</summary>
34
+ <ol>
35
+ <li>
36
+ <a href="#about-the-project">About The Project</a>
37
+ <ul>
38
+ <li><a href="#built-with">Built With</a></li>
39
+ </ul>
40
+ </li>
41
+ <li>
42
+ <a href="#getting-started">Getting Started</a>
43
+ <ul>
44
+ <li><a href="#prerequisites">Prerequisites</a></li>
45
+ <li><a href="#installation">Installation</a></li>
46
+ </ul>
47
+ </li>
48
+ <li><a href="#usage">Usage</a></li>
49
+ <li><a href="#architecture">Architecture</a></li>
50
+ <li><a href="#tooling">Tooling</a></li>
51
+ <li><a href="#license">License</a></li>
52
+ <li><a href="#contact">Contact</a></li>
53
+ <li><a href="#acknowledgments">Acknowledgments</a></li>
54
+ </ol>
55
+ </details>
56
+
57
+ ## About The Project
58
+
59
+ [![N3 SDK Screenshot][product-screenshot]](https://n3.exchange)
60
+
61
+ The **N3 SDK** provides a unified, developer-friendly way to interact with the **N3 Network**, a privacy-preserving hybrid trading, liquidity, and settlement layer.
62
+
63
+ It enables you to:
64
+ - Fetch **market data** (GraphQL)
65
+ - Subscribe to **real-time feeds** (WebSocket)
66
+ - Execute **exchange actions** like orders, cancels, and deposits
67
+ - Sync **Merkle-proven private notes** for encrypted balances
68
+
69
+ ### Why N3 SDK?
70
+
71
+ * Built for privacy-first decentralized trading infrastructure
72
+ * Clean, type-safe, and DRY architecture
73
+ * Works seamlessly across Bun, Node, and browser environments
74
+ * Fully modular — import only what you need
75
+
76
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
77
+
78
+ ### Built With
79
+
80
+ * [![TypeScript][TypeScript-shield]][TypeScript-url]
81
+ * [![GraphQL][GraphQL-shield]][GraphQL-url]
82
+ * [![Bun][Bun-shield]][Bun-url]
83
+ * [![Viem][Viem-shield]][Viem-url]
84
+ * [![WebSocket][WebSocket-shield]][WebSocket-url]
85
+
86
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
87
+
88
+ ## Getting Started
89
+
90
+ Follow these steps to get started with N3 SDK in your project.
91
+
92
+ ### Prerequisites
93
+
94
+ You’ll need one of the following installed:
95
+ * Node.js ≥ 18
96
+ * Bun ≥ 1.1
97
+
98
+ Check your version:
99
+ ```bash
100
+ node -v
101
+ # or
102
+ bun -v
103
+
104
+ Installation
105
+
106
+ Install from npm:
107
+
108
+ npm install n3-sdk
109
+ # or
110
+ bun add n3-sdk
111
+ # or
112
+ pnpm add n3-sdk
113
+
114
+ Usage
115
+
116
+ Initialize the SDK
117
+ import { N3SDK } from "n3-sdk";
118
+
119
+ const sdk = new N3SDK({
120
+ gqlUrl: "https://api.n3.exchange/graphql",
121
+ wsUrl: "wss://api.n3.exchange/ws",
122
+ });
123
+
124
+ Fetch Market Data
125
+
126
+ const candles = await sdk.info.candles.list(241, "1m", 100);
127
+ const trades = await sdk.info.trades.list(241, 50);
128
+
129
+ Subscribe to Live Streams
130
+
131
+ const sub = sdk.subscriptions.trades.stream(241, (trade) => {
132
+ console.log("Live trade:", trade);
133
+ });
134
+ sub.off();
135
+
136
+
137
+ await sdk.exchange.order({
138
+ hl: { /* order data */ },
139
+ grouping: "limit",
140
+ domain: { pool: "0xPool", chainIdDec: 42161, DOMAIN_DEC: 1 },
141
+ });
142
+
143
+ Deposit ERC20
144
+
145
+ await sdk.exchange.depositERC20({
146
+ clients,
147
+ token: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
148
+ assetId: 100, (Hyperliquid tokenIDs)
149
+ amount: 1000n * 10n ** 6n,
150
+ });
151
+
152
+ Receiver Sync
153
+
154
+ const stop = sdk.startReceiverSync(noteStore, clients);
155
+ stop();
156
+
157
+ Architecture
158
+
159
+ ┌────────────────────────────┐
160
+ │ Client App │
161
+ │ (Web / Node / Mobile) │
162
+ └────────────┬───────────────┘
163
+
164
+
165
+ ┌────────────────────┐
166
+ │ N3 SDK │
167
+ │────────────────────│
168
+ │ Info (GraphQL) │ → Historical data
169
+ │ Subscriptions (WS) │ → Live streams
170
+ │ Exchange Actions │ → Orders & Withdrawals
171
+ │ Notes / Receiver │ → Merkle tracking
172
+ └────────────────────┘
173
+
174
+
175
+ ┌────────────────────┐
176
+ │ N3 Gateway + TEE │
177
+ └────────────────────┘
178
+
179
+
180
+ The SDK exposes three namespaces:
181
+ • info → Historical GraphQL queries
182
+ • subscriptions → WebSocket data fan-outs
183
+ • exchange → Orders, cancels, deposits, withdrawals
184
+
185
+ Tooling
186
+
187
+ Tool
188
+ Purpose
189
+ TypeScript
190
+ Full static typing
191
+ Tsup
192
+ High-speed bundler (ESM output)
193
+ Viem
194
+ Blockchain client abstraction
195
+ GraphQL
196
+ Data layer
197
+ WebSocket
198
+ Real-time transport
199
+ Bun
200
+ Dev runtime & test harness
201
+
202
+
203
+ License
204
+ Distributed under the MIT License. See LICENSE.txt for details.
205
+
206
+
207
+ Contact
208
+
209
+ N3 Labs
210
+ Website: https://n3.exchange
211
+ Docs: https://docs.n3.exchange
212
+ Twitter: @n3labs
213
+ Email: dev@n3.exchange
214
+ Project Link: https://github.com/n3labs/n3-sdk