@gmsol-labs/gmsol-sdk 0.7.0 → 0.7.1

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
@@ -14,17 +14,17 @@
14
14
 
15
15
  | Program | Last Audit Date | Version |
16
16
  | ------------------- | --------------- | --------- |
17
- | [gmsol-store] | [2025-07-28] | [3202f7c] |
18
- | [gmsol-treasury] | [2025-07-28] | [3202f7c] |
19
- | [gmsol-timelock] | [2025-07-28] | [3202f7c] |
20
- | [gmsol-competition] | [2025-07-28] | [3202f7c] |
17
+ | [gmsol-store] | [2025-08-08] | [cd0dfc8] |
18
+ | [gmsol-treasury] | [2025-08-08] | [cd0dfc8] |
19
+ | [gmsol-timelock] | [2025-08-08] | [cd0dfc8] |
20
+ | [gmsol-competition] | [2025-08-08] | [cd0dfc8] |
21
21
 
22
22
  [gmsol-store]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/store
23
23
  [gmsol-treasury]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/treasury
24
24
  [gmsol-timelock]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/timelock
25
25
  [gmsol-competition]: https://github.com/gmsol-labs/gmx-solana/tree/main/programs/competition
26
- [2025-07-28]: https://github.com/gmsol-labs/gmx-solana-audits/blob/main/GMX_Solana_Audit_Report_July_28_2025_Zenith.pdf
27
- [3202f7c]: https://github.com/gmsol-labs/gmx-solana/commit/3202f7ca1a01a076425af59d2bca7369fe9c156c
26
+ [2025-08-08]: https://github.com/gmsol-labs/gmx-solana-audits/blob/main/GMX_Solana_Audit_Report_August_8_2025_Zenith.pdf
27
+ [cd0dfc8]: https://github.com/gmsol-labs/gmx-solana/commit/cd0dfc84b5e2b1857f54c6cdbe25459fb6e43145
28
28
 
29
29
  ## Integration
30
30
 
@@ -34,7 +34,7 @@ Add the following to your `Cargo.toml`:
34
34
 
35
35
  ```toml
36
36
  [dependencies]
37
- gmsol-sdk = { version = "0.7.0", features = ["client"] }
37
+ gmsol-sdk = { version = "0.7", features = ["client"] }
38
38
  ```
39
39
 
40
40
  Create a `Client` and start using the core APIs:
package/index.d.ts CHANGED
@@ -53,7 +53,7 @@ export interface MarketStatusParams {
53
53
  }
54
54
 
55
55
  /**
56
- * Best Swap path.
56
+ * Best swap path.
57
57
  */
58
58
  export interface BestSwapPath {
59
59
  /**
@@ -74,6 +74,47 @@ export interface BestSwapPath {
74
74
  arbitrage_exists: boolean | undefined;
75
75
  }
76
76
 
77
+ /**
78
+ * Arguments for order simulation.
79
+ */
80
+ export interface SimulateOrderArgs {
81
+ kind: CreateOrderKind;
82
+ params: CreateOrderParams;
83
+ collateral_or_swap_out_token: StringPubkey;
84
+ pay_token?: StringPubkey | undefined;
85
+ receive_token?: StringPubkey | undefined;
86
+ swap_path?: StringPubkey[] | undefined;
87
+ prefer_swap_out_token_update?: boolean | undefined;
88
+ }
89
+
90
+ /**
91
+ * Simulation output for increase order.
92
+ */
93
+ export interface IncreaseOrderSimulationOutput {
94
+ swaps: string[];
95
+ report: string;
96
+ position: string;
97
+ }
98
+
99
+ /**
100
+ * Simulation output for decrease order.
101
+ */
102
+ export interface DecreaseOrderSimulationOutput {
103
+ swaps: string[];
104
+ report: string;
105
+ position: string;
106
+ decrease_swap: string | undefined;
107
+ }
108
+
109
+ /**
110
+ * Simulation output for swap order.
111
+ */
112
+ export interface SwapOrderSimulationOutput {
113
+ output_token: StringPubkey;
114
+ amount: bigint;
115
+ report: string[];
116
+ }
117
+
77
118
  /**
78
119
  * Options for creating orders.
79
120
  */
@@ -836,6 +877,10 @@ export class MarketGraph {
836
877
  * Compute best swap path.
837
878
  */
838
879
  best_swap_path(source: string, target: string, skip_bellman_ford: boolean): BestSwapPath;
880
+ /**
881
+ * Simulates order execution.
882
+ */
883
+ simulate_order(args: SimulateOrderArgs, position?: Position | null): OrderSimulationOutput;
839
884
  }
840
885
  /**
841
886
  * Wrapper of [`MarketModel`].
@@ -865,6 +910,25 @@ export class Message {
865
910
  */
866
911
  recent_blockhash: Hash;
867
912
  }
