@gmsol-labs/gmsol-sdk 0.8.0-beta.0 → 0.8.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/index.d.ts CHANGED
@@ -56,6 +56,40 @@ export interface MarketStatusParams {
56
56
  prices: Prices;
57
57
  }
58
58
 
59
+ /**
60
+ * Parameters for creating empty position model.
61
+ */
62
+ export interface CreateEmptyPositionArgs {
63
+ /**
64
+ * Is long side.
65
+ */
66
+ is_long: boolean;
67
+ /**
68
+ * Collateral token.
69
+ */
70
+ collateral_token: StringPubkey;
71
+ /**
72
+ * The owner of the position.
73
+ *
74
+ * If set to `None`, the `owner` will use the default pubkey.
75
+ */
76
+ owner?: StringPubkey | undefined;
77
+ /**
78
+ * The timestamp of the position creation.
79
+ */
80
+ created_at?: number | undefined;
81
+ /**
82
+ * Whether to generate a bump seed.
83
+ *
84
+ * If set `false`, the `bump` will be fixed to `0`.
85
+ */
86
+ generate_bump?: boolean | undefined;
87
+ /**
88
+ * The store program ID used to generate the bump seed.
89
+ */
90
+ store_program_id?: StringPubkey | undefined;
91
+ }
92
+
59
93
  /**
60
94
  * Best swap path.
61
95
  */
@@ -78,47 +112,6 @@ export interface BestSwapPath {
78
112
  arbitrage_exists: boolean | undefined;
79
113
  }
80
114
 
81
- /**
82
- * Arguments for order simulation.
83
- */
84
- export interface SimulateOrderArgs {
85
- kind: CreateOrderKind;
86
- params: CreateOrderParams;
87
- collateral_or_swap_out_token: StringPubkey;
88
- pay_token?: StringPubkey | undefined;
89
- receive_token?: StringPubkey | undefined;
90
- swap_path?: StringPubkey[] | undefined;
91
- prefer_swap_out_token_update?: boolean | undefined;
92
- }
93
-
94
- /**
95
- * Simulation output for increase order.
96
- */
97
- export interface IncreaseOrderSimulationOutput {
98
- swaps: string[];
99
- report: string;
100
- position: string;
101
- }
102
-
103
- /**
104
- * Simulation output for decrease order.
105
- */
106
- export interface DecreaseOrderSimulationOutput {
107
- swaps: string[];
108
- report: string;
109
- position: string;
110
- decrease_swap: string | undefined;
111
- }
112
-
113
- /**
114
- * Simulation output for swap order.
115
- */
116
- export interface SwapOrderSimulationOutput {
117
- output_token: StringPubkey;
118
- amount: bigint;
119
- report: string[];
120
- }
121
-
122
115
  /**
123
116
  * Options for creating orders.
124
117
  */
@@ -196,6 +189,50 @@ export interface BuildTransactionOptions {
196
189
  compute_unit_min_priority_lamports?: number | undefined;
197
190
  }
198
191
 
192
+ /**
193
+ * Arguments for order simulation.
194
+ */
195
+ export interface SimulateOrderArgs {
196
+ kind: CreateOrderKind;
197
+ params: CreateOrderParams;
198
+ collateral_or_swap_out_token: StringPubkey;
199
+ pay_token?: StringPubkey | undefined;
200
+ receive_token?: StringPubkey | undefined;
201
+ swap_path?: StringPubkey[] | undefined;
202
+ prefer_swap_out_token_update?: boolean | undefined;
203
+ skip_limit_price_validation?: boolean | undefined;
204
+ limit_swap_slippage?: bigint | undefined;
205
+ update_prices_for_limit_order?: boolean | undefined;
206
+ }
207
+
208
+ /**
209
+ * Simulation output for increase order.
210
+ */
211
+ export interface IncreaseOrderSimulationOutput {
212
+ swaps: string[];
213
+ report: string;
214
+ position: string | undefined;
215
+ }
216
+
217
+ /**
218
+ * Simulation output for decrease order.
219
+ */
220
+ export interface DecreaseOrderSimulationOutput {
221
+ swaps: string[];
222
+ report: string;
223
+ position: string | undefined;
224
+ decrease_swap: string | undefined;
225
+ }
226
+
227
+ /**
228
+ * Simulation output for swap order.
229
+ */
230
+ export interface SwapOrderSimulationOutput {
231
+ output_token: StringPubkey;
232
+ amount: bigint;
233
+ report: string[];
234
+ }
235
+
199
236
 
