@gmsol-labs/gmsol-sdk 0.5.0-alpha.13 → 0.5.0-alpha.15

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
@@ -1,9 +1,21 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * Get default [`StoreProgram`].
5
+ */
6
+ export function default_store_program(): StoreProgram;
3
7
  /**
4
8
  * Build transactions for creating orders.
5
9
  */
6
10
  export function create_orders(kind: CreateOrderKind, orders: CreateOrderParams[], options: CreateOrderOptions): TransactionGroup;
11
+ /**
12
+ * Build transactions for closing orders.
13
+ */
14
+ export function close_orders(args: CloseOrderArgs): TransactionGroup;
15
+ /**
16
+ * Build transactions for updating orders.
17
+ */
18
+ export function update_orders(args: UpdateOrderArgs): TransactionGroup;
7
19
  /**
8
20
  * Apply `factor` to the `value`.
9
21
  */
@@ -79,6 +91,33 @@ export interface CreateOrderOptions {
79
91
  transaction_group?: TransactionGroupOptions;
80
92
  }
81
93
 
94
+ /**
95
+ * Parameters for closing orders.
96
+ */
97
+ export interface CloseOrderArgs {
98
+ recent_blockhash: string;
99
+ payer: StringPubkey;
100
+ orders: Map<StringPubkey, CloseOrderHint>;
101
+ program?: StoreProgram | undefined;
102
+ transaction_group?: TransactionGroupOptions;
103
+ }
104
+
105
+ export interface UpdateParams {
106
+ params: UpdateOrderParams;
107
+ hint: UpdateOrderHint;
108
+ }
109
+
110
+ /**
111
+ * Parameters for updating orders.
112
+ */
113
+ export interface UpdateOrderArgs {
114
+ recent_blockhash: string;
115
+ payer: StringPubkey;
116
+ orders: Map<StringPubkey, UpdateParams>;
117
+ program?: StoreProgram | undefined;
118
+ transaction_group?: TransactionGroupOptions;
119
+ }
120
+
82
121
  /**
83
122
  * A JS version transaction group options.
84
123
  */
@@ -320,17 +359,125 @@ export interface Value {
320
359
  }
321
360
 
322
361
  /**
323
- * A store program.
362
+ * Hint for [`UpdateOrder`].
324
363
  */
