@gmsol-labs/gmsol-sdk 0.5.0-alpha.10
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 +122 -0
- package/index.d.ts +825 -0
- package/index.js +5 -0
- package/index_bg.js +1864 -0
- package/index_bg.wasm +0 -0
- package/package.json +28 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,825 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Build transactions for creating orders.
|
|
5
|
+
*/
|
|
6
|
+
export function create_orders(kind: CreateOrderKind, orders: CreateOrderParams[], options: CreateOrderOptions): TransactionGroup;
|
|
7
|
+
/**
|
|
8
|
+
* Apply `factor` to the `value`.
|
|
9
|
+
*/
|
|
10
|
+
export function apply_factor(value: bigint, factor: bigint): bigint | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Initialize Javascript logging and panic handler
|
|
13
|
+
*/
|
|
14
|
+
export function solana_program_init(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Params for calculating market token price.
|
|
17
|
+
*/
|
|
18
|
+
export interface MarketTokenPriceParams {
|
|
19
|
+
/**
|
|
20
|
+
* Prices.
|
|
21
|
+
*/
|
|
22
|
+
prices: Prices;
|
|
23
|
+
/**
|
|
24
|
+
* Pnl Factor.
|
|
25
|
+
*/
|
|
26
|
+
pnl_factor?: PnlFactorKind;
|
|
27
|
+
/**
|
|
28
|
+
* Maximize.
|
|
29
|
+
*/
|
|
30
|
+
maximize: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Params for calculating market status.
|
|
35
|
+
*/
|
|
36
|
+
export interface MarketStatusParams {
|
|
37
|
+
/**
|
|
38
|
+
* Prices.
|
|
39
|
+
*/
|
|
40
|
+
prices: Prices;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Best Swap path.
|
|
45
|
+
*/
|
|
46
|
+
export interface BestSwapPath {
|
|
47
|
+
/**
|
|
48
|
+
* Params.
|
|
49
|
+
*/
|
|
50
|
+
params: SwapEstimationParams;
|
|
51
|
+
/**
|
|
52
|
+
* Exchange rate.
|
|
53
|
+
*/
|
|
54
|
+
exchange_rate: bigint | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Path.
|
|
57
|
+
*/
|
|
58
|
+
path: string[];
|
|
59
|
+
/**
|
|
60
|
+
* Arbitrage exists.
|
|
61
|
+
*/
|
|
62
|
+
arbitrage_exists: boolean | undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Options for creating orders.
|
|
67
|
+
*/
|
|
68
|
+
export interface CreateOrderOptions {
|
|
69
|
+
recent_blockhash: string;
|
|
70
|
+
payer: StringPubkey;
|
|
71
|
+
collateral_or_swap_out_token: StringPubkey;
|
|
72
|
+
hints: Map<StringPubkey, CreateOrderHint>;
|
|
73
|
+
program?: StoreProgram | undefined;
|
|
74
|
+
pay_token?: StringPubkey | undefined;
|
|
75
|
+
receive_token?: StringPubkey | undefined;
|
|
76
|
+
swap_path?: StringPubkey[] | undefined;
|
|
77
|
+
skip_wrap_native_on_pay?: boolean | undefined;
|
|
78
|
+
skip_unwrap_native_on_receive?: boolean | undefined;
|
|
79
|
+
transaction_group?: TransactionGroupOptions;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A JS version transaction group options.
|
|
84
|
+
*/
|
|
85
|
+
export interface TransactionGroupOptions {
|
|
86
|
+
max_transaction_size?: number | undefined;
|
|
87
|
+
max_instructions_per_tx?: number | undefined;
|
|
88
|
+
compute_unit_price_micro_lamports?: number | undefined;
|
|
89
|
+
luts?: Map<StringPubkey, StringPubkey[]>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Serialized transaction group.
|
|
94
|
+
*/
|
|
95
|
+
export type SerializedTransactionGroup = number[][][];
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A Base58-encoded string representing a public key.
|
|
100
|
+
*/
|
|
101
|
+
export type StringPubkey = string;
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Config for [`MarketGraph`].
|
|
106
|
+
*/
|
|
107
|
+
export interface MarketGraphConfig {
|
|
108
|
+
/**
|
|
109
|
+
* Estimation Params for swap.
|
|
110
|
+
*/
|
|
111
|
+
swap_estimation_params: SwapEstimationParams;
|
|
112
|
+
/**
|
|
113
|
+
* Max steps.
|
|
114
|
+
*/
|
|
115
|
+
max_steps: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Estimation Parameters for Swap.
|
|
120
|
+
*/
|
|
121
|
+
export interface SwapEstimationParams {
|
|
122
|
+
/**
|
|
123
|
+
* Value.
|
|
124
|
+
*/
|
|
125
|
+
value: bigint;
|
|
126
|
+
/**
|
|
127
|
+
* Base cost.
|
|
128
|
+
*/
|
|
129
|
+
base_cost: bigint;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Js Prices.
|
|
134
|
+
*/
|
|
135
|
+
export interface Prices {
|
|
136
|
+
/**
|
|
137
|
+
* Index token price.
|
|
138
|
+
*/
|
|
139
|
+
index_token: Value;
|
|
140
|
+
/**
|
|
141
|
+
* Long token price.
|
|
142
|
+
*/
|
|
143
|
+
long_token: Value;
|
|
144
|
+
/**
|
|
145
|
+
* Short token price.
|
|
146
|
+
*/
|
|
147
|
+
short_token: Value;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Position Status.
|
|
152
|
+
*/
|
|
153
|
+
export interface PositionStatus {
|
|
154
|
+
/**
|
|
155
|
+
* Entry price.
|
|
156
|
+
*/
|
|
157
|
+
entry_price: bigint;
|
|
158
|
+
/**
|
|
159
|
+
* Collateral value.
|
|
160
|
+
*/
|
|
161
|
+
collateral_value: bigint;
|
|
162
|
+
/**
|
|
163
|
+
* Pending PnL.
|
|
164
|
+
*/
|
|
165
|
+
pending_pnl: bigint;
|
|
166
|
+
/**
|
|
167
|
+
* Pending borrowing fee value.
|
|
168
|
+
*/
|
|
169
|
+
pending_borrowing_fee_value: bigint;
|
|
170
|
+
/**
|
|
171
|
+
* Pending funding fee value.
|
|
172
|
+
*/
|
|
173
|
+
pending_funding_fee_value: bigint;
|
|
174
|
+
/**
|
|
175
|
+
* Pending claimable funding fee value in long token.
|
|
176
|
+
*/
|
|
177
|
+
pending_claimable_funding_fee_value_in_long_token: bigint;
|
|
178
|
+
/**
|
|
179
|
+
* Pending claimable funding fee value in short token.
|
|
180
|
+
*/
|
|
181
|
+
pending_claimable_funding_fee_value_in_short_token: bigint;
|
|
182
|
+
/**
|
|
183
|
+
* Close order fee value.
|
|
184
|
+
*/
|
|
185
|
+
close_order_fee_value: bigint;
|
|
186
|
+
/**
|
|
187
|
+
* Net value.
|
|
188
|
+
*/
|
|
189
|
+
net_value: bigint;
|
|
190
|
+
/**
|
|
191
|
+
* Leverage.
|
|
192
|
+
*/
|
|
193
|
+
leverage: bigint;
|
|
194
|
+
/**
|
|
195
|
+
* Liquidation price.
|
|
196
|
+
*/
|
|
197
|
+
liquidation_price: bigint;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Market Status.
|
|
202
|
+
*/
|
|
203
|
+
export interface MarketStatus {
|
|
204
|
+
/**
|
|
205
|
+
* Funding fee rate per hour for long.
|
|
206
|
+
*/
|
|
207
|
+
funding_rate_per_second_for_long: bigint;
|
|
208
|
+
/**
|
|
209
|
+
* Funding fee rate per hour for short.
|
|
210
|
+
*/
|
|
211
|
+
funding_rate_per_second_for_short: bigint;
|
|
212
|
+
/**
|
|
213
|
+
* Borrowing fee rate per second for long.
|
|
214
|
+
*/
|
|
215
|
+
borrowing_rate_per_second_for_long: bigint;
|
|
216
|
+
/**
|
|
217
|
+
* Borrowing fee rate per second for short.
|
|
218
|
+
*/
|
|
219
|
+
borrowing_rate_per_second_for_short: bigint;
|
|
220
|
+
/**
|
|
221
|
+
* Pending pnl for long.
|
|
222
|
+
*/
|
|
223
|
+
pending_pnl_for_long: SignedValue;
|
|
224
|
+
/**
|
|
225
|
+
* Pending pnl for short.
|
|
226
|
+
*/
|
|
227
|
+
pending_pnl_for_short: SignedValue;
|
|
228
|
+
/**
|
|
229
|
+
* Reserved value for long.
|
|
230
|
+
*/
|
|
231
|
+
reserved_value_for_long: bigint;
|
|
232
|
+
/**
|
|
233
|
+
* Reserved value for short.
|
|
234
|
+
*/
|
|
235
|
+
reserved_value_for_short: bigint;
|
|
236
|
+
/**
|
|
237
|
+
* Pool value without pnl for long.
|
|
238
|
+
*/
|
|
239
|
+
pool_value_without_pnl_for_long: Value;
|
|
240
|
+
/**
|
|
241
|
+
* Pool avlue without pnl for short.
|
|
242
|
+
*/
|
|
243
|
+
pool_value_without_pnl_for_short: Value;
|
|
244
|
+
/**
|
|
245
|
+
* Liquidity for long.
|
|
246
|
+
*/
|
|
247
|
+
liquidity_for_long: bigint;
|
|
248
|
+
/**
|
|
249
|
+
* Liquidity for short.
|
|
250
|
+
*/
|
|
251
|
+
liquidity_for_short: bigint;
|
|
252
|
+
/**
|
|
253
|
+
* Open interest for long.
|
|
254
|
+
*/
|
|
255
|
+
open_interest_for_long: bigint;
|
|
256
|
+
/**
|
|
257
|
+
* Open interest for short.
|
|
258
|
+
*/
|
|
259
|
+
open_interest_for_short: bigint;
|
|
260
|
+
/**
|
|
261
|
+
* Open interest in tokens for long.
|
|
262
|
+
*/
|
|
263
|
+
open_interest_in_tokens_for_long: bigint;
|
|
264
|
+
/**
|
|
265
|
+
* Open interest in tokens for short.
|
|
266
|
+
*/
|
|
267
|
+
open_interest_in_tokens_for_short: bigint;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Min max signed values.
|
|
272
|
+
*/
|
|
273
|
+
export interface SignedValue {
|
|
274
|
+
/**
|
|
275
|
+
* Min value.
|
|
276
|
+
*/
|
|
277
|
+
min: bigint;
|
|
278
|
+
/**
|
|
279
|
+
* Max value.
|
|
280
|
+
*/
|
|
281
|
+
max: bigint;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Min max values.
|
|
286
|
+
*/
|
|
287
|
+
export interface Value {
|
|
288
|
+
/**
|
|
289
|
+
* Min value.
|
|
290
|
+
*/
|
|
291
|
+
min: bigint;
|
|
292
|
+
/**
|
|
293
|
+
* Max value.
|
|
294
|
+
*/
|
|
295
|
+
max: bigint;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* A store program.
|
|
300
|
+
*/
|
|
301
|
+
export interface StoreProgram {
|
|
302
|
+
/**
|
|
303
|
+
* Program ID.
|
|
304
|
+
*/
|
|
305
|
+
id: StringPubkey;
|
|
306
|
+
/**
|
|
307
|
+
* Store address.
|
|
308
|
+
*/
|
|
309
|
+
store: StringPubkey;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Hint for [`CreateOrder`].
|
|
314
|
+
*/
|
|
315
|
+
export interface CreateOrderHint {
|
|
316
|
+
/**
|
|
317
|
+
* Long token.
|
|
318
|
+
*/
|
|
319
|
+
long_token: StringPubkey;
|
|
320
|
+
/**
|
|
321
|
+
* Short token.
|
|
322
|
+
*/
|
|
323
|
+
short_token: StringPubkey;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Instruction builder for the `create_order` instruction.
|
|
328
|
+
*/
|
|
329
|
+
export interface CreateOrder {
|
|
330
|
+
/**
|
|
331
|
+
* Program.
|
|
332
|
+
*/
|
|
333
|
+
program?: StoreProgram;
|
|
334
|
+
/**
|
|
335
|
+
* Payer (a.k.a. owner).
|
|
336
|
+
*/
|
|
337
|
+
payer: StringPubkey;
|
|
338
|
+
/**
|
|
339
|
+
* Reciever.
|
|
340
|
+
*/
|
|
341
|
+
receiver?: StringPubkey | undefined;
|
|
342
|
+
/**
|
|
343
|
+
* Nonce for the order.
|
|
344
|
+
*/
|
|
345
|
+
nonce?: NonceBytes | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* Execution fee paid to the keeper in lamports.
|
|
348
|
+
*/
|
|
349
|
+
execution_lamports?: number;
|
|
350
|
+
/**
|
|
351
|
+
* Order Kind.
|
|
352
|
+
*/
|
|
353
|
+
kind: CreateOrderKind;
|
|
354
|
+
/**
|
|
355
|
+
* Collateral or swap out token.
|
|
356
|
+
*/
|
|
357
|
+
collateral_or_swap_out_token: StringPubkey;
|
|
358
|
+
/**
|
|
359
|
+
* Order Parameters.
|
|
360
|
+
*/
|
|
361
|
+
params: CreateOrderParams;
|
|
362
|
+
/**
|
|
363
|
+
* Pay token.
|
|
364
|
+
*/
|
|
365
|
+
pay_token?: StringPubkey | undefined;
|
|
366
|
+
/**
|
|
367
|
+
* Pay token account.
|
|
368
|
+
*/
|
|
369
|
+
pay_token_account?: StringPubkey | undefined;
|
|
370
|
+
/**
|
|
371
|
+
* Receive token.
|
|
372
|
+
*/
|
|
373
|
+
receive_token?: StringPubkey | undefined;
|
|
374
|
+
/**
|
|
375
|
+
* Swap path.
|
|
376
|
+
*/
|
|
377
|
+
swap_path?: StringPubkey[];
|
|
378
|
+
/**
|
|
379
|
+
* Whether to unwrap the native token when receiving (e.g., convert WSOL to SOL).
|
|
380
|
+
*/
|
|
381
|
+
unwrap_native_on_receive?: boolean;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Parameters for creating an order.
|
|
386
|
+
*/
|
|
387
|
+
export interface CreateOrderParams {
|
|
388
|
+
/**
|
|
389
|
+
* The market token of the market in which the order will be created.
|
|
390
|
+
*/
|
|
391
|
+
market_token: StringPubkey;
|
|
392
|
+
/**
|
|
393
|
+
* Whether the order is for a long or short position.
|
|
394
|
+
*/
|
|
395
|
+
is_long: boolean;
|
|
396
|
+
/**
|
|
397
|
+
* Delta size in USD.
|
|
398
|
+
*/
|
|
399
|
+
size: bigint;
|
|
400
|
+
/**
|
|
401
|
+
* Delta amount of tokens:
|
|
402
|
+
* - For increase / swap orders, it is the amount of pay tokens.
|
|
403
|
+
* - For decrease orders, it is the amount of collateral tokens to withdraw.
|
|
404
|
+
*/
|
|
405
|
+
amount?: bigint;
|
|
406
|
+
/**
|
|
407
|
+
* Minimum amount or value of output tokens.
|
|
408
|
+
*
|
|
409
|
+
* - Minimum collateral amount for increase-position orders after swap.
|
|
410
|
+
* - Minimum swap-out amount for swap orders.
|
|
411
|
+
* - Minimum output value for decrease-position orders.
|
|
412
|
+
*/
|
|
413
|
+
min_output?: bigint;
|
|
414
|
+
/**
|
|
415
|
+
* Trigger price (in unit price).
|
|
416
|
+
*/
|
|
417
|
+
trigger_price?: bigint | undefined;
|
|
418
|
+
/**
|
|
419
|
+
* Acceptable price (in unit price).
|
|
420
|
+
*/
|
|
421
|
+
acceptable_price?: bigint | undefined;
|
|
422
|
+
/**
|
|
423
|
+
* Decrease Position Swap Type.
|
|
424
|
+
*/
|
|
425
|
+
decrease_position_swap_type?: DecreasePositionSwapType | undefined;
|
|
426
|
+
/**
|
|
427
|
+
* Timestamp from which the order becomes valid.
|
|
428
|
+
*/
|
|
429
|
+
valid_from_ts?: number | undefined;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Swap type for decreasing position.
|
|
434
|
+
*/
|
|
435
|
+
export type DecreasePositionSwapType = "NoSwap" | "PnlTokenToCollateralToken" | "CollateralToPnlToken";
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Create Order Kind.
|
|
439
|
+
*/
|
|
440
|
+
export type CreateOrderKind = "MarketSwap" | "MarketIncrease" | "MarketDecrease" | "LimitSwap" | "LimitIncrease" | "LimitDecrease" | "StopLossDecrease";
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Pnl Factor Kind.
|
|
444
|
+
*/
|
|
445
|
+
export type PnlFactorKind = "max_after_deposit" | "max_after_withdrawal" | "max_for_trader" | "for_adl" | "min_after_adl";
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* A hash; the 32-byte output of a hashing algorithm.
|
|
449
|
+
*
|
|
450
|
+
* This struct is used most often in `solana-sdk` and related crates to contain
|
|
451
|
+
* a [SHA-256] hash, but may instead contain a [blake3] hash, as created by the
|
|
452
|
+
* [`blake3`] module (and used in [`Message::hash`]).
|
|
453
|
+
*
|
|
454
|
+
* [SHA-256]: https://en.wikipedia.org/wiki/SHA-2
|
|
455
|
+
* [blake3]: https://github.com/BLAKE3-team/BLAKE3
|
|
456
|
+
* [`blake3`]: crate::blake3
|
|
457
|
+
* [`Message::hash`]: crate::message::Message::hash
|
|
458
|
+
*/
|
|
459
|
+
export class Hash {
|
|
460
|
+
free(): void;
|
|
461
|
+
/**
|
|
462
|
+
* Create a new Hash object
|
|
463
|
+
*
|
|
464
|
+
* * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]`
|
|
465
|
+
*/
|
|
466
|
+
constructor(value: any);
|
|
467
|
+
/**
|
|
468
|
+
* Return the base58 string representation of the hash
|
|
469
|
+
*/
|
|
470
|
+
toString(): string;
|
|
471
|
+
/**
|
|
472
|
+
* Checks if two `Hash`s are equal
|
|
473
|
+
*/
|
|
474
|
+
equals(other: Hash): boolean;
|
|
475
|
+
/**
|
|
476
|
+
* Return the `Uint8Array` representation of the hash
|
|
477
|
+
*/
|
|
478
|
+
toBytes(): Uint8Array;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* A directive for a single invocation of a Solana program.
|
|
482
|
+
*
|
|
483
|
+
* An instruction specifies which program it is calling, which accounts it may
|
|
484
|
+
* read or modify, and additional data that serves as input to the program. One
|
|
485
|
+
* or more instructions are included in transactions submitted by Solana
|
|
486
|
+
* clients. Instructions are also used to describe [cross-program
|
|
487
|
+
* invocations][cpi].
|
|
488
|
+
*
|
|
489
|
+
* [cpi]: https://solana.com/docs/core/cpi
|
|
490
|
+
*
|
|
491
|
+
* During execution, a program will receive a list of account data as one of
|
|
492
|
+
* its arguments, in the same order as specified during `Instruction`
|
|
493
|
+
* construction.
|
|
494
|
+
*
|
|
495
|
+
* While Solana is agnostic to the format of the instruction data, it has
|
|
496
|
+
* built-in support for serialization via [`borsh`] and [`bincode`].
|
|
497
|
+
*
|
|
498
|
+
* [`borsh`]: https://docs.rs/borsh/latest/borsh/
|
|
499
|
+
* [`bincode`]: https://docs.rs/bincode/latest/bincode/
|
|
500
|
+
*
|
|
501
|
+
* # Specifying account metadata
|
|
502
|
+
*
|
|
503
|
+
* When constructing an [`Instruction`], a list of all accounts that may be
|
|
504
|
+
* read or written during the execution of that instruction must be supplied as
|
|
505
|
+
* [`AccountMeta`] values.
|
|
506
|
+
*
|
|
507
|
+
* Any account whose data may be mutated by the program during execution must
|
|
508
|
+
* be specified as writable. During execution, writing to an account that was
|
|
509
|
+
* not specified as writable will cause the transaction to fail. Writing to an
|
|
510
|
+
* account that is not owned by the program will cause the transaction to fail.
|
|
511
|
+
*
|
|
512
|
+
* Any account whose lamport balance may be mutated by the program during
|
|
513
|
+
* execution must be specified as writable. During execution, mutating the
|
|
514
|
+
* lamports of an account that was not specified as writable will cause the
|
|
515
|
+
* transaction to fail. While _subtracting_ lamports from an account not owned
|
|
516
|
+
* by the program will cause the transaction to fail, _adding_ lamports to any
|
|
517
|
+
* account is allowed, as long is it is mutable.
|
|
518
|
+
*
|
|
519
|
+
* Accounts that are not read or written by the program may still be specified
|
|
520
|
+
* in an `Instruction`'s account list. These will affect scheduling of program
|
|
521
|
+
* execution by the runtime, but will otherwise be ignored.
|
|
522
|
+
*
|
|
523
|
+
* When building a transaction, the Solana runtime coalesces all accounts used
|
|
524
|
+
* by all instructions in that transaction, along with accounts and permissions
|
|
525
|
+
* required by the runtime, into a single account list. Some accounts and
|
|
526
|
+
* account permissions required by the runtime to process a transaction are
|
|
527
|
+
* _not_ required to be included in an `Instruction`s account list. These
|
|
528
|
+
* include:
|
|
529
|
+
*
|
|
530
|
+
* - The program ID — it is a separate field of `Instruction`
|
|
531
|
+
* - The transaction's fee-paying account — it is added during [`Message`]
|
|
532
|
+
* construction. A program may still require the fee payer as part of the
|
|
533
|
+
* account list if it directly references it.
|
|
534
|
+
*
|
|
535
|
+
* [`Message`]: crate::message::Message
|
|
536
|
+
*
|
|
537
|
+
* Programs may require signatures from some accounts, in which case they
|
|
538
|
+
* should be specified as signers during `Instruction` construction. The
|
|
539
|
+
* program must still validate during execution that the account is a signer.
|
|
540
|
+
*/
|
|
541
|
+
export class Instruction {
|
|
542
|
+
private constructor();
|
|
543
|
+
free(): void;
|
|
544
|
+
}
|
|
545
|
+
export class Instructions {
|
|
546
|
+
free(): void;
|
|
547
|
+
constructor();
|
|
548
|
+
push(instruction: Instruction): void;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* A vanilla Ed25519 key pair
|
|
552
|
+
*/
|
|
553
|
+
export class Keypair {
|
|
554
|
+
free(): void;
|
|
555
|
+
/**
|
|
556
|
+
* Create a new `Keypair `
|
|
557
|
+
*/
|
|
558
|
+
constructor();
|
|
559
|
+
/**
|
|
560
|
+
* Convert a `Keypair` to a `Uint8Array`
|
|
561
|
+
*/
|
|
562
|
+
toBytes(): Uint8Array;
|
|
563
|
+
/**
|
|
564
|
+
* Recover a `Keypair` from a `Uint8Array`
|
|
565
|
+
*/
|
|
566
|
+
static fromBytes(bytes: Uint8Array): Keypair;
|
|
567
|
+
/**
|
|
568
|
+
* Return the `Pubkey` for this `Keypair`
|
|
569
|
+
*/
|
|
570
|
+
pubkey(): Pubkey;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Wrapper of [`Market`].
|
|
574
|
+
*/
|
|
575
|
+
export class Market {
|
|
576
|
+
private constructor();
|
|
577
|
+
free(): void;
|
|
578
|
+
/**
|
|
579
|
+
* Create from base64 encoded account data.
|
|
580
|
+
*/
|
|
581
|
+
static decode_from_base64(data: string): Market;
|
|
582
|
+
/**
|
|
583
|
+
* Create from account data.
|
|
584
|
+
*/
|
|
585
|
+
static decode(data: Uint8Array): Market;
|
|
586
|
+
/**
|
|
587
|
+
* Convert into [`JsMarketModel`]
|
|
588
|
+
*/
|
|
589
|
+
to_model(supply: bigint): MarketModel;
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* A JS binding for [`MarkegGraph`].
|
|
593
|
+
*/
|
|
594
|
+
export class MarketGraph {
|
|
595
|
+
free(): void;
|
|
596
|
+
/**
|
|
597
|
+
* Create an empty market graph.
|
|
598
|
+
*/
|
|
599
|
+
constructor(config: MarketGraphConfig);
|
|
600
|
+
/**
|
|
601
|
+
* Insert market from base64 encoded data.
|
|
602
|
+
*/
|
|
603
|
+
insert_market_from_base64(data: string, supply: bigint): boolean;
|
|
604
|
+
/**
|
|
605
|
+
* Update token price.
|
|
606
|
+
*/
|
|
607
|
+
update_token_price(token: string, price: Value): void;
|
|
608
|
+
/**
|
|
609
|
+
* Update value.
|
|
610
|
+
*/
|
|
611
|
+
update_value(value: bigint): void;
|
|
612
|
+
/**
|
|
613
|
+
* Update base cost.
|
|
614
|
+
*/
|
|
615
|
+
update_base_cost(base_cost: bigint): void;
|
|
616
|
+
/**
|
|
617
|
+
* Update max steps.
|
|
618
|
+
*/
|
|
619
|
+
update_max_steps(max_steps: number): void;
|
|
620
|
+
/**
|
|
621
|
+
* Get market by its market token.
|
|
622
|
+
*/
|
|
623
|
+
get_market(market_token: string): MarketModel | undefined;
|
|
624
|
+
/**
|
|
625
|
+
* Get all market tokens.
|
|
626
|
+
*/
|
|
627
|
+
market_tokens(): string[];
|
|
628
|
+
/**
|
|
629
|
+
* Get all index tokens.
|
|
630
|
+
*/
|
|
631
|
+
index_tokens(): string[];
|
|
632
|
+
/**
|
|
633
|
+
* Compute best swap path.
|
|
634
|
+
*/
|
|
635
|
+
best_swap_path(source: string, target: string, skip_bellman_ford: boolean): BestSwapPath;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Wrapper of [`MarketModel`].
|
|
639
|
+
*/
|
|
640
|
+
export class MarketModel {
|
|
641
|
+
private constructor();
|
|
642
|
+
free(): void;
|
|
643
|
+
/**
|
|
644
|
+
* Get market token price.
|
|
645
|
+
*/
|
|
646
|
+
market_token_price(params: MarketTokenPriceParams): bigint;
|
|
647
|
+
/**
|
|
648
|
+
* Get market status.
|
|
649
|
+
*/
|
|
650
|
+
status(params: MarketStatusParams): MarketStatus;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* A Solana transaction message (legacy).
|
|
654
|
+
*
|
|
655
|
+
* See the [`message`] module documentation for further description.
|
|
656
|
+
*
|
|
657
|
+
* [`message`]: crate::message
|
|
658
|
+
*
|
|
659
|
+
* Some constructors accept an optional `payer`, the account responsible for
|
|
660
|
+
* paying the cost of executing a transaction. In most cases, callers should
|
|
661
|
+
* specify the payer explicitly in these constructors. In some cases though,
|
|
662
|
+
* the caller is not _required_ to specify the payer, but is still allowed to:
|
|
663
|
+
* in the `Message` structure, the first account is always the fee-payer, so if
|
|
664
|
+
* the caller has knowledge that the first account of the constructed
|
|
665
|
+
* transaction's `Message` is both a signer and the expected fee-payer, then
|
|
666
|
+
* redundantly specifying the fee-payer is not strictly required.
|
|
667
|
+
*/
|
|
668
|
+
export class Message {
|
|
669
|
+
private constructor();
|
|
670
|
+
free(): void;
|
|
671
|
+
/**
|
|
672
|
+
* The id of a recent ledger entry.
|
|
673
|
+
*/
|
|
674
|
+
recent_blockhash: Hash;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* JS version of [`Position`].
|
|
678
|
+
*/
|
|
679
|
+
export class Position {
|
|
680
|
+
private constructor();
|
|
681
|
+
free(): void;
|
|
682
|
+
/**
|
|
683
|
+
* Create from base64 encoded account data.
|
|
684
|
+
*/
|
|
685
|
+
static decode_from_base64(data: string): Position;
|
|
686
|
+
/**
|
|
687
|
+
* Convert to a [`JsPositionModel`].
|
|
688
|
+
*/
|
|
689
|
+
to_model(market: MarketModel): PositionModel;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* JS version of [`PositionModel`].
|
|
693
|
+
*/
|
|
694
|
+
export class PositionModel {
|
|
695
|
+
private constructor();
|
|
696
|
+
free(): void;
|
|
697
|
+
/**
|
|
698
|
+
* Get position status.
|
|
699
|
+
*/
|
|
700
|
+
status(prices: Prices): PositionStatus;
|
|
701
|
+
/**
|
|
702
|
+
* Get position size.
|
|
703
|
+
*/
|
|
704
|
+
size(): bigint;
|
|
705
|
+
/**
|
|
706
|
+
* Get position size in tokens.
|
|
707
|
+
*/
|
|
708
|
+
size_in_tokens(): bigint;
|
|
709
|
+
/**
|
|
710
|
+
* Get collateral amount.
|
|
711
|
+
*/
|
|
712
|
+
collateral_amount(): bigint;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* The address of a [Solana account][acc].
|
|
716
|
+
*
|
|
717
|
+
* Some account addresses are [ed25519] public keys, with corresponding secret
|
|
718
|
+
* keys that are managed off-chain. Often, though, account addresses do not
|
|
719
|
+
* have corresponding secret keys — as with [_program derived
|
|
720
|
+
* addresses_][pdas] — or the secret key is not relevant to the operation
|
|
721
|
+
* of a program, and may have even been disposed of. As running Solana programs
|
|
722
|
+
* can not safely create or manage secret keys, the full [`Keypair`] is not
|
|
723
|
+
* defined in `solana-program` but in `solana-sdk`.
|
|
724
|
+
*
|
|
725
|
+
* [acc]: https://solana.com/docs/core/accounts
|
|
726
|
+
* [ed25519]: https://ed25519.cr.yp.to/
|
|
727
|
+
* [pdas]: https://solana.com/docs/core/cpi#program-derived-addresses
|
|
728
|
+
* [`Keypair`]: https://docs.rs/solana-sdk/latest/solana_sdk/signer/keypair/struct.Keypair.html
|
|
729
|
+
*/
|
|
730
|
+
export class Pubkey {
|
|
731
|
+
free(): void;
|
|
732
|
+
/**
|
|
733
|
+
* Create a new Pubkey object
|
|
734
|
+
*
|
|
735
|
+
* * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]`
|
|
736
|
+
*/
|
|
737
|
+
constructor(value: any);
|
|
738
|
+
/**
|
|
739
|
+
* Return the base58 string representation of the public key
|
|
740
|
+
*/
|
|
741
|
+
toString(): string;
|
|
742
|
+
/**
|
|
743
|
+
* Check if a `Pubkey` is on the ed25519 curve.
|
|
744
|
+
*/
|
|
745
|
+
isOnCurve(): boolean;
|
|
746
|
+
/**
|
|
747
|
+
* Checks if two `Pubkey`s are equal
|
|
748
|
+
*/
|
|
749
|
+
equals(other: Pubkey): boolean;
|
|
750
|
+
/**
|
|
751
|
+
* Return the `Uint8Array` representation of the public key
|
|
752
|
+
*/
|
|
753
|
+
toBytes(): Uint8Array;
|
|
754
|
+
/**
|
|
755
|
+
* Derive a Pubkey from another Pubkey, string seed, and a program id
|
|
756
|
+
*/
|
|
757
|
+
static createWithSeed(base: Pubkey, seed: string, owner: Pubkey): Pubkey;
|
|
758
|
+
/**
|
|
759
|
+
* Derive a program address from seeds and a program id
|
|
760
|
+
*/
|
|
761
|
+
static createProgramAddress(seeds: any[], program_id: Pubkey): Pubkey;
|
|
762
|
+
/**
|
|
763
|
+
* Find a valid program address
|
|
764
|
+
*
|
|
765
|
+
* Returns:
|
|
766
|
+
* * `[PubKey, number]` - the program address and bump seed
|
|
767
|
+
*/
|
|
768
|
+
static findProgramAddress(seeds: any[], program_id: Pubkey): any;
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* An atomically-committed sequence of instructions.
|
|
772
|
+
*
|
|
773
|
+
* While [`Instruction`]s are the basic unit of computation in Solana,
|
|
774
|
+
* they are submitted by clients in [`Transaction`]s containing one or
|
|
775
|
+
* more instructions, and signed by one or more [`Signer`]s.
|
|
776
|
+
*
|
|
777
|
+
* [`Signer`]: crate::signer::Signer
|
|
778
|
+
*
|
|
779
|
+
* See the [module documentation] for more details about transactions.
|
|
780
|
+
*
|
|
781
|
+
* [module documentation]: self
|
|
782
|
+
*
|
|
783
|
+
* Some constructors accept an optional `payer`, the account responsible for
|
|
784
|
+
* paying the cost of executing a transaction. In most cases, callers should
|
|
785
|
+
* specify the payer explicitly in these constructors. In some cases though,
|
|
786
|
+
* the caller is not _required_ to specify the payer, but is still allowed to:
|
|
787
|
+
* in the [`Message`] structure, the first account is always the fee-payer, so
|
|
788
|
+
* if the caller has knowledge that the first account of the constructed
|
|
789
|
+
* transaction's `Message` is both a signer and the expected fee-payer, then
|
|
790
|
+
* redundantly specifying the fee-payer is not strictly required.
|
|
791
|
+
*/
|
|
792
|
+
export class Transaction {
|
|
793
|
+
free(): void;
|
|
794
|
+
/**
|
|
795
|
+
* Create a new `Transaction`
|
|
796
|
+
*/
|
|
797
|
+
constructor(instructions: Instructions, payer?: Pubkey | null);
|
|
798
|
+
/**
|
|
799
|
+
* Return a message containing all data that should be signed.
|
|
800
|
+
*/
|
|
801
|
+
message(): Message;
|
|
802
|
+
/**
|
|
803
|
+
* Return the serialized message data to sign.
|
|
804
|
+
*/
|
|
805
|
+
messageData(): Uint8Array;
|
|
806
|
+
/**
|
|
807
|
+
* Verify the transaction
|
|
808
|
+
*/
|
|
809
|
+
verify(): void;
|
|
810
|
+
partialSign(keypair: Keypair, recent_blockhash: Hash): void;
|
|
811
|
+
isSigned(): boolean;
|
|
812
|
+
toBytes(): Uint8Array;
|
|
813
|
+
static fromBytes(bytes: Uint8Array): Transaction;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* A JS binding for transaction group.
|
|
817
|
+
*/
|
|
818
|
+
export class TransactionGroup {
|
|
819
|
+
private constructor();
|
|
820
|
+
free(): void;
|
|
821
|
+
/**
|
|
822
|
+
* Returns serialized transaciton group.
|
|
823
|
+
*/
|
|
824
|
+
serialize(): SerializedTransactionGroup;
|
|
825
|
+
}
|