@gmsol-labs/gmsol-sdk 0.9.0-alpha.0 → 0.9.0-alpha.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 +106 -0
- package/index_bg.js +204 -0
- package/index_bg.wasm +0 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -66,6 +66,16 @@ export interface MarketStatusParams {
|
|
|
66
66
|
prices: Prices;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Params for calculating max sellable avlue.
|
|
71
|
+
*/
|
|
72
|
+
export interface MaxSellableValueParams {
|
|
73
|
+
/**
|
|
74
|
+
* Prices.
|
|
75
|
+
*/
|
|
76
|
+
prices: Prices;
|
|
77
|
+
}
|
|
78
|
+
|
|
69
79
|
/**
|
|
70
80
|
* Parameters for creating empty position model.
|
|
71
81
|
*/
|
|
@@ -390,6 +400,22 @@ export interface SimulateShiftArgs {
|
|
|
390
400
|
params: CreateShiftParamsJs;
|
|
391
401
|
}
|
|
392
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
|
+
|
|
393
419
|
/**
|
|
394
420
|
* Arguments for withdrawal simulation.
|
|
395
421
|
*/
|
|
@@ -470,6 +496,20 @@ export interface Prices {
|
|
|
470
496
|
short_token: Value;
|
|
471
497
|
}
|
|
472
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
|
+
|
|
473
513
|
/**
|
|
474
514
|
* Position Status.
|
|
475
515
|
*/
|
|
@@ -1948,6 +1988,10 @@ export class MarketModel {
|
|
|
1948
1988
|
* Get market token price.
|
|
1949
1989
|
*/
|
|
1950
1990
|
market_token_price(params: MarketTokenPriceParams): bigint;
|
|
1991
|
+
/**
|
|
1992
|
+
* Calculates max sellable value.
|
|
1993
|
+
*/
|
|
1994
|
+
max_sellable_value(params: MaxSellableValueParams): bigint;
|
|
1951
1995
|
/**
|
|
1952
1996
|
* Get market status.
|
|
1953
1997
|
*/
|
|
@@ -2186,6 +2230,22 @@ export class Simulator {
|
|
|
2186
2230
|
* Upsert a GLV model.
|
|
2187
2231
|
*/
|
|
2188
2232
|
insert_glv(glv: GlvModel): void;
|
|
2233
|
+
/**
|
|
2234
|
+
* Insert a virtual inventory model.
|
|
2235
|
+
*/
|
|
2236
|
+
insert_vi(vi_address: string, vi: VirtualInventoryModel): void;
|
|
2237
|
+
/**
|
|
2238
|
+
* Get virtual inventory model by address.
|
|
2239
|
+
*/
|
|
2240
|
+
get_vi(vi_address: string): VirtualInventoryModel | undefined;
|
|
2241
|
+
/**
|
|
2242
|
+
* Set whether to disable virtual inventories for simulations.
|
|
2243
|
+
*/
|
|
2244
|
+
set_disable_vis(disable: boolean): void;
|
|
2245
|
+
/**
|
|
2246
|
+
* Get whether virtual inventories are disabled.
|
|
2247
|
+
*/
|
|
2248
|
+
disable_vis(): boolean;
|
|
2189
2249
|
/**
|
|
2190
2250
|
* Simulate an order execution.
|
|
2191
2251
|
*/
|
|
@@ -2214,6 +2274,14 @@ export class Simulator {
|
|
|
2214
2274
|
* Create a clone of this simulator.
|
|
2215
2275
|
*/
|
|
2216
2276
|
clone(): Simulator;
|
|
2277
|
+
/**
|
|
2278
|
+
* Calculates GLV status.
|
|
2279
|
+
*/
|
|
2280
|
+
get_glv_status(args: GetGlvStatusArgs): GlvStatus;
|
|
2281
|
+
/**
|
|
2282
|
+
* Calculates GLV token value.
|
|
2283
|
+
*/
|
|
2284
|
+
get_glv_token_value(args: GetGlvTokenValueArgs): bigint;
|
|
2217
2285
|
}
|
|
2218
2286
|
/**
|
|
2219
2287
|
* JS version of [`TradeEvent`].
|
|
@@ -2328,6 +2396,44 @@ export class User {
|
|
|
2328
2396
|
*/
|
|
2329
2397
|
gt_minted_fee_value(): bigint;
|
|
2330
2398
|
}
|
|
2399
|
+
/**
|
|
2400
|
+
* Wrapper of [`VirtualInventory`].
|
|
2401
|
+
*/
|
|
2402
|
+
export class VirtualInventory {
|
|
2403
|
+
private constructor();
|
|
2404
|
+
free(): void;
|
|
2405
|
+
/**
|
|
2406
|
+
* Create from base64 encoded account data with options.
|
|
2407
|
+
*/
|
|
2408
|
+
static decode_from_base64_with_options(data: string, no_discriminator?: boolean | null): VirtualInventory;
|
|
2409
|
+
/**
|
|
2410
|
+
* Create from base64 encoded account data.
|
|
2411
|
+
*/
|
|
2412
|
+
static decode_from_base64(data: string): VirtualInventory;
|
|
2413
|
+
/**
|
|
2414
|
+
* Create from account data.
|
|
2415
|
+
*/
|
|
2416
|
+
static decode(data: Uint8Array): VirtualInventory;
|
|
2417
|
+
/**
|
|
2418
|
+
* Convert into [`JsVirtualInventoryModel`].
|
|
2419
|
+
*/
|
|
2420
|
+
to_model(): VirtualInventoryModel;
|
|
2421
|
+
/**
|
|
2422
|
+
* Create a clone of this virtual inventory.
|
|
2423
|
+
*/
|
|
2424
|
+
clone(): VirtualInventory;
|
|
2425
|
+
}
|
|
2426
|
+
/**
|
|
2427
|
+
* Wrapper of [`VirtualInventoryModel`].
|
|
2428
|
+
*/
|
|
2429
|
+
export class VirtualInventoryModel {
|
|
2430
|
+
private constructor();
|
|
2431
|
+
free(): void;
|
|
2432
|
+
/**
|
|
2433
|
+
* Create a clone of this virtual inventory model.
|
|
2434
|
+
*/
|
|
2435
|
+
clone(): VirtualInventoryModel;
|
|
2436
|
+
}
|
|
2331
2437
|
/**
|
|
2332
2438
|
* Simulation output for withdrawal.
|
|
2333
2439
|
*/
|
package/index_bg.js
CHANGED
|
@@ -1854,6 +1854,18 @@ export class MarketModel {
|
|
|
1854
1854
|
}
|
|
1855
1855
|
return (BigInt.asUintN(64, ret[0]) | (BigInt.asUintN(64, ret[1]) << BigInt(64)));
|
|
1856
1856
|
}
|
|
1857
|
+
/**
|
|
1858
|
+
* Calculates max sellable value.
|
|
1859
|
+
* @param {MaxSellableValueParams} params
|
|
1860
|
+
* @returns {bigint}
|
|
1861
|
+
*/
|
|
1862
|
+
max_sellable_value(params) {
|
|
1863
|
+
const ret = wasm.marketmodel_max_sellable_value(this.__wbg_ptr, params);
|
|
1864
|
+
if (ret[3]) {
|
|
1865
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1866
|
+
}
|
|
1867
|
+
return (BigInt.asUintN(64, ret[0]) | (BigInt.asUintN(64, ret[1]) << BigInt(64)));
|
|
1868
|
+
}
|
|
1857
1869
|
/**
|
|
1858
1870
|
* Get market status.
|
|
1859
1871
|
* @param {MarketStatusParams} params
|
|
@@ -2623,6 +2635,49 @@ export class Simulator {
|
|
|
2623
2635
|
throw takeFromExternrefTable0(ret[0]);
|
|
2624
2636
|
}
|
|
2625
2637
|
}
|
|
2638
|
+
/**
|
|
2639
|
+
* Insert a virtual inventory model.
|
|
2640
|
+
* @param {string} vi_address
|
|
2641
|
+
* @param {VirtualInventoryModel} vi
|
|
2642
|
+
*/
|
|
2643
|
+
insert_vi(vi_address, vi) {
|
|
2644
|
+
const ptr0 = passStringToWasm0(vi_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2645
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2646
|
+
_assertClass(vi, VirtualInventoryModel);
|
|
2647
|
+
const ret = wasm.simulator_insert_vi(this.__wbg_ptr, ptr0, len0, vi.__wbg_ptr);
|
|
2648
|
+
if (ret[1]) {
|
|
2649
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
/**
|
|
2653
|
+
* Get virtual inventory model by address.
|
|
2654
|
+
* @param {string} vi_address
|
|
2655
|
+
* @returns {VirtualInventoryModel | undefined}
|
|
2656
|
+
*/
|
|
2657
|
+
get_vi(vi_address) {
|
|
2658
|
+
const ptr0 = passStringToWasm0(vi_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2659
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2660
|
+
const ret = wasm.simulator_get_vi(this.__wbg_ptr, ptr0, len0);
|
|
2661
|
+
if (ret[2]) {
|
|
2662
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2663
|
+
}
|
|
2664
|
+
return ret[0] === 0 ? undefined : VirtualInventoryModel.__wrap(ret[0]);
|
|
2665
|
+
}
|
|
2666
|
+
/**
|
|
2667
|
+
* Set whether to disable virtual inventories for simulations.
|
|
2668
|
+
* @param {boolean} disable
|
|
2669
|
+
*/
|
|
2670
|
+
set_disable_vis(disable) {
|
|
2671
|
+
wasm.simulator_set_disable_vis(this.__wbg_ptr, disable);
|
|
2672
|
+
}
|
|
2673
|
+
/**
|
|
2674
|
+
* Get whether virtual inventories are disabled.
|
|
2675
|
+
* @returns {boolean}
|
|
2676
|
+
*/
|
|
2677
|
+
disable_vis() {
|
|
2678
|
+
const ret = wasm.simulator_disable_vis(this.__wbg_ptr);
|
|
2679
|
+
return ret !== 0;
|
|
2680
|
+
}
|
|
2626
2681
|
/**
|
|
2627
2682
|
* Simulate an order execution.
|
|
2628
2683
|
* @param {SimulateOrderArgs} args
|
|
@@ -2709,6 +2764,30 @@ export class Simulator {
|
|
|
2709
2764
|
const ret = wasm.simulator_clone(this.__wbg_ptr);
|
|
2710
2765
|
return Simulator.__wrap(ret);
|
|
2711
2766
|
}
|
|
2767
|
+
/**
|
|
2768
|
+
* Calculates GLV status.
|
|
2769
|
+
* @param {GetGlvStatusArgs} args
|
|
2770
|
+
* @returns {GlvStatus}
|
|
2771
|
+
*/
|
|
2772
|
+
get_glv_status(args) {
|
|
2773
|
+
const ret = wasm.simulator_get_glv_status(this.__wbg_ptr, args);
|
|
2774
|
+
if (ret[2]) {
|
|
2775
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2776
|
+
}
|
|
2777
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2778
|
+
}
|
|
2779
|
+
/**
|
|
2780
|
+
* Calculates GLV token value.
|
|
2781
|
+
* @param {GetGlvTokenValueArgs} args
|
|
2782
|
+
* @returns {bigint}
|
|
2783
|
+
*/
|
|
2784
|
+
get_glv_token_value(args) {
|
|
2785
|
+
const ret = wasm.simulator_get_glv_token_value(this.__wbg_ptr, args);
|
|
2786
|
+
if (ret[3]) {
|
|
2787
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2788
|
+
}
|
|
2789
|
+
return (BigInt.asUintN(64, ret[0]) | (BigInt.asUintN(64, ret[1]) << BigInt(64)));
|
|
2790
|
+
}
|
|
2712
2791
|
}
|
|
2713
2792
|
|
|
2714
2793
|
const SystemInstructionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -3291,6 +3370,131 @@ export class User {
|
|
|
3291
3370
|
}
|
|
3292
3371
|
}
|
|
3293
3372
|
|
|
3373
|
+
const VirtualInventoryFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3374
|
+
? { register: () => {}, unregister: () => {} }
|
|
3375
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_virtualinventory_free(ptr >>> 0, 1));
|
|
3376
|
+
/**
|
|
3377
|
+
* Wrapper of [`VirtualInventory`].
|
|
3378
|
+
*/
|
|
3379
|
+
export class VirtualInventory {
|
|
3380
|
+
|
|
3381
|
+
static __wrap(ptr) {
|
|
3382
|
+
ptr = ptr >>> 0;
|
|
3383
|
+
const obj = Object.create(VirtualInventory.prototype);
|
|
3384
|
+
obj.__wbg_ptr = ptr;
|
|
3385
|
+
VirtualInventoryFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
3386
|
+
return obj;
|
|
3387
|
+
}
|
|
3388
|
+
|
|
3389
|
+
__destroy_into_raw() {
|
|
3390
|
+
const ptr = this.__wbg_ptr;
|
|
3391
|
+
this.__wbg_ptr = 0;
|
|
3392
|
+
VirtualInventoryFinalization.unregister(this);
|
|
3393
|
+
return ptr;
|
|
3394
|
+
}
|
|
3395
|
+
|
|
3396
|
+
free() {
|
|
3397
|
+
const ptr = this.__destroy_into_raw();
|
|
3398
|
+
wasm.__wbg_virtualinventory_free(ptr, 0);
|
|
3399
|
+
}
|
|
3400
|
+
/**
|
|
3401
|
+
* Create from base64 encoded account data with options.
|
|
3402
|
+
* @param {string} data
|
|
3403
|
+
* @param {boolean | null} [no_discriminator]
|
|
3404
|
+
* @returns {VirtualInventory}
|
|
3405
|
+
*/
|
|
3406
|
+
static decode_from_base64_with_options(data, no_discriminator) {
|
|
3407
|
+
const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3408
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3409
|
+
const ret = wasm.virtualinventory_decode_from_base64_with_options(ptr0, len0, isLikeNone(no_discriminator) ? 0xFFFFFF : no_discriminator ? 1 : 0);
|
|
3410
|
+
if (ret[2]) {
|
|
3411
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3412
|
+
}
|
|
3413
|
+
return VirtualInventory.__wrap(ret[0]);
|
|
3414
|
+
}
|
|
3415
|
+
/**
|
|
3416
|
+
* Create from base64 encoded account data.
|
|
3417
|
+
* @param {string} data
|
|
3418
|
+
* @returns {VirtualInventory}
|
|
3419
|
+
*/
|
|
3420
|
+
static decode_from_base64(data) {
|
|
3421
|
+
const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3422
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3423
|
+
const ret = wasm.virtualinventory_decode_from_base64(ptr0, len0);
|
|
3424
|
+
if (ret[2]) {
|
|
3425
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3426
|
+
}
|
|
3427
|
+
return VirtualInventory.__wrap(ret[0]);
|
|
3428
|
+
}
|
|
3429
|
+
/**
|
|
3430
|
+
* Create from account data.
|
|
3431
|
+
* @param {Uint8Array} data
|
|
3432
|
+
* @returns {VirtualInventory}
|
|
3433
|
+
*/
|
|
3434
|
+
static decode(data) {
|
|
3435
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
3436
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3437
|
+
const ret = wasm.virtualinventory_decode(ptr0, len0);
|
|
3438
|
+
if (ret[2]) {
|
|
3439
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3440
|
+
}
|
|
3441
|
+
return VirtualInventory.__wrap(ret[0]);
|
|
3442
|
+
}
|
|
3443
|
+
/**
|
|
3444
|
+
* Convert into [`JsVirtualInventoryModel`].
|
|
3445
|
+
* @returns {VirtualInventoryModel}
|
|
3446
|
+
*/
|
|
3447
|
+
to_model() {
|
|
3448
|
+
const ret = wasm.virtualinventory_to_model(this.__wbg_ptr);
|
|
3449
|
+
return VirtualInventoryModel.__wrap(ret);
|
|
3450
|
+
}
|
|
3451
|
+
/**
|
|
3452
|
+
* Create a clone of this virtual inventory.
|
|
3453
|
+
* @returns {VirtualInventory}
|
|
3454
|
+
*/
|
|
3455
|
+
clone() {
|
|
3456
|
+
const ret = wasm.virtualinventory_clone(this.__wbg_ptr);
|
|
3457
|
+
return VirtualInventory.__wrap(ret);
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
|
|
3461
|
+
const VirtualInventoryModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3462
|
+
? { register: () => {}, unregister: () => {} }
|
|
3463
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_virtualinventorymodel_free(ptr >>> 0, 1));
|
|
3464
|
+
/**
|
|
3465
|
+
* Wrapper of [`VirtualInventoryModel`].
|
|
3466
|
+
*/
|
|
3467
|
+
export class VirtualInventoryModel {
|
|
3468
|
+
|
|
3469
|
+
static __wrap(ptr) {
|
|
3470
|
+
ptr = ptr >>> 0;
|
|
3471
|
+
const obj = Object.create(VirtualInventoryModel.prototype);
|
|
3472
|
+
obj.__wbg_ptr = ptr;
|
|
3473
|
+
VirtualInventoryModelFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
3474
|
+
return obj;
|
|
3475
|
+
}
|
|
3476
|
+
|
|
3477
|
+
__destroy_into_raw() {
|
|
3478
|
+
const ptr = this.__wbg_ptr;
|
|
3479
|
+
this.__wbg_ptr = 0;
|
|
3480
|
+
VirtualInventoryModelFinalization.unregister(this);
|
|
3481
|
+
return ptr;
|
|
3482
|
+
}
|
|
3483
|
+
|
|
3484
|
+
free() {
|
|
3485
|
+
const ptr = this.__destroy_into_raw();
|
|
3486
|
+
wasm.__wbg_virtualinventorymodel_free(ptr, 0);
|
|
3487
|
+
}
|
|
3488
|
+
/**
|
|
3489
|
+
* Create a clone of this virtual inventory model.
|
|
3490
|
+
* @returns {VirtualInventoryModel}
|
|
3491
|
+
*/
|
|
3492
|
+
clone() {
|
|
3493
|
+
const ret = wasm.virtualinventorymodel_clone(this.__wbg_ptr);
|
|
3494
|
+
return VirtualInventoryModel.__wrap(ret);
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
|
|
3294
3498
|
const WithdrawalSimulationOutputFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3295
3499
|
? { register: () => {}, unregister: () => {} }
|
|
3296
3500
|
: new FinalizationRegistry(ptr => wasm.__wbg_withdrawalsimulationoutput_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.9.0-alpha.
|
|
5
|
+
"version": "0.9.0-alpha.2",
|
|
6
6
|
"license": "SEE LICENSE IN ../../LICENSE",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|