@gmsol-labs/gmsol-sdk 0.8.0 → 0.9.0-alpha.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/index.d.ts CHANGED
@@ -20,6 +20,16 @@ export function close_orders(args: CloseOrderArgs): TransactionGroup;
20
20
  * Build transactions for updating orders.
21
21
  */
22
22
  export function update_orders(args: UpdateOrderArgs): TransactionGroup;
23
+ export function create_deposits_builder(deposits: CreateDepositParamsJs[], options: CreateDepositOptions): CreateDepositsBuilder;
24
+ export function create_deposits(deposits: CreateDepositParamsJs[], options: CreateDepositOptions): TransactionGroup;
25
+ export function create_withdrawals_builder(withdrawals: CreateWithdrawalParamsJs[], options: CreateWithdrawalOptions): CreateWithdrawalsBuilder;
26
+ export function create_withdrawals(withdrawals: CreateWithdrawalParamsJs[], options: CreateWithdrawalOptions): TransactionGroup;
27
+ export function create_shifts_builder(shifts: CreateShiftParamsJs[], options: CreateShiftOptions): CreateShiftsBuilder;
28
+ export function create_shifts(shifts: CreateShiftParamsJs[], options: CreateShiftOptions): TransactionGroup;
29
+ export function create_glv_deposits_builder(deposits: CreateGlvDepositParamsJs[], options: CreateGlvDepositOptions): CreateGlvDepositsBuilder;
30
+ export function create_glv_deposits(deposits: CreateGlvDepositParamsJs[], options: CreateGlvDepositOptions): TransactionGroup;
31
+ export function create_glv_withdrawals_builder(withdrawals: CreateGlvWithdrawalParamsJs[], options: CreateGlvWithdrawalOptions): CreateGlvWithdrawalsBuilder;
32
+ export function create_glv_withdrawals(withdrawals: CreateGlvWithdrawalParamsJs[], options: CreateGlvWithdrawalOptions): TransactionGroup;
23
33
  /**
24
34
  * Apply `factor` to the `value`.
25
35
  */
@@ -56,6 +66,16 @@ export interface MarketStatusParams {
56
66
  prices: Prices;
57
67
  }
58
68
 
69
+ /**
70
+ * Params for calculating max sellable avlue.
71
+ */
72
+ export interface MaxSellableValueParams {
73
+ /**
74
+ * Prices.
75
+ */
76
+ prices: Prices;
77
+ }
78
+
59
79
  /**
60
80
  * Parameters for creating empty position model.
61
81
  */
@@ -165,6 +185,125 @@ export interface UpdateOrderArgs {
165
185
  transaction_group?: TransactionGroupOptions;
166
186
  }
167
187
 
