@deriverse/kit 1.0.38 → 1.0.41

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 (59) hide show
  1. package/dist/auto_buffer.d.ts +0 -2
  2. package/dist/auto_data.d.ts +0 -2
  3. package/dist/constants.d.ts +12 -0
  4. package/dist/constants.js +26 -0
  5. package/dist/engine/account-helpers.d.ts +59 -0
  6. package/dist/engine/account-helpers.js +177 -0
  7. package/dist/engine/account-helpers.test.d.ts +1 -0
  8. package/dist/engine/account-helpers.test.js +199 -0
  9. package/dist/engine/client-queries.d.ts +36 -0
  10. package/dist/engine/client-queries.js +498 -0
  11. package/dist/engine/client-queries.test.d.ts +1 -0
  12. package/dist/engine/client-queries.test.js +341 -0
  13. package/dist/engine/context-builders.d.ts +16 -0
  14. package/dist/engine/context-builders.js +158 -0
  15. package/dist/engine/context-builders.test.d.ts +1 -0
  16. package/dist/engine/context-builders.test.js +156 -0
  17. package/dist/engine/index.d.ts +101 -0
  18. package/dist/engine/index.js +745 -0
  19. package/dist/engine/index.test.d.ts +1 -0
  20. package/dist/engine/index.test.js +663 -0
  21. package/dist/engine/logs-decoder.d.ts +18 -0
  22. package/dist/engine/logs-decoder.js +414 -0
  23. package/dist/engine/logs-decoder.test.d.ts +1 -0
  24. package/dist/engine/logs-decoder.test.js +836 -0
  25. package/dist/engine/perp-instructions.d.ts +68 -0
  26. package/dist/engine/perp-instructions.js +478 -0
  27. package/dist/engine/perp-instructions.test.d.ts +1 -0
  28. package/dist/engine/perp-instructions.test.js +296 -0
  29. package/dist/engine/spot-instructions.d.ts +52 -0
  30. package/dist/engine/spot-instructions.js +376 -0
  31. package/dist/engine/spot-instructions.test.d.ts +1 -0
  32. package/dist/engine/spot-instructions.test.js +221 -0
  33. package/dist/engine/utils.d.ts +23 -0
  34. package/dist/engine/utils.js +329 -0
  35. package/dist/engine/utils.test.d.ts +1 -0
  36. package/dist/engine/utils.test.js +120 -0
  37. package/dist/index.d.ts +6 -247
  38. package/dist/index.js +14 -2925
  39. package/dist/instruction_models.d.ts +0 -2
  40. package/dist/instruction_models.js +39 -40
  41. package/dist/logs_models.d.ts +0 -2
  42. package/dist/types/engine-args.d.ts +32 -0
  43. package/dist/types/engine-args.js +2 -0
  44. package/dist/types/enums.d.ts +43 -0
  45. package/dist/{types.js → types/enums.js} +3 -5
  46. package/dist/types/index.d.ts +8 -0
  47. package/dist/types/index.js +38 -0
  48. package/dist/types/log-message.d.ts +2 -0
  49. package/dist/types/log-message.js +2 -0
  50. package/dist/types/responses.d.ts +248 -0
  51. package/dist/types/responses.js +2 -0
  52. package/dist/types/schemas.d.ts +165 -0
  53. package/dist/types/schemas.js +254 -0
  54. package/dist/types/schemas.test.d.ts +1 -0
  55. package/dist/types/schemas.test.js +94 -0
  56. package/dist/utils.d.ts +0 -0
  57. package/dist/utils.js +1 -0
  58. package/package.json +26 -6
  59. package/dist/types.d.ts +0 -565