200
237
  /**
201
238
  * A Base58-encoded string representing a public key.
@@ -203,6 +240,26 @@ export interface BuildTransactionOptions {
203
240
  export type StringPubkey = string;
204
241
 
205
242
 
243
+ /**
244
+ * Options for updating [`MarketGraph`] with [`Simulator`].
245
+ */
246
+ export interface UpdateGraphWithSimulatorOptions {
247
+ /**
248
+ * Whether to update token prices with the simulator.
249
+ */
250
+ update_token_prices?: boolean | undefined;
251
+ }
252
+
253
+ /**
254
+ * Options for creating [`Simulator`].
255
+ */
256
+ export interface CreateGraphSimulatorOptions {
257
+ /**
258
+ * Market filter.
259
+ */
260
+ market_filter?: StringPubkey[] | undefined;
261
+ }
262
+
206
263
  /**
207
264
  * Config for [`MarketGraph`](super::MarketGraph).
208
265
  */
@@ -443,6 +500,426 @@ export interface Callback {
443
500
  partitioned_data: StringPubkey;
444
501
  }
445
502
 
503
+ /**
504
+ * Hint for pool tokens.
505
+ */
506
+ export interface PoolTokenHint {
507
+ /**
508
+ * Long token.
509
+ */
510
+ long_token: StringPubkey;
511
+ /**
512
+ * Short token.
513
+ */
514
+ short_token: StringPubkey;
515
+ }
516
+
517
+ /**
518
+ * Hint for [`CreateGlvWithdrawal`].
519
+ */
520
+ export interface CreateGlvWithdrawalHint {
521
+ /**
522
+ * Pool tokens.
523
+ */
524
+ pool_tokens: PoolTokenHint;
525
+ }
526
+
527
+ /**
528
+ * Builder for the `create_glv_withdrawal` instruction.
529
+ */
530
+ export interface CreateGlvWithdrawal {
531
+ /**
532
+ * Program.
533
+ */
534
+ program?: StoreProgram;
535
+ /**
536
+ * Payer (a.k.a. owner).
537
+ */
538
+ payer: StringPubkey;
539
+ /**
540
+ * Reciever.
541
+ */
542
+ receiver?: StringPubkey | undefined;
543
+ /**
544
+ * Nonce for the GLV withdrawal.
545
+ */
546
+ nonce?: NonceBytes | undefined;
547
+ /**
548
+ * Execution fee paid to the keeper in lamports.
549
+ */
550
+ execution_lamports?: number;
551
+ /**
552
+ * The GLV token.
553
+ */
554
+ glv_token: StringPubkey;
555
+ /**
556
+ * The market token of the market in which the GLV withdrawal will be created.
557
+ */
558
+ market_token: StringPubkey;
559
+ /**
560
+ * GLV token account.
561
+ */
562
+ glv_token_account?: StringPubkey | undefined;
563
+ /**
564
+ * Long receive token.
565
+ */
566
+ long_receive_token?: StringPubkey | undefined;
567
+ /**
568
+ * Swap path for long receive token.
569
+ */
570
+ long_swap_path?: StringPubkey[];
571
+ /**
572
+ * Short receive token.
573
+ */
574
+ short_receive_token?: StringPubkey | undefined;
575
+ /**
576
+ * Swap path for short receive token.
577
+ */
578
+ short_swap_path?: StringPubkey[];
579
+ /**
580
+ * GLV token amount.
581
+ */
582
+ glv_token_amount?: number;
583
+ /**
584
+ * Minimum amount of long receive tokens.
585
+ */
586
+ min_long_receive_amount?: number;
587
+ /**
588
+ * Minimum amount of short receive tokens.
589
+ */
590
+ min_short_receive_amount?: number;
591
+ /**
592
+ * Whether to unwrap the native token when receiving (e.g., convert WSOL to SOL).
593
+ */
594
+ unwrap_native_on_receive?: boolean;
595
+ /**
596
+ * Whether to skip the creation of long receive token ATA.
597
+ */
598
+ skip_long_receive_token_ata_creation?: boolean;
599
+ /**
600
+ * Whether to skip the creation of short receive token ATA.
601
+ */
602
+ skip_short_receive_token_ata_creation?: boolean;
603
+ }
604
+
605
+ /**
606
+ * Hint for [`CreateGlvDeposit`].
607
+ */
608
+ export interface CreateGlvDepositHint {
609
+ /**
610
+ * Pool tokens.
611
+ */
612
+ pool_tokens: PoolTokenHint;
613
+ }
614
+
615
+ /**
616
+ * Builder for the `create_glv_deposit` instruction.
617
+ */
618
+ export interface CreateGlvDeposit {
619
+ /**
620
+ * Program.
621
+ */
622
+ program?: StoreProgram;
623
+ /**
624
+ * Payer (a.k.a. owner).
625
+ */
626
+ payer: StringPubkey;
627
+ /**
628
+ * Reciever.
629
+ */
630
+ receiver?: StringPubkey | undefined;
631
+ /**
632
+ * Nonce for the deposit.
633
+ */
634
+ nonce?: NonceBytes | undefined;
635
+ /**
636
+ * The GLV token.
637
+ */
638
+ glv_token: StringPubkey;
639
+ /**
640
+ * The market token of the market in which the deposit will be created.
641
+ */
642
+ market_token: StringPubkey;
643
+ /**
644
+ * Execution fee paid to the keeper in lamports.
645
+ */
646
+ execution_lamports?: number;
647
+ /**
648
+ * Long pay token.
649
+ */
650
+ long_pay_token?: StringPubkey | undefined;
651
+ /**
652
+ * Long pay token account.
653
+ */
654
+ long_pay_token_account?: StringPubkey | undefined;
655
+ /**
656
+ * Swap path for long pay token.
657
+ */
658
+ long_swap_path?: StringPubkey[];
659
+ /**
660
+ * Short pay token.
661
+ */
662
+ short_pay_token?: StringPubkey | undefined;
663
+ /**
664
+ * Short pay token account.
665
+ */
666
+ short_pay_token_account?: StringPubkey | undefined;
667
+ /**
668
+ * Swap path for short pay token.
669
+ */
670
+ short_swap_path?: StringPubkey[];
671
+ /**
672
+ * Market token account.
673
+ */
674
+ market_token_account?: StringPubkey | undefined;
675
+ /**
676
+ * Long pay token amount.
677
+ */
678
+ long_pay_amount?: number;
679
+ /**
680
+ * Short pay token amount.
681
+ */
682
+ short_pay_amount?: number;
683
+ /**
684
+ * Market token amount to pay.
685
+ */
686
+ market_token_amount?: number;
687
+ /**
688
+ * Minimum amount of output market tokens.
689
+ */
690
+ min_market_token_amount?: number;
691
+ /**
692
+ * Minimum amount of output GLV tokens.
693
+ */
694
+ min_receive_amount?: number;
695
+ /**
696
+ * Whether to unwrap the native token when receiving (e.g., convert WSOL to SOL).
697
+ */
698
+ unwrap_native_on_receive?: boolean;
699
+ /**
700
+ * Whether to skip the creation of GLV token ATA.
701
+ */
702
+ skip_glv_token_ata_creation?: boolean;
703
+ }
704
+
705
+ /**
706
+ * Builder for the `create_shift` instruction.
707
+ */
708
+ export interface CreateShift {
709
+ /**
710
+ * Program.
711
+ */
712
+ program?: StoreProgram;
713
+ /**
714
+ * Payer (a.k.a. owner).
715
+ */
716
+ payer: StringPubkey;
717
+ /**
718
+ * Reciever.
719
+ */
720
+ receiver?: StringPubkey | undefined;
721
+ /**
722
+ * Nonce for the shift.
723
+ */
724
+ nonce?: NonceBytes | undefined;
725
+ /**
726
+ * The from-market token.
727
+ */
728
+ from_market_token: StringPubkey;
729
+ /**
730
+ * From-market token account.
731
+ */
732
+ from_market_token_account?: StringPubkey | undefined;
733
+ /**
734
+ * The to-market token.
735
+ */
736
+ to_market_token: StringPubkey;
737
+ /**
738
+ * Execution fee paid to the keeper in lamports.
739
+ */
740
+ execution_lamports?: number;
741
+ /**
742
+ * From-market token amount to pay.
743
+ */
744
+ from_market_token_amount?: number;
745
+ /**
746
+ * Minimum to-market token amount to receive.
747
+ */
748
+ min_to_market_token_amount?: number;
749
+ /**
750
+ * Whether to skip the creation of to-market token ATA.
751
+ */
752
+ skip_to_market_token_ata_creation?: boolean;
753
+ }
754
+
755
+ /**
756
+ * Hint for [`CreateWithdrawal`].
757
+ */
758
+ export interface CreateWithdrawalHint {
759
+ /**
760
+ * Pool tokens.
761
+ */
762
+ pool_tokens: PoolTokenHint;
763
+ }
764
+
765
+ /**
766
+ * Builder for the `create_withdrawal` instruction.
767
+ */
768
+ export interface CreateWithdrawal {
769
+ /**
770
+ * Program.
771
+ */
772
+ program?: StoreProgram;
773
+ /**
774
+ * Payer (a.k.a. owner).
775
+ */
776
+ payer: StringPubkey;
777
+ /**
778
+ * Reciever.
779
+ */
780
+ receiver?: StringPubkey | undefined;
781
+ /**
782
+ * Nonce for the withdrawal.
783
+ */
784
+ nonce?: NonceBytes | undefined;
785
+ /**
786
+ * Execution fee paid to the keeper in lamports.
787
+ */
788
+ execution_lamports?: number;
789
+ /**
790
+ * The market token of the market in which the withdrawal will be created.
791
+ */
792
+ market_token: StringPubkey;
793
+ /**
794
+ * Market token account.
795
+ */
796
+ market_token_account?: StringPubkey | undefined;
797
+ /**
798
+ * Long receive token.
799
+ */
800
+ long_receive_token?: StringPubkey | undefined;
801
+ /**
802
+ * Swap path for long receive token.
803
+ */
804
+ long_swap_path?: StringPubkey[];
805
+ /**
806
+ * Short receive token.
807
+ */
808
+ short_receive_token?: StringPubkey | undefined;
809
+ /**
810
+ * Swap path for short receive token.
811
+ */
812
+ short_swap_path?: StringPubkey[];
813
+ /**
814
+ * Market token amount.
815
+ */
816
+ market_token_amount?: number;
817
+ /**
818
+ * Minimum amount of long receive tokens.
819
+ */
820
+ min_long_receive_amount?: number;
821
+ /**
822
+ * Minimum amount of short receive tokens.
823
+ */
824
+ min_short_receive_amount?: number;
825
+ /**
826
+ * Whether to unwrap the native token when receiving (e.g., convert WSOL to SOL).
827
+ */
828
+ unwrap_native_on_receive?: boolean;
829
+ /**
830
+ * Whether to skip the creation of long receive token ATA.
831
+ */
832
+ skip_long_receive_token_ata_creation?: boolean;
833
+ /**
834
+ * Whether to skip the creation of short receive token ATA.
835
+ */
836
+ skip_short_receive_token_ata_creation?: boolean;
837
+ }
838
+
839
+ /**
840
+ * Hint for [`CreateDeposit`].
841
+ */
842
+ export interface CreateDepositHint {
843
+ /**
844
+ * Pool tokens.
845
+ */
846
+ pool_tokens: PoolTokenHint;
847
+ }
848
+
849
+ /**
850
+ * Builder for the `create_deposit` instruction.
851
+ */
852
+ export interface CreateDeposit {
853
+ /**
854
+ * Program.
855
+ */
856
+ program?: StoreProgram;
857
+ /**
858
+ * Payer (a.k.a. owner).
859
+ */
860
+ payer: StringPubkey;
861
+ /**
862
+ * Reciever.
863
+ */
864
+ receiver?: StringPubkey | undefined;
865
+ /**
866
+ * Nonce for the deposit.
867
+ */
868
+ nonce?: NonceBytes | undefined;
869
+ /**
870
+ * The market token of the market in which the deposit will be created.
871
+ */
872
+ market_token: StringPubkey;
873
+ /**
874
+ * Execution fee paid to the keeper in lamports.
875
+ */
876
+ execution_lamports?: number;
877
+ /**
878
+ * Long pay token.
879
+ */
880
+ long_pay_token?: StringPubkey | undefined;
881
+ /**
882
+ * Long pay token account.
883
+ */
884
+ long_pay_token_account?: StringPubkey | undefined;
885
+ /**
886
+ * Swap path for long pay token.
887
+ */
888
+ long_swap_path?: StringPubkey[];
889
+ /**
890
+ * Short pay token.
891
+ */
892
+ short_pay_token?: StringPubkey | undefined;
893
+ /**
894
+ * Short pay token account.
895
+ */
896
+ short_pay_token_account?: StringPubkey | undefined;
897
+ /**
898
+ * Swap path for short pay token.
899
+ */
900
+ short_swap_path?: StringPubkey[];
901
+ /**
902
+ * Long pay token amount.
903
+ */
904
+ long_pay_amount?: number;
905
+ /**
906
+ * Short pay token amount.
907
+ */
908
+ short_pay_amount?: number;
909
+ /**
910
+ * Minimum amount of output market tokens.
911
+ */
912
+ min_receive_amount?: number;
913
+ /**
914
+ * Whether to unwrap the native token when receiving (e.g., convert WSOL to SOL).
915
+ */
916
+ unwrap_native_on_receive?: boolean;
917
+ /**
918
+ * Whether to skip the creation of market token ATA.
919
+ */
920
+ skip_market_token_ata_creation?: boolean;
921
+ }
922
+
446
923
  /**
447
924
  * Hint for [`UpdateFeesState`].
448
925
  */