188
+ export interface CreateDepositParamsJs {
189
+ market_token: StringPubkey;
190
+ receiver?: StringPubkey | undefined;
191
+ long_pay_token?: StringPubkey | undefined;
192
+ short_pay_token?: StringPubkey | undefined;
193
+ long_swap_path?: StringPubkey[] | undefined;
194
+ short_swap_path?: StringPubkey[] | undefined;
195
+ long_pay_amount?: bigint | undefined;
196
+ short_pay_amount?: bigint | undefined;
197
+ min_receive_amount?: bigint | undefined;
198
+ skip_unwrap_native_on_receive?: boolean | undefined;
199
+ }
200
+
201
+ export interface CreateDepositOptions {
202
+ recent_blockhash: string;
203
+ payer: StringPubkey;
204
+ program?: StoreProgram | undefined;
205
+ compute_unit_price_micro_lamports?: number | undefined;
206
+ compute_unit_min_priority_lamports?: number | undefined;
207
+ hints: Map<StringPubkey, CreateDepositHint>;
208
+ transaction_group?: TransactionGroupOptions;
209
+ skip_wrap_native_on_pay?: boolean | undefined;
210
+ }
211
+
212
+ export interface CreateWithdrawalParamsJs {
213
+ market_token: StringPubkey;
214
+ receiver?: StringPubkey | undefined;
215
+ long_receive_token?: StringPubkey | undefined;
216
+ short_receive_token?: StringPubkey | undefined;
217
+ long_swap_path?: StringPubkey[] | undefined;
218
+ short_swap_path?: StringPubkey[] | undefined;
219
+ market_token_amount?: bigint | undefined;
220
+ min_long_receive_amount?: bigint | undefined;
221
+ min_short_receive_amount?: bigint | undefined;
222
+ skip_unwrap_native_on_receive?: boolean | undefined;
223
+ }
224
+
225
+ export interface CreateWithdrawalOptions {
226
+ recent_blockhash: string;
227
+ payer: StringPubkey;
228
+ program?: StoreProgram | undefined;
229
+ compute_unit_price_micro_lamports?: number | undefined;
230
+ compute_unit_min_priority_lamports?: number | undefined;
231
+ hints: Map<StringPubkey, CreateWithdrawalHint>;
232
+ transaction_group?: TransactionGroupOptions;
233
+ }
234
+
235
+ export interface CreateShiftParamsJs {
236
+ from_market_token: StringPubkey;
237
+ to_market_token: StringPubkey;
238
+ receiver?: StringPubkey | undefined;
239
+ from_market_token_amount?: bigint | undefined;
240
+ min_to_market_token_amount?: bigint | undefined;
241
+ skip_to_market_token_ata_creation?: boolean | undefined;
242
+ }
243
+
244
+ export interface CreateShiftOptions {
245
+ recent_blockhash: string;
246
+ payer: StringPubkey;
247
+ program?: StoreProgram | undefined;
248
+ compute_unit_price_micro_lamports?: number | undefined;
249
+ compute_unit_min_priority_lamports?: number | undefined;
250
+ transaction_group?: TransactionGroupOptions;
251
+ }
252
+
253
+ export interface CreateGlvDepositParamsJs {
254
+ glv_token: StringPubkey;
255
+ market_token: StringPubkey;
256
+ receiver?: StringPubkey | undefined;
257
+ long_pay_token?: StringPubkey | undefined;
258
+ short_pay_token?: StringPubkey | undefined;
259
+ long_swap_path?: StringPubkey[] | undefined;
260
+ short_swap_path?: StringPubkey[] | undefined;
261
+ long_pay_amount?: bigint | undefined;
262
+ short_pay_amount?: bigint | undefined;
263
+ market_token_amount?: bigint | undefined;
264
+ min_market_token_amount?: bigint | undefined;
265
+ min_receive_amount?: bigint | undefined;
266
+ skip_unwrap_native_on_receive?: boolean | undefined;
267
+ skip_glv_token_ata_creation?: boolean | undefined;
268
+ }
269
+
270
+ export interface CreateGlvDepositOptions {
271
+ recent_blockhash: string;
272
+ payer: StringPubkey;
273
+ program?: StoreProgram | undefined;
274
+ compute_unit_price_micro_lamports?: number | undefined;
275
+ compute_unit_min_priority_lamports?: number | undefined;
276
+ hints: Map<StringPubkey, CreateGlvDepositHint>;
277
+ transaction_group?: TransactionGroupOptions;
278
+ skip_wrap_native_on_pay?: boolean | undefined;
279
+ }
280
+
281
+ export interface CreateGlvWithdrawalParamsJs {
282
+ glv_token: StringPubkey;
283
+ market_token: StringPubkey;
284
+ receiver?: StringPubkey | undefined;
285
+ long_receive_token?: StringPubkey | undefined;
286
+ short_receive_token?: StringPubkey | undefined;
287
+ long_swap_path?: StringPubkey[] | undefined;
288
+ short_swap_path?: StringPubkey[] | undefined;
289
+ glv_token_amount?: bigint | undefined;
290
+ min_long_receive_amount?: bigint | undefined;
291
+ min_short_receive_amount?: bigint | undefined;
292
+ skip_unwrap_native_on_receive?: boolean | undefined;
293
+ skip_long_receive_token_ata_creation?: boolean | undefined;
294
+ skip_short_receive_token_ata_creation?: boolean | undefined;
295
+ }
296
+
297
+ export interface CreateGlvWithdrawalOptions {
298
+ recent_blockhash: string;
299
+ payer: StringPubkey;
300
+ program?: StoreProgram | undefined;
301
+ compute_unit_price_micro_lamports?: number | undefined;
302
+ compute_unit_min_priority_lamports?: number | undefined;
303
+ hints: Map<StringPubkey, CreateGlvWithdrawalHint>;
304
+ transaction_group?: TransactionGroupOptions;
305
+ }
306
+
168
307
  /**
169
308
  * A JS version transaction group options.
170
309
  */
@@ -189,6 +328,27 @@ export interface BuildTransactionOptions {
189
328
  compute_unit_min_priority_lamports?: number | undefined;
190
329
  }
191
330
 