913
+ /**
914
+ * A JS binding for [`OrderSimulationOutput`].
915
+ */
916
+ export class OrderSimulationOutput {
917
+ private constructor();
918
+ free(): void;
919
+ /**
920
+ * Returns increase order simulation output.
921
+ */
922
+ increase(): IncreaseOrderSimulationOutput | undefined;
923
+ /**
924
+ * Returns decrease order simulation output.
925
+ */
926
+ decrease(): DecreaseOrderSimulationOutput | undefined;
927
+ /**
928
+ * Returns swap order simulation output.
929
+ */
930
+ swap(): SwapOrderSimulationOutput | undefined;
931
+ }
868
932
  /**
869
933
  * The `ElGamalPubkey` type as a `Pod`.
870
934
  */
@@ -928,6 +992,10 @@ export class PositionModel {
928
992
  * Get collateral amount.
929
993
  */
930
994
  collateral_amount(): bigint;
995
+ /**
996
+ * Returns the inner [`JsPosition`].
997
+ */
998
+ position(): Position;
931
999
  }
932
1000
  /**
933
1001
  * The address of a [Solana account][acc].
package/index_bg.js CHANGED
@@ -212,6 +212,12 @@ function getArrayJsValueFromWasm0(ptr, len) {
212
212
  return result;
213
213
  }
214
214
 
215
+ function _assertClass(instance, klass) {
216
+ if (!(instance instanceof klass)) {
217
+ throw new Error(`expected instance of ${klass.name}`);
218
+ }
219
+ }
220
+
215
221
  function passArrayJsValueToWasm0(array, malloc) {
216
222
  const ptr = malloc(array.length * 4, 4) >>> 0;
217
223
  for (let i = 0; i < array.length; i++) {
@@ -264,11 +270,6 @@ export function update_orders(args) {
264
270
  return TransactionGroup.__wrap(ret[0]);
265
271
  }
266
272
 
267
- function _assertClass(instance, klass) {
268
- if (!(instance instanceof klass)) {
269
- throw new Error(`expected instance of ${klass.name}`);
270
- }
271
- }
272
273
  /**
273
274
  * Apply `factor` to the `value`.
274
275
  * @param {bigint} value
@@ -844,6 +845,24 @@ export class MarketGraph {
844
845
  }
845
846
  return takeFromExternrefTable0(ret[0]);
846
847
  }
848
+ /**
849
+ * Simulates order execution.
850
+ * @param {SimulateOrderArgs} args
851
+ * @param {Position | null} [position]
852
+ * @returns {OrderSimulationOutput}
853
+ */
854
+ simulate_order(args, position) {
855
+ let ptr0 = 0;
856
+ if (!isLikeNone(position)) {
857
+ _assertClass(position, Position);
858
+ ptr0 = position.__destroy_into_raw();
859
+ }
860
+ const ret = wasm.marketgraph_simulate_order(this.__wbg_ptr, args, ptr0);
861
+ if (ret[2]) {
862
+ throw takeFromExternrefTable0(ret[1]);
863
+ }
864
+ return OrderSimulationOutput.__wrap(ret[0]);
865
+ }
847
866
  }
848
867
 
849
868
  const MarketModelFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -947,6 +966,68 @@ export class Message {
947
966
  }