@@ -1102,6 +1579,14 @@ export class MarketGraph {
1102
1579
  * Simulates order execution.
1103
1580
  */
1104
1581
  simulate_order(args: SimulateOrderArgs, position?: Position | null): OrderSimulationOutput;
1582
+ /**
1583
+ * Create a simulator.
1584
+ */
1585
+ to_simulator(options?: CreateGraphSimulatorOptions | null): Simulator;
1586
+ /**
1587
+ * Update with simulator.
1588
+ */
1589
+ update_with_simulator(simulator: Simulator, options?: UpdateGraphWithSimulatorOptions | null): void;
1105
1590
  }
1106
1591
  /**
1107
1592
  * Wrapper of [`MarketModel`].
@@ -1117,6 +1602,10 @@ export class MarketModel {
1117
1602
  * Get market status.
1118
1603
  */
1119
1604
  status(params: MarketStatusParams): MarketStatus;
1605
+ /**
1606
+ * Create an empty position model.
1607
+ */
1608
+ create_empty_position(args: CreateEmptyPositionArgs): PositionModel;
1120
1609
  }
1121
1610
  /**
1122
1611
  * wasm-bindgen version of the Message struct.
@@ -1140,15 +1629,19 @@ export class OrderSimulationOutput {
1140
1629
  /**
1141
1630
  * Returns increase order simulation output.
1142
1631
  */
