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

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
@@ -4,6 +4,10 @@
4
4
  * Build transactions for creating orders.
5
5
  */
6
6
  export function create_orders(kind: CreateOrderKind, orders: CreateOrderParams[], options: CreateOrderOptions): TransactionGroup;
7
+ /**
8
+ * Build transactions for closing orders.
9
+ */
10
+ export function close_orders(params: CloseOrderParams): TransactionGroup;
7
11
  /**
8
12
  * Apply `factor` to the `value`.
9
13
  */
@@ -79,6 +83,17 @@ export interface CreateOrderOptions {
79
83
  transaction_group?: TransactionGroupOptions;
80
84
  }
81
85
 
86
+ /**
87
+ * Parameters for closing orders.
88
+ */
89
+ export interface CloseOrderParams {
90
+ recent_blockhash: string;
91
+ payer: StringPubkey;
92
+ orders: Map<StringPubkey, CloseOrderHint>;
93
+ program?: StoreProgram | undefined;
94
+ transaction_group?: TransactionGroupOptions;
95
+ }
96
+
82
97
  /**
83
98
  * A JS version transaction group options.
84
99
  */
@@ -320,17 +335,67 @@ export interface Value {
320
335
  }
321
336
 
322
337
  /**
323
- * A store program.
338
+ * Hint for [`CloseOrder`].
324
339
  */
