@n1xyz/nord-ts 0.1.7 → 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 (84) hide show
  1. package/dist/actions.js +39 -82
  2. package/dist/bundle.js +79181 -0
  3. package/dist/client/Nord.d.ts +2 -2
  4. package/dist/client/Nord.js +46 -78
  5. package/dist/client/NordAdmin.d.ts +2 -2
  6. package/dist/client/NordAdmin.js +57 -89
  7. package/dist/client/NordUser.js +118 -147
  8. package/dist/const.js +5 -8
  9. package/dist/error.js +7 -5
  10. package/dist/gen/nord_pb.js +88 -92
  11. package/dist/gen/openapi.d.ts +5 -6
  12. package/dist/gen/openapi.js +1 -2
  13. package/dist/index.js +10 -49
  14. package/dist/types.d.ts +1 -0
  15. package/dist/types.js +21 -60
  16. package/dist/utils.js +38 -86
  17. package/dist/websocket/NordWebSocketClient.js +12 -17
  18. package/dist/websocket/Subscriber.js +6 -7
  19. package/dist/websocket/events.js +1 -2
  20. package/dist/websocket/index.js +10 -15
  21. package/package.json +2 -3
  22. package/dist/api/client.d.ts +0 -14
  23. package/dist/api/client.js +0 -45
  24. package/dist/bridge/client.d.ts +0 -151
  25. package/dist/bridge/client.js +0 -434
  26. package/dist/bridge/const.d.ts +0 -23
  27. package/dist/bridge/const.js +0 -47
  28. package/dist/bridge/index.d.ts +0 -4
  29. package/dist/bridge/index.js +0 -23
  30. package/dist/bridge/types.d.ts +0 -120
  31. package/dist/bridge/types.js +0 -18
  32. package/dist/bridge/utils.d.ts +0 -64
  33. package/dist/bridge/utils.js +0 -131
  34. package/dist/gen/common.d.ts +0 -68
  35. package/dist/gen/common.js +0 -215
  36. package/dist/gen/nord.d.ts +0 -882
  37. package/dist/gen/nord.js +0 -6520
  38. package/dist/idl/bridge.d.ts +0 -569
  39. package/dist/idl/bridge.js +0 -8
  40. package/dist/idl/bridge.json +0 -1506
  41. package/dist/idl/index.d.ts +0 -607
  42. package/dist/idl/index.js +0 -8
  43. package/dist/nord/api/actions.d.ts +0 -126
  44. package/dist/nord/api/actions.js +0 -397
  45. package/dist/nord/api/core.d.ts +0 -16
  46. package/dist/nord/api/core.js +0 -81
  47. package/dist/nord/api/market.d.ts +0 -36
  48. package/dist/nord/api/market.js +0 -96
  49. package/dist/nord/api/metrics.d.ts +0 -67
  50. package/dist/nord/api/metrics.js +0 -229
  51. package/dist/nord/api/queries.d.ts +0 -46
  52. package/dist/nord/api/queries.js +0 -109
  53. package/dist/nord/api/triggers.d.ts +0 -7
  54. package/dist/nord/api/triggers.js +0 -38
  55. package/dist/nord/client/Nord.d.ts +0 -396
  56. package/dist/nord/client/Nord.js +0 -747
  57. package/dist/nord/client/NordAdmin.d.ts +0 -259
  58. package/dist/nord/client/NordAdmin.js +0 -395
  59. package/dist/nord/client/NordClient.d.ts +0 -33
  60. package/dist/nord/client/NordClient.js +0 -45
  61. package/dist/nord/client/NordUser.d.ts +0 -362
  62. package/dist/nord/client/NordUser.js +0 -781
  63. package/dist/nord/index.d.ts +0 -11
  64. package/dist/nord/index.js +0 -36
  65. package/dist/nord/models/Subscriber.d.ts +0 -37
  66. package/dist/nord/models/Subscriber.js +0 -25
  67. package/dist/nord/utils/NordError.d.ts +0 -35
  68. package/dist/nord/utils/NordError.js +0 -49
  69. package/src/actions.ts +0 -333
  70. package/src/client/Nord.ts +0 -934
  71. package/src/client/NordAdmin.ts +0 -484
  72. package/src/client/NordUser.ts +0 -1122
  73. package/src/const.ts +0 -34
  74. package/src/error.ts +0 -76
  75. package/src/gen/.gitkeep +0 -0
  76. package/src/gen/nord_pb.ts +0 -5053
  77. package/src/gen/openapi.ts +0 -2904
  78. package/src/index.ts +0 -11
  79. package/src/types.ts +0 -327
  80. package/src/utils.ts +0 -266
  81. package/src/websocket/NordWebSocketClient.ts +0 -316
  82. package/src/websocket/Subscriber.ts +0 -56
  83. package/src/websocket/events.ts +0 -31
  84. package/src/websocket/index.ts +0 -105