331
+ /**
332
+ * Arguments for deposit simulation.
333
+ */
334
+ export interface SimulateDepositArgs {
335
+ params: CreateDepositParamsJs;
336
+ }
337
+
338
+ /**
339
+ * Arguments for GLV deposit simulation.
340
+ */
341
+ export interface SimulateGlvDepositArgs {
342
+ params: CreateGlvDepositParamsJs;
343
+ }
344
+
345
+ /**
346
+ * Arguments for GLV withdrawal simulation.
347
+ */
348
+ export interface SimulateGlvWithdrawalArgs {
349
+ params: CreateGlvWithdrawalParamsJs;
350
+ }
351
+
192
352
  /**
193
353
  * Arguments for order simulation.
194
354
  */
@@ -233,6 +393,36 @@ export interface SwapOrderSimulationOutput {
233
393
  report: string[];
234
394
  }
235
395
 
396
+ /**
397
+ * Arguments for shift simulation.
398
+ */
399
+ export interface SimulateShiftArgs {
400
+ params: CreateShiftParamsJs;
401
+ }
402
+
403
+ /**
404
+ * Arguments for GLV status calculations.
405
+ */
406
+ export interface GetGlvStatusArgs {
407
+ glv_token: StringPubkey;
408
+ }
409
+
410
+ /**
411
+ * Arguments for GLV status calculations.
412
+ */
413
+ export interface GetGlvTokenValueArgs {
414
+ glv_token: StringPubkey;
415
+ amount: bigint;
416
+ maximize: boolean;
417
+ }
418
+
419
+ /**
420
+ * Arguments for withdrawal simulation.
421
+ */
422
+ export interface SimulateWithdrawalArgs {
423
+ params: CreateWithdrawalParamsJs;
424
+ }
425
+
236
426
 
237
427
  /**
238
428
  * A Base58-encoded string representing a public key.
@@ -306,6 +496,20 @@ export interface Prices {
306
496
  short_token: Value;
307
497
  }
308
498
 
499
+ /**
500
+ * GLV Status.
501
+ */
502
+ export interface GlvStatus {
503
+ /**
504
+ * The estimated max sellable value in the GLV.
505
+ */
506
+ max_sellable_value: bigint;
507
+ /**
508
+ * The estimated total GLV value.
509
+ */
510
+ total_value: Value;
511
+ }
512
+
309
513
  /**
310
514
  * Position Status.
311
515
  */
