@n1xyz/nord-ts 0.1.4 → 0.1.6

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.
@@ -1,14 +1,25 @@
1
+ import { PublicKey } from "@solana/web3.js";
1
2
  import * as proto from "../../gen/nord_pb";
2
- import { NordClient } from "./NordClient";
3
- import type { NordClientParams } from "./NordClient";
4
- import type { NordUser } from "./NordUser";
3
+ import { Nord } from "./Nord";
4
+ import { FeeTierConfig } from "../../gen/nord_pb";
5
+ export declare enum AclRole {
6
+ FEE_MANAGER = 1,
7
+ MARKET_MANAGER = 2,
8
+ ADMIN = -2147483648
9
+ }
10
+ /**
11
+ * Parameters required to register a new token via the admin API.
12
+ */
5
13
  export interface CreateTokenParams {
6
14
  tokenDecimals: number;
7
15
  weightBps: number;
8
16
  viewSymbol: string;
9
17
  oracleSymbol: string;
10
- solAddr: Uint8Array;
18
+ mintAddr: PublicKey;
11
19
  }
20
+ /**
21
+ * Parameters used when creating a new market.
22
+ */
12
23
  export interface CreateMarketParams {
13
24
  sizeDecimals: number;
14
25
  priceDecimals: number;
@@ -20,51 +31,229 @@ export interface CreateMarketParams {
20
31
  oracleSymbol: string;
21
32
  baseTokenId: number;
22
33
  }
34
+ /**
35
+ * Configuration for updating the Wormhole guardian set on the oracle.
36
+ */
23
37
  export interface PythSetWormholeGuardiansParams {
24
38
  guardianSetIndex: number;
25
- addresses: Uint8Array[];
39
+ addresses: string[];
26
40
  }
41
+ /**
42
+ * Parameters required to link an oracle symbol to a Pyth price feed.
43
+ */
27
44
  export interface PythSetSymbolFeedParams {
28
45
  oracleSymbol: string;
29
- priceFeedId: Uint8Array;
46
+ priceFeedId: string;
30
47
  }
48
+ /**
49
+ * Identifies a market that should be frozen.
50
+ */
31
51
  export interface FreezeMarketParams {
32
52
  marketId: number;
33
53
  }
54
+ /**
55
+ * Identifies a market that should be unfrozen.
56
+ */
34
57
  export interface UnfreezeMarketParams {
35
58
  marketId: number;
36
59
  }
37
- export interface NordAdminParams extends NordClientParams {
38
- signFn: (message: Uint8Array) => Promise<Uint8Array>;
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;
39
72
  }
40
- export declare class NordAdmin extends NordClient {
73
+ /**
74
+ * Administrative client capable of submitting privileged configuration actions.
75
+ */
76
+ export declare class NordAdmin {
77
+ private readonly nord;
78
+ private readonly admin;
41
79
  private readonly signFn;
42
- constructor(params: NordAdminParams);
43
- clone(): NordAdmin;
44
- static fromUser(user: NordUser, adminSignFn: (message: Uint8Array) => Promise<Uint8Array>): NordAdmin;
80
+ private constructor();
81
+ /** Create a new admin client.
82
+ *
83
+ * @param nord - Nord instance
84
+ * @param admin - The user that will be signing actions.
85
+ * @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
+ */
104
+ static new({ nord, admin, signFn, }: Readonly<{
105
+ nord: Nord;
106
+ admin: PublicKey;
107
+ signFn: (m: Uint8Array) => Promise<Uint8Array>;
108
+ }>): NordAdmin;
109
+ /**
110
+ * Submit an action and append the admin signature before sending it to Nord.
111
+ *
112
+ * @param kind - Action payload describing the admin request
113
+ * @throws {NordError} If signing or submission fails
114
+ */
45
115
  private submitAction;
46
- createToken(params: CreateTokenParams): Promise<{
116
+ /** Set acl permissions for a given user.
117
+ *
118
+ * If all roles are removed, the user is removed from the acl.
119
+ *
120
+ * @param target - User to update.
121
+ * @param addRoles - Roles to add to the user.
122
+ * @param removeRoles - Reles to remove from the user.
123
+ */
124
+ updateAcl({ target, addRoles, removeRoles, }: Readonly<{
125
+ target: PublicKey;
126
+ addRoles: AclRole[];
127
+ removeRoles: AclRole[];
128
+ }>): Promise<{
129
+ actionId: bigint;
130
+ } & proto.Receipt_AclUpdated>;
131
+ /**
132
+ * Register a new token that can be listed on Nord.
133
+ *
134
+ * @param params - Token configuration values
135
+ * @returns Action identifier and resulting token metadata
136
+ * @throws {NordError} If the action submission fails
137
+ */
138
+ createToken({ tokenDecimals, weightBps, viewSymbol, oracleSymbol, mintAddr, }: CreateTokenParams): Promise<{
47
139
  actionId: bigint;
48
140
  } & proto.Receipt_InsertTokenResult>;
141
+ /**
142
+ * Open a new market with the provided trading parameters.
143
+ *
144
+ * @param params - Market configuration to apply
145
+ * @returns Action identifier and resulting market metadata
146
+ * @throws {NordError} If the action submission fails
147
+ */
49
148
  createMarket(params: CreateMarketParams): Promise<{
50
149
  actionId: bigint;
51
150
  } & proto.Receipt_InsertMarketResult>;
151
+ /**
152
+ * Update the Pyth guardian set used for verifying Wormhole messages.
153
+ *
154
+ * Each address must decode from a 20-byte hex string (with or without a
155
+ * leading `0x` prefix). The engine validates the supplied guardian set index
156
+ * before applying the update.
157
+ *
158
+ * @param params - Guardian set index and guardian addresses
159
+ * @returns Action identifier and guardian update receipt
160
+ * @throws {NordError} If the action submission fails
161
+ */
52
162
  pythSetWormholeGuardians(params: PythSetWormholeGuardiansParams): Promise<{
53
163
  actionId: bigint;
54
164
  } & proto.Receipt_UpdateGuardianSetResult>;
165
+ /**
166
+ * Link an oracle symbol to a specific Pyth price feed.
167
+ *
168
+ * The price feed identifier must decode to 32 bytes (with or without a
169
+ * leading `0x` prefix). Use this call to create or update the mapping used
170
+ * by the oracle integration.
171
+ *
172
+ * @param params - Oracle symbol and price feed identifier
173
+ * @returns Action identifier and symbol feed receipt
174
+ * @throws {NordError} If the action submission fails
175
+ */
55
176
  pythSetSymbolFeed(params: PythSetSymbolFeedParams): Promise<{
56
177
  actionId: bigint;
57
178
  } & proto.Receipt_OracleSymbolFeedResult>;
179
+ /**
180
+ * Pause all trading activity on the exchange.
181
+ *
182
+ * @returns Action identifier confirming the pause
183
+ * @throws {NordError} If the action submission fails
184
+ */
58
185
  pause(): Promise<{
59
186
  actionId: bigint;
60
187
  }>;
188
+ /**
189
+ * Resume trading activity after a pause.
190
+ *
191
+ * @returns Action identifier confirming the unpause
192
+ * @throws {NordError} If the action submission fails
193
+ */
61
194
  unpause(): Promise<{
62
195
  actionId: bigint;
63
196
  }>;
197
+ /**
198
+ * Freeze an individual market, preventing new trades and orders.
199
+ *
200
+ * @param params - Target market identifier
201
+ * @returns Action identifier and freeze receipt
202
+ * @throws {NordError} If the action submission fails
203
+ */
64
204
  freezeMarket(params: FreezeMarketParams): Promise<{
65
205
  actionId: bigint;
66
206
  } & proto.Receipt_MarketFreezeUpdated>;
207
+ /**
208
+ * Unfreeze a market that was previously halted.
209
+ *
210
+ * @param params - Target market identifier
211
+ * @returns Action identifier and freeze receipt
212
+ * @throws {NordError} If the action submission fails
213
+ */
67
214
  unfreezeMarket(params: UnfreezeMarketParams): Promise<{
68
215
  actionId: bigint;
69
216
  } & proto.Receipt_MarketFreezeUpdated>;
217
+ /**
218
+ * Append a new fee tier to the account bracket configuration.
219
+ *
220
+ * - The engine supports at most 16 tiers (ids 0–15). Tier 0 is reserved for
221
+ * the default Nord fees; use `updateFeeTier` if you need to change it.
222
+ * - The first appended tier receives id 1, and subsequent tiers increment the id.
223
+ *
224
+ * @param params - Fee tier configuration to insert
225
+ * @returns Action identifier and fee tier addition receipt
226
+ * @throws {NordError} If the action submission fails or the new tier exceeds the maximum range (0-15).
227
+ */
228
+ addFeeTier(params: AddFeeTierParams): Promise<{
229
+ actionId: bigint;
230
+ } & proto.Receipt_FeeTierAdded>;
231
+ /**
232
+ * Update an existing fee tier with new maker/taker rates.
233
+ *
234
+ * Tier identifiers must already exist; attempting to update a missing tier
235
+ * causes the action to fail.
236
+ *
237
+ * @param params - Fee tier identifier and updated configuration
238
+ * @returns Action identifier and fee tier update receipt
239
+ * @throws {NordError} If the action submission fails or the tier ID exceeds the configured range.
240
+ */
241
+ updateFeeTier(params: UpdateFeeTierParams): Promise<{
242
+ actionId: bigint;
243
+ } & proto.Receipt_FeeTierUpdated>;
244
+ /**
245
+ * Assign a fee tier to one or more accounts.
246
+ *
247
+ * The tier id must be within the configured range (0–15). Every account starts
248
+ * on tier 0; assigning it to another tier requires that tier to exist already.
249
+ * Invalid account ids or tier ids cause the action to fail.
250
+ *
251
+ * @param accounts - Account IDs to update
252
+ * @param tierId - Target fee tier identifier
253
+ * @returns Action identifier and accounts-tier receipt
254
+ * @throws {NordError} If the tier id exceeds the configured range or an account id is invalid.
255
+ */
256
+ updateAccountsTier(accounts: number[], tierId: number): Promise<{
257
+ actionId: bigint;
258
+ } & proto.Receipt_AccountsTierUpdated>;
70
259
  }