@n1xyz/nord-ts 0.1.6 → 0.1.8

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.
Files changed (85) hide show
  1. package/dist/actions.d.ts +57 -0
  2. package/dist/actions.js +186 -0
  3. package/dist/bundle.js +79181 -0
  4. package/dist/{nord/client → client}/Nord.d.ts +90 -107
  5. package/dist/{nord/client → client}/Nord.js +157 -218
  6. package/dist/{nord/client → client}/NordAdmin.d.ts +68 -102
  7. package/dist/{nord/client → client}/NordAdmin.js +109 -140
  8. package/dist/{nord/client → client}/NordUser.d.ts +86 -98
  9. package/dist/{nord/client → client}/NordUser.js +204 -271
  10. package/dist/const.js +5 -8
  11. package/dist/{nord/utils/NordError.js → error.js} +7 -5
  12. package/dist/gen/nord_pb.js +88 -92
  13. package/dist/gen/openapi.d.ts +39 -0
  14. package/dist/gen/openapi.js +1 -2
  15. package/dist/index.d.ts +6 -1
  16. package/dist/index.js +10 -21
  17. package/dist/types.d.ts +5 -50
  18. package/dist/types.js +21 -83
  19. package/dist/utils.d.ts +8 -11
  20. package/dist/utils.js +55 -90
  21. package/dist/websocket/NordWebSocketClient.js +12 -17
  22. package/dist/{nord/models → websocket}/Subscriber.d.ts +1 -1
  23. package/dist/{nord/models → websocket}/Subscriber.js +6 -7
  24. package/dist/websocket/events.js +1 -2
  25. package/dist/websocket/index.d.ts +19 -2
  26. package/dist/websocket/index.js +80 -5
  27. package/package.json +2 -3
  28. package/dist/api/client.d.ts +0 -14
  29. package/dist/api/client.js +0 -45
  30. package/dist/bridge/client.d.ts +0 -151
  31. package/dist/bridge/client.js +0 -434
  32. package/dist/bridge/const.d.ts +0 -23
  33. package/dist/bridge/const.js +0 -47
  34. package/dist/bridge/index.d.ts +0 -4
  35. package/dist/bridge/index.js +0 -23
  36. package/dist/bridge/types.d.ts +0 -120
  37. package/dist/bridge/types.js +0 -18
  38. package/dist/bridge/utils.d.ts +0 -64
  39. package/dist/bridge/utils.js +0 -131
  40. package/dist/gen/common.d.ts +0 -68
  41. package/dist/gen/common.js +0 -215
  42. package/dist/gen/nord.d.ts +0 -882
  43. package/dist/gen/nord.js +0 -6520
  44. package/dist/idl/bridge.d.ts +0 -569
  45. package/dist/idl/bridge.js +0 -8
  46. package/dist/idl/bridge.json +0 -1506
  47. package/dist/idl/index.d.ts +0 -607
  48. package/dist/idl/index.js +0 -8
  49. package/dist/nord/api/actions.d.ts +0 -126
  50. package/dist/nord/api/actions.js +0 -397
  51. package/dist/nord/api/core.d.ts +0 -16
  52. package/dist/nord/api/core.js +0 -81
  53. package/dist/nord/api/market.d.ts +0 -36
  54. package/dist/nord/api/market.js +0 -96
  55. package/dist/nord/api/metrics.d.ts +0 -67
  56. package/dist/nord/api/metrics.js +0 -229
  57. package/dist/nord/api/queries.d.ts +0 -46
  58. package/dist/nord/api/queries.js +0 -109
  59. package/dist/nord/api/triggers.d.ts +0 -7
  60. package/dist/nord/api/triggers.js +0 -38
  61. package/dist/nord/client/NordClient.d.ts +0 -33
  62. package/dist/nord/client/NordClient.js +0 -45
  63. package/dist/nord/index.d.ts +0 -11
  64. package/dist/nord/index.js +0 -36
  65. package/src/const.ts +0 -34
  66. package/src/gen/.gitkeep +0 -0
  67. package/src/gen/nord_pb.ts +0 -5053
  68. package/src/gen/openapi.ts +0 -2864
  69. package/src/index.ts +0 -5
  70. package/src/nord/api/actions.ts +0 -648
  71. package/src/nord/api/core.ts +0 -96
  72. package/src/nord/api/metrics.ts +0 -269
  73. package/src/nord/client/Nord.ts +0 -937
  74. package/src/nord/client/NordAdmin.ts +0 -514
  75. package/src/nord/client/NordClient.ts +0 -79
  76. package/src/nord/client/NordUser.ts +0 -1211
  77. package/src/nord/index.ts +0 -25
  78. package/src/nord/models/Subscriber.ts +0 -56
  79. package/src/nord/utils/NordError.ts +0 -76
  80. package/src/types.ts +0 -377
  81. package/src/utils.ts +0 -269
  82. package/src/websocket/NordWebSocketClient.ts +0 -316
  83. package/src/websocket/events.ts +0 -31
  84. package/src/websocket/index.ts +0 -2
  85. /package/dist/{nord/utils/NordError.d.ts → error.d.ts} +0 -0