325
- export interface StoreProgram {
340
+ export interface CloseOrderHint {
326
341
  /**
327
- * Program ID.
342
+ * Owner.
328
343
  */
329
- id: StringPubkey;
344
+ owner: StringPubkey;
330
345
  /**
331
- * Store address.
346
+ * Receiver.
332
347
  */
333
- store: StringPubkey;
348
+ receiver: StringPubkey;
349
+ /**
350
+ * Rent Receiver.
351
+ */
352
+ rent_receiver: StringPubkey;
353
+ /**
354
+ * Referrer.
355
+ */
356
+ referrer: StringPubkey | undefined;
357
+ /**
358
+ * Initial collateral token.
359
+ */
360
+ initial_collateral_token: StringPubkey | undefined;
361
+ /**
362
+ * Final output token.
363
+ */
364
+ final_output_token: StringPubkey | undefined;
365
+ /**
366
+ * Long token.
367
+ */
368
+ long_token: StringPubkey | undefined;
369
+ /**
370
+ * Short token.
371
+ */
372
+ short_token: StringPubkey | undefined;
373
+ /**
374
+ * `should_unwrap_native_token` flag.
375
+ */
376
+ should_unwrap_native_token: boolean;
377
+ }
378
+
379
+ /**
380
+ * Builder for the `close_order` instruction.
381
+ */
382
+ export interface CloseOrder {
383
+ /**
384
+ * Program.
385
+ */
386
+ program?: StoreProgram;
387
+ /**
388
+ * Payer.
389
+ */
390
+ payer: StringPubkey;
391
+ /**
392
+ * Order.
393
+ */
394
+ order: StringPubkey;
395
+ /**
396
+ * Reason.
397
+ */
398
+ reason: string;
334
399
  }
335
400
 
336
401
  /**
@@ -348,7 +413,7 @@ export interface CreateOrderHint {
348
413
  }
349
414
 
350
415
  /**
351
- * Instruction builder for the `create_order` instruction.
416
+ * Builder for the `create_order` instruction.
352
417
  */
353
418
  export interface CreateOrder {
354
419
  /**
@@ -463,6 +528,20 @@ export type DecreasePositionSwapType = "NoSwap" | "PnlTokenToCollateralToken" |
463
528
  */
464
529
  export type CreateOrderKind = "MarketSwap" | "MarketIncrease" | "MarketDecrease" | "LimitSwap" | "LimitIncrease" | "LimitDecrease" | "StopLossDecrease";
465
530
 
531
+ /**
532
+ * A store program.
533
+ */
534
+ export interface StoreProgram {
535
+ /**
536
+ * Program ID.
537
+ */
538
+ id: StringPubkey;
539
+ /**
540
+ * Store address.
541
+ */
542
+ store: StringPubkey;
543
+ }
544
+
466
545
  /**
467
546
  * Pnl Factor Kind.
468
547
  */
@@ -847,3 +926,54 @@ export class TransactionGroup {
847
926
  */
848
927
  serialize(): SerializedTransactionGroup;
849
928
  }
929
+ /**
930
+ * JS binding wrapper for [`UserHeader`]
931
+ */
932
+ export class User {
933
+ private constructor();
934
+ free(): void;
935
+ /**
936
+ * Create from base64 encoded account data.
937
+ */
938
+ static decode_from_base64(data: string): User;
939
+ /**
940
+ * Get the owner address.
941
+ */
942
+ owner_address(): string;
943
+ /**
944
+ * Get the store address.
945
+ */
946
+ store_address(): string;
947
+ /**
948
+ * Get the referral code address.
949
+ */
950
+ referral_code_address(): string | undefined;
951
+ /**
952
+ * Get the referrer address.
953
+ */
954
+ referrer_address(): string | undefined;
955
+ /**
956
+ * Get the GT rank.
957
+ */
958
+ gt_rank(): number;
959
+ /**
960
+ * Get GT last minted at.
961
+ */
962
+ gt_last_minted_at(): bigint;
963
+ /**
964
+ * Get total minted GT amount.
965
+ */
966
+ gt_total_minted(): bigint;
967
+ /**
968
+ * Get GT amount.
969
+ */
970
+ gt_amount(): bigint;
971
+ /**
972
+ * Get paid fee value of GT.
973
+ */
974
+ gt_paid_fee_value(): bigint;
975
+ /**
976
+ * Get minted fee value of GT.
977
+ */
978
+ gt_minted_fee_value(): bigint;
979
+ }
package/index_bg.js CHANGED
@@ -230,6 +230,19 @@ export function create_orders(kind, orders, options) {
230
230
  return TransactionGroup.__wrap(ret[0]);
231
231
  }
232
232
 
233
+ /**
234
+ * Build transactions for closing orders.
235
+ * @param {CloseOrderParams} params
236
+ * @returns {TransactionGroup}
237
+ */
238
+ export function close_orders(params) {
239
+ const ret = wasm.close_orders(params);
240
+ if (ret[2]) {
241
+ throw takeFromExternrefTable0(ret[1]);
242
+ }
243
+ return TransactionGroup.__wrap(ret[0]);
244
+ }
245
+
233
246
  function _assertClass(instance, klass) {
234
247
  if (!(instance instanceof klass)) {
235
248
  throw new Error(`expected instance of ${klass.name}`);
@@ -1479,6 +1492,155 @@ export class TransactionGroup {
1479
1492
  }
1480
1493
  }
1481
1494
 
1495
+ const UserFinalization = (typeof FinalizationRegistry === 'undefined')
1496
+ ? { register: () => {}, unregister: () => {} }
1497
+ : new FinalizationRegistry(ptr => wasm.__wbg_user_free(ptr >>> 0, 1));
1498
+ /**
1499
+ * JS binding wrapper for [`UserHeader`]
1500
+ */
1501
+ export class User {
1502
+
1503
+ static __wrap(ptr) {
1504
+ ptr = ptr >>> 0;
1505
+ const obj = Object.create(User.prototype);
1506
+ obj.__wbg_ptr = ptr;
1507
+ UserFinalization.register(obj, obj.__wbg_ptr, obj);
1508
+ return obj;
1509
+ }
1510
+
1511
+ __destroy_into_raw() {
1512
+ const ptr = this.__wbg_ptr;
1513
+ this.__wbg_ptr = 0;
1514
+ UserFinalization.unregister(this);
1515
+ return ptr;
1516
+ }
1517
+
1518
+ free() {
1519
+ const ptr = this.__destroy_into_raw();
1520
+ wasm.__wbg_user_free(ptr, 0);
1521
+ }
1522
+ /**
1523
+ * Create from base64 encoded account data.
1524
+ * @param {string} data
1525
+ * @returns {User}
1526
+ */
1527
+ static decode_from_base64(data) {
1528
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1529
+ const len0 = WASM_VECTOR_LEN;
1530
+ const ret = wasm.user_decode_from_base64(ptr0, len0);
1531
+ if (ret[2]) {
1532
+ throw takeFromExternrefTable0(ret[1]);
1533
+ }
1534
+ return User.__wrap(ret[0]);
1535
+ }
1536
+ /**
1537
+ * Get the owner address.
1538
+ * @returns {string}
1539
+ */
1540
+ owner_address() {
1541
+ let deferred1_0;
1542
+ let deferred1_1;
1543
+ try {
1544
+ const ret = wasm.user_owner_address(this.__wbg_ptr);
1545
+ deferred1_0 = ret[0];
1546
+ deferred1_1 = ret[1];
1547
+ return getStringFromWasm0(ret[0], ret[1]);
1548
+ } finally {
1549
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1550
+ }
1551
+ }
1552
+ /**
1553
+ * Get the store address.
1554
+ * @returns {string}
1555
+ */
1556
+ store_address() {
1557
+ let deferred1_0;
1558
+ let deferred1_1;
1559
+ try {
1560
+ const ret = wasm.user_store_address(this.__wbg_ptr);
1561
+ deferred1_0 = ret[0];
1562
+ deferred1_1 = ret[1];
1563
+ return getStringFromWasm0(ret[0], ret[1]);
1564
+ } finally {
1565
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1566
+ }
1567
+ }
1568
+ /**
1569
+ * Get the referral code address.
1570
+ * @returns {string | undefined}
1571
+ */
1572
+ referral_code_address() {
1573
+ const ret = wasm.user_referral_code_address(this.__wbg_ptr);
1574
+ let v1;
1575
+ if (ret[0] !== 0) {
1576
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
1577
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1578
+ }
1579
+ return v1;
1580
+ }
1581
+ /**
1582
+ * Get the referrer address.
1583
+ * @returns {string | undefined}
1584
+ */
1585
+ referrer_address() {
1586
+ const ret = wasm.user_referrer_address(this.__wbg_ptr);
1587
+ let v1;
1588
+ if (ret[0] !== 0) {
1589
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
1590
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1591
+ }
1592
+ return v1;
1593
+ }
1594
+ /**
1595
+ * Get the GT rank.
1596
+ * @returns {number}
1597
+ */
1598
+ gt_rank() {
1599
+ const ret = wasm.user_gt_rank(this.__wbg_ptr);
1600
+ return ret;
1601
+ }
1602
+ /**
1603
+ * Get GT last minted at.
1604
+ * @returns {bigint}
1605
+ */
1606
+ gt_last_minted_at() {
1607
+ const ret = wasm.user_gt_last_minted_at(this.__wbg_ptr);
1608
+ return ret;
1609
+ }
1610
+ /**
1611
+ * Get total minted GT amount.
1612
+ * @returns {bigint}
1613
+ */
1614
+ gt_total_minted() {
1615
+ const ret = wasm.user_gt_total_minted(this.__wbg_ptr);
1616
+ return BigInt.asUintN(64, ret);
1617
+ }
1618
+ /**
1619
+ * Get GT amount.
1620
+ * @returns {bigint}
1621
+ */
1622
+ gt_amount() {
1623
+ const ret = wasm.user_gt_amount(this.__wbg_ptr);
1624
+ return BigInt.asUintN(64, ret);
1625
+ }
1626
+ /**
1627
+ * Get paid fee value of GT.
1628
+ * @returns {bigint}
1629
+ */
1630
+ gt_paid_fee_value() {
1631
+ const ret = wasm.user_gt_paid_fee_value(this.__wbg_ptr);
1632
+ return (BigInt.asUintN(64, ret[0]) | (BigInt.asUintN(64, ret[1]) << BigInt(64)));
1633
+ }
1634
+ /**
1635
+ * Get minted fee value of GT.
1636
+ * @returns {bigint}
1637
+ */
1638
+ gt_minted_fee_value() {
1639
+ const ret = wasm.user_gt_minted_fee_value(this.__wbg_ptr);
1640
+ return (BigInt.asUintN(64, ret[0]) | (BigInt.asUintN(64, ret[1]) << BigInt(64)));
1641
+ }
1642
+ }
1643
+
1482
1644
  export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
1483
1645
  const ret = String(arg1);
1484
1646
  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.14",
6
6
  "license": "SEE LICENSE IN ../../LICENSE",
7
7
  "repository": {
8
8
  "type": "git",