1143
- increase(): IncreaseOrderSimulationOutput | undefined;
1632
+ increase(skip_position?: boolean | null): IncreaseOrderSimulationOutput | undefined;
1144
1633
  /**
1145
1634
  * Returns decrease order simulation output.
1146
1635
  */
1147
- decrease(): DecreaseOrderSimulationOutput | undefined;
1636
+ decrease(skip_position?: boolean | null): DecreaseOrderSimulationOutput | undefined;
1148
1637
  /**
1149
1638
  * Returns swap order simulation output.
1150
1639
  */
1151
1640
  swap(): SwapOrderSimulationOutput | undefined;
1641
+ /**
1642
+ * Returns the result position model.
1643
+ */
1644
+ position_model(): PositionModel | undefined;
1152
1645
  }
1153
1646
  /**
1154
1647
  * The `ElGamalPubkey` type as a `Pod`.
@@ -1225,6 +1718,10 @@ export class PositionModel {
1225
1718
  * Returns the inner [`JsPosition`].
1226
1719
  */
1227
1720
  position(): Position;
1721
+ /**
1722
+ * Update with trade event.
1723
+ */
1724
+ update_with_trade_event(event: TradeEvent, force_update?: boolean | null): boolean;
1228
1725
  }
1229
1726
  /**
1230
1727
  * The address of a [Solana account][acc].
@@ -1282,6 +1779,49 @@ export class Pubkey {
1282
1779
  */