@@ -1409,6 +1613,21 @@ export interface StoreProgram {
1409
1613
  */
1410
1614
  export type PnlFactorKind = "max_after_deposit" | "max_after_withdrawal" | "max_for_trader" | "for_adl" | "min_after_adl";
1411
1615
 
1616
+ export class CreateDepositsBuilder {
1617
+ private constructor();
1618
+ free(): void;
1619
+ build_with_options(transaction_group?: TransactionGroupOptions | null, build?: BuildTransactionOptions | null): TransactionGroup;
1620
+ }
1621
+ export class CreateGlvDepositsBuilder {
1622
+ private constructor();
1623
+ free(): void;
1624
+ build_with_options(transaction_group?: TransactionGroupOptions | null, build?: BuildTransactionOptions | null): TransactionGroup;
1625
+ }
1626
+ export class CreateGlvWithdrawalsBuilder {
1627
+ private constructor();
1628
+ free(): void;
1629
+ build_with_options(transaction_group?: TransactionGroupOptions | null, build?: BuildTransactionOptions | null): TransactionGroup;
1630
+ }
1412
1631
  /**
1413
1632
  * Builder for create-order ixs.
1414
1633
  */
@@ -1424,6 +1643,35 @@ export class CreateOrdersBuilder {
1424
1643
  */
1425
1644
  merge(other: CreateOrdersBuilder): void;
1426
1645
  }
1646
+ export class CreateShiftsBuilder {
1647
+ private constructor();
1648
+ free(): void;
1649
+ build_with_options(transaction_group?: TransactionGroupOptions | null, build?: BuildTransactionOptions | null): TransactionGroup;
1650
+ }
1651
+ export class CreateWithdrawalsBuilder {
1652
+ private constructor();
1653
+ free(): void;
1654
+ build_with_options(transaction_group?: TransactionGroupOptions | null, build?: BuildTransactionOptions | null): TransactionGroup;
1655
+ }
1656
+ /**
1657
+ * Simulation output for deposit.
1658
+ */
1659
+ export class DepositSimulationOutput {
1660
+ private constructor();
1661
+ free(): void;
1662
+ /**
1663
+ * Returns the deposit report.
1664
+ */
1665
+ report(): string;
1666
+ /**
1667
+ * Returns swap reports for the long token path.
1668
+ */
1669
+ long_swaps(): string[];
1670
+ /**
1671
+ * Returns swap reports for the short token path.
1672
+ */
1673
+ short_swaps(): string[];
1674
+ }
1427
1675
  /**
1428
1676
  * A (twisted) ElGamal encryption keypair.
1429
1677
  *
@@ -1447,6 +1695,118 @@ export class ElGamalPubkey {
1447
1695
  private constructor();
1448
1696
  free(): void;
1449
1697
  }
1698
+ /**
1699
+ * Wrapper of [`Glv`].
1700
+ */
1701
+ export class Glv {
1702
+ private constructor();
1703
+ free(): void;
1704
+ /**
1705
+ * Create from base64 encoded account data with options.
1706
+ */
1707
+ static decode_from_base64_with_options(data: string, no_discriminator?: boolean | null): Glv;
1708
+ /**
1709
+ * Create from base64 encoded account data with options.
1710
+ */
1711
+ static decode_with_options(data: Uint8Array, no_discriminator?: boolean | null): Glv;
1712
+ /**
1713
+ * Convert into [`JsGlvModel`].
1714
+ */
1715
+ to_model(supply: bigint): GlvModel;
1716
+ /**
1717
+ * Returns GLV token address.
1718
+ */
1719
+ glv_token_address(): string;
1720
+ /**
1721
+ * Returns long token address.
1722
+ */
1723
+ long_token_address(): string;
1724
+ /**
1725
+ * Returns short token address.
1726
+ */
1727
+ short_token_address(): string;
1728
+ /**
1729
+ * Create a clone of this market.
1730
+ */
1731
+ clone(): Glv;
1732
+ }
1733
+ /**
1734
+ * Simulation output for GLV deposit.
1735
+ */
1736
+ export class GlvDepositSimulationOutput {
1737
+ private constructor();
1738
+ free(): void;
1739
+ /**
1740
+ * Returns the deposit report.
1741
+ */
1742
+ deposit_report(): string | undefined;
1743
+ /**
1744
+ * Returns swap reports for the long token path.
1745
+ */
1746
+ long_swaps(): string[];
1747
+ /**
1748
+ * Returns swap reports for the short token path.
1749
+ */
1750
+ short_swaps(): string[];
1751
+ /**
1752
+ * Returns the output GLV token amount.
1753
+ */
1754
+ output_amount(): bigint;
1755
+ }
1756
+ /**
1757
+ * Wrapper of [`GlvModel`].
1758
+ */
1759
+ export class GlvModel {
1760
+ private constructor();
1761
+ free(): void;
1762
+ /**
1763
+ * Returns current supply.
1764
+ */
1765
+ supply(): bigint;
1766
+ /**
1767
+ * Returns GLV token address.
1768
+ */
1769
+ glv_token_address(): string;
1770
+ /**
1771
+ * Returns long token address.
1772
+ */
1773
+ long_token_address(): string;
1774
+ /**
1775
+ * Returns short token address.
1776
+ */
1777
+ short_token_address(): string;
1778
+ /**
1779
+ * Create a clone of this market model.
1780
+ */
1781
+ clone(): GlvModel;
1782
+ }
1783
+ /**
1784
+ * Simulation output for withdrawal.
1785
+ */
1786
+ export class GlvWithdrawalSimulationOutput {
1787
+ private constructor();
1788
+ free(): void;
1789
+ /**
1790
+ * Returns the withdraw report.
1791
+ */
1792
+ withdraw_report(): string;
1793
+ /**
1794
+ * Returns swap reports for the long token path.
1795
+ */
1796
+ long_swaps(): string[];
1797
+ /**
1798
+ * Returns swap reports for the short token path.
1799
+ */
1800
+ short_swaps(): string[];
1801
+ /**
1802
+ * Returns long token output amount.
1803
+ */
1804
+ long_output_amount(): bigint;
1805
+ /**
1806
+ * Returns short token output amount.
1807
+ */
1808
+ short_output_amount(): bigint;
1809
+ }
1450
1810
  /**
1451
1811
  * A hash; the 32-byte output of a hashing algorithm.
1452
1812
  *
@@ -1628,10 +1988,18 @@ export class MarketModel {
1628
1988
  * Get market token price.
1629
1989
  */
1630
1990
  market_token_price(params: MarketTokenPriceParams): bigint;
1991
+ /**
1992
+ * Calculates max sellable value.
1993
+ */
1994
+ max_sellable_value(params: MaxSellableValueParams): bigint;
1631
1995
  /**
1632
1996
  * Get market status.
1633
1997
  */
1634
1998
  status(params: MarketStatusParams): MarketStatus;
1999
+ /**
2000
+ * Returns current supply.
2001
+ */
2002
+ supply(): bigint;
1635
2003
  /**
1636
2004
  * Create an empty position model.
1637
2005
  */
@@ -1821,6 +2189,21 @@ export class Pubkey {
1821
2189
  */
1822
2190
  static findProgramAddress(seeds: any[], program_id: Pubkey): any;
1823
2191
  }
2192
+ /**
2193
+ * Simulation output for shift.
2194
+ */
2195
+ export class ShiftSimulationOutput {
2196
+ private constructor();
2197
+ free(): void;
2198
+ /**
2199
+ * Returns the deposit report.
2200
+ */
2201
+ deposit_report(): string;
2202
+ /**
2203
+ * Returns the withdraw report.
2204
+ */
2205
+ withdraw_report(): string;
2206
+ }
1824
2207
  /**
1825
2208
  * A JS binding for [`Simulator`].
1826
2209
  */
@@ -1835,15 +2218,54 @@ export class Simulator {
1835
2218
  * Get price for the given token.
1836
2219
  */
1837
2220
  get_price(token: string): Value | undefined;
2221
+ /**
2222
+ * Get GLV by its GLV token.
2223
+ */
2224
+ get_glv(glv_token: string): GlvModel | undefined;
1838
2225
  /**
1839
2226
  * Upsert the prices for the given token.
1840
2227
  */
1841
2228
  insert_price(token: string, price: Value): void;
2229
+ /**
2230
+ * Upsert a GLV model.
2231
+ */
2232
+ insert_glv(glv: GlvModel): void;
2233
+ /**
2234
+ * Simulate an order execution.
2235
+ */
1842
2236
  simulate_order(args: SimulateOrderArgs, position?: Position | null): OrderSimulationOutput;
2237
+ /**
2238
+ * Simulate a deposit execution.
2239
+ */
2240
+ simulate_deposit(args: SimulateDepositArgs): DepositSimulationOutput;
2241
+ /**
2242
+ * Simulate a withdrawal execution.
2243
+ */
2244
+ simulate_withdrawal(args: SimulateWithdrawalArgs): WithdrawalSimulationOutput;
2245
+ /**
2246
+ * Simulate a shift execution.
2247
+ */
2248
+ simulate_shift(args: SimulateShiftArgs): ShiftSimulationOutput;
2249
+ /**
2250
+ * Simulate a GLV deposit execution.
2251
+ */
2252
+ simulate_glv_deposit(args: SimulateGlvDepositArgs): GlvDepositSimulationOutput;
2253
+ /**
2254
+ * Simulate a GLV withdrawal execution.
2255
+ */
2256
+ simulate_glv_withdrawal(args: SimulateGlvWithdrawalArgs): GlvWithdrawalSimulationOutput;
1843
2257
  /**
1844
2258
  * Create a clone of this simulator.
1845
2259
  */
1846
2260
  clone(): Simulator;
2261
+ /**
2262
+ * Calculates GLV status.
2263
+ */
2264
+ get_glv_status(args: GetGlvStatusArgs): GlvStatus;
2265
+ /**
2266
+ * Calculates GLV token value.
2267
+ */
2268
+ get_glv_token_value(args: GetGlvTokenValueArgs): bigint;
1847
2269
  }
1848
2270
  /**
1849
2271
  * JS version of [`TradeEvent`].
@@ -1958,3 +2380,30 @@ export class User {
1958
2380
  */
1959
2381
  gt_minted_fee_value(): bigint;
1960
2382
  }
2383
+ /**
2384
+ * Simulation output for withdrawal.
2385
+ */
2386
+ export class WithdrawalSimulationOutput {
2387
+ private constructor();
2388
+ free(): void;
2389
+ /**
2390
+ * Returns the withdraw report.
2391
+ */
2392
+ report(): string;
2393
+ /**
2394
+ * Returns swap reports for the long token path.
2395
+ */
2396
+ long_swaps(): string[];
2397
+ /**
2398
+ * Returns swap reports for the short token path.
2399
+ */
2400
+ short_swaps(): string[];
2401
+ /**
2402
+ * Returns long token output amount.
2403
+ */
2404
+ long_output_amount(): bigint;
2405
+ /**
2406
+ * Returns short token output amount.
2407
+ */
2408
+ short_output_amount(): bigint;
2409
+ }