@@ -1,74 +1,11 @@
1
- import { PublicKey } from "@solana/web3.js";
2
- import * as proto from "../../gen/nord_pb";
1
+ import { PublicKey, Transaction } from "@solana/web3.js";
2
+ import * as proto from "../gen/nord_pb";
3
3
  import { Nord } from "./Nord";
4
- import { FeeTierConfig } from "../../gen/nord_pb";
4
+ import { FeeTierConfig } from "../gen/nord_pb";
5
5
  export declare enum AclRole {
6
6
  FEE_MANAGER = 1,
7
7
  MARKET_MANAGER = 2,
8
- ADMIN = -2147483648
9
- }
10
- /**
11
- * Parameters required to register a new token via the admin API.
12
- */
13
- export interface CreateTokenParams {
14
- tokenDecimals: number;
15
- weightBps: number;
16
- viewSymbol: string;
17
- oracleSymbol: string;
18
- mintAddr: PublicKey;
19
- }
20
- /**
21
- * Parameters used when creating a new market.
22
- */
23
- export interface CreateMarketParams {
24
- sizeDecimals: number;
25
- priceDecimals: number;
26
- imfBps: number;
27
- cmfBps: number;
28
- mmfBps: number;
29
- marketType: proto.MarketType;
30
- viewSymbol: string;
31
- oracleSymbol: string;
32
- baseTokenId: number;
33
- }
34
- /**
35
- * Configuration for updating the Wormhole guardian set on the oracle.
36
- */
37
- export interface PythSetWormholeGuardiansParams {
38
- guardianSetIndex: number;
39
- addresses: string[];
40
- }
41
- /**
42
- * Parameters required to link an oracle symbol to a Pyth price feed.
43
- */
44
- export interface PythSetSymbolFeedParams {
45
- oracleSymbol: string;
46
- priceFeedId: string;
47
- }
48
- /**
49
- * Identifies a market that should be frozen.
50
- */
51
- export interface FreezeMarketParams {
52
- marketId: number;
53
- }
54
- /**
55
- * Identifies a market that should be unfrozen.
56
- */
57
- export interface UnfreezeMarketParams {
58
- marketId: number;
59
- }
60
- /**
61
- * Parameters for adding a new fee tier.
62
- */
63
- export interface AddFeeTierParams {
64
- config: FeeTierConfig;
65
- }
66
- /**
67
- * Parameters for updating an existing fee tier.
68
- */
69
- export interface UpdateFeeTierParams {
70
- tierId: number;
71
- config: FeeTierConfig;
8
+ ADMIN = 2147483648
72
9
  }
73
10
  /**
74
11
  * Administrative client capable of submitting privileged configuration actions.
@@ -83,29 +20,12 @@ export declare class NordAdmin {
83
20
  * @param nord - Nord instance
84
21
  * @param admin - The user that will be signing actions.
85
22
  * @param signFn - Function to sign messages with the admin's wallet.
86
- *
87
- * `signFn` must sign the _hex-encoded_ message, not the raw message itself, for
88
- * the purpose of being compatible with Solana wallets.
89
- *
90
- * In practice, you will do something along the lines of:
91
- *
92
- * ```typescript
93
- * (x) => wallet.signMessage(new TextEncoder().encode(x.toHex()));
94
- * ```
95
- *
96
- * For a software signing key, this might look more like:
97
- *
98
- * ```typescript
99
- * (x) => nacl.sign.detached(new TextEncoder().encode(x.toHex()), sk);
100
- * ``
101
- *
102
- * where `nacl` is the tweetnacl library.
103
23
  */