1283
1780
  static findProgramAddress(seeds: any[], program_id: Pubkey): any;
1284
1781
  }
1782
+ /**
1783
+ * A JS binding for [`Simulator`].
1784
+ */
1785
+ export class Simulator {
1786
+ private constructor();
1787
+ free(): void;
1788
+ /**
1789
+ * Get market by its market token.
1790
+ */
1791
+ get_market(market_token: string): MarketModel | undefined;
1792
+ /**
1793
+ * Get price for the given token.
1794
+ */
1795
+ get_price(token: string): Value | undefined;
1796
+ /**
1797
+ * Upsert the prices for the given token.
1798
+ */
1799
+ insert_price(token: string, price: Value): void;
1800
+ simulate_order(args: SimulateOrderArgs, position?: Position | null): OrderSimulationOutput;
1801
+ }
1802
+ /**
1803
+ * JS version of [`TradeEvent`].
1804
+ */
1805
+ export class TradeEvent {
1806
+ private constructor();
1807
+ free(): void;
1808
+ /**
1809
+ * Create from base64 encoded event data with options.
1810
+ */
1811
+ static decode_from_base64_with_options(data: string, no_discriminator?: boolean | null): TradeEvent;
1812
+ /**
1813
+ * Create from base64 encoded event data.
1814
+ */
1815
+ static decode_from_base64(data: string): TradeEvent;
1816
+ /**
1817
+ * Create from event data.
1818
+ */
1819
+ static decode_with_options(data: Uint8Array, no_discriminator?: boolean | null): TradeEvent;
1820
+ /**
1821
+ * Convert into a position model.
1822
+ */
1823
+ to_position_model(market: MarketModel): PositionModel;
1824
+ }
1285
1825
  /**
1286
1826
  * wasm-bindgen version of the Transaction struct.
1287
1827
  * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
package/index_bg.js CHANGED
@@ -949,6 +949,27 @@ export class MarketGraph {
949
949
  }
950
950
  return OrderSimulationOutput.__wrap(ret[0]);
951
951
  }
952
+ /**
953
+ * Create a simulator.
954
+ * @param {CreateGraphSimulatorOptions | null} [options]
955
+ * @returns {Simulator}
956
+ */
957
+ to_simulator(options) {
958
+ const ret = wasm.marketgraph_to_simulator(this.__wbg_ptr, isLikeNone(options) ? 0 : addToExternrefTable0(options));
959
+ return Simulator.__wrap(ret);
960
+ }
961
+ /**
962
+ * Update with simulator.
963
+ * @param {Simulator} simulator
964
+ * @param {UpdateGraphWithSimulatorOptions | null} [options]
965
+ */
966
+ update_with_simulator(simulator, options) {
967
+ _assertClass(simulator, Simulator);
968
+ const ret = wasm.marketgraph_update_with_simulator(this.__wbg_ptr, simulator.__wbg_ptr, isLikeNone(options) ? 0 : addToExternrefTable0(options));
969
+ if (ret[1]) {
970
+ throw takeFromExternrefTable0(ret[0]);
971
+ }
972
+ }
952
973
  }
