@gmsol-labs/gmsol-sdk 0.5.0 → 0.7.0-beta.2

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 CHANGED
@@ -4,19 +4,23 @@
4
4
  [![Docs.rs](https://docs.rs/gmsol-sdk/badge.svg)](https://docs.rs/gmsol-sdk)
5
5
  [![npm](https://img.shields.io/npm/v/@gmsol-labs/gmsol-sdk.svg)](https://www.npmjs.com/package/@gmsol-labs/gmsol-sdk)
6
6
 
7
+ [Examples](https://github.com/gmsol-labs/gmx-solana/tree/main/examples)
8
+
7
9
  ## Audits
8
10
 
9
- | Program | Last Audit Date | Version |
10
- | ---------------- | --------------- | --------- |
11
- | [gmsol-store] | [2025-03-07] | [2a66761] |
12
- | [gmsol-treasury] | [2025-03-07] | [2a66761] |
13
- | [gmsol-timelock] | [2025-03-07] | [2a66761] |
11
+ | Program | Last Audit Date | Version |
12
+ | ------------------- | --------------- | --------- |
13
+ | [gmsol-store] | [2025-07-28] | [3202f7c] |
14
+ | [gmsol-treasury] | [2025-07-28] | [3202f7c] |
15
+ | [gmsol-timelock] | [2025-07-28] | [3202f7c] |
16
+ | [gmsol-competition] | [2025-07-28] | [3202f7c] |
14
17
 
15
- [gmsol-store]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/gmsol-store
16
- [gmsol-treasury]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/gmsol-treasury
17
- [gmsol-timelock]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/gmsol-timelock
18
- [2025-03-07]: https://github.com/gmsol-labs/gmx-solana-audits/blob/main/GMX_Solana_Audit_Report_Mar_7_2025_Zenith.pdf
19
- [2a66761]: https://github.com/gmsol-labs/gmx-solana/commit/2a66761d6573a6db6160a19fc3057e2091aebbfe
18
+ [gmsol-store]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/store
19
+ [gmsol-treasury]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/treasury
20
+ [gmsol-timelock]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/timelock
21
+ [gmsol-competition]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/competition
22
+ [2025-07-28]: https://github.com/gmsol-labs/gmx-solana-audits/blob/main/GMX_Solana_Audit_Report_July_28_2025_Zenith.pdf
23
+ [3202f7c]: https://github.com/gmsol-labs/gmx-solana/commit/3202f7ca1a01a076425af59d2bca7369fe9c156c
20
24
 
21
25
  ## Integration
22
26
 
@@ -26,7 +30,7 @@ Add the following to your `Cargo.toml`:
26
30
 
27
31
  ```toml
28
32
  [dependencies]
29
- gmsol-sdk = { version = "0.5.0", features = ["client"] }
33
+ gmsol-sdk = { version = "0.7.0", features = ["client"] }
30
34
  ```
31
35
 
32
36
  Create a `Client` and start using the core APIs:
@@ -71,8 +75,8 @@ Create a new Rust project and include `anchor_lang` and `bytemuck` as dependenci
71
75
 
72
76
  ```toml
73
77
  [dependencies]
74
- anchor-lang = "0.30.1"
75
- bytemuck = { version = "1.19.0", features = ["min_const_generics"] }
78
+ anchor-lang = "0.31.1"
79
+ bytemuck = { version = "1.19.0", features = ["min_const_generics", "derive"] }
76
80
  ```
77
81
 
78
82
  #### 2. Download and Store IDLs in `{PROJECT_ROOT}/idls/`
@@ -124,13 +128,55 @@ For a working implementation, check out the [gmx-solana-programs][gmx-solana-pro
124
128
  [treasury-program-link]: https://explorer.solana.com/address/GTuvYD5SxkTq4FLG6JV1FQ5dkczr1AfgDcBHaFsBdtBg/anchor-program
125
129
  [gmx-solana-programs-link]: https://github.com/gmsol-labs/gmx-solana-programs
126
130
 
131
+ ## Known Issues
132
+
133
+ ### Keepers
134
+
135
+ - Order keepers can use prices from different timestamps for limit orders with a swap, which would lead to different output amounts.
136
+
137
+ - Order Keepers are expected to select an execution fee that does not exceed the actual network fee incurred. In addition, the execution fee that the Order Keeper can specify is capped by the program. Even if the actual network fee incurred exceeds this cap, it will not affect the executability of the request.
138
+
139
+ - A malicious Order Keeper could potentially profit consistently by manipulating the execution order of orders, but this risk can be mitigated by deploying a sufficient number of high-frequency and trusted Order Keepers, since a successful attack would require the malicious Order Keeper to ensure that the orders it creates are not executed within the valid price time window, which is typically 30 seconds.
140
+
141
+ - A malicious Order Keeper could potentially extract rent paid by other Order Keepers by closing claimable accounts created by them. However, since claimable accounts are typically created and closed within the same transaction that executes the order, such situations are extremely rare.
142
+
143
+ - Orders may be prevented from execution by a malicious user intentionally causing a market to be unbalanced resulting in a high price impact, this should be costly and difficult to benefit from.
144
+
145
+ ### Price Impact
146
+
147
+ - Price impact can be reduced by using positions and swaps and trading across markets, chains, forks, other protocols, this is partially mitigated with virtual inventory tracking.
148
+
149
+ - A user can reduce price impact by using high leverage positions, this is partially mitigated with the MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER value.
150
+
151
+ - Calculation of price impact values do not account for fees and the effects resulting from the price impact itself, for most cases the effect on the price impact calculation should be small.
152
+
153
+ ### Market Token Price
154
+
155
+ - It is rare but possible for a pool's value to become negative, this can happen since the impactPoolAmount and pending PnL is subtracted from the worth of the tokens in the pool.
156
+
157
+ - Due to the difference in positive and negative position price impact, there can be a build up of virtual token amounts in the position impact pool which would affect the pricing of market tokens, the position impact pool should be gradually distributed if needed.
158
+
159
+ ### Virtual Inventory
160
+
161
+ - Virtual inventory (for swap) tracks the amount of tokens in pools, it must be ensured that the tokens in each grouping are the same type and have the same decimals, i.e. the long tokens across pools in the group should have the same decimals, the short tokens across pools in the group should have the same decimals, assuming USDC has 6 decimals and WBTC has 8 decimals, markets like WSOL-USDC, WSOL-WBTC should not be grouped.
162
+
163
+ ### GLV
164
+
165
+ - The GLV shift feature can be exploited by temporarily increasing the utilization in a market that typically has low utilization. Once the keeper executes the shift, the attacker can lower the utilization back to its normal levels. Position fees and price impact should be configured in a way that makes this attack expensive enough to cover the GLV loss.
166
+
167
+ - In GLV there may be GM markets which are above their maximum pnl_to_pool_factor_for_traders. If this GM market's max_pnl_factor_for_deposits is higher than max_pnl_factor_for_traders then the GM market is valued lower during deposits than it will be once traders have realized their capped profits. Malicious user may observe a GM market in such a condition and deposit into the GLV containing it in order to gain from ADLs which will soon follow. To avoid this max_pnl_factor_for_deposits should be less than or equal to max_pnl_factor_for_traders.
168
+
169
+ - It's technically possible for market value to become negative. In this case the GLV would be unusable until the market value becomes positive.
170
+
171
+ - GM tokens could become illiquid due to high pnl factor or high reserved usd. Users can deposit illiquid GM tokens into GLV and withdraw liquidity from a different market, leaving the GLV with illiquid tokens. The glv_max_market_token_value and glv_max_market_token_amount parameters should account for the riskiness of a market to avoid having too many GM tokens from a risky market.
172
+
127
173
  ## Development
128
174
 
129
175
  ### Prerequisites
130
176
 
131
177
  - [Rust](https://www.rust-lang.org/tools/install)
132
- - [Solana v1.18.26](https://docs.anza.xyz/cli/install)
133
- - [Anchor v0.30.1](https://www.anchor-lang.com/docs/installation)
178
+ - [Solana v2.1.21](https://docs.anza.xyz/cli/install)
179
+ - [Anchor v0.31.1](https://www.anchor-lang.com/docs/installation)
134
180
  - [Node](https://nodejs.org/en/download)
135
181
  - [Just](https://github.com/casey/just?tab=readme-ov-file#installation)
136
182
 
@@ -142,16 +188,22 @@ To run all tests:
142
188
  just
143
189
  ```
144
190
 
191
+ To use the `gmsol` CLI in development mode:
192
+
193
+ ```bash
194
+ just cli
195
+ ```
196
+
145
197
  To install the `gmsol` CLI:
146
198
 
147
199
  ```bash
148
- cargo install-gmsol
200
+ just install-cli
149
201
  ```
150
202
 
151
203
  Use the following command to verify the CLI is installed properly:
152
204
 
153
205
  ```bash
154
- gmsol --version
206
+ gmsol -V
155
207
  ```
156
208
 
157
209
  ### Troubleshooting
package/index.d.ts CHANGED
@@ -79,6 +79,8 @@ export interface BestSwapPath {
79
79
  */
80
80
  export interface CreateOrderOptions {
81
81
  recent_blockhash: string;
82
+ compute_unit_price_micro_lamports?: number | undefined;
83
+ compute_unit_min_priority_lamports?: number | undefined;
82
84
  payer: StringPubkey;
83
85
  collateral_or_swap_out_token: StringPubkey;
84
86
  hints: Map<StringPubkey, CreateOrderHint>;
@@ -88,6 +90,7 @@ export interface CreateOrderOptions {
88
90
  swap_path?: StringPubkey[] | undefined;
89
91
  skip_wrap_native_on_pay?: boolean | undefined;
90
92
  skip_unwrap_native_on_receive?: boolean | undefined;
93
+ callback?: Callback | undefined;
91
94
  transaction_group?: TransactionGroupOptions;
92
95
  }
93
96
 
@@ -96,6 +99,8 @@ export interface CreateOrderOptions {
96
99
  */
97
100
  export interface CloseOrderArgs {
98
101
  recent_blockhash: string;
102
+ compute_unit_price_micro_lamports?: number | undefined;
103
+ compute_unit_min_priority_lamports?: number | undefined;
99
104
  payer: StringPubkey;
100
105
  orders: Map<StringPubkey, CloseOrderHint>;
101
106
  program?: StoreProgram | undefined;
@@ -112,6 +117,8 @@ export interface UpdateParams {
112
117
  */
113
118
  export interface UpdateOrderArgs {
114
119
  recent_blockhash: string;
120
+ compute_unit_price_micro_lamports?: number | undefined;
121
+ compute_unit_min_priority_lamports?: number | undefined;
115
122
  payer: StringPubkey;
116
123
  orders: Map<StringPubkey, UpdateParams>;
117
124
  program?: StoreProgram | undefined;
@@ -124,7 +131,6 @@ export interface UpdateOrderArgs {
124
131
  export interface TransactionGroupOptions {
125
132
  max_transaction_size?: number | undefined;
126
133
  max_instructions_per_tx?: number | undefined;
127
- compute_unit_price_micro_lamports?: number | undefined;
128
134
  luts?: Map<StringPubkey, StringPubkey[]>;
129
135
  memo?: string | undefined;
130
136
  }
@@ -286,7 +292,7 @@ export interface MarketStatus {
286
292
  */
287
293
  pool_value_without_pnl_for_long: Value;
288
294
  /**
289
- * Pool avlue without pnl for short.
295
+ * Pool value without pnl for short.
290
296
  */
291
297
  pool_value_without_pnl_for_short: Value;
292
298
  /**
@@ -359,6 +365,28 @@ export interface Value {
359
365
  max: bigint;
360
366
  }
361
367
 
368
+ /**
369
+ * Callback.
370
+ */
371
+ export interface Callback {
372
+ /**
373
+ * Callback version.
374
+ */
375
+ version: number;
376
+ /**
377
+ * Callback program ID.
378
+ */
379
+ program: StringPubkey;
380
+ /**
381
+ * The address of shared data account.
382
+ */
383
+ shared_data: StringPubkey;
384
+ /**
385
+ * The address of partitioned data account.
386
+ */
387
+ partitioned_data: StringPubkey;
388
+ }
389
+
362
390
  /**
363
391
  * Hint for [`UpdateOrder`].
364
392
  */
@@ -367,6 +395,10 @@ export interface UpdateOrderHint {
367
395
  * Market token.
368
396
  */
369
397
  market_token: StringPubkey;
398
+ /**
399
+ * Callback.
400
+ */
401
+ callback: Callback | undefined;
370
402
  }
371
403
 
372
404
  /**
@@ -457,6 +489,10 @@ export interface CloseOrderHint {
457
489
  * `should_unwrap_native_token` flag.
458
490
  */
459
491
  should_unwrap_native_token: boolean;
492
+ /**
493
+ * Callback.
494
+ */
495
+ callback: Callback | undefined;
460
496
  }
461
497
 
462
498
  /**
@@ -551,6 +587,7 @@ export interface CreateOrder {
551
587
  * Whether to unwrap the native token when receiving (e.g., convert WSOL to SOL).
552
588
  */
553
589
  unwrap_native_on_receive?: boolean;
590
+ callback?: Callback | undefined;
554
591
  }
555
592
 
556
593
  /**
@@ -630,17 +667,37 @@ export interface StoreProgram {
630
667
  */
631
668
  export type PnlFactorKind = "max_after_deposit" | "max_after_withdrawal" | "max_for_trader" | "for_adl" | "min_after_adl";
632
669
 
670
+ /**
671
+ * A (twisted) ElGamal encryption keypair.
672
+ *
673
+ * The instances of the secret key are zeroized on drop.
674
+ */
675
+ export class ElGamalKeypair {
676
+ private constructor();
677
+ free(): void;
678
+ /**
679
+ * Generates the public and secret keys for ElGamal encryption.
680
+ *
681
+ * This function is randomized. It internally samples a scalar element using `OsRng`.
682
+ */
683
+ static new_rand(): ElGamalKeypair;
684
+ pubkey_owned(): ElGamalPubkey;
685
+ }
686
+ /**
687
+ * Public key for the ElGamal encryption scheme.
688
+ */
689
+ export class ElGamalPubkey {
690
+ private constructor();
691
+ free(): void;
692
+ }
633
693
  /**
634
694
  * A hash; the 32-byte output of a hashing algorithm.
635
695
  *
636
696
  * This struct is used most often in `solana-sdk` and related crates to contain
637
- * a [SHA-256] hash, but may instead contain a [blake3] hash, as created by the
638
- * [`blake3`] module (and used in [`Message::hash`]).
697
+ * a [SHA-256] hash, but may instead contain a [blake3] hash.
639
698
  *
640
699
  * [SHA-256]: https://en.wikipedia.org/wiki/SHA-2
641
700
  * [blake3]: https://github.com/BLAKE3-team/BLAKE3
642
- * [`blake3`]: crate::blake3
643
- * [`Message::hash`]: crate::message::Message::hash
644
701
  */
645
702
  export class Hash {
646
703
  free(): void;
@@ -664,65 +721,9 @@ export class Hash {
664
721
  toBytes(): Uint8Array;
665
722
  }
666
723
  /**
667
- * A directive for a single invocation of a Solana program.
668
- *
669
- * An instruction specifies which program it is calling, which accounts it may
670
- * read or modify, and additional data that serves as input to the program. One
671
- * or more instructions are included in transactions submitted by Solana
672
- * clients. Instructions are also used to describe [cross-program
673
- * invocations][cpi].
674
- *
675
- * [cpi]: https://solana.com/docs/core/cpi
676
- *
677
- * During execution, a program will receive a list of account data as one of
678
- * its arguments, in the same order as specified during `Instruction`
679
- * construction.
680
- *
681
- * While Solana is agnostic to the format of the instruction data, it has
682
- * built-in support for serialization via [`borsh`] and [`bincode`].
683
- *
684
- * [`borsh`]: https://docs.rs/borsh/latest/borsh/
685
- * [`bincode`]: https://docs.rs/bincode/latest/bincode/
686
- *
687
- * # Specifying account metadata
688
- *
689
- * When constructing an [`Instruction`], a list of all accounts that may be
690
- * read or written during the execution of that instruction must be supplied as
691
- * [`AccountMeta`] values.
692
- *
693
- * Any account whose data may be mutated by the program during execution must
694
- * be specified as writable. During execution, writing to an account that was
695
- * not specified as writable will cause the transaction to fail. Writing to an
696
- * account that is not owned by the program will cause the transaction to fail.
697
- *
698
- * Any account whose lamport balance may be mutated by the program during
699
- * execution must be specified as writable. During execution, mutating the
700
- * lamports of an account that was not specified as writable will cause the
701
- * transaction to fail. While _subtracting_ lamports from an account not owned
702
- * by the program will cause the transaction to fail, _adding_ lamports to any
703
- * account is allowed, as long is it is mutable.
704
- *
705
- * Accounts that are not read or written by the program may still be specified
706
- * in an `Instruction`'s account list. These will affect scheduling of program
707
- * execution by the runtime, but will otherwise be ignored.
708
- *
709
- * When building a transaction, the Solana runtime coalesces all accounts used
710
- * by all instructions in that transaction, along with accounts and permissions
711
- * required by the runtime, into a single account list. Some accounts and
712
- * account permissions required by the runtime to process a transaction are
713
- * _not_ required to be included in an `Instruction`s account list. These
714
- * include:
715
- *
716
- * - The program ID &mdash; it is a separate field of `Instruction`
717
- * - The transaction's fee-paying account &mdash; it is added during [`Message`]
718
- * construction. A program may still require the fee payer as part of the
719
- * account list if it directly references it.
720
- *
721
- * [`Message`]: crate::message::Message
722
- *
723
- * Programs may require signatures from some accounts, in which case they
724
- * should be specified as signers during `Instruction` construction. The
725
- * program must still validate during execution that the account is a signer.
724
+ * wasm-bindgen version of the Instruction struct.
725
+ * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
726
+ * is fixed. This must not diverge from the regular non-wasm Instruction struct.
726
727
  */
727
728
  export class Instruction {
728
729
  private constructor();
@@ -791,7 +792,7 @@ export class Market {
791
792
  short_token_address(): string;
792
793
  }
793
794
  /**
794
- * A JS binding for [`MarkegGraph`].
795
+ * A JS binding for [`MarketGraph`].
795
796
  */
796
797
  export class MarketGraph {
797
798
  free(): void;
@@ -852,20 +853,9 @@ export class MarketModel {
852
853
  status(params: MarketStatusParams): MarketStatus;
853
854
  }
854
855
  /**
855
- * A Solana transaction message (legacy).
856
- *
857
- * See the [`message`] module documentation for further description.
858
- *
859
- * [`message`]: crate::message
860
- *
861
- * Some constructors accept an optional `payer`, the account responsible for
862
- * paying the cost of executing a transaction. In most cases, callers should
863
- * specify the payer explicitly in these constructors. In some cases though,
864
- * the caller is not _required_ to specify the payer, but is still allowed to:
865
- * in the `Message` structure, the first account is always the fee-payer, so if
866
- * the caller has knowledge that the first account of the constructed
867
- * transaction's `Message` is both a signer and the expected fee-payer, then
868
- * redundantly specifying the fee-payer is not strictly required.
856
+ * wasm-bindgen version of the Message struct.
857
+ * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
858
+ * is fixed. This must not diverge from the regular non-wasm Message struct.
869
859
  */
870
860
  export class Message {
871
861
  private constructor();
@@ -875,6 +865,32 @@ export class Message {
875
865
  */
876
866
  recent_blockhash: Hash;
877
867
  }
868
+ /**
869
+ * The `ElGamalPubkey` type as a `Pod`.
870
+ */
871
+ export class PodElGamalPubkey {
872
+ free(): void;
873
+ /**
874
+ * Create a new `PodElGamalPubkey` object
875
+ *
876
+ * * `value` - optional public key as a base64 encoded string, `Uint8Array`, `[number]`
877
+ */
878
+ constructor(value: any);
879
+ /**
880
+ * Return the base64 string representation of the public key
881
+ */
882
+ toString(): string;
883
+ /**
884
+ * Checks if two `ElGamalPubkey`s are equal
885
+ */
886
+ equals(other: PodElGamalPubkey): boolean;
887
+ /**
888
+ * Return the `Uint8Array` representation of the public key
889
+ */
890
+ toBytes(): Uint8Array;
891
+ static compressed(decoded: ElGamalPubkey): PodElGamalPubkey;
892
+ decompressed(): ElGamalPubkey;
893
+ }
878
894
  /**
879
895
  * JS version of [`Position`].
880
896
  */
@@ -970,26 +986,9 @@ export class Pubkey {
970
986
  static findProgramAddress(seeds: any[], program_id: Pubkey): any;
971
987
  }
972
988
  /**
973
- * An atomically-committed sequence of instructions.
974
- *
975
- * While [`Instruction`]s are the basic unit of computation in Solana,
976
- * they are submitted by clients in [`Transaction`]s containing one or
977
- * more instructions, and signed by one or more [`Signer`]s.
978
- *
979
- * [`Signer`]: crate::signer::Signer
980
- *
981
- * See the [module documentation] for more details about transactions.
982
- *
983
- * [module documentation]: self
984
- *
985
- * Some constructors accept an optional `payer`, the account responsible for
986
- * paying the cost of executing a transaction. In most cases, callers should
987
- * specify the payer explicitly in these constructors. In some cases though,
988
- * the caller is not _required_ to specify the payer, but is still allowed to:
989
- * in the [`Message`] structure, the first account is always the fee-payer, so
990
- * if the caller has knowledge that the first account of the constructed
991
- * transaction's `Message` is both a signer and the expected fee-payer, then
992
- * redundantly specifying the fee-payer is not strictly required.
989
+ * wasm-bindgen version of the Transaction struct.
990
+ * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
991
+ * is fixed. This must not diverge from the regular non-wasm Transaction struct.
993
992
  */
994
993
  export class Transaction {
995
994
  free(): void;
package/index_bg.js CHANGED
@@ -287,6 +287,83 @@ export function solana_program_init() {
287
287
  wasm.solana_program_init();
288
288
  }
289
289
 
290
+ const ElGamalKeypairFinalization = (typeof FinalizationRegistry === 'undefined')
291
+ ? { register: () => {}, unregister: () => {} }
292
+ : new FinalizationRegistry(ptr => wasm.__wbg_elgamalkeypair_free(ptr >>> 0, 1));
293
+ /**
294
+ * A (twisted) ElGamal encryption keypair.
295
+ *
296
+ * The instances of the secret key are zeroized on drop.
297
+ */
298
+ export class ElGamalKeypair {
299
+
300
+ static __wrap(ptr) {
301
+ ptr = ptr >>> 0;
302
+ const obj = Object.create(ElGamalKeypair.prototype);
303
+ obj.__wbg_ptr = ptr;
304
+ ElGamalKeypairFinalization.register(obj, obj.__wbg_ptr, obj);
305
+ return obj;
306
+ }
307
+
308
+ __destroy_into_raw() {
309
+ const ptr = this.__wbg_ptr;
310
+ this.__wbg_ptr = 0;
311
+ ElGamalKeypairFinalization.unregister(this);
312
+ return ptr;
313
+ }
314
+
315
+ free() {
316
+ const ptr = this.__destroy_into_raw();
317
+ wasm.__wbg_elgamalkeypair_free(ptr, 0);
318
+ }
319
+ /**
320
+ * Generates the public and secret keys for ElGamal encryption.
321
+ *
322
+ * This function is randomized. It internally samples a scalar element using `OsRng`.
323
+ * @returns {ElGamalKeypair}
324
+ */
325
+ static new_rand() {
326
+ const ret = wasm.elgamalkeypair_new_rand();
327
+ return ElGamalKeypair.__wrap(ret);
328
+ }
329
+ /**
330
+ * @returns {ElGamalPubkey}
331
+ */
332
+ pubkey_owned() {
333
+ const ret = wasm.elgamalkeypair_pubkey_owned(this.__wbg_ptr);
334
+ return ElGamalPubkey.__wrap(ret);
335
+ }
336
+ }
337
+
338
+ const ElGamalPubkeyFinalization = (typeof FinalizationRegistry === 'undefined')
339
+ ? { register: () => {}, unregister: () => {} }
340
+ : new FinalizationRegistry(ptr => wasm.__wbg_elgamalpubkey_free(ptr >>> 0, 1));
341
+ /**
342
+ * Public key for the ElGamal encryption scheme.
343
+ */
344
+ export class ElGamalPubkey {
345
+
346
+ static __wrap(ptr) {
347
+ ptr = ptr >>> 0;
348
+ const obj = Object.create(ElGamalPubkey.prototype);
349
+ obj.__wbg_ptr = ptr;
350
+ ElGamalPubkeyFinalization.register(obj, obj.__wbg_ptr, obj);
351
+ return obj;
352
+ }
353
+
354
+ __destroy_into_raw() {
355
+ const ptr = this.__wbg_ptr;
356
+ this.__wbg_ptr = 0;
357
+ ElGamalPubkeyFinalization.unregister(this);
358
+ return ptr;
359
+ }
360
+
361
+ free() {
362
+ const ptr = this.__destroy_into_raw();
363
+ wasm.__wbg_elgamalpubkey_free(ptr, 0);
364
+ }
365
+ }
366
+
290
367
  const HashFinalization = (typeof FinalizationRegistry === 'undefined')
291
368
  ? { register: () => {}, unregister: () => {} }
292
369
  : new FinalizationRegistry(ptr => wasm.__wbg_hash_free(ptr >>> 0, 1));
@@ -294,13 +371,10 @@ const HashFinalization = (typeof FinalizationRegistry === 'undefined')
294
371
  * A hash; the 32-byte output of a hashing algorithm.
295
372
  *
296
373
  * This struct is used most often in `solana-sdk` and related crates to contain
297
- * a [SHA-256] hash, but may instead contain a [blake3] hash, as created by the
298
- * [`blake3`] module (and used in [`Message::hash`]).
374
+ * a [SHA-256] hash, but may instead contain a [blake3] hash.
299
375
  *
300
376
  * [SHA-256]: https://en.wikipedia.org/wiki/SHA-2
301
377
  * [blake3]: https://github.com/BLAKE3-team/BLAKE3
302
- * [`blake3`]: crate::blake3
303
- * [`Message::hash`]: crate::message::Message::hash
304
378
  */
305
379
  export class Hash {
306
380
 
@@ -380,65 +454,9 @@ const InstructionFinalization = (typeof FinalizationRegistry === 'undefined')
380
454
  ? { register: () => {}, unregister: () => {} }
381
455
  : new FinalizationRegistry(ptr => wasm.__wbg_instruction_free(ptr >>> 0, 1));
382
456
  /**
383
- * A directive for a single invocation of a Solana program.
384
- *
385
- * An instruction specifies which program it is calling, which accounts it may
386
- * read or modify, and additional data that serves as input to the program. One
387
- * or more instructions are included in transactions submitted by Solana
388
- * clients. Instructions are also used to describe [cross-program
389
- * invocations][cpi].
390
- *
391
- * [cpi]: https://solana.com/docs/core/cpi
392
- *
393
- * During execution, a program will receive a list of account data as one of
394
- * its arguments, in the same order as specified during `Instruction`
395
- * construction.
396
- *
397
- * While Solana is agnostic to the format of the instruction data, it has
398
- * built-in support for serialization via [`borsh`] and [`bincode`].
399
- *
400
- * [`borsh`]: https://docs.rs/borsh/latest/borsh/
401
- * [`bincode`]: https://docs.rs/bincode/latest/bincode/
402
- *
403
- * # Specifying account metadata
404
- *
405
- * When constructing an [`Instruction`], a list of all accounts that may be
406
- * read or written during the execution of that instruction must be supplied as
407
- * [`AccountMeta`] values.
408
- *
409
- * Any account whose data may be mutated by the program during execution must
410
- * be specified as writable. During execution, writing to an account that was
411
- * not specified as writable will cause the transaction to fail. Writing to an
412
- * account that is not owned by the program will cause the transaction to fail.
413
- *
414
- * Any account whose lamport balance may be mutated by the program during
415
- * execution must be specified as writable. During execution, mutating the
416
- * lamports of an account that was not specified as writable will cause the
417
- * transaction to fail. While _subtracting_ lamports from an account not owned
418
- * by the program will cause the transaction to fail, _adding_ lamports to any
419
- * account is allowed, as long is it is mutable.
420
- *
421
- * Accounts that are not read or written by the program may still be specified
422
- * in an `Instruction`'s account list. These will affect scheduling of program
423
- * execution by the runtime, but will otherwise be ignored.
424
- *
425
- * When building a transaction, the Solana runtime coalesces all accounts used
426
- * by all instructions in that transaction, along with accounts and permissions
427
- * required by the runtime, into a single account list. Some accounts and
428
- * account permissions required by the runtime to process a transaction are
429
- * _not_ required to be included in an `Instruction`s account list. These
430
- * include:
431
- *
432
- * - The program ID &mdash; it is a separate field of `Instruction`
433
- * - The transaction's fee-paying account &mdash; it is added during [`Message`]
434
- * construction. A program may still require the fee payer as part of the
435
- * account list if it directly references it.
436
- *
437
- * [`Message`]: crate::message::Message
438
- *
439
- * Programs may require signatures from some accounts, in which case they
440
- * should be specified as signers during `Instruction` construction. The
441
- * program must still validate during execution that the account is a signer.
457
+ * wasm-bindgen version of the Instruction struct.
458
+ * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
459
+ * is fixed. This must not diverge from the regular non-wasm Instruction struct.
442
460
  */
443
461
  export class Instruction {
444
462
 
@@ -700,7 +718,7 @@ const MarketGraphFinalization = (typeof FinalizationRegistry === 'undefined')
700
718
  ? { register: () => {}, unregister: () => {} }
701
719
  : new FinalizationRegistry(ptr => wasm.__wbg_marketgraph_free(ptr >>> 0, 1));
702
720
  /**
703
- * A JS binding for [`MarkegGraph`].
721
+ * A JS binding for [`MarketGraph`].
704
722
  */
705
723
  export class MarketGraph {
706
724
 
@@ -885,20 +903,9 @@ const MessageFinalization = (typeof FinalizationRegistry === 'undefined')
885
903
  ? { register: () => {}, unregister: () => {} }
886
904
  : new FinalizationRegistry(ptr => wasm.__wbg_message_free(ptr >>> 0, 1));
887
905
  /**
888
- * A Solana transaction message (legacy).
889
- *
890
- * See the [`message`] module documentation for further description.
891
- *
892
- * [`message`]: crate::message
893
- *
894
- * Some constructors accept an optional `payer`, the account responsible for
895
- * paying the cost of executing a transaction. In most cases, callers should
896
- * specify the payer explicitly in these constructors. In some cases though,
897
- * the caller is not _required_ to specify the payer, but is still allowed to:
898
- * in the `Message` structure, the first account is always the fee-payer, so if
899
- * the caller has knowledge that the first account of the constructed
900
- * transaction's `Message` is both a signer and the expected fee-payer, then
901
- * redundantly specifying the fee-payer is not strictly required.
906
+ * wasm-bindgen version of the Message struct.
907
+ * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
908
+ * is fixed. This must not diverge from the regular non-wasm Message struct.
902
909
  */
903
910
  export class Message {
904
911
 
@@ -940,6 +947,105 @@ export class Message {
940
947
  }
941
948
  }
942
949
 
950
+ const PodElGamalPubkeyFinalization = (typeof FinalizationRegistry === 'undefined')
951
+ ? { register: () => {}, unregister: () => {} }
952
+ : new FinalizationRegistry(ptr => wasm.__wbg_podelgamalpubkey_free(ptr >>> 0, 1));
953
+ /**
954
+ * The `ElGamalPubkey` type as a `Pod`.
955
+ */
956
+ export class PodElGamalPubkey {
957
+
958
+ static __wrap(ptr) {
959
+ ptr = ptr >>> 0;
960
+ const obj = Object.create(PodElGamalPubkey.prototype);
961
+ obj.__wbg_ptr = ptr;
962
+ PodElGamalPubkeyFinalization.register(obj, obj.__wbg_ptr, obj);
963
+ return obj;
964
+ }
965
+
966
+ __destroy_into_raw() {
967
+ const ptr = this.__wbg_ptr;
968
+ this.__wbg_ptr = 0;
969
+ PodElGamalPubkeyFinalization.unregister(this);
970
+ return ptr;
971
+ }
972
+
973
+ free() {
974
+ const ptr = this.__destroy_into_raw();
975
+ wasm.__wbg_podelgamalpubkey_free(ptr, 0);
976
+ }
977
+ /**
978
+ * Create a new `PodElGamalPubkey` object
979
+ *
980
+ * * `value` - optional public key as a base64 encoded string, `Uint8Array`, `[number]`
981
+ * @param {any} value
982
+ */
983
+ constructor(value) {
984
+ const ret = wasm.podelgamalpubkey_constructor(value);
985
+ if (ret[2]) {
986
+ throw takeFromExternrefTable0(ret[1]);
987
+ }
988
+ this.__wbg_ptr = ret[0] >>> 0;
989
+ PodElGamalPubkeyFinalization.register(this, this.__wbg_ptr, this);
990
+ return this;
991
+ }
992
+ /**
993
+ * Return the base64 string representation of the public key
994
+ * @returns {string}
995
+ */
996
+ toString() {
997
+ let deferred1_0;
998
+ let deferred1_1;
999
+ try {
1000
+ const ret = wasm.podelgamalpubkey_toString(this.__wbg_ptr);
1001
+ deferred1_0 = ret[0];
1002
+ deferred1_1 = ret[1];
1003
+ return getStringFromWasm0(ret[0], ret[1]);
1004
+ } finally {
1005
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1006
+ }
1007
+ }
1008
+ /**
1009
+ * Checks if two `ElGamalPubkey`s are equal
1010
+ * @param {PodElGamalPubkey} other
1011
+ * @returns {boolean}
1012
+ */
1013
+ equals(other) {
1014
+ _assertClass(other, PodElGamalPubkey);
1015
+ const ret = wasm.podelgamalpubkey_equals(this.__wbg_ptr, other.__wbg_ptr);
1016
+ return ret !== 0;
1017
+ }
1018
+ /**
1019
+ * Return the `Uint8Array` representation of the public key
1020
+ * @returns {Uint8Array}
1021
+ */
1022
+ toBytes() {
1023
+ const ret = wasm.podelgamalpubkey_toBytes(this.__wbg_ptr);
1024
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1025
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1026
+ return v1;
1027
+ }
1028
+ /**
1029
+ * @param {ElGamalPubkey} decoded
1030
+ * @returns {PodElGamalPubkey}
1031
+ */
1032
+ static compressed(decoded) {
1033
+ _assertClass(decoded, ElGamalPubkey);
1034
+ const ret = wasm.podelgamalpubkey_compressed(decoded.__wbg_ptr);
1035
+ return PodElGamalPubkey.__wrap(ret);
1036
+ }
1037
+ /**
1038
+ * @returns {ElGamalPubkey}
1039
+ */
1040
+ decompressed() {
1041
+ const ret = wasm.podelgamalpubkey_decompressed(this.__wbg_ptr);
1042
+ if (ret[2]) {
1043
+ throw takeFromExternrefTable0(ret[1]);
1044
+ }
1045
+ return ElGamalPubkey.__wrap(ret[0]);
1046
+ }
1047
+ }
1048
+
943
1049
  const PositionFinalization = (typeof FinalizationRegistry === 'undefined')
944
1050
  ? { register: () => {}, unregister: () => {} }
945
1051
  : new FinalizationRegistry(ptr => wasm.__wbg_position_free(ptr >>> 0, 1));
@@ -1147,7 +1253,7 @@ export class Pubkey {
1147
1253
  */
1148
1254
  equals(other) {
1149
1255
  _assertClass(other, Pubkey);
1150
- const ret = wasm.hash_equals(this.__wbg_ptr, other.__wbg_ptr);
1256
+ const ret = wasm.pubkey_equals(this.__wbg_ptr, other.__wbg_ptr);
1151
1257
  return ret !== 0;
1152
1258
  }
1153
1259
  /**
@@ -1410,26 +1516,9 @@ const TransactionFinalization = (typeof FinalizationRegistry === 'undefined')
1410
1516
  ? { register: () => {}, unregister: () => {} }
1411
1517
  : new FinalizationRegistry(ptr => wasm.__wbg_transaction_free(ptr >>> 0, 1));
1412
1518
  /**
1413
- * An atomically-committed sequence of instructions.
1414
- *
1415
- * While [`Instruction`]s are the basic unit of computation in Solana,
1416
- * they are submitted by clients in [`Transaction`]s containing one or
1417
- * more instructions, and signed by one or more [`Signer`]s.
1418
- *
1419
- * [`Signer`]: crate::signer::Signer
1420
- *
1421
- * See the [module documentation] for more details about transactions.
1422
- *
1423
- * [module documentation]: self
1424
- *
1425
- * Some constructors accept an optional `payer`, the account responsible for
1426
- * paying the cost of executing a transaction. In most cases, callers should
1427
- * specify the payer explicitly in these constructors. In some cases though,
1428
- * the caller is not _required_ to specify the payer, but is still allowed to:
1429
- * in the [`Message`] structure, the first account is always the fee-payer, so
1430
- * if the caller has knowledge that the first account of the constructed
1431
- * transaction's `Message` is both a signer and the expected fee-payer, then
1432
- * redundantly specifying the fee-payer is not strictly required.
1519
+ * wasm-bindgen version of the Transaction struct.
1520
+ * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
1521
+ * is fixed. This must not diverge from the regular non-wasm Transaction struct.
1433
1522
  */
1434
1523
  export class Transaction {
1435
1524
 
@@ -1744,11 +1833,21 @@ export function __wbg_call_672a4d21634d4a24() { return handleError(function (arg
1744
1833
  return ret;
1745
1834
  }, arguments) };
1746
1835
 
1836
+ export function __wbg_call_7cccdd69e0791ae2() { return handleError(function (arg0, arg1, arg2) {
1837
+ const ret = arg0.call(arg1, arg2);
1838
+ return ret;
1839
+ }, arguments) };
1840
+
1747
1841
  export function __wbg_crypto_038798f665f985e2(arg0) {
1748
1842
  const ret = arg0.crypto;
1749
1843
  return ret;
1750
1844
  };
1751
1845
 
1846
+ export function __wbg_crypto_574e78ad8b13b65f(arg0) {
1847
+ const ret = arg0.crypto;
1848
+ return ret;
1849
+ };
1850
+
1752
1851
  export function __wbg_debug_3cb59063b29f58c1(arg0) {
1753
1852
  console.debug(arg0);
1754
1853
  };
@@ -1788,6 +1887,10 @@ export function __wbg_getRandomValues_7dfe5bd1b67c9ca1(arg0) {
1788
1887
  return ret;
1789
1888
  };
1790
1889
 
1890
+ export function __wbg_getRandomValues_b8f5dbd5f3995a9e() { return handleError(function (arg0, arg1) {
1891
+ arg0.getRandomValues(arg1);
1892
+ }, arguments) };
1893
+
1791
1894
  export function __wbg_getTime_46267b1c24877e30(arg0) {
1792
1895
  const ret = arg0.getTime();
1793
1896
  return ret;
@@ -1868,6 +1971,11 @@ export function __wbg_log_c222819a41e063d3(arg0) {
1868
1971
  console.log(arg0);
1869
1972
  };
1870
1973
 
1974
+ export function __wbg_msCrypto_a61aeb35a24c1329(arg0) {
1975
+ const ret = arg0.msCrypto;
1976
+ return ret;
1977
+ };
1978
+
1871
1979
  export function __wbg_msCrypto_ff35fce085fab2a3(arg0) {
1872
1980
  const ret = arg0.msCrypto;
1873
1981
  return ret;
@@ -1898,6 +2006,16 @@ export function __wbg_new_a12002a7f91c75be(arg0) {
1898
2006
  return ret;
1899
2007
  };
1900
2008
 
2009
+ export function __wbg_newnoargs_105ed471475aaf50(arg0, arg1) {
2010
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
2011
+ return ret;
2012
+ };
2013
+
2014
+ export function __wbg_newwithbyteoffsetandlength_d97e637ebe145a9a(arg0, arg1, arg2) {
2015
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
2016
+ return ret;
2017
+ };
2018
+
1901
2019
  export function __wbg_newwithlength_a381634e90c276d4(arg0) {
1902
2020
  const ret = new Uint8Array(arg0 >>> 0);
1903
2021
  return ret;
@@ -1918,6 +2036,16 @@ export function __wbg_next_6574e1a8a62d1055() { return handleError(function (arg
1918
2036
  return ret;
1919
2037
  }, arguments) };
1920
2038
 
2039
+ export function __wbg_node_905d3e251edff8a2(arg0) {
2040
+ const ret = arg0.node;
2041
+ return ret;
2042
+ };
2043
+
2044
+ export function __wbg_process_dc0fbacc7c1c06f7(arg0) {
2045
+ const ret = arg0.process;
2046
+ return ret;
2047
+ };
2048
+
1921
2049
  export function __wbg_pubkey_new(arg0) {
1922
2050
  const ret = Pubkey.__wrap(arg0);
1923
2051
  return ret;
@@ -1932,11 +2060,20 @@ export function __wbg_randomFillSync_994ac6d9ade7a695(arg0, arg1, arg2) {
1932
2060
  arg0.randomFillSync(getArrayU8FromWasm0(arg1, arg2));
1933
2061
  };
1934
2062
 
2063
+ export function __wbg_randomFillSync_ac0988aba3254290() { return handleError(function (arg0, arg1) {
2064
+ arg0.randomFillSync(arg1);
2065
+ }, arguments) };
2066
+
1935
2067
  export function __wbg_require_0d6aeaec3c042c88(arg0, arg1, arg2) {
1936
2068
  const ret = arg0.require(getStringFromWasm0(arg1, arg2));
1937
2069
  return ret;
1938
2070
  };
1939
2071
 
2072
+ export function __wbg_require_60cc747a6bc5215a() { return handleError(function () {
2073
+ const ret = module.require;
2074
+ return ret;
2075
+ }, arguments) };
2076
+
1940
2077
  export function __wbg_self_25aabeb5a7b41685() { return handleError(function () {
1941
2078
  const ret = self.self;
1942
2079
  return ret;
@@ -1962,11 +2099,31 @@ export function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
1962
2099
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1963
2100
  };
1964
2101
 
2102
+ export function __wbg_static_accessor_GLOBAL_88a902d13a557d07() {
2103
+ const ret = typeof global === 'undefined' ? null : global;
2104
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2105
+ };
2106
+
2107
+ export function __wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0() {
2108
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
2109
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2110
+ };
2111
+
1965
2112
  export function __wbg_static_accessor_MODULE_ef3aa2eb251158a5() {
1966
2113
  const ret = module;
1967
2114
  return ret;
1968
2115
  };
1969
2116
 
2117
+ export function __wbg_static_accessor_SELF_37c5d418e4bf5819() {
2118
+ const ret = typeof self === 'undefined' ? null : self;
2119
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2120
+ };
2121
+
2122
+ export function __wbg_static_accessor_WINDOW_5de37043a91a9c40() {
2123
+ const ret = typeof window === 'undefined' ? null : window;
2124
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2125
+ };
2126
+
1970
2127
  export function __wbg_subarray_aa9065fa9dc5df96(arg0, arg1, arg2) {
1971
2128
  const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1972
2129
  return ret;
@@ -1982,6 +2139,11 @@ export function __wbg_values_99f7a68c7f313d66(arg0) {
1982
2139
  return ret;
1983
2140
  };
1984
2141
 
2142
+ export function __wbg_versions_c01dfd4722a88165(arg0) {
2143
+ const ret = arg0.versions;
2144
+ return ret;
2145
+ };
2146
+
1985
2147
  export function __wbg_warn_4ca3906c248c47c4(arg0) {
1986
2148
  console.warn(arg0);
1987
2149
  };
package/index_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@gmsol-labs/gmsol-sdk",
3
3
  "type": "module",
4
4
  "description": "GMX-Solana is an extension of GMX on the Solana blockchain.",
5
- "version": "0.5.0",
5
+ "version": "0.7.0-beta.2",
6
6
  "license": "SEE LICENSE IN ../../LICENSE",
7
7
  "repository": {
8
8
  "type": "git",