@gmsol-labs/gmsol-sdk 0.8.0 → 0.9.0-alpha.0

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
  */
@@ -165,6 +175,125 @@ export interface UpdateOrderArgs {
165
175
  transaction_group?: TransactionGroupOptions;
166
176
  }
167
177
 
178
+ export interface CreateDepositParamsJs {
179
+ market_token: StringPubkey;
180
+ receiver?: StringPubkey | undefined;
181
+ long_pay_token?: StringPubkey | undefined;
182
+ short_pay_token?: StringPubkey | undefined;
183
+ long_swap_path?: StringPubkey[] | undefined;
184
+ short_swap_path?: StringPubkey[] | undefined;
185
+ long_pay_amount?: bigint | undefined;
186
+ short_pay_amount?: bigint | undefined;
187
+ min_receive_amount?: bigint | undefined;
188
+ skip_unwrap_native_on_receive?: boolean | undefined;
189
+ }
190
+
191
+ export interface CreateDepositOptions {
192
+ recent_blockhash: string;
193
+ payer: StringPubkey;
194
+ program?: StoreProgram | undefined;
195
+ compute_unit_price_micro_lamports?: number | undefined;
196
+ compute_unit_min_priority_lamports?: number | undefined;
197
+ hints: Map<StringPubkey, CreateDepositHint>;
198
+ transaction_group?: TransactionGroupOptions;
199
+ skip_wrap_native_on_pay?: boolean | undefined;
200
+ }
201
+
202
+ export interface CreateWithdrawalParamsJs {
203
+ market_token: StringPubkey;
204
+ receiver?: StringPubkey | undefined;
205
+ long_receive_token?: StringPubkey | undefined;
206
+ short_receive_token?: StringPubkey | undefined;
207
+ long_swap_path?: StringPubkey[] | undefined;
208
+ short_swap_path?: StringPubkey[] | undefined;
209
+ market_token_amount?: bigint | undefined;
210
+ min_long_receive_amount?: bigint | undefined;
211
+ min_short_receive_amount?: bigint | undefined;
212
+ skip_unwrap_native_on_receive?: boolean | undefined;
213
+ }
214
+
215
+ export interface CreateWithdrawalOptions {
216
+ recent_blockhash: string;
217
+ payer: StringPubkey;
218
+ program?: StoreProgram | undefined;
219
+ compute_unit_price_micro_lamports?: number | undefined;
220
+ compute_unit_min_priority_lamports?: number | undefined;
221
+ hints: Map<StringPubkey, CreateWithdrawalHint>;
222
+ transaction_group?: TransactionGroupOptions;
223
+ }
224
+
225
+ export interface CreateShiftParamsJs {
226
+ from_market_token: StringPubkey;
227
+ to_market_token: StringPubkey;
228
+ receiver?: StringPubkey | undefined;
229
+ from_market_token_amount?: bigint | undefined;
230
+ min_to_market_token_amount?: bigint | undefined;
231
+ skip_to_market_token_ata_creation?: boolean | undefined;
232
+ }
233
+
234
+ export interface CreateShiftOptions {
235
+ recent_blockhash: string;
236
+ payer: StringPubkey;
237
+ program?: StoreProgram | undefined;
238
+ compute_unit_price_micro_lamports?: number | undefined;
239
+ compute_unit_min_priority_lamports?: number | undefined;
240
+ transaction_group?: TransactionGroupOptions;
241
+ }
242
+
243
+ export interface CreateGlvDepositParamsJs {
244
+ glv_token: StringPubkey;
245
+ market_token: StringPubkey;
246
+ receiver?: StringPubkey | undefined;
247
+ long_pay_token?: StringPubkey | undefined;
248
+ short_pay_token?: StringPubkey | undefined;
249
+ long_swap_path?: StringPubkey[] | undefined;
250
+ short_swap_path?: StringPubkey[] | undefined;
251
+ long_pay_amount?: bigint | undefined;
252
+ short_pay_amount?: bigint | undefined;
253
+ market_token_amount?: bigint | undefined;
254
+ min_market_token_amount?: bigint | undefined;
255
+ min_receive_amount?: bigint | undefined;
256
+ skip_unwrap_native_on_receive?: boolean | undefined;
257
+ skip_glv_token_ata_creation?: boolean | undefined;
258
+ }
259
+
260
+ export interface CreateGlvDepositOptions {
261
+ recent_blockhash: string;
262
+ payer: StringPubkey;
263
+ program?: StoreProgram | undefined;
264
+ compute_unit_price_micro_lamports?: number | undefined;
265
+ compute_unit_min_priority_lamports?: number | undefined;
266
+ hints: Map<StringPubkey, CreateGlvDepositHint>;
267
+ transaction_group?: TransactionGroupOptions;
268
+ skip_wrap_native_on_pay?: boolean | undefined;
269
+ }
270
+
271
+ export interface CreateGlvWithdrawalParamsJs {
272
+ glv_token: StringPubkey;
273
+ market_token: StringPubkey;
274
+ receiver?: StringPubkey | undefined;
275
+ long_receive_token?: StringPubkey | undefined;
276
+ short_receive_token?: StringPubkey | undefined;
277
+ long_swap_path?: StringPubkey[] | undefined;
278
+ short_swap_path?: StringPubkey[] | undefined;
279
+ glv_token_amount?: bigint | undefined;
280
+ min_long_receive_amount?: bigint | undefined;
281
+ min_short_receive_amount?: bigint | undefined;
282
+ skip_unwrap_native_on_receive?: boolean | undefined;
283
+ skip_long_receive_token_ata_creation?: boolean | undefined;
284
+ skip_short_receive_token_ata_creation?: boolean | undefined;
285
+ }
286
+
287
+ export interface CreateGlvWithdrawalOptions {
288
+ recent_blockhash: string;
289
+ payer: StringPubkey;
290
+ program?: StoreProgram | undefined;
291
+ compute_unit_price_micro_lamports?: number | undefined;
292
+ compute_unit_min_priority_lamports?: number | undefined;
293
+ hints: Map<StringPubkey, CreateGlvWithdrawalHint>;
294
+ transaction_group?: TransactionGroupOptions;
295
+ }
296
+
168
297
  /**
169
298
  * A JS version transaction group options.
170
299
  */