953
974
 
954
975
  const MarketModelFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -1002,6 +1023,18 @@ export class MarketModel {
1002
1023
  }
1003
1024
  return takeFromExternrefTable0(ret[0]);
1004
1025
  }
1026
+ /**
1027
+ * Create an empty position model.
1028
+ * @param {CreateEmptyPositionArgs} args
1029
+ * @returns {PositionModel}
1030
+ */
1031
+ create_empty_position(args) {
1032
+ const ret = wasm.marketmodel_create_empty_position(this.__wbg_ptr, args);
1033
+ if (ret[2]) {
1034
+ throw takeFromExternrefTable0(ret[1]);
1035
+ }
1036
+ return PositionModel.__wrap(ret[0]);
1037
+ }
1005
1038
  }
1006
1039
 
1007
1040
  const MessageFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -1081,10 +1114,11 @@ export class OrderSimulationOutput {
1081
1114
  }
1082
1115
  /**
1083
1116
  * Returns increase order simulation output.
1117
+ * @param {boolean | null} [skip_position]
1084
1118
  * @returns {IncreaseOrderSimulationOutput | undefined}
1085
1119
  */
1086
- increase() {
1087
- const ret = wasm.ordersimulationoutput_increase(this.__wbg_ptr);
1120
+ increase(skip_position) {
1121
+ const ret = wasm.ordersimulationoutput_increase(this.__wbg_ptr, isLikeNone(skip_position) ? 0xFFFFFF : skip_position ? 1 : 0);
1088
1122
  if (ret[2]) {
1089
1123
  throw takeFromExternrefTable0(ret[1]);
1090
1124
  }
@@ -1092,10 +1126,11 @@ export class OrderSimulationOutput {
1092
1126
  }
1093
1127
  /**
1094
1128
  * Returns decrease order simulation output.
1129
+ * @param {boolean | null} [skip_position]
1095
1130
  * @returns {DecreaseOrderSimulationOutput | undefined}
1096
1131
  */
1097
- decrease() {
1098
- const ret = wasm.ordersimulationoutput_decrease(this.__wbg_ptr);
1132
+ decrease(skip_position) {
1133
+ const ret = wasm.ordersimulationoutput_decrease(this.__wbg_ptr, isLikeNone(skip_position) ? 0xFFFFFF : skip_position ? 1 : 0);
1099
1134
  if (ret[2]) {
1100
1135
  throw takeFromExternrefTable0(ret[1]);
1101
1136
  }
@@ -1112,6 +1147,14 @@ export class OrderSimulationOutput {
1112
1147
  }
1113
1148
  return takeFromExternrefTable0(ret[0]);
1114
1149
  }
1150
+ /**
1151
+ * Returns the result position model.
1152
+ * @returns {PositionModel | undefined}
1153
+ */
1154
+ position_model() {
1155
+ const ret = wasm.ordersimulationoutput_position_model(this.__wbg_ptr);
1156
+ return ret === 0 ? undefined : PositionModel.__wrap(ret);
1157
+ }
1115
1158
  }
1116
1159
 
1117
1160
  const PodElGamalPubkeyFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -1369,6 +1412,20 @@ export class PositionModel {
1369
1412
  const ret = wasm.positionmodel_position(this.__wbg_ptr);
1370
1413
  return Position.__wrap(ret);
1371
1414
  }
1415
+ /**
1416
+ * Update with trade event.
1417
+ * @param {TradeEvent} event
1418
+ * @param {boolean | null} [force_update]
1419
+ * @returns {boolean}
1420
+ */
1421
+ update_with_trade_event(event, force_update) {
1422
+ _assertClass(event, TradeEvent);
1423
+ const ret = wasm.positionmodel_update_with_trade_event(this.__wbg_ptr, event.__wbg_ptr, isLikeNone(force_update) ? 0xFFFFFF : force_update ? 1 : 0);
1424
+ if (ret[2]) {
1425
+ throw takeFromExternrefTable0(ret[1]);
1426
+ }
1427
+ return ret[0] !== 0;
1428
+ }
1372
1429
  }
1373
1430
 
1374
1431
  const PubkeyFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -1525,6 +1582,93 @@ export class Pubkey {
1525
1582
  }
1526
1583
  }