@@ -1,259 +0,0 @@
1
- import { PublicKey } from "@solana/web3.js";
2
- import * as proto from "../../gen/nord_pb";
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
- */
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;
72
- }
73
- /**
74
- * Administrative client capable of submitting privileged configuration actions.
75
- */
76
- export declare class NordAdmin {
77
- private readonly nord;
78
- private readonly admin;
79
- private readonly signFn;
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
- */
115
- private submitAction;
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<{
139
- actionId: bigint;
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
- */
148
- createMarket(params: CreateMarketParams): Promise<{
149
- actionId: bigint;
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
- */
162
- pythSetWormholeGuardians(params: PythSetWormholeGuardiansParams): Promise<{
163
- actionId: bigint;
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
- */
176
- pythSetSymbolFeed(params: PythSetSymbolFeedParams): Promise<{
177
- actionId: bigint;
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
- */
185
- pause(): Promise<{
186
- actionId: bigint;
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
- */
194
- unpause(): Promise<{
195
- actionId: bigint;
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
- */
204
- freezeMarket(params: FreezeMarketParams): Promise<{
205
- actionId: bigint;
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
- */
214
- unfreezeMarket(params: UnfreezeMarketParams): Promise<{
215
- actionId: bigint;
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>;
259
- }
@@ -1,395 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.NordAdmin = exports.AclRole = void 0;
37
- const protobuf_1 = require("@bufbuild/protobuf");
38
- const proto = __importStar(require("../../gen/nord_pb"));
39
- const utils_1 = require("../../utils");
40
- const actions_1 = require("../api/actions");
41
- const NordError_1 = require("../utils/NordError");
42
- // NOTE: keep in sync with `acl.rs`.
43
- // NOTE: don't forget `number` as int is internally a u32.
44
- var AclRole;
45
- (function (AclRole) {
46
- AclRole[AclRole["FEE_MANAGER"] = 1] = "FEE_MANAGER";
47
- AclRole[AclRole["MARKET_MANAGER"] = 2] = "MARKET_MANAGER";
48
- // TODO: unsure about this?
49
- AclRole[AclRole["ADMIN"] = -2147483648] = "ADMIN";
50
- })(AclRole || (exports.AclRole = AclRole = {}));
51
- /**
52
- * Administrative client capable of submitting privileged configuration actions.
53
- */
54
- class NordAdmin {
55
- constructor({ nord, admin, signFn, }) {
56
- this.nord = nord;
57
- this.admin = admin;
58
- this.signFn = signFn;
59
- }
60
- /** Create a new admin client.
61
- *
62
- * @param nord - Nord instance
63
- * @param admin - The user that will be signing actions.
64
- * @param signFn - Function to sign messages with the admin's wallet.
65
- *
66
- * `signFn` must sign the _hex-encoded_ message, not the raw message itself, for
67
- * the purpose of being compatible with Solana wallets.
68
- *
69
- * In practice, you will do something along the lines of:
70
- *
71
- * ```typescript
72
- * (x) => wallet.signMessage(new TextEncoder().encode(x.toHex()));
73
- * ```
74
- *
75
- * For a software signing key, this might look more like:
76
- *
77
- * ```typescript
78
- * (x) => nacl.sign.detached(new TextEncoder().encode(x.toHex()), sk);
79
- * ``
80
- *
81
- * where `nacl` is the tweetnacl library.
82
- */
83
- static new({ nord, admin, signFn, }) {
84
- return new NordAdmin({
85
- nord,
86
- admin,
87
- signFn,
88
- });
89
- }
90
- /**
91
- * Submit an action and append the admin signature before sending it to Nord.
92
- *
93
- * @param kind - Action payload describing the admin request
94
- * @throws {NordError} If signing or submission fails
95
- */
96
- async submitAction(kind) {
97
- const timestamp = await this.nord.getTimestamp();
98
- const action = (0, actions_1.createAction)(timestamp, 0, kind);
99
- return (0, actions_1.sendAction)(this.nord.webServerUrl, async (xs) => {
100
- const signature = await this.signFn(xs);
101
- if (signature.length !== 64) {
102
- throw new NordError_1.NordError("invalid signature length; must be 64 bytes");
103
- }
104
- return Uint8Array.from([...xs, ...signature]);
105
- }, action);
106
- }
107
- /** Set acl permissions for a given user.
108
- *
109
- * If all roles are removed, the user is removed from the acl.
110
- *
111
- * @param target - User to update.
112
- * @param addRoles - Roles to add to the user.
113
- * @param removeRoles - Reles to remove from the user.
114
- */
115
- async updateAcl({ target, addRoles, removeRoles, }) {
116
- const allRoles = addRoles.concat(removeRoles);
117
- if (allRoles.length !== new Set(allRoles).size) {
118
- throw new NordError_1.NordError("duplicate roles in acl update; must be unique");
119
- }
120
- let mask = 0;
121
- let values = 0;
122
- for (const role of allRoles) {
123
- mask |= role;
124
- }
125
- for (const role of addRoles) {
126
- values |= role;
127
- }
128
- const receipt = await this.submitAction({
129
- case: "updateAcl",
130
- value: (0, protobuf_1.create)(proto.Action_UpdateAclSchema, {
131
- aclPubkey: this.admin.toBytes(),
132
- targetPubkey: target.toBytes(),
133
- rolesValue: values,
134
- rolesMask: mask,
135
- }),
136
- });
137
- (0, actions_1.expectReceiptKind)(receipt, "aclUpdated", "update acl");
138
- return { ...receipt.kind.value, actionId: receipt.actionId };
139
- }
140
- /**
141
- * Register a new token that can be listed on Nord.
142
- *
143
- * @param params - Token configuration values
144
- * @returns Action identifier and resulting token metadata
145
- * @throws {NordError} If the action submission fails
146
- */
147
- async createToken({ tokenDecimals, weightBps, viewSymbol, oracleSymbol, mintAddr, }) {
148
- const receipt = await this.submitAction({
149
- case: "createToken",
150
- value: (0, protobuf_1.create)(proto.Action_CreateTokenSchema, {
151
- aclPubkey: this.admin.toBytes(),
152
- tokenDecimals,
153
- weightBps,
154
- viewSymbol,
155
- oracleSymbol,
156
- solAddr: mintAddr.toBytes(),
157
- }),
158
- });
159
- (0, actions_1.expectReceiptKind)(receipt, "insertTokenResult", "create token");
160
- return { actionId: receipt.actionId, ...receipt.kind.value };
161
- }
162
- /**
163
- * Open a new market with the provided trading parameters.
164
- *
165
- * @param params - Market configuration to apply
166
- * @returns Action identifier and resulting market metadata
167
- * @throws {NordError} If the action submission fails
168
- */
169
- async createMarket(params) {
170
- const receipt = await this.submitAction({
171
- case: "createMarket",
172
- value: (0, protobuf_1.create)(proto.Action_CreateMarketSchema, {
173
- aclPubkey: this.admin.toBytes(),
174
- sizeDecimals: params.sizeDecimals,
175
- priceDecimals: params.priceDecimals,
176
- imfBps: params.imfBps,
177
- cmfBps: params.cmfBps,
178
- mmfBps: params.mmfBps,
179
- marketType: params.marketType,
180
- viewSymbol: params.viewSymbol,
181
- oracleSymbol: params.oracleSymbol,
182
- baseTokenId: params.baseTokenId,
183
- }),
184
- });
185
- (0, actions_1.expectReceiptKind)(receipt, "insertMarketResult", "create market");
186
- return { actionId: receipt.actionId, ...receipt.kind.value };
187
- }
188
- /**
189
- * Update the Pyth guardian set used for verifying Wormhole messages.
190
- *
191
- * Each address must decode from a 20-byte hex string (with or without a
192
- * leading `0x` prefix). The engine validates the supplied guardian set index
193
- * before applying the update.
194
- *
195
- * @param params - Guardian set index and guardian addresses
196
- * @returns Action identifier and guardian update receipt
197
- * @throws {NordError} If the action submission fails
198
- */
199
- async pythSetWormholeGuardians(params) {
200
- const addresses = params.addresses.map((address) => {
201
- try {
202
- const decoded = (0, utils_1.decodeHex)(address);
203
- if (decoded.length !== 20) {
204
- throw new Error("guardian address must be 20 bytes");
205
- }
206
- return decoded;
207
- }
208
- catch (e) {
209
- throw new NordError_1.NordError("invalid guardian address; must be a 20 byte hex address", { cause: e });
210
- }
211
- });
212
- const receipt = await this.submitAction({
213
- case: "pythSetWormholeGuardians",
214
- value: (0, protobuf_1.create)(proto.Action_PythSetWormholeGuardiansSchema, {
215
- aclPubkey: this.admin.toBytes(),
216
- guardianSetIndex: params.guardianSetIndex,
217
- addresses,
218
- }),
219
- });
220
- (0, actions_1.expectReceiptKind)(receipt, "updateGuardianSetResult", "update wormhole guardians");
221
- return { actionId: receipt.actionId, ...receipt.kind.value };
222
- }
223
- /**
224
- * Link an oracle symbol to a specific Pyth price feed.
225
- *
226
- * The price feed identifier must decode to 32 bytes (with or without a
227
- * leading `0x` prefix). Use this call to create or update the mapping used
228
- * by the oracle integration.
229
- *
230
- * @param params - Oracle symbol and price feed identifier
231
- * @returns Action identifier and symbol feed receipt
232
- * @throws {NordError} If the action submission fails
233
- */
234
- async pythSetSymbolFeed(params) {
235
- let priceFeedId;
236
- try {
237
- priceFeedId = (0, utils_1.decodeHex)(params.priceFeedId);
238
- if (priceFeedId.length !== 32) {
239
- throw new Error("price feed id must be 32 bytes");
240
- }
241
- }
242
- catch (e) {
243
- throw new NordError_1.NordError("invalid price feed id; must be a 32 byte hex id", {
244
- cause: e,
245
- });
246
- }
247
- const receipt = await this.submitAction({
248
- case: "pythSetSymbolFeed",
249
- value: (0, protobuf_1.create)(proto.Action_PythSetSymbolFeedSchema, {
250
- aclPubkey: this.admin.toBytes(),
251
- oracleSymbol: params.oracleSymbol,
252
- priceFeedId,
253
- }),
254
- });
255
- (0, actions_1.expectReceiptKind)(receipt, "oracleSymbolFeedResult", "set symbol feed");
256
- return { actionId: receipt.actionId, ...receipt.kind.value };
257
- }
258
- /**
259
- * Pause all trading activity on the exchange.
260
- *
261
- * @returns Action identifier confirming the pause
262
- * @throws {NordError} If the action submission fails
263
- */
264
- async pause() {
265
- const receipt = await this.submitAction({
266
- case: "pause",
267
- value: (0, protobuf_1.create)(proto.Action_PauseSchema, {
268
- aclPubkey: this.admin.toBytes(),
269
- }),
270
- });
271
- (0, actions_1.expectReceiptKind)(receipt, "paused", "pause");
272
- return { actionId: receipt.actionId };
273
- }
274
- /**
275
- * Resume trading activity after a pause.
276
- *
277
- * @returns Action identifier confirming the unpause
278
- * @throws {NordError} If the action submission fails
279
- */
280
- async unpause() {
281
- const receipt = await this.submitAction({
282
- case: "unpause",
283
- value: (0, protobuf_1.create)(proto.Action_UnpauseSchema, {
284
- aclPubkey: this.admin.toBytes(),
285
- }),
286
- });
287
- (0, actions_1.expectReceiptKind)(receipt, "unpaused", "unpause");
288
- return { actionId: receipt.actionId };
289
- }
290
- /**
291
- * Freeze an individual market, preventing new trades and orders.
292
- *
293
- * @param params - Target market identifier
294
- * @returns Action identifier and freeze receipt
295
- * @throws {NordError} If the action submission fails
296
- */
297
- async freezeMarket(params) {
298
- const receipt = await this.submitAction({
299
- case: "freezeMarket",
300
- value: (0, protobuf_1.create)(proto.Action_FreezeMarketSchema, {
301
- marketId: params.marketId,
302
- aclPubkey: this.admin.toBytes(),
303
- }),
304
- });
305
- (0, actions_1.expectReceiptKind)(receipt, "marketFreezeUpdated", "freeze market");
306
- return { actionId: receipt.actionId, ...receipt.kind.value };
307
- }
308
- /**
309
- * Unfreeze a market that was previously halted.
310
- *
311
- * @param params - Target market identifier
312
- * @returns Action identifier and freeze receipt
313
- * @throws {NordError} If the action submission fails
314
- */
315
- async unfreezeMarket(params) {
316
- const receipt = await this.submitAction({
317
- case: "unfreezeMarket",
318
- value: (0, protobuf_1.create)(proto.Action_UnfreezeMarketSchema, {
319
- marketId: params.marketId,
320
- aclPubkey: this.admin.toBytes(),
321
- }),
322
- });
323
- (0, actions_1.expectReceiptKind)(receipt, "marketFreezeUpdated", "unfreeze market");
324
- return { actionId: receipt.actionId, ...receipt.kind.value };
325
- }
326
- /**
327
- * Append a new fee tier to the account bracket configuration.
328
- *
329
- * - The engine supports at most 16 tiers (ids 0–15). Tier 0 is reserved for
330
- * the default Nord fees; use `updateFeeTier` if you need to change it.
331
- * - The first appended tier receives id 1, and subsequent tiers increment the id.
332
- *
333
- * @param params - Fee tier configuration to insert
334
- * @returns Action identifier and fee tier addition receipt
335
- * @throws {NordError} If the action submission fails or the new tier exceeds the maximum range (0-15).
336
- */
337
- async addFeeTier(params) {
338
- const receipt = await this.submitAction({
339
- case: "addFeeTier",
340
- value: (0, protobuf_1.create)(proto.Action_AddFeeTierSchema, {
341
- aclPubkey: this.admin.toBytes(),
342
- config: (0, protobuf_1.create)(proto.FeeTierConfigSchema, params.config),
343
- }),
344
- });
345
- (0, actions_1.expectReceiptKind)(receipt, "feeTierAdded", "add fee tier");
346
- return { actionId: receipt.actionId, ...receipt.kind.value };
347
- }
348
- /**
349
- * Update an existing fee tier with new maker/taker rates.
350
- *
351
- * Tier identifiers must already exist; attempting to update a missing tier
352
- * causes the action to fail.
353
- *
354
- * @param params - Fee tier identifier and updated configuration
355
- * @returns Action identifier and fee tier update receipt
356
- * @throws {NordError} If the action submission fails or the tier ID exceeds the configured range.
357
- */
358
- async updateFeeTier(params) {
359
- const receipt = await this.submitAction({
360
- case: "updateFeeTier",
361
- value: (0, protobuf_1.create)(proto.Action_UpdateFeeTierSchema, {
362
- aclPubkey: this.admin.toBytes(),
363
- id: params.tierId,
364
- config: (0, protobuf_1.create)(proto.FeeTierConfigSchema, params.config),
365
- }),
366
- });
367
- (0, actions_1.expectReceiptKind)(receipt, "feeTierUpdated", "update fee tier");
368
- return { actionId: receipt.actionId, ...receipt.kind.value };
369
- }
370
- /**
371
- * Assign a fee tier to one or more accounts.
372
- *
373
- * The tier id must be within the configured range (0–15). Every account starts
374
- * on tier 0; assigning it to another tier requires that tier to exist already.
375
- * Invalid account ids or tier ids cause the action to fail.
376
- *
377
- * @param accounts - Account IDs to update
378
- * @param tierId - Target fee tier identifier
379
- * @returns Action identifier and accounts-tier receipt
380
- * @throws {NordError} If the tier id exceeds the configured range or an account id is invalid.
381
- */
382
- async updateAccountsTier(accounts, tierId) {
383
- const receipt = await this.submitAction({
384
- case: "updateAccountsTier",
385
- value: (0, protobuf_1.create)(proto.Action_UpdateAccountsTierSchema, {
386
- aclPubkey: this.admin.toBytes(),
387
- accounts,
388
- tierId,
389
- }),
390
- });
391
- (0, actions_1.expectReceiptKind)(receipt, "accountsTierUpdated", "update accounts tier");
392
- return { actionId: receipt.actionId, ...receipt.kind.value };
393
- }
394
- }
395
- exports.NordAdmin = NordAdmin;
@@ -1,33 +0,0 @@
1
- import { Connection, PublicKey } from "@solana/web3.js";
2
- import type { Transaction } from "@solana/web3.js";
3
- import * as proto from "../../gen/nord_pb";
4
- import { Nord } from "./Nord";
5
- export interface NordClientParams {
6
- nord: Nord;
7
- address: PublicKey;
8
- walletSignFn: (message: Uint8Array | string) => Promise<Uint8Array>;
9
- sessionSignFn: (message: Uint8Array) => Promise<Uint8Array>;
10
- transactionSignFn: <T extends Transaction>(tx: T) => Promise<T>;
11
- connection?: Connection;
12
- sessionId?: bigint;
13
- sessionPubKey: Uint8Array;
14
- publicKey: PublicKey;
15
- }
16
- export declare abstract class NordClient {
17
- readonly nord: Nord;
18
- readonly address: PublicKey;
19
- readonly walletSignFn: (message: Uint8Array | string) => Promise<Uint8Array>;
20
- readonly sessionSignFn: (message: Uint8Array) => Promise<Uint8Array>;
21
- readonly transactionSignFn: <T extends Transaction>(tx: T) => Promise<T>;
22
- connection: Connection;
23
- sessionId?: bigint;
24
- sessionPubKey: Uint8Array;
25
- publicKey: PublicKey;
26
- lastTs: number;
27
- protected actionNonce: number;
28
- protected constructor(params: NordClientParams);
29
- protected submitSignedAction(kind: proto.Action["kind"], makeSignedMessage: (message: Uint8Array) => Promise<Uint8Array>): Promise<proto.Receipt>;
30
- protected nextActionNonce(): number;
31
- protected cloneClientState(target: NordClient): void;
32
- getSolanaPublicKey(): PublicKey;
33
- }