@@ -189,6 +318,27 @@ export interface BuildTransactionOptions {
189
318
  compute_unit_min_priority_lamports?: number | undefined;
190
319
  }
191
320
 
321
+ /**
322
+ * Arguments for deposit simulation.
323
+ */
324
+ export interface SimulateDepositArgs {
325
+ params: CreateDepositParamsJs;
326
+ }
327
+
328
+ /**
329
+ * Arguments for GLV deposit simulation.
330
+ */
331
+ export interface SimulateGlvDepositArgs {
332
+ params: CreateGlvDepositParamsJs;
333
+ }
334
+
335
+ /**
336
+ * Arguments for GLV withdrawal simulation.
337
+ */
338
+ export interface SimulateGlvWithdrawalArgs {
339
+ params: CreateGlvWithdrawalParamsJs;
340
+ }
341
+
192
342
  /**
193
343
  * Arguments for order simulation.
194
344
  */
@@ -233,6 +383,20 @@ export interface SwapOrderSimulationOutput {
233
383
  report: string[];
234
384
  }
235
385
 
386
+ /**
387
+ * Arguments for shift simulation.
388
+ */
389
+ export interface SimulateShiftArgs {
390
+ params: CreateShiftParamsJs;
391
+ }
392
+
393
+ /**
394
+ * Arguments for withdrawal simulation.
395
+ */
396
+ export interface SimulateWithdrawalArgs {
397
+ params: CreateWithdrawalParamsJs;
398
+ }
399
+
236
400
 
237
401
  /**
238
402
  * A Base58-encoded string representing a public key.
@@ -1409,6 +1573,21 @@ export interface StoreProgram {
1409
1573
  */
1410
1574
  export type PnlFactorKind = "max_after_deposit" | "max_after_withdrawal" | "max_for_trader" | "for_adl" | "min_after_adl";
1411
1575
 
1576
+ export class CreateDepositsBuilder {
1577
+ private constructor();
1578
+ free(): void;
1579
+ build_with_options(transaction_group?: TransactionGroupOptions | null, build?: BuildTransactionOptions | null): TransactionGroup;
1580
+ }
1581
+ export class CreateGlvDepositsBuilder {
1582
+ private constructor();
1583
+ free(): void;
1584
+ build_with_options(transaction_group?: TransactionGroupOptions | null, build?: BuildTransactionOptions | null): TransactionGroup;
1585
+ }
1586
+ export class CreateGlvWithdrawalsBuilder {
1587
+ private constructor();
1588
+ free(): void;
1589
+ build_with_options(transaction_group?: TransactionGroupOptions | null, build?: BuildTransactionOptions | null): TransactionGroup;
1590
+ }
1412
1591
  /**
1413
1592
  * Builder for create-order ixs.
1414
1593
  */
@@ -1424,6 +1603,35 @@ export class CreateOrdersBuilder {
1424
1603
  */
1425
1604
  merge(other: CreateOrdersBuilder): void;
1426
1605
  }