1527
1584
 
1585
+ const SimulatorFinalization = (typeof FinalizationRegistry === 'undefined')
1586
+ ? { register: () => {}, unregister: () => {} }
1587
+ : new FinalizationRegistry(ptr => wasm.__wbg_simulator_free(ptr >>> 0, 1));
1588
+ /**
1589
+ * A JS binding for [`Simulator`].
1590
+ */
1591
+ export class Simulator {
1592
+
1593
+ static __wrap(ptr) {
1594
+ ptr = ptr >>> 0;
1595
+ const obj = Object.create(Simulator.prototype);
1596
+ obj.__wbg_ptr = ptr;
1597
+ SimulatorFinalization.register(obj, obj.__wbg_ptr, obj);
1598
+ return obj;
1599
+ }
1600
+
1601
+ __destroy_into_raw() {
1602
+ const ptr = this.__wbg_ptr;
1603
+ this.__wbg_ptr = 0;
1604
+ SimulatorFinalization.unregister(this);
1605
+ return ptr;
1606
+ }
1607
+
1608
+ free() {
1609
+ const ptr = this.__destroy_into_raw();
1610
+ wasm.__wbg_simulator_free(ptr, 0);
1611
+ }
1612
+ /**
1613
+ * Get market by its market token.
1614
+ * @param {string} market_token
1615
+ * @returns {MarketModel | undefined}
1616
+ */
1617
+ get_market(market_token) {
1618
+ const ptr0 = passStringToWasm0(market_token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1619
+ const len0 = WASM_VECTOR_LEN;
1620
+ const ret = wasm.simulator_get_market(this.__wbg_ptr, ptr0, len0);
1621
+ if (ret[2]) {
1622
+ throw takeFromExternrefTable0(ret[1]);
1623
+ }
1624
+ return ret[0] === 0 ? undefined : MarketModel.__wrap(ret[0]);
1625
+ }
1626
+ /**
1627
+ * Get price for the given token.
1628
+ * @param {string} token
1629
+ * @returns {Value | undefined}
1630
+ */
1631
+ get_price(token) {
1632
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1633
+ const len0 = WASM_VECTOR_LEN;
1634
+ const ret = wasm.simulator_get_price(this.__wbg_ptr, ptr0, len0);
1635
+ if (ret[2]) {
1636
+ throw takeFromExternrefTable0(ret[1]);
1637
+ }
1638
+ return takeFromExternrefTable0(ret[0]);
1639
+ }
1640
+ /**
1641
+ * Upsert the prices for the given token.
1642
+ * @param {string} token
1643
+ * @param {Value} price
1644
+ */
1645
+ insert_price(token, price) {
1646
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1647
+ const len0 = WASM_VECTOR_LEN;
1648
+ const ret = wasm.simulator_insert_price(this.__wbg_ptr, ptr0, len0, price);
1649
+ if (ret[1]) {
1650
+ throw takeFromExternrefTable0(ret[0]);
1651
+ }
1652
+ }
1653
+ /**
1654
+ * @param {SimulateOrderArgs} args
1655
+ * @param {Position | null} [position]
1656
+ * @returns {OrderSimulationOutput}
1657
+ */
1658
+ simulate_order(args, position) {
1659
+ let ptr0 = 0;
1660
+ if (!isLikeNone(position)) {
1661
+ _assertClass(position, Position);
1662
+ ptr0 = position.__destroy_into_raw();
1663
+ }
1664
+ const ret = wasm.simulator_simulate_order(this.__wbg_ptr, args, ptr0);
1665
+ if (ret[2]) {
1666
+ throw takeFromExternrefTable0(ret[1]);
1667
+ }
1668
+ return OrderSimulationOutput.__wrap(ret[0]);
1669
+ }
1670
+ }
1671
+
1528
1672
  const SystemInstructionFinalization = (typeof FinalizationRegistry === 'undefined')
1529
1673
  ? { register: () => {}, unregister: () => {} }
1530
1674
  : new FinalizationRegistry(ptr => wasm.__wbg_systeminstruction_free(ptr >>> 0, 1));
@@ -1716,6 +1860,92 @@ export class SystemInstruction {
1716
1860
  }
1717
1861
  }