325
- export interface StoreProgram {
364
+ export interface UpdateOrderHint {
326
365
  /**
327
- * Program ID.
366
+ * Market token.
328
367
  */
329
- id: StringPubkey;
368
+ market_token: StringPubkey;
369
+ }
370
+
371
+ /**
372
+ * Parameters for creating an order.
373
+ */
374
+ export interface UpdateOrderParams {
330
375
  /**
331
- * Store address.
376
+ * Size delta value.
332
377
  */
333
- store: StringPubkey;
378
+ size_delta_value?: bigint | undefined;
379
+ /**
380
+ * Acceptable price.
381
+ */
382
+ acceptable_price?: bigint | undefined;
383
+ /**
384
+ * Trigger price.
385
+ */
386
+ trigger_price?: bigint | undefined;
387
+ /**
388
+ * Min output.
389
+ */
390
+ min_output?: bigint | undefined;
391
+ /**
392
+ * Valid from this timestamp.
393
+ */
394
+ valid_from_ts?: number | undefined;
395
+ }
396
+
397
+ /**
398
+ * Builder for the `update_order` instruction.
399
+ */
400
+ export interface UpdateOrder {
401
+ /**
402
+ * Program.
403
+ */
404
+ program?: StoreProgram;
405
+ /**
406
+ * Payer (a.k.a. owner).
407
+ */
408
+ payer: StringPubkey;
409
+ /**
410
+ * Order.
411
+ */
412
+ order: StringPubkey;
413
+ /**
414
+ * Parameters.
415
+ */
416
+ params: UpdateOrderParams;
417
+ }
418
+
419
+ /**
420
+ * Hint for [`CloseOrder`].
421
+ */
422
+ export interface CloseOrderHint {
423
+ /**
424
+ * Owner.
425
+ */
426
+ owner: StringPubkey;
427
+ /**
428
+ * Receiver.
429
+ */
430
+ receiver: StringPubkey;
431
+ /**
432
+ * Rent Receiver.
433
+ */
434
+ rent_receiver: StringPubkey;
435
+ /**
436
+ * Referrer.
437
+ */
438
+ referrer: StringPubkey | undefined;
439
+ /**
440
+ * Initial collateral token.
441
+ */
442
+ initial_collateral_token: StringPubkey | undefined;
443
+ /**
444
+ * Final output token.
445
+ */
446
+ final_output_token: StringPubkey | undefined;
447
+ /**
448
+ * Long token.
449
+ */
450
+ long_token: StringPubkey | undefined;
451
+ /**
452
+ * Short token.
453
+ */
454
+ short_token: StringPubkey | undefined;
455
+ /**
456
+ * `should_unwrap_native_token` flag.
457
+ */
458
+ should_unwrap_native_token: boolean;
459
+ }
460
+
461
+ /**
462
+ * Builder for the `close_order` instruction.
463
+ */
464
+ export interface CloseOrder {
465
+ /**
466
+ * Program.
467
+ */
468
+ program?: StoreProgram;
469
+ /**
470
+ * Payer.
471
+ */
472
+ payer: StringPubkey;
473
+ /**
474
+ * Order.
475
+ */
476
+ order: StringPubkey;
477
+ /**
478
+ * Reason.
479
+ */
480
+ reason: string;
334
481
  }
335
482
 
336
483
  /**
@@ -348,7 +495,7 @@ export interface CreateOrderHint {
348
495
  }
349
496
 
350
497
  /**
351
- * Instruction builder for the `create_order` instruction.
498
+ * Builder for the `create_order` instruction.
352
499
  */
353
500
  export interface CreateOrder {
354
501
  /**
@@ -463,6 +610,20 @@ export type DecreasePositionSwapType = "NoSwap" | "PnlTokenToCollateralToken" |
463
610
  */
464
611
  export type CreateOrderKind = "MarketSwap" | "MarketIncrease" | "MarketDecrease" | "LimitSwap" | "LimitIncrease" | "LimitDecrease" | "StopLossDecrease";
465
612
 
613
+ /**
614
+ * A store program.
615
+ */
616
+ export interface StoreProgram {
617
+ /**
618
+ * Program ID.
619
+ */
620
+ id: StringPubkey;
621
+ /**
622
+ * Store address.
623
+ */
624
+ store: StringPubkey;
625
+ }
626
+
466
627
  /**
467
628
  * Pnl Factor Kind.
468
629
  */
@@ -611,6 +772,22 @@ export class Market {
611
772
  * Convert into [`JsMarketModel`]
612
773
  */
613
774
  to_model(supply: bigint): MarketModel;
775
+ /**
776
+ * Get market token address.
777
+ */
778
+ market_token_address(): string;
779
+ /**
780
+ * Get index token address.
781
+ */
782
+ index_token_address(): string;
783
+ /**
784
+ * Get long token address.
785
+ */
786
+ long_token_address(): string;
787
+ /**
788
+ * Get short token address.
789
+ */
790
+ short_token_address(): string;
614
791
  }
615
792
  /**
616
793
  * A JS binding for [`MarkegGraph`].
@@ -847,3 +1024,54 @@ export class TransactionGroup {
847
1024
  */
848
1025
  serialize(): SerializedTransactionGroup;
849
1026
  }
1027
+ /**
1028
+ * JS binding wrapper for [`UserHeader`]
1029
+ */
1030
+ export class User {
1031
+ private constructor();
1032
+ free(): void;
1033
+ /**
1034
+ * Create from base64 encoded account data.
1035
+ */
1036
+ static decode_from_base64(data: string): User;
1037
+ /**
1038
+ * Get the owner address.
1039
+ */
1040
+ owner_address(): string;
1041
+ /**
1042
+ * Get the store address.
1043
+ */
1044
+ store_address(): string;
1045
+ /**
1046
+ * Get the referral code address.
1047
+ */
1048
+ referral_code_address(): string | undefined;
1049
+ /**
1050
+ * Get the referrer address.
1051
+ */
1052
+ referrer_address(): string | undefined;
1053
+ /**
1054
+ * Get the GT rank.
1055
+ */
1056
+ gt_rank(): number;
1057
+ /**
1058
+ * Get GT last minted at.
1059
+ */
1060
+ gt_last_minted_at(): bigint;
1061
+ /**
1062
+ * Get total minted GT amount.
1063
+ */
1064
+ gt_total_minted(): bigint;
1065
+ /**
1066
+ * Get GT amount.
1067
+ */
1068
+ gt_amount(): bigint;
1069
+ /**
1070
+ * Get paid fee value of GT.
1071
+ */
1072
+ gt_paid_fee_value(): bigint;
1073
+ /**
1074
+ * Get minted fee value of GT.
1075
+ */
1076
+ gt_minted_fee_value(): bigint;
1077
+ }
package/index_bg.js CHANGED
@@ -179,6 +179,14 @@ function debugString(val) {
179
179
  // TODO we could test for more things here, like `Set`s and `Map`s.
180
180
  return className;
181
181
  }
182
+ /**
183
+ * Get default [`StoreProgram`].
184
+ * @returns {StoreProgram}
185
+ */
186
+ export function default_store_program() {
187
+ const ret = wasm.default_store_program();
188
+ return ret;
189
+ }
182
190
 
183
191
  function takeFromExternrefTable0(idx) {
184
192
  const value = wasm.__wbindgen_export_4.get(idx);
@@ -230,6 +238,32 @@ export function create_orders(kind, orders, options) {
230
238
  return TransactionGroup.__wrap(ret[0]);
231
239
  }
232
240
 
241
+ /**
242
+ * Build transactions for closing orders.
243
+ * @param {CloseOrderArgs} args
244
+ * @returns {TransactionGroup}
245
+ */
246
+ export function close_orders(args) {
247
+ const ret = wasm.close_orders(args);
248
+ if (ret[2]) {
249
+ throw takeFromExternrefTable0(ret[1]);
250
+ }
251
+ return TransactionGroup.__wrap(ret[0]);
252
+ }
253
+
254
+ /**
255
+ * Build transactions for updating orders.
256
+ * @param {UpdateOrderArgs} args
257
+ * @returns {TransactionGroup}
258
+ */
259
+ export function update_orders(args) {
260
+ const ret = wasm.update_orders(args);
261
+ if (ret[2]) {
262
+ throw takeFromExternrefTable0(ret[1]);
263
+ }
264
+ return TransactionGroup.__wrap(ret[0]);
265
+ }
266
+
233
267
  function _assertClass(instance, klass) {
234
268
  if (!(instance instanceof klass)) {
235
269
  throw new Error(`expected instance of ${klass.name}`);
@@ -596,6 +630,70 @@ export class Market {
596
630
  const ret = wasm.market_to_model(this.__wbg_ptr, supply);
597
631
  return MarketModel.__wrap(ret);
598
632
  }
633
+ /**
634
+ * Get market token address.
635
+ * @returns {string}
636
+ */
637
+ market_token_address() {
638
+ let deferred1_0;
639
+ let deferred1_1;
640
+ try {
641
+ const ret = wasm.market_market_token_address(this.__wbg_ptr);
642
+ deferred1_0 = ret[0];
643
+ deferred1_1 = ret[1];
644
+ return getStringFromWasm0(ret[0], ret[1]);
645
+ } finally {
646
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
647
+ }
648
+ }
649
+ /**
650
+ * Get index token address.
651
+ * @returns {string}
652
+ */
653
+ index_token_address() {
654
+ let deferred1_0;
655
+ let deferred1_1;
656
+ try {
657
+ const ret = wasm.market_index_token_address(this.__wbg_ptr);
658
+ deferred1_0 = ret[0];
659
+ deferred1_1 = ret[1];
660
+ return getStringFromWasm0(ret[0], ret[1]);
661
+ } finally {
662
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
663
+ }
664
+ }
665
+ /**
666
+ * Get long token address.
667
+ * @returns {string}
668
+ */
669
+ long_token_address() {
670
+ let deferred1_0;
671
+ let deferred1_1;
672
+ try {
673
+ const ret = wasm.market_long_token_address(this.__wbg_ptr);
674
+ deferred1_0 = ret[0];
675
+ deferred1_1 = ret[1];
676
+ return getStringFromWasm0(ret[0], ret[1]);
677
+ } finally {
678
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
679
+ }
680
+ }
681
+ /**
682
+ * Get short token address.
683
+ * @returns {string}
684
+ */
685
+ short_token_address() {
686
+ let deferred1_0;
687
+ let deferred1_1;
688
+ try {
689
+ const ret = wasm.market_short_token_address(this.__wbg_ptr);
690
+ deferred1_0 = ret[0];
691
+ deferred1_1 = ret[1];
692
+ return getStringFromWasm0(ret[0], ret[1]);
693
+ } finally {
694
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
695
+ }
696
+ }
599
697
  }
600
698
 
601
699
  const MarketGraphFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -1479,6 +1577,155 @@ export class TransactionGroup {
1479
1577
  }
1480
1578
  }
1481
1579
 
1580
+ const UserFinalization = (typeof FinalizationRegistry === 'undefined')
1581
+ ? { register: () => {}, unregister: () => {} }
1582
+ : new FinalizationRegistry(ptr => wasm.__wbg_user_free(ptr >>> 0, 1));
1583
+ /**
1584
+ * JS binding wrapper for [`UserHeader`]
1585
+ */
1586
+ export class User {
1587
+
1588
+ static __wrap(ptr) {
1589
+ ptr = ptr >>> 0;
1590
+ const obj = Object.create(User.prototype);
1591
+ obj.__wbg_ptr = ptr;
1592
+ UserFinalization.register(obj, obj.__wbg_ptr, obj);
1593
+ return obj;
1594
+ }
1595
+
1596
+ __destroy_into_raw() {
1597
+ const ptr = this.__wbg_ptr;
1598
+ this.__wbg_ptr = 0;
1599
+ UserFinalization.unregister(this);
1600
+ return ptr;
1601
+ }
1602
+
1603
+ free() {
1604
+ const ptr = this.__destroy_into_raw();
1605
+ wasm.__wbg_user_free(ptr, 0);
1606
+ }
1607
+ /**
1608
+ * Create from base64 encoded account data.
1609
+ * @param {string} data
1610
+ * @returns {User}
1611
+ */
1612
+ static decode_from_base64(data) {
1613
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1614
+ const len0 = WASM_VECTOR_LEN;
1615
+ const ret = wasm.user_decode_from_base64(ptr0, len0);
1616
+ if (ret[2]) {
1617
+ throw takeFromExternrefTable0(ret[1]);
1618
+ }
1619
+ return User.__wrap(ret[0]);
1620
+ }
1621
+ /**
1622
+ * Get the owner address.
1623
+ * @returns {string}
1624
+ */
1625
+ owner_address() {
1626
+ let deferred1_0;
1627
+ let deferred1_1;
1628
+ try {
1629
+ const ret = wasm.user_owner_address(this.__wbg_ptr);
1630
+ deferred1_0 = ret[0];
1631
+ deferred1_1 = ret[1];
1632
+ return getStringFromWasm0(ret[0], ret[1]);
1633
+ } finally {
1634
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1635
+ }
1636
+ }
1637
+ /**
1638
+ * Get the store address.
1639
+ * @returns {string}
1640
+ */
1641
+ store_address() {
1642
+ let deferred1_0;
1643
+ let deferred1_1;
1644
+ try {
1645
+ const ret = wasm.user_store_address(this.__wbg_ptr);
1646
+ deferred1_0 = ret[0];
1647
+ deferred1_1 = ret[1];
1648
+ return getStringFromWasm0(ret[0], ret[1]);
1649
+ } finally {
1650
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1651
+ }
1652
+ }
1653
+ /**
1654
+ * Get the referral code address.
1655
+ * @returns {string | undefined}
1656
+ */
1657
+ referral_code_address() {
1658
+ const ret = wasm.user_referral_code_address(this.__wbg_ptr);
1659
+ let v1;
1660
+ if (ret[0] !== 0) {
1661
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
1662
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1663
+ }
1664
+ return v1;
1665
+ }
1666
+ /**
1667
+ * Get the referrer address.
1668
+ * @returns {string | undefined}
1669
+ */
1670
+ referrer_address() {
1671
+ const ret = wasm.user_referrer_address(this.__wbg_ptr);
1672
+ let v1;
1673
+ if (ret[0] !== 0) {
1674
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
1675
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1676
+ }
1677
+ return v1;
1678
+ }
1679
+ /**
1680
+ * Get the GT rank.
1681
+ * @returns {number}
1682
+ */
1683
+ gt_rank() {
1684
+ const ret = wasm.user_gt_rank(this.__wbg_ptr);
1685
+ return ret;
1686
+ }
1687
+ /**
1688
+ * Get GT last minted at.
1689
+ * @returns {bigint}
1690
+ */
1691
+ gt_last_minted_at() {
1692
+ const ret = wasm.user_gt_last_minted_at(this.__wbg_ptr);
1693
+ return ret;
1694
+ }
1695
+ /**
1696
+ * Get total minted GT amount.
1697
+ * @returns {bigint}
1698
+ */
1699
+ gt_total_minted() {
1700
+ const ret = wasm.user_gt_total_minted(this.__wbg_ptr);
1701
+ return BigInt.asUintN(64, ret);
1702
+ }
1703
+ /**
1704
+ * Get GT amount.
1705
+ * @returns {bigint}
1706
+ */
1707
+ gt_amount() {
1708
+ const ret = wasm.user_gt_amount(this.__wbg_ptr);
1709
+ return BigInt.asUintN(64, ret);
1710
+ }
1711
+ /**
1712
+ * Get paid fee value of GT.
1713
+ * @returns {bigint}
1714
+ */
1715
+ gt_paid_fee_value() {
1716
+ const ret = wasm.user_gt_paid_fee_value(this.__wbg_ptr);
1717
+ return (BigInt.asUintN(64, ret[0]) | (BigInt.asUintN(64, ret[1]) << BigInt(64)));
1718
+ }
1719
+ /**
1720
+ * Get minted fee value of GT.
1721
+ * @returns {bigint}
1722
+ */
1723
+ gt_minted_fee_value() {
1724
+ const ret = wasm.user_gt_minted_fee_value(this.__wbg_ptr);
1725
+ return (BigInt.asUintN(64, ret[0]) | (BigInt.asUintN(64, ret[1]) << BigInt(64)));
1726
+ }
1727
+ }
1728
+
1482
1729
  export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
1483
1730
  const ret = String(arg1);
1484
1731
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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-alpha.13",
5
+ "version": "0.5.0-alpha.15",
6
6
  "license": "SEE LICENSE IN ../../LICENSE",
7
7
  "repository": {
8
8
  "type": "git",