1606
+ export class CreateShiftsBuilder {
1607
+ private constructor();
1608
+ free(): void;
1609
+ build_with_options(transaction_group?: TransactionGroupOptions | null, build?: BuildTransactionOptions | null): TransactionGroup;
1610
+ }
1611
+ export class CreateWithdrawalsBuilder {
1612
+ private constructor();
1613
+ free(): void;
1614
+ build_with_options(transaction_group?: TransactionGroupOptions | null, build?: BuildTransactionOptions | null): TransactionGroup;
1615
+ }
1616
+ /**
1617
+ * Simulation output for deposit.
1618
+ */
1619
+ export class DepositSimulationOutput {
1620
+ private constructor();
1621
+ free(): void;
1622
+ /**
1623
+ * Returns the deposit report.
1624
+ */
1625
+ report(): string;
1626
+ /**
1627
+ * Returns swap reports for the long token path.
1628
+ */
1629
+ long_swaps(): string[];
1630
+ /**
1631
+ * Returns swap reports for the short token path.
1632
+ */
1633
+ short_swaps(): string[];
1634
+ }
1427
1635
  /**
1428
1636
  * A (twisted) ElGamal encryption keypair.
1429
1637
  *
@@ -1447,6 +1655,118 @@ export class ElGamalPubkey {
1447
1655
  private constructor();
1448
1656
  free(): void;
1449
1657
  }
1658
+ /**
1659
+ * Wrapper of [`Glv`].
1660
+ */
1661
+ export class Glv {
1662
+ private constructor();
1663
+ free(): void;
1664
+ /**
1665
+ * Create from base64 encoded account data with options.
1666
+ */
1667
+ static decode_from_base64_with_options(data: string, no_discriminator?: boolean | null): Glv;
1668
+ /**
1669
+ * Create from base64 encoded account data with options.
1670
+ */
1671
+ static decode_with_options(data: Uint8Array, no_discriminator?: boolean | null): Glv;
1672
+ /**
1673
+ * Convert into [`JsGlvModel`].
1674
+ */
1675
+ to_model(supply: bigint): GlvModel;
1676
+ /**
1677
+ * Returns GLV token address.
1678
+ */
1679
+ glv_token_address(): string;
1680
+ /**
1681
+ * Returns long token address.
1682
+ */
1683
+ long_token_address(): string;
1684
+ /**
1685
+ * Returns short token address.
1686
+ */
1687
+ short_token_address(): string;
1688
+ /**
1689
+ * Create a clone of this market.
1690
+ */
1691
+ clone(): Glv;
1692
+ }
1693
+ /**
1694
+ * Simulation output for GLV deposit.
1695
+ */
1696
+ export class GlvDepositSimulationOutput {
1697
+ private constructor();
1698
+ free(): void;
1699
+ /**
1700
+ * Returns the deposit report.
1701
+ */
1702
+ deposit_report(): string | undefined;
1703
+ /**
1704
+ * Returns swap reports for the long token path.
1705
+ */
1706
+ long_swaps(): string[];
1707
+ /**
1708
+ * Returns swap reports for the short token path.
1709
+ */
1710
+ short_swaps(): string[];
1711
+ /**
1712
+ * Returns the output GLV token amount.
1713
+ */
1714
+ output_amount(): bigint;
1715
+ }
1716
+ /**
1717
+ * Wrapper of [`GlvModel`].
1718
+ */
1719
+ export class GlvModel {
1720
+ private constructor();
1721
+ free(): void;
1722
+ /**
1723
+ * Returns current supply.
1724
+ */
1725
+ supply(): bigint;
1726
+ /**
1727
+ * Returns GLV token address.
1728
+ */
1729
+ glv_token_address(): string;
1730
+ /**
1731
+ * Returns long token address.
1732
+ */
1733
+ long_token_address(): string;
1734
+ /**
1735
+ * Returns short token address.
1736
+ */
1737
+ short_token_address(): string;
1738
+ /**
1739
+ * Create a clone of this market model.
1740
+ */
1741
+ clone(): GlvModel;
1742
+ }
1743
+ /**
1744
+ * Simulation output for withdrawal.
1745
+ */
1746
+ export class GlvWithdrawalSimulationOutput {
1747
+ private constructor();
1748
+ free(): void;
1749
+ /**
1750
+ * Returns the withdraw report.
1751
+ */
1752
+ withdraw_report(): string;
1753
+ /**
1754
+ * Returns swap reports for the long token path.
1755
+ */
1756
+ long_swaps(): string[];
1757
+ /**
1758
+ * Returns swap reports for the short token path.
1759
+ */
1760
+ short_swaps(): string[];
1761
+ /**
1762
+ * Returns long token output amount.
1763
+ */
1764
+ long_output_amount(): bigint;
1765
+ /**
1766
+ * Returns short token output amount.
1767
+ */
1768
+ short_output_amount(): bigint;
1769
+ }
1450
1770
  /**
1451
1771
  * A hash; the 32-byte output of a hashing algorithm.
1452
1772
  *
@@ -1632,6 +1952,10 @@ export class MarketModel {
1632
1952
  * Get market status.
1633
1953
  */