1718
1862
 
1863
+ const TradeEventFinalization = (typeof FinalizationRegistry === 'undefined')
1864
+ ? { register: () => {}, unregister: () => {} }
1865
+ : new FinalizationRegistry(ptr => wasm.__wbg_tradeevent_free(ptr >>> 0, 1));
1866
+ /**
1867
+ * JS version of [`TradeEvent`].
1868
+ */
1869
+ export class TradeEvent {
1870
+
1871
+ static __wrap(ptr) {
1872
+ ptr = ptr >>> 0;
1873
+ const obj = Object.create(TradeEvent.prototype);
1874
+ obj.__wbg_ptr = ptr;
1875
+ TradeEventFinalization.register(obj, obj.__wbg_ptr, obj);
1876
+ return obj;
1877
+ }
1878
+
1879
+ __destroy_into_raw() {
1880
+ const ptr = this.__wbg_ptr;
1881
+ this.__wbg_ptr = 0;
1882
+ TradeEventFinalization.unregister(this);
1883
+ return ptr;
1884
+ }
1885
+
1886
+ free() {
1887
+ const ptr = this.__destroy_into_raw();
1888
+ wasm.__wbg_tradeevent_free(ptr, 0);
1889
+ }
1890
+ /**
1891
+ * Create from base64 encoded event data with options.
1892
+ * @param {string} data
1893
+ * @param {boolean | null} [no_discriminator]
1894
+ * @returns {TradeEvent}
1895
+ */
1896
+ static decode_from_base64_with_options(data, no_discriminator) {
1897
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1898
+ const len0 = WASM_VECTOR_LEN;
1899
+ const ret = wasm.tradeevent_decode_from_base64_with_options(ptr0, len0, isLikeNone(no_discriminator) ? 0xFFFFFF : no_discriminator ? 1 : 0);
1900
+ if (ret[2]) {
1901
+ throw takeFromExternrefTable0(ret[1]);
1902
+ }
1903
+ return TradeEvent.__wrap(ret[0]);
1904
+ }
1905
+ /**
1906
+ * Create from base64 encoded event data.
1907
+ * @param {string} data
1908
+ * @returns {TradeEvent}
1909
+ */
1910
+ static decode_from_base64(data) {
1911
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1912
+ const len0 = WASM_VECTOR_LEN;
1913
+ const ret = wasm.tradeevent_decode_from_base64(ptr0, len0);
1914
+ if (ret[2]) {
1915
+ throw takeFromExternrefTable0(ret[1]);
1916
+ }
1917
+ return TradeEvent.__wrap(ret[0]);
1918
+ }
1919
+ /**
1920
+ * Create from event data.
1921
+ * @param {Uint8Array} data
1922
+ * @param {boolean | null} [no_discriminator]
1923
+ * @returns {TradeEvent}
1924
+ */
1925
+ static decode_with_options(data, no_discriminator) {
1926
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
1927
+ const len0 = WASM_VECTOR_LEN;
1928
+ const ret = wasm.tradeevent_decode_with_options(ptr0, len0, isLikeNone(no_discriminator) ? 0xFFFFFF : no_discriminator ? 1 : 0);
1929
+ if (ret[2]) {
1930
+ throw takeFromExternrefTable0(ret[1]);
1931
+ }
1932
+ return TradeEvent.__wrap(ret[0]);
1933
+ }
1934
+ /**
1935
+ * Convert into a position model.
1936
+ * @param {MarketModel} market
1937
+ * @returns {PositionModel}
1938
+ */
1939
+ to_position_model(market) {
1940
+ _assertClass(market, MarketModel);
1941
+ const ret = wasm.tradeevent_to_position_model(this.__wbg_ptr, market.__wbg_ptr);
1942
+ if (ret[2]) {
1943
+ throw takeFromExternrefTable0(ret[1]);
1944
+ }
1945
+ return PositionModel.__wrap(ret[0]);
1946
+ }
1947
+ }
1948
+
1719
1949
  const TransactionFinalization = (typeof FinalizationRegistry === 'undefined')
1720
1950
  ? { register: () => {}, unregister: () => {} }
1721
1951
  : new FinalizationRegistry(ptr => wasm.__wbg_transaction_free(ptr >>> 0, 1));
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.8.0-beta.0",
5
+ "version": "0.8.0-beta.2",
6
6
  "license": "SEE LICENSE IN ../../LICENSE",
7
7
  "repository": {
8
8
  "type": "git",