948
967
  }
949
968
 
969
+ const OrderSimulationOutputFinalization = (typeof FinalizationRegistry === 'undefined')
970
+ ? { register: () => {}, unregister: () => {} }
971
+ : new FinalizationRegistry(ptr => wasm.__wbg_ordersimulationoutput_free(ptr >>> 0, 1));
972
+ /**
973
+ * A JS binding for [`OrderSimulationOutput`].
974
+ */
975
+ export class OrderSimulationOutput {
976
+
977
+ static __wrap(ptr) {
978
+ ptr = ptr >>> 0;
979
+ const obj = Object.create(OrderSimulationOutput.prototype);
980
+ obj.__wbg_ptr = ptr;
981
+ OrderSimulationOutputFinalization.register(obj, obj.__wbg_ptr, obj);
982
+ return obj;
983
+ }
984
+
985
+ __destroy_into_raw() {
986
+ const ptr = this.__wbg_ptr;
987
+ this.__wbg_ptr = 0;
988
+ OrderSimulationOutputFinalization.unregister(this);
989
+ return ptr;
990
+ }
991
+
992
+ free() {
993
+ const ptr = this.__destroy_into_raw();
994
+ wasm.__wbg_ordersimulationoutput_free(ptr, 0);
995
+ }
996
+ /**
997
+ * Returns increase order simulation output.
998
+ * @returns {IncreaseOrderSimulationOutput | undefined}
999
+ */
1000
+ increase() {
1001
+ const ret = wasm.ordersimulationoutput_increase(this.__wbg_ptr);
1002
+ if (ret[2]) {
1003
+ throw takeFromExternrefTable0(ret[1]);
1004
+ }
1005
+ return takeFromExternrefTable0(ret[0]);
1006
+ }
1007
+ /**
1008
+ * Returns decrease order simulation output.
1009
+ * @returns {DecreaseOrderSimulationOutput | undefined}
1010
+ */
1011
+ decrease() {
1012
+ const ret = wasm.ordersimulationoutput_decrease(this.__wbg_ptr);
1013
+ if (ret[2]) {
1014
+ throw takeFromExternrefTable0(ret[1]);
1015
+ }
1016
+ return takeFromExternrefTable0(ret[0]);
1017
+ }
1018
+ /**
1019
+ * Returns swap order simulation output.
1020
+ * @returns {SwapOrderSimulationOutput | undefined}
1021
+ */
1022
+ swap() {
1023
+ const ret = wasm.ordersimulationoutput_swap(this.__wbg_ptr);
1024
+ if (ret[2]) {
1025
+ throw takeFromExternrefTable0(ret[1]);
1026
+ }
1027
+ return takeFromExternrefTable0(ret[0]);
1028
+ }
1029
+ }
1030
+
950
1031
  const PodElGamalPubkeyFinalization = (typeof FinalizationRegistry === 'undefined')
951
1032
  ? { register: () => {}, unregister: () => {} }
952
1033
  : new FinalizationRegistry(ptr => wasm.__wbg_podelgamalpubkey_free(ptr >>> 0, 1));
@@ -1165,6 +1246,14 @@ export class PositionModel {
1165
1246
  const ret = wasm.positionmodel_collateral_amount(this.__wbg_ptr);
1166
1247
  return (BigInt.asUintN(64, ret[0]) | (BigInt.asUintN(64, ret[1]) << BigInt(64)));
1167
1248
  }
1249
+ /**
1250
+ * Returns the inner [`JsPosition`].
1251
+ * @returns {Position}
1252
+ */
1253
+ position() {
1254
+ const ret = wasm.positionmodel_position(this.__wbg_ptr);
1255
+ return Position.__wrap(ret);
1256
+ }
1168
1257
  }
1169
1258
 
1170
1259
  const PubkeyFinalization = (typeof FinalizationRegistry === 'undefined')
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.7.0",
5
+ "version": "0.7.1",
6
6
  "license": "SEE LICENSE IN ../../LICENSE",
7
7
  "repository": {
8
8
  "type": "git",