1634
1954
  status(params: MarketStatusParams): MarketStatus;
1955
+ /**
1956
+ * Returns current supply.
1957
+ */
1958
+ supply(): bigint;
1635
1959
  /**
1636
1960
  * Create an empty position model.
1637
1961
  */
@@ -1821,6 +2145,21 @@ export class Pubkey {
1821
2145
  */
1822
2146
  static findProgramAddress(seeds: any[], program_id: Pubkey): any;
1823
2147
  }
2148
+ /**
2149
+ * Simulation output for shift.
2150
+ */
2151
+ export class ShiftSimulationOutput {
2152
+ private constructor();
2153
+ free(): void;
2154
+ /**
2155
+ * Returns the deposit report.
2156
+ */
2157
+ deposit_report(): string;
2158
+ /**
2159
+ * Returns the withdraw report.
2160
+ */
2161
+ withdraw_report(): string;
2162
+ }
1824
2163
  /**
1825
2164
  * A JS binding for [`Simulator`].
1826
2165
  */
@@ -1835,11 +2174,42 @@ export class Simulator {
1835
2174
  * Get price for the given token.
1836
2175
  */
1837
2176
  get_price(token: string): Value | undefined;
2177
+ /**
2178
+ * Get GLV by its GLV token.
2179
+ */
2180
+ get_glv(glv_token: string): GlvModel | undefined;
1838
2181
  /**
1839
2182
  * Upsert the prices for the given token.
1840
2183
  */
1841
2184
  insert_price(token: string, price: Value): void;
2185
+ /**
2186
+ * Upsert a GLV model.
2187
+ */
2188
+ insert_glv(glv: GlvModel): void;
2189
+ /**
2190
+ * Simulate an order execution.
2191
+ */
1842
2192
  simulate_order(args: SimulateOrderArgs, position?: Position | null): OrderSimulationOutput;
2193
+ /**
2194
+ * Simulate a deposit execution.
2195
+ */
2196
+ simulate_deposit(args: SimulateDepositArgs): DepositSimulationOutput;
2197
+ /**
2198
+ * Simulate a withdrawal execution.
2199
+ */
2200
+ simulate_withdrawal(args: SimulateWithdrawalArgs): WithdrawalSimulationOutput;
2201
+ /**
2202
+ * Simulate a shift execution.
2203
+ */
2204
+ simulate_shift(args: SimulateShiftArgs): ShiftSimulationOutput;
2205
+ /**
2206
+ * Simulate a GLV deposit execution.
2207
+ */
2208
+ simulate_glv_deposit(args: SimulateGlvDepositArgs): GlvDepositSimulationOutput;
2209
+ /**
2210
+ * Simulate a GLV withdrawal execution.
2211
+ */
2212
+ simulate_glv_withdrawal(args: SimulateGlvWithdrawalArgs): GlvWithdrawalSimulationOutput;
1843
2213
  /**
1844
2214
  * Create a clone of this simulator.
1845
2215
  */
@@ -1958,3 +2328,30 @@ export class User {
1958
2328
  */
1959
2329
  gt_minted_fee_value(): bigint;
1960
2330
  }
2331
+ /**
2332
+ * Simulation output for withdrawal.
2333
+ */
2334
+ export class WithdrawalSimulationOutput {
2335
+ private constructor();
2336
+ free(): void;
2337
+ /**
2338
+ * Returns the withdraw report.
2339
+ */
2340
+ report(): string;
2341
+ /**
2342
+ * Returns swap reports for the long token path.
2343
+ */
2344
+ long_swaps(): string[];
2345
+ /**
2346
+ * Returns swap reports for the short token path.
2347
+ */
2348
+ short_swaps(): string[];
2349
+ /**
2350
+ * Returns long token output amount.
2351
+ */
2352
+ long_output_amount(): bigint;
2353
+ /**
2354
+ * Returns short token output amount.
2355
+ */
2356
+ short_output_amount(): bigint;
2357
+ }