@@ -0,0 +1,296 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const vitest_1 = require("vitest");
13
+ const kit_1 = require("@solana/kit");
14
+ const perp_instructions_1 = require("./perp-instructions");
15
+ const structure_models_1 = require("../structure_models");
16
+ vitest_1.vi.mock('./account-helpers', () => ({
17
+ getAccountByTag: vitest_1.vi.fn().mockResolvedValue('MockAccountByTag11111111111111'),
18
+ getInstrAccountByTag: vitest_1.vi.fn().mockResolvedValue('MockInstrAccount1111111111111'),
19
+ getTokenAccount: vitest_1.vi.fn().mockResolvedValue('MockTokenAccount111111111111111'),
20
+ getTokenId: vitest_1.vi.fn().mockResolvedValue(1),
21
+ getInstrId: vitest_1.vi.fn().mockResolvedValue(1),
22
+ findClientPrimaryAccount: vitest_1.vi.fn().mockResolvedValue('MockClientPrimary11111111111'),
23
+ findClientCommunityAccount: vitest_1.vi.fn().mockResolvedValue('MockClientCommunity111111111'),
24
+ }));
25
+ vitest_1.vi.mock('./context-builders', () => ({
26
+ getSpotContext: vitest_1.vi.fn().mockResolvedValue([]),
27
+ getSpotCandles: vitest_1.vi.fn().mockResolvedValue([]),
28
+ getPerpContext: vitest_1.vi.fn().mockResolvedValue([
29
+ { address: 'PerpCtx1111111111111111111111111', role: kit_1.AccountRole.WRITABLE },
30
+ { address: 'PerpCtx2222222222222222222222222', role: kit_1.AccountRole.WRITABLE },
31
+ { address: 'PerpCtx3333333333333333333333333', role: kit_1.AccountRole.WRITABLE },
32
+ { address: 'PerpCtx4444444444444444444444444', role: kit_1.AccountRole.WRITABLE },
33
+ { address: 'PerpCtx5555555555555555555555555', role: kit_1.AccountRole.WRITABLE },
34
+ { address: 'PerpCtx6666666666666666666666666', role: kit_1.AccountRole.WRITABLE },
35
+ { address: 'PerpCtx7777777777777777777777777', role: kit_1.AccountRole.WRITABLE },
36
+ { address: 'PerpCtx8888888888888888888888888', role: kit_1.AccountRole.WRITABLE },
37
+ { address: 'PerpCtx9999999999999999999999999', role: kit_1.AccountRole.WRITABLE },
38
+ { address: 'PerpCtxAAAAAAAAAAAAAAAAAAAAAAAAA', role: kit_1.AccountRole.WRITABLE },
39
+ { address: 'PerpCtxBBBBBBBBBBBBBBBBBBBBBBBBB', role: kit_1.AccountRole.WRITABLE },
40
+ { address: 'PerpCtxCCCCCCCCCCCCCCCCCCCCCCCCC', role: kit_1.AccountRole.WRITABLE },
41
+ { address: 'PerpCtxDDDDDDDDDDDDDDDDDDDDDDDDD', role: kit_1.AccountRole.WRITABLE },
42
+ { address: 'PerpCtxEEEEEEEEEEEEEEEEEEEEEEEEE', role: kit_1.AccountRole.WRITABLE },
43
+ { address: 'PerpCtxFFFFFFFFFFFFFFFFFFFFFFFFF', role: kit_1.AccountRole.WRITABLE },
44
+ ]),
45
+ }));
46
+ vitest_1.vi.mock('./utils', () => ({
47
+ findAssociatedTokenAddress: vitest_1.vi.fn().mockResolvedValue('MockATA1111111111111111111111111'),
48
+ getLookupTableAddress: vitest_1.vi.fn().mockResolvedValue('MockLUT1111111111111111111111111'),
49
+ perpSeatReserve: vitest_1.vi.fn().mockReturnValue(100),
50
+ tokenDec: vitest_1.vi.fn().mockReturnValue(1000000000), // 10^9
51
+ }));
52
+ // Helper to create a mock token
53
+ function createMockToken(id, decimals = 9) {
54
+ const token = new structure_models_1.TokenStateModel();
55
+ token.id = id;
56
+ token.mask = decimals; // decimals stored in lower byte
57
+ token.address = `MockToken${id}${'1'.repeat(32 - 10 - id.toString().length)}`;
58
+ token.programAddress = `MockProgramAddress${id}${'1'.repeat(32 - 19 - id.toString().length)}`;
59
+ return token;
60
+ }
61
+ // Helper to create a mock instrument
62
+ function createMockInstrument(instrId, assetTokenId = 1, crncyTokenId = 0) {
63
+ const header = new structure_models_1.InstrAccountHeaderModel();
64
+ header.instrId = instrId;
65
+ header.assetTokenId = assetTokenId;
66
+ header.crncyTokenId = crncyTokenId;
67
+ header.mapsAddress = '11111111111111111111111111111111';
68
+ header.perpMapsAddress = '22222222222222222222222222222222';
69
+ header.perpClientsCount = 10;
70
+ header.mask = 0;
71
+ return {
72
+ address: `MockInstr${instrId}${'1'.repeat(32 - 9 - instrId.toString().length)}`,
73
+ header,
74
+ spotBids: [],
75
+ spotAsks: [],
76
+ perpBids: [],
77
+ perpAsks: [],
78
+ };
79
+ }
80
+ // Helper to create a mock root state model
81
+ function createMockRootStateModel() {
82
+ const model = new structure_models_1.RootStateModel();
83
+ model.tokensCount = 5;
84
+ model.instrCount = 3;
85
+ return model;
86
+ }
87
+ // Helper to create a mock context
88
+ function createMockPerpContext(overrides = {}) {
89
+ const tokens = new Map();
90
+ tokens.set(0, createMockToken(0, 9)); // DRVS token
91
+ tokens.set(1, createMockToken(1, 9)); // SOL-like token
92
+ const instruments = new Map();
93
+ instruments.set(1, createMockInstrument(1, 1, 0));
94
+ return Object.assign({ rpc: {}, programId: 'DRVSvY68xD69Zwwgj9N8hRBu2eXvEzy8eejiVLNYGLti', version: 1, commitment: 'confirmed', drvsAuthority: 'DRVStQsAKhF8gpz1xLzWyk2Q1HKKF3g21tknXtHpVLab', instruments,
95
+ tokens, rootStateModel: createMockRootStateModel(), uiNumbers: true, signer: 'SignerAddress111111111111111111', rootAccount: 'RootAccount1111111111111111111111', clientPrimaryAccount: 'ClientPrimary11111111111111111', clientCommunityAccount: 'ClientCommunity111111111111111', refClientPrimaryAccount: null, refClientCommunityAccount: null }, overrides);
96
+ }
97
+ (0, vitest_1.describe)('perp instruction builders', () => {
98
+ (0, vitest_1.beforeEach)(() => {
99
+ vitest_1.vi.clearAllMocks();
100
+ });
101
+ (0, vitest_1.describe)('buildPerpDepositInstruction', () => {
102
+ (0, vitest_1.it)('builds perp deposit instruction', () => __awaiter(void 0, void 0, void 0, function* () {
103
+ const ctx = createMockPerpContext();
104
+ const instr = ctx.instruments.get(1);
105
+ const args = { instrId: 1, amount: 100 };
106
+ const instruction = yield (0, perp_instructions_1.buildPerpDepositInstruction)(ctx, args, instr);
107
+ (0, vitest_1.expect)(instruction).toBeDefined();
108
+ (0, vitest_1.expect)(instruction.programAddress).toBe(ctx.programId);
109
+ (0, vitest_1.expect)(instruction.accounts).toBeDefined();
110
+ (0, vitest_1.expect)(instruction.accounts.length).toBeGreaterThan(0);
111
+ (0, vitest_1.expect)(instruction.data).toBeInstanceOf(Uint8Array);
112
+ (0, vitest_1.expect)(instruction.data[0]).toBe(11); // perpDeposit instruction tag
113
+ }));
114
+ (0, vitest_1.it)('converts amount with uiNumbers', () => __awaiter(void 0, void 0, void 0, function* () {
115
+ const ctx = createMockPerpContext({ uiNumbers: true });
116
+ const instr = ctx.instruments.get(1);
117
+ const args = { instrId: 1, amount: 1 };
118
+ const instruction = yield (0, perp_instructions_1.buildPerpDepositInstruction)(ctx, args, instr);
119
+ (0, vitest_1.expect)(instruction).toBeDefined();
120
+ // Amount should be multiplied by 10^9 for token with 9 decimals
121
+ }));
122
+ });
123
+ (0, vitest_1.describe)('buildNewPerpOrderInstruction', () => {
124
+ (0, vitest_1.it)('builds new perp order instruction', () => __awaiter(void 0, void 0, void 0, function* () {
125
+ const ctx = createMockPerpContext();
126
+ const instr = ctx.instruments.get(1);
127
+ const args = { instrId: 1, side: 0, price: 100, qty: 10 };
128
+ const instruction = yield (0, perp_instructions_1.buildNewPerpOrderInstruction)(ctx, args, instr);
129
+ (0, vitest_1.expect)(instruction).toBeDefined();
130
+ (0, vitest_1.expect)(instruction.programAddress).toBe(ctx.programId);
131
+ (0, vitest_1.expect)(instruction.data[0]).toBe(19); // newPerpOrder instruction tag
132
+ }));
133
+ (0, vitest_1.it)('includes IOC flag when provided', () => __awaiter(void 0, void 0, void 0, function* () {
134
+ const ctx = createMockPerpContext();
135
+ const instr = ctx.instruments.get(1);
136
+ const args = { instrId: 1, side: 1, price: 100, qty: 10, ioc: 1 };
137
+ const instruction = yield (0, perp_instructions_1.buildNewPerpOrderInstruction)(ctx, args, instr);
138
+ (0, vitest_1.expect)(instruction).toBeDefined();
139
+ (0, vitest_1.expect)(instruction.data[1]).toBe(1); // ioc flag
140
+ }));
141
+ (0, vitest_1.it)('includes leverage when provided', () => __awaiter(void 0, void 0, void 0, function* () {
142
+ const ctx = createMockPerpContext();
143
+ const instr = ctx.instruments.get(1);
144
+ const args = { instrId: 1, side: 0, price: 100, qty: 10, leverage: 5 };
145
+ const instruction = yield (0, perp_instructions_1.buildNewPerpOrderInstruction)(ctx, args, instr);
146
+ (0, vitest_1.expect)(instruction).toBeDefined();
147
+ (0, vitest_1.expect)(instruction.data[2]).toBe(5); // leverage
148
+ }));
149
+ (0, vitest_1.it)('includes ref accounts when provided', () => __awaiter(void 0, void 0, void 0, function* () {
150
+ const ctx = createMockPerpContext({
151
+ refClientPrimaryAccount: 'RefPrimary1111111111111111111111',
152
+ refClientCommunityAccount: 'RefCommunity11111111111111111111',
153
+ });
154
+ const instr = ctx.instruments.get(1);
155
+ const args = { instrId: 1, side: 0, price: 100, qty: 10 };
156
+ const instruction = yield (0, perp_instructions_1.buildNewPerpOrderInstruction)(ctx, args, instr);
157
+ (0, vitest_1.expect)(instruction.accounts.length).toBeGreaterThan(20);
158
+ }));
159
+ });
160
+ (0, vitest_1.describe)('buildPerpOrderCancelInstruction', () => {
161
+ (0, vitest_1.it)('builds perp order cancel instruction', () => __awaiter(void 0, void 0, void 0, function* () {
162
+ const ctx = createMockPerpContext();
163
+ const instr = ctx.instruments.get(1);
164
+ const args = { instrId: 1, side: 0, orderId: 12345 };
165
+ const instruction = yield (0, perp_instructions_1.buildPerpOrderCancelInstruction)(ctx, args, instr);
166
+ (0, vitest_1.expect)(instruction).toBeDefined();
167
+ (0, vitest_1.expect)(instruction.programAddress).toBe(ctx.programId);
168
+ (0, vitest_1.expect)(instruction.data[0]).toBe(30); // perpOrderCancel instruction tag
169
+ }));
170
+ });
171
+ (0, vitest_1.describe)('buildPerpMassCancelInstruction', () => {
172
+ (0, vitest_1.it)('builds perp mass cancel instruction', () => __awaiter(void 0, void 0, void 0, function* () {
173
+ const ctx = createMockPerpContext();
174
+ const instr = ctx.instruments.get(1);
175
+ const args = { instrId: 1 };
176
+ const instruction = yield (0, perp_instructions_1.buildPerpMassCancelInstruction)(ctx, args, instr);
177
+ (0, vitest_1.expect)(instruction).toBeDefined();
178
+ (0, vitest_1.expect)(instruction.programAddress).toBe(ctx.programId);
179
+ (0, vitest_1.expect)(instruction.data[0]).toBe(36); // perpMassCancel instruction tag
180
+ }));
181
+ });
182
+ (0, vitest_1.describe)('buildPerpChangeLeverageInstruction', () => {
183
+ (0, vitest_1.it)('builds perp change leverage instruction', () => __awaiter(void 0, void 0, void 0, function* () {
184
+ const ctx = createMockPerpContext();
185
+ const instr = ctx.instruments.get(1);
186
+ const args = { instrId: 1, leverage: 10 };
187
+ const instruction = yield (0, perp_instructions_1.buildPerpChangeLeverageInstruction)(ctx, args, instr);
188
+ (0, vitest_1.expect)(instruction).toBeDefined();
189
+ (0, vitest_1.expect)(instruction.programAddress).toBe(ctx.programId);
190
+ (0, vitest_1.expect)(instruction.data[0]).toBe(37); // perpChangeLeverage instruction tag
191
+ }));
192
+ });
193
+ (0, vitest_1.describe)('buildNewRefLinkInstruction', () => {
194
+ (0, vitest_1.it)('builds new ref link instruction', () => __awaiter(void 0, void 0, void 0, function* () {
195
+ const ctx = createMockPerpContext();
196
+ const instruction = yield (0, perp_instructions_1.buildNewRefLinkInstruction)(ctx);
197
+ (0, vitest_1.expect)(instruction).toBeDefined();
198
+ (0, vitest_1.expect)(instruction.programAddress).toBe(ctx.programId);
199
+ (0, vitest_1.expect)(instruction.accounts.length).toBe(3);
200
+ (0, vitest_1.expect)(instruction.data[0]).toBe(45); // newRefLink instruction tag
201
+ }));
202
+ });
203
+ (0, vitest_1.describe)('buildPerpBuySeatInstruction', () => {
204
+ (0, vitest_1.it)('builds perp buy seat instruction', () => __awaiter(void 0, void 0, void 0, function* () {
205
+ const ctx = createMockPerpContext();
206
+ const instr = ctx.instruments.get(1);
207
+ const args = { instrId: 1, amount: 100 };
208
+ const instruction = yield (0, perp_instructions_1.buildPerpBuySeatInstruction)(ctx, args, instr);
209
+ (0, vitest_1.expect)(instruction).toBeDefined();
210
+ (0, vitest_1.expect)(instruction.programAddress).toBe(ctx.programId);
211
+ (0, vitest_1.expect)(instruction.data[0]).toBe(47); // buyMarketSeat instruction tag
212
+ }));
213
+ (0, vitest_1.it)('handles slippage parameter', () => __awaiter(void 0, void 0, void 0, function* () {
214
+ const ctx = createMockPerpContext();
215
+ const instr = ctx.instruments.get(1);
216
+ const args = { instrId: 1, amount: 100, slippage: 0.05 };
217
+ const instruction = yield (0, perp_instructions_1.buildPerpBuySeatInstruction)(ctx, args, instr);
218
+ (0, vitest_1.expect)(instruction).toBeDefined();
219
+ (0, vitest_1.expect)(instruction.data[0]).toBe(47);
220
+ }));
221
+ (0, vitest_1.it)('defaults slippage to 0 when not provided', () => __awaiter(void 0, void 0, void 0, function* () {
222
+ const ctx = createMockPerpContext();
223
+ const instr = ctx.instruments.get(1);
224
+ const args = { instrId: 1, amount: 50 };
225
+ const instruction = yield (0, perp_instructions_1.buildPerpBuySeatInstruction)(ctx, args, instr);
226
+ (0, vitest_1.expect)(instruction).toBeDefined();
227
+ }));
228
+ });
229
+ (0, vitest_1.describe)('buildPerpSellSeatInstruction', () => {
230
+ (0, vitest_1.it)('builds perp sell seat instruction', () => __awaiter(void 0, void 0, void 0, function* () {
231
+ const ctx = createMockPerpContext();
232
+ const instr = ctx.instruments.get(1);
233
+ const args = { instrId: 1 };
234
+ const instruction = yield (0, perp_instructions_1.buildPerpSellSeatInstruction)(ctx, args, instr);
235
+ (0, vitest_1.expect)(instruction).toBeDefined();
236
+ (0, vitest_1.expect)(instruction.programAddress).toBe(ctx.programId);
237
+ (0, vitest_1.expect)(instruction.data[0]).toBe(48); // sellMarketSeat instruction tag
238
+ }));
239
+ (0, vitest_1.it)('handles slippage parameter', () => __awaiter(void 0, void 0, void 0, function* () {
240
+ const ctx = createMockPerpContext();
241
+ const instr = ctx.instruments.get(1);
242
+ const args = { instrId: 1, slippage: 0.1 };
243
+ const instruction = yield (0, perp_instructions_1.buildPerpSellSeatInstruction)(ctx, args, instr);
244
+ (0, vitest_1.expect)(instruction).toBeDefined();
245
+ (0, vitest_1.expect)(instruction.data[0]).toBe(48);
246
+ }));
247
+ });
248
+ (0, vitest_1.describe)('buildPerpQuotesReplaceInstruction', () => {
249
+ (0, vitest_1.it)('builds perp quotes replace instruction', () => __awaiter(void 0, void 0, void 0, function* () {
250
+ const ctx = createMockPerpContext();
251
+ const instr = ctx.instruments.get(1);
252
+ const args = {
253
+ instrId: 1,
254
+ newBidPrice: 99,
255
+ newBidQty: 10,
256
+ bidOrderIdToCancel: 12345,
257
+ newAskPrice: 101,
258
+ newAskQty: 10,
259
+ askOrderIdToCancel: 67890,
260
+ };
261
+ const instruction = yield (0, perp_instructions_1.buildPerpQuotesReplaceInstruction)(ctx, args, instr);
262
+ (0, vitest_1.expect)(instruction).toBeDefined();
263
+ (0, vitest_1.expect)(instruction.programAddress).toBe(ctx.programId);
264
+ (0, vitest_1.expect)(instruction.data[0]).toBe(42); // perpQuotesReplace instruction tag
265
+ }));
266
+ (0, vitest_1.it)('includes ref accounts when provided', () => __awaiter(void 0, void 0, void 0, function* () {
267
+ const ctx = createMockPerpContext({
268
+ refClientPrimaryAccount: 'RefPrimary1111111111111111111111',
269
+ refClientCommunityAccount: 'RefCommunity11111111111111111111',
270
+ });
271
+ const instr = ctx.instruments.get(1);
272
+ const args = {
273
+ instrId: 1,
274
+ newBidPrice: 99,
275
+ newBidQty: 10,
276
+ bidOrderIdToCancel: 12345,
277
+ newAskPrice: 101,
278
+ newAskQty: 10,
279
+ askOrderIdToCancel: 67890,
280
+ };
281
+ const instruction = yield (0, perp_instructions_1.buildPerpQuotesReplaceInstruction)(ctx, args, instr);
282
+ (0, vitest_1.expect)(instruction.accounts.length).toBeGreaterThan(18);
283
+ }));
284
+ });
285
+ (0, vitest_1.describe)('buildPerpStatisticsResetInstruction', () => {
286
+ (0, vitest_1.it)('builds perp statistics reset instruction', () => __awaiter(void 0, void 0, void 0, function* () {
287
+ const ctx = createMockPerpContext();
288
+ const instr = ctx.instruments.get(1);
289
+ const args = { instrId: 1 };
290
+ const instruction = yield (0, perp_instructions_1.buildPerpStatisticsResetInstruction)(ctx, args, instr);
291
+ (0, vitest_1.expect)(instruction).toBeDefined();
292
+ (0, vitest_1.expect)(instruction.programAddress).toBe(ctx.programId);
293
+ (0, vitest_1.expect)(instruction.data[0]).toBe(46); // perpStatisticsReset instruction tag
294
+ }));
295
+ });
296
+ });
@@ -0,0 +1,52 @@
1
+ import { Address } from '@solana/kit';
2
+ import { Instrument, DepositArgs, WithdrawArgs, SpotLpArgs, NewSpotOrderArgs, SpotQuotesReplaceArgs, SpotOrderCancelArgs, SpotMassCancelArgs, SwapArgs, Instruction } from '../types';
3
+ import { TokenStateModel } from '../structure_models';
4
+ import { AccountHelperContext } from './account-helpers';
5
+ /**
6
+ * Context needed for spot instruction builders
7
+ */
8
+ export interface SpotInstructionContext extends AccountHelperContext {
9
+ instruments: Map<number, Instrument>;
10
+ tokens: Map<number, TokenStateModel>;
11
+ uiNumbers: boolean;
12
+ signer: Address;
13
+ rootAccount: Address;
14
+ clientPrimaryAccount: Address;
15
+ clientCommunityAccount: Address;
16
+ refClientPrimaryAccount: Address | null;
17
+ refClientCommunityAccount: Address | null;
18
+ privateMode: boolean;
19
+ }
20
+ /**
21
+ * Build deposit instruction
22
+ */
23
+ declare function buildDepositInstruction(ctx: SpotInstructionContext, args: DepositArgs, exists: boolean, rpcGetSlot: () => Promise<bigint>): Promise<Instruction>;
24
+ /**
25
+ * Build withdraw instruction
26
+ */
27
+ declare function buildWithdrawInstruction(ctx: SpotInstructionContext, args: WithdrawArgs): Promise<Instruction>;
28
+ /**
29
+ * Build spot LP instruction
30
+ */
31
+ declare function buildSpotLpInstruction(ctx: SpotInstructionContext, args: SpotLpArgs, instr: Instrument): Promise<Instruction>;
32
+ /**
33
+ * Build new spot order instruction
34
+ */
35
+ declare function buildNewSpotOrderInstruction(ctx: SpotInstructionContext, args: NewSpotOrderArgs, instr: Instrument): Promise<Instruction>;
36
+ /**
37
+ * Build spot quotes replace instruction
38
+ */
39
+ declare function buildSpotQuotesReplaceInstruction(ctx: SpotInstructionContext, args: SpotQuotesReplaceArgs, instr: Instrument): Promise<Instruction>;
40
+ /**
41
+ * Build spot order cancel instruction
42
+ */
43
+ declare function buildSpotOrderCancelInstruction(ctx: SpotInstructionContext, args: SpotOrderCancelArgs, instr: Instrument): Promise<Instruction>;
44
+ /**
45
+ * Build spot mass cancel instruction
46
+ */
47
+ declare function buildSpotMassCancelInstruction(ctx: SpotInstructionContext, args: SpotMassCancelArgs, instr: Instrument): Promise<Instruction>;
48
+ /**
49
+ * Build swap instruction
50
+ */
51
+ declare function buildSwapInstruction(ctx: SpotInstructionContext, args: SwapArgs, instr: Instrument): Promise<Instruction>;
52
+ export { buildDepositInstruction, buildWithdrawInstruction, buildSpotLpInstruction, buildNewSpotOrderInstruction, buildSpotQuotesReplaceInstruction, buildSpotOrderCancelInstruction, buildSpotMassCancelInstruction, buildSwapInstruction, };