@gmsol-labs/gmsol-sdk 0.8.0-beta.1 → 0.8.0-beta.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 +148 -43
- package/index_bg.js +122 -4
- package/index_bg.wasm +0 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -112,47 +112,6 @@ export interface BestSwapPath {
|
|
|
112
112
|
arbitrage_exists: boolean | undefined;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
/**
|
|
116
|
-
* Arguments for order simulation.
|
|
117
|
-
*/
|
|
118
|
-
export interface SimulateOrderArgs {
|
|
119
|
-
kind: CreateOrderKind;
|
|
120
|
-
params: CreateOrderParams;
|
|
121
|
-
collateral_or_swap_out_token: StringPubkey;
|
|
122
|
-
pay_token?: StringPubkey | undefined;
|
|
123
|
-
receive_token?: StringPubkey | undefined;
|
|
124
|
-
swap_path?: StringPubkey[] | undefined;
|
|
125
|
-
prefer_swap_out_token_update?: boolean | undefined;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Simulation output for increase order.
|
|
130
|
-
*/
|
|
131
|
-
export interface IncreaseOrderSimulationOutput {
|
|
132
|
-
swaps: string[];
|
|
133
|
-
report: string;
|
|
134
|
-
position: string;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Simulation output for decrease order.
|
|
139
|
-
*/
|
|
140
|
-
export interface DecreaseOrderSimulationOutput {
|
|
141
|
-
swaps: string[];
|
|
142
|
-
report: string;
|
|
143
|
-
position: string;
|
|
144
|
-
decrease_swap: string | undefined;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Simulation output for swap order.
|
|
149
|
-
*/
|
|
150
|
-
export interface SwapOrderSimulationOutput {
|
|
151
|
-
output_token: StringPubkey;
|
|
152
|
-
amount: bigint;
|
|
153
|
-
report: string[];
|
|
154
|
-
}
|
|
155
|
-
|
|
156
115
|
/**
|
|
157
116
|
* Options for creating orders.
|
|
158
117
|
*/
|
|
@@ -230,6 +189,50 @@ export interface BuildTransactionOptions {
|
|
|
230
189
|
compute_unit_min_priority_lamports?: number | undefined;
|
|
231
190
|
}
|
|
232
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Arguments for order simulation.
|
|
194
|
+
*/
|
|
195
|
+
export interface SimulateOrderArgs {
|
|
196
|
+
kind: CreateOrderKind;
|
|
197
|
+
params: CreateOrderParams;
|
|
198
|
+
collateral_or_swap_out_token: StringPubkey;
|
|
199
|
+
pay_token?: StringPubkey | undefined;
|
|
200
|
+
receive_token?: StringPubkey | undefined;
|
|
201
|
+
swap_path?: StringPubkey[] | undefined;
|
|
202
|
+
prefer_swap_out_token_update?: boolean | undefined;
|
|
203
|
+
skip_limit_price_validation?: boolean | undefined;
|
|
204
|
+
limit_swap_slippage?: bigint | undefined;
|
|
205
|
+
update_prices_for_limit_order?: boolean | undefined;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Simulation output for increase order.
|
|
210
|
+
*/
|
|
211
|
+
export interface IncreaseOrderSimulationOutput {
|
|
212
|
+
swaps: string[];
|
|
213
|
+
report: string;
|
|
214
|
+
position: string | undefined;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Simulation output for decrease order.
|
|
219
|
+
*/
|
|
220
|
+
export interface DecreaseOrderSimulationOutput {
|
|
221
|
+
swaps: string[];
|
|
222
|
+
report: string;
|
|
223
|
+
position: string | undefined;
|
|
224
|
+
decrease_swap: string | undefined;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Simulation output for swap order.
|
|
229
|
+
*/
|
|
230
|
+
export interface SwapOrderSimulationOutput {
|
|
231
|
+
output_token: StringPubkey;
|
|
232
|
+
amount: bigint;
|
|
233
|
+
report: string[];
|
|
234
|
+
}
|
|
235
|
+
|
|
233
236
|
|
|
234
237
|
/**
|
|
235
238
|
* A Base58-encoded string representing a public key.
|
|
@@ -237,6 +240,26 @@ export interface BuildTransactionOptions {
|
|
|
237
240
|
export type StringPubkey = string;
|
|
238
241
|
|
|
239
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Options for updating [`MarketGraph`] with [`Simulator`].
|
|
245
|
+
*/
|
|
246
|
+
export interface UpdateGraphWithSimulatorOptions {
|
|
247
|
+
/**
|
|
248
|
+
* Whether to update token prices with the simulator.
|
|
249
|
+
*/
|
|
250
|
+
update_token_prices?: boolean | undefined;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Options for creating [`Simulator`].
|
|
255
|
+
*/
|
|
256
|
+
export interface CreateGraphSimulatorOptions {
|
|
257
|
+
/**
|
|
258
|
+
* Market filter.
|
|
259
|
+
*/
|
|
260
|
+
market_filter?: StringPubkey[] | undefined;
|
|
261
|
+
}
|
|
262
|
+
|
|
240
263
|
/**
|
|
241
264
|
* Config for [`MarketGraph`](super::MarketGraph).
|
|
242
265
|
*/
|
|
@@ -679,6 +702,56 @@ export interface CreateGlvDeposit {
|
|
|
679
702
|
skip_glv_token_ata_creation?: boolean;
|
|
680
703
|
}
|
|
681
704
|
|
|
705
|
+
/**
|
|
706
|
+
* Builder for the `create_shift` instruction.
|
|
707
|
+
*/
|
|
708
|
+
export interface CreateShift {
|
|
709
|
+
/**
|
|
710
|
+
* Program.
|
|
711
|
+
*/
|
|
712
|
+
program?: StoreProgram;
|
|
713
|
+
/**
|
|
714
|
+
* Payer (a.k.a. owner).
|
|
715
|
+
*/
|
|
716
|
+
payer: StringPubkey;
|
|
717
|
+
/**
|
|
718
|
+
* Reciever.
|
|
719
|
+
*/
|
|
720
|
+
receiver?: StringPubkey | undefined;
|
|
721
|
+
/**
|
|
722
|
+
* Nonce for the shift.
|
|
723
|
+
*/
|
|
724
|
+
nonce?: NonceBytes | undefined;
|
|
725
|
+
/**
|
|
726
|
+
* The from-market token.
|
|
727
|
+
*/
|
|
728
|
+
from_market_token: StringPubkey;
|
|
729
|
+
/**
|
|
730
|
+
* From-market token account.
|
|
731
|
+
*/
|
|
732
|
+
from_market_token_account?: StringPubkey | undefined;
|
|
733
|
+
/**
|
|
734
|
+
* The to-market token.
|
|
735
|
+
*/
|
|
736
|
+
to_market_token: StringPubkey;
|
|
737
|
+
/**
|
|
738
|
+
* Execution fee paid to the keeper in lamports.
|
|
739
|
+
*/
|
|
740
|
+
execution_lamports?: number;
|
|
741
|
+
/**
|
|
742
|
+
* From-market token amount to pay.
|
|
743
|
+
*/
|
|
744
|
+
from_market_token_amount?: number;
|
|
745
|
+
/**
|
|
746
|
+
* Minimum to-market token amount to receive.
|
|
747
|
+
*/
|
|
748
|
+
min_to_market_token_amount?: number;
|
|
749
|
+
/**
|
|
750
|
+
* Whether to skip the creation of to-market token ATA.
|
|
751
|
+
*/
|
|
752
|
+
skip_to_market_token_ata_creation?: boolean;
|
|
753
|
+
}
|
|
754
|
+
|
|
682
755
|
/**
|
|
683
756
|
* Hint for [`CreateWithdrawal`].
|
|
684
757
|
*/
|
|
@@ -1506,6 +1579,14 @@ export class MarketGraph {
|
|
|
1506
1579
|
* Simulates order execution.
|
|
1507
1580
|
*/
|
|
1508
1581
|
simulate_order(args: SimulateOrderArgs, position?: Position | null): OrderSimulationOutput;
|
|
1582
|
+
/**
|
|
1583
|
+
* Create a simulator.
|
|
1584
|
+
*/
|
|
1585
|
+
to_simulator(options?: CreateGraphSimulatorOptions | null): Simulator;
|
|
1586
|
+
/**
|
|
1587
|
+
* Update with simulator.
|
|
1588
|
+
*/
|
|
1589
|
+
update_with_simulator(simulator: Simulator, options?: UpdateGraphWithSimulatorOptions | null): void;
|
|
1509
1590
|
}
|
|
1510
1591
|
/**
|
|
1511
1592
|
* Wrapper of [`MarketModel`].
|
|
@@ -1548,15 +1629,19 @@ export class OrderSimulationOutput {
|
|
|
1548
1629
|
/**
|
|
1549
1630
|
* Returns increase order simulation output.
|
|
1550
1631
|
*/
|
|
1551
|
-
increase(): IncreaseOrderSimulationOutput | undefined;
|
|
1632
|
+
increase(skip_position?: boolean | null): IncreaseOrderSimulationOutput | undefined;
|
|
1552
1633
|
/**
|
|
1553
1634
|
* Returns decrease order simulation output.
|
|
1554
1635
|
*/
|
|
1555
|
-
decrease(): DecreaseOrderSimulationOutput | undefined;
|
|
1636
|
+
decrease(skip_position?: boolean | null): DecreaseOrderSimulationOutput | undefined;
|
|
1556
1637
|
/**
|
|
1557
1638
|
* Returns swap order simulation output.
|
|
1558
1639
|
*/
|
|
1559
1640
|
swap(): SwapOrderSimulationOutput | undefined;
|
|
1641
|
+
/**
|
|
1642
|
+
* Returns the result position model.
|
|
1643
|
+
*/
|
|
1644
|
+
position_model(): PositionModel | undefined;
|
|
1560
1645
|
}
|
|
1561
1646
|
/**
|
|
1562
1647
|
* The `ElGamalPubkey` type as a `Pod`.
|
|
@@ -1694,6 +1779,26 @@ export class Pubkey {
|
|
|
1694
1779
|
*/
|
|
1695
1780
|
static findProgramAddress(seeds: any[], program_id: Pubkey): any;
|
|
1696
1781
|
}
|
|
1782
|
+
/**
|
|
1783
|
+
* A JS binding for [`Simulator`].
|
|
1784
|
+
*/
|
|
1785
|
+
export class Simulator {
|
|
1786
|
+
private constructor();
|
|
1787
|
+
free(): void;
|
|
1788
|
+
/**
|
|
1789
|
+
* Get market by its market token.
|
|
1790
|
+
*/
|
|
1791
|
+
get_market(market_token: string): MarketModel | undefined;
|
|
1792
|
+
/**
|
|
1793
|
+
* Get price for the given token.
|
|
1794
|
+
*/
|
|
1795
|
+
get_price(token: string): Value | undefined;
|
|
1796
|
+
/**
|
|
1797
|
+
* Upsert the prices for the given token.
|
|
1798
|
+
*/
|
|
1799
|
+
insert_price(token: string, price: Value): void;
|
|
1800
|
+
simulate_order(args: SimulateOrderArgs, position?: Position | null): OrderSimulationOutput;
|
|
1801
|
+
}
|
|
1697
1802
|
/**
|
|
1698
1803
|
* JS version of [`TradeEvent`].
|
|
1699
1804
|
*/
|
package/index_bg.js
CHANGED
|
@@ -949,6 +949,27 @@ export class MarketGraph {
|
|
|
949
949
|
}
|
|
950
950
|
return OrderSimulationOutput.__wrap(ret[0]);
|
|
951
951
|
}
|
|
952
|
+
/**
|
|
953
|
+
* Create a simulator.
|
|
954
|
+
* @param {CreateGraphSimulatorOptions | null} [options]
|
|
955
|
+
* @returns {Simulator}
|
|
956
|
+
*/
|
|
957
|
+
to_simulator(options) {
|
|
958
|
+
const ret = wasm.marketgraph_to_simulator(this.__wbg_ptr, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
959
|
+
return Simulator.__wrap(ret);
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Update with simulator.
|
|
963
|
+
* @param {Simulator} simulator
|
|
964
|
+
* @param {UpdateGraphWithSimulatorOptions | null} [options]
|
|
965
|
+
*/
|
|
966
|
+
update_with_simulator(simulator, options) {
|
|
967
|
+
_assertClass(simulator, Simulator);
|
|
968
|
+
const ret = wasm.marketgraph_update_with_simulator(this.__wbg_ptr, simulator.__wbg_ptr, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
969
|
+
if (ret[1]) {
|
|
970
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
952
973
|
}
|
|
953
974
|
|
|
954
975
|
const MarketModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -1093,10 +1114,11 @@ export class OrderSimulationOutput {
|
|
|
1093
1114
|
}
|
|
1094
1115
|
/**
|
|
1095
1116
|
* Returns increase order simulation output.
|
|
1117
|
+
* @param {boolean | null} [skip_position]
|
|
1096
1118
|
* @returns {IncreaseOrderSimulationOutput | undefined}
|
|
1097
1119
|
*/
|
|
1098
|
-
increase() {
|
|
1099
|
-
const ret = wasm.ordersimulationoutput_increase(this.__wbg_ptr);
|
|
1120
|
+
increase(skip_position) {
|
|
1121
|
+
const ret = wasm.ordersimulationoutput_increase(this.__wbg_ptr, isLikeNone(skip_position) ? 0xFFFFFF : skip_position ? 1 : 0);
|
|
1100
1122
|
if (ret[2]) {
|
|
1101
1123
|
throw takeFromExternrefTable0(ret[1]);
|
|
1102
1124
|
}
|
|
@@ -1104,10 +1126,11 @@ export class OrderSimulationOutput {
|
|
|
1104
1126
|
}
|
|
1105
1127
|
/**
|
|
1106
1128
|
* Returns decrease order simulation output.
|
|
1129
|
+
* @param {boolean | null} [skip_position]
|
|
1107
1130
|
* @returns {DecreaseOrderSimulationOutput | undefined}
|
|
1108
1131
|
*/
|
|
1109
|
-
decrease() {
|
|
1110
|
-
const ret = wasm.ordersimulationoutput_decrease(this.__wbg_ptr);
|
|
1132
|
+
decrease(skip_position) {
|
|
1133
|
+
const ret = wasm.ordersimulationoutput_decrease(this.__wbg_ptr, isLikeNone(skip_position) ? 0xFFFFFF : skip_position ? 1 : 0);
|
|
1111
1134
|
if (ret[2]) {
|
|
1112
1135
|
throw takeFromExternrefTable0(ret[1]);
|
|
1113
1136
|
}
|
|
@@ -1124,6 +1147,14 @@ export class OrderSimulationOutput {
|
|
|
1124
1147
|
}
|
|
1125
1148
|
return takeFromExternrefTable0(ret[0]);
|
|
1126
1149
|
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Returns the result position model.
|
|
1152
|
+
* @returns {PositionModel | undefined}
|
|
1153
|
+
*/
|
|
1154
|
+
position_model() {
|
|
1155
|
+
const ret = wasm.ordersimulationoutput_position_model(this.__wbg_ptr);
|
|
1156
|
+
return ret === 0 ? undefined : PositionModel.__wrap(ret);
|
|
1157
|
+
}
|
|
1127
1158
|
}
|
|
1128
1159
|
|
|
1129
1160
|
const PodElGamalPubkeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -1551,6 +1582,93 @@ export class Pubkey {
|
|
|
1551
1582
|
}
|
|
1552
1583
|
}
|
|
1553
1584
|
|
|
1585
|
+
const SimulatorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1586
|
+
? { register: () => {}, unregister: () => {} }
|
|
1587
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_simulator_free(ptr >>> 0, 1));
|
|
1588
|
+
/**
|
|
1589
|
+
* A JS binding for [`Simulator`].
|
|
1590
|
+
*/
|
|
1591
|
+
export class Simulator {
|
|
1592
|
+
|
|
1593
|
+
static __wrap(ptr) {
|
|
1594
|
+
ptr = ptr >>> 0;
|
|
1595
|
+
const obj = Object.create(Simulator.prototype);
|
|
1596
|
+
obj.__wbg_ptr = ptr;
|
|
1597
|
+
SimulatorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1598
|
+
return obj;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
__destroy_into_raw() {
|
|
1602
|
+
const ptr = this.__wbg_ptr;
|
|
1603
|
+
this.__wbg_ptr = 0;
|
|
1604
|
+
SimulatorFinalization.unregister(this);
|
|
1605
|
+
return ptr;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
free() {
|
|
1609
|
+
const ptr = this.__destroy_into_raw();
|
|
1610
|
+
wasm.__wbg_simulator_free(ptr, 0);
|
|
1611
|
+
}
|
|
1612
|
+
/**
|
|
1613
|
+
* Get market by its market token.
|
|
1614
|
+
* @param {string} market_token
|
|
1615
|
+
* @returns {MarketModel | undefined}
|
|
1616
|
+
*/
|
|
1617
|
+
get_market(market_token) {
|
|
1618
|
+
const ptr0 = passStringToWasm0(market_token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1619
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1620
|
+
const ret = wasm.simulator_get_market(this.__wbg_ptr, ptr0, len0);
|
|
1621
|
+
if (ret[2]) {
|
|
1622
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1623
|
+
}
|
|
1624
|
+
return ret[0] === 0 ? undefined : MarketModel.__wrap(ret[0]);
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Get price for the given token.
|
|
1628
|
+
* @param {string} token
|
|
1629
|
+
* @returns {Value | undefined}
|
|
1630
|
+
*/
|
|
1631
|
+
get_price(token) {
|
|
1632
|
+
const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1633
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1634
|
+
const ret = wasm.simulator_get_price(this.__wbg_ptr, ptr0, len0);
|
|
1635
|
+
if (ret[2]) {
|
|
1636
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1637
|
+
}
|
|
1638
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1639
|
+
}
|
|
1640
|
+
/**
|
|
1641
|
+
* Upsert the prices for the given token.
|
|
1642
|
+
* @param {string} token
|
|
1643
|
+
* @param {Value} price
|
|
1644
|
+
*/
|
|
1645
|
+
insert_price(token, price) {
|
|
1646
|
+
const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1647
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1648
|
+
const ret = wasm.simulator_insert_price(this.__wbg_ptr, ptr0, len0, price);
|
|
1649
|
+
if (ret[1]) {
|
|
1650
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* @param {SimulateOrderArgs} args
|
|
1655
|
+
* @param {Position | null} [position]
|
|
1656
|
+
* @returns {OrderSimulationOutput}
|
|
1657
|
+
*/
|
|
1658
|
+
simulate_order(args, position) {
|
|
1659
|
+
let ptr0 = 0;
|
|
1660
|
+
if (!isLikeNone(position)) {
|
|
1661
|
+
_assertClass(position, Position);
|
|
1662
|
+
ptr0 = position.__destroy_into_raw();
|
|
1663
|
+
}
|
|
1664
|
+
const ret = wasm.simulator_simulate_order(this.__wbg_ptr, args, ptr0);
|
|
1665
|
+
if (ret[2]) {
|
|
1666
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1667
|
+
}
|
|
1668
|
+
return OrderSimulationOutput.__wrap(ret[0]);
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1554
1672
|
const SystemInstructionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1555
1673
|
? { register: () => {}, unregister: () => {} }
|
|
1556
1674
|
: new FinalizationRegistry(ptr => wasm.__wbg_systeminstruction_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.8.0-beta.
|
|
5
|
+
"version": "0.8.0-beta.2",
|
|
6
6
|
"license": "SEE LICENSE IN ../../LICENSE",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|