104
24
  static new({ nord, admin, signFn, }: Readonly<{
105
25
  nord: Nord;
106
26
  admin: PublicKey;
107
- signFn: (m: Uint8Array) => Promise<Uint8Array>;
108
- }>): NordAdmin;
27
+ signFn: (m: Transaction) => Promise<Transaction>;
28
+ }>): Promise<NordAdmin>;
109
29
  /**
110
30
  * Submit an action and append the admin signature before sending it to Nord.
111
31
  *
@@ -131,21 +51,49 @@ export declare class NordAdmin {
131
51
  /**
132
52
  * Register a new token that can be listed on Nord.
133
53
  *
134
- * @param params - Token configuration values
54
+ * @param tokenDecimals - Decimal shift used when parsing deposits/withdrawals
55
+ * @param weightBps - Risk weight in basis points applied in account value calculations
56
+ * @param viewSymbol - Symbol surfaced to Nord clients
57
+ * @param oracleSymbol - Symbol resolved by the oracle adapter
58
+ * @param mintAddr - Solana mint backing this token
135
59
  * @returns Action identifier and resulting token metadata
136
60
  * @throws {NordError} If the action submission fails
137
61
  */
138
- createToken({ tokenDecimals, weightBps, viewSymbol, oracleSymbol, mintAddr, }: CreateTokenParams): Promise<{
62
+ createToken({ tokenDecimals, weightBps, viewSymbol, oracleSymbol, mintAddr, }: Readonly<{
63
+ tokenDecimals: number;
64
+ weightBps: number;
65
+ viewSymbol: string;
66
+ oracleSymbol: string;
67
+ mintAddr: PublicKey;
68
+ }>): Promise<{
139
69
  actionId: bigint;
140
70
  } & proto.Receipt_InsertTokenResult>;
141
71
  /**
142
72
  * Open a new market with the provided trading parameters.
143
73
  *
144
- * @param params - Market configuration to apply
74
+ * @param sizeDecimals - Decimal shift for contract sizes
75
+ * @param priceDecimals - Decimal shift for price ticks
76
+ * @param imfBps - Base initial margin fraction (IMF) in basis points, see docs/MARKETS.md
77
+ * @param cmfBps - Cancel margin fraction (CMF) in basis points, see docs/MARKETS.md
78
+ * @param mmfBps - Maintenance margin fraction (MMF) in basis points, see docs/MARKETS.md
79
+ * @param marketType - Spot or perpetual market type
80
+ * @param viewSymbol - Symbol exposed to Nord clients
81
+ * @param oracleSymbol - Symbol resolved by the oracle adapter
82
+ * @param baseTokenId - Registered base token backing this market
145
83
  * @returns Action identifier and resulting market metadata
146
84
  * @throws {NordError} If the action submission fails
147
85
  */
148
- createMarket(params: CreateMarketParams): Promise<{
86
+ createMarket({ sizeDecimals, priceDecimals, imfBps, cmfBps, mmfBps, marketType, viewSymbol, oracleSymbol, baseTokenId, }: Readonly<{
87
+ sizeDecimals: number;
88
+ priceDecimals: number;
89
+ imfBps: number;
90
+ cmfBps: number;
91
+ mmfBps: number;
92
+ marketType: proto.MarketType;
93
+ viewSymbol: string;
94
+ oracleSymbol: string;
95
+ baseTokenId: number;
96
+ }>): Promise<{
149
97
  actionId: bigint;
150
98
  } & proto.Receipt_InsertMarketResult>;
151
99
  /**
@@ -155,11 +103,15 @@ export declare class NordAdmin {
155
103
  * leading `0x` prefix). The engine validates the supplied guardian set index
156
104
  * before applying the update.
157
105
  *
158
- * @param params - Guardian set index and guardian addresses
106
+ * @param guardianSetIndex - Wormhole guardian set index that must already exist
107
+ * @param addresses - 20-byte hex-encoded guardian addresses
159
108
  * @returns Action identifier and guardian update receipt
160
109
  * @throws {NordError} If the action submission fails
161
110
  */
162
- pythSetWormholeGuardians(params: PythSetWormholeGuardiansParams): Promise<{
111
+ pythSetWormholeGuardians({ guardianSetIndex, addresses, }: Readonly<{
112
+ guardianSetIndex: number;
113
+ addresses: readonly string[];
114
+ }>): Promise<{
163
115
  actionId: bigint;
164
116
  } & proto.Receipt_UpdateGuardianSetResult>;
165
117
  /**
@@ -169,11 +121,15 @@ export declare class NordAdmin {
169
121
  * leading `0x` prefix). Use this call to create or update the mapping used
170
122
  * by the oracle integration.
171
123
  *
172
- * @param params - Oracle symbol and price feed identifier
124
+ * @param oracleSymbol - Symbol resolved by the oracle adapter
125
+ * @param priceFeedId - 32-byte hex-encoded Pyth price feed identifier
173
126
  * @returns Action identifier and symbol feed receipt
174
127
  * @throws {NordError} If the action submission fails
175
128
  */
176
- pythSetSymbolFeed(params: PythSetSymbolFeedParams): Promise<{
129
+ pythSetSymbolFeed({ oracleSymbol, priceFeedId: priceFeedIdHex, }: Readonly<{
130
+ oracleSymbol: string;
131
+ priceFeedId: string;
132
+ }>): Promise<{
177
133
  actionId: bigint;
178
134
  } & proto.Receipt_OracleSymbolFeedResult>;
179
135
  /**
@@ -197,21 +153,25 @@ export declare class NordAdmin {
197
153
  /**
198
154
  * Freeze an individual market, preventing new trades and orders.
199
155
  *
200
- * @param params - Target market identifier
156
+ * @param marketId - Target market identifier
201
157
  * @returns Action identifier and freeze receipt
202
158
  * @throws {NordError} If the action submission fails
203
159
  */
204
- freezeMarket(params: FreezeMarketParams): Promise<{
160
+ freezeMarket({ marketId, }: Readonly<{
161
+ marketId: number;
162
+ }>): Promise<{
205
163
  actionId: bigint;
206
164
  } & proto.Receipt_MarketFreezeUpdated>;
207
165
  /**
208
166
  * Unfreeze a market that was previously halted.
209
167
  *
210
- * @param params - Target market identifier
168
+ * @param marketId - Target market identifier
211
169
  * @returns Action identifier and freeze receipt
212
170
  * @throws {NordError} If the action submission fails
213
171
  */
214
- unfreezeMarket(params: UnfreezeMarketParams): Promise<{
172
+ unfreezeMarket({ marketId, }: Readonly<{
173
+ marketId: number;
174
+ }>): Promise<{
215
175
  actionId: bigint;
216
176
  } & proto.Receipt_MarketFreezeUpdated>;
217
177
  /**
@@ -221,11 +181,13 @@ export declare class NordAdmin {
221
181
  * the default Nord fees; use `updateFeeTier` if you need to change it.
222
182
  * - The first appended tier receives id 1, and subsequent tiers increment the id.
223
183
  *
224
- * @param params - Fee tier configuration to insert
184
+ * @param config - Fee tier configuration to insert
225
185
  * @returns Action identifier and fee tier addition receipt
226
186
  * @throws {NordError} If the action submission fails or the new tier exceeds the maximum range (0-15).
227
187
  */
228
- addFeeTier(params: AddFeeTierParams): Promise<{
188
+ addFeeTier({ config, }: Readonly<{
189
+ config: FeeTierConfig;
190
+ }>): Promise<{
229
191
  actionId: bigint;
230
192
  } & proto.Receipt_FeeTierAdded>;
231
193
  /**
@@ -234,11 +196,15 @@ export declare class NordAdmin {
234
196
  * Tier identifiers must already exist; attempting to update a missing tier
235
197
  * causes the action to fail.
236
198
  *
237
- * @param params - Fee tier identifier and updated configuration
199
+ * @param tierId - Existing fee tier identifier to update
200
+ * @param config - Replacement configuration for the tier
238
201
  * @returns Action identifier and fee tier update receipt
239
202
  * @throws {NordError} If the action submission fails or the tier ID exceeds the configured range.
240
203
  */
241
- updateFeeTier(params: UpdateFeeTierParams): Promise<{
204
+ updateFeeTier({ tierId, config, }: Readonly<{
205
+ tierId: number;
206
+ config: FeeTierConfig;
207
+ }>): Promise<{
242
208
  actionId: bigint;
243
209
  } & proto.Receipt_FeeTierUpdated>;
244
210
  /**