@crypticdot/defituna-core 3.1.0 → 3.2.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.
@@ -173,22 +173,1428 @@ function debugString(val) {
173
173
  return className;
174
174
  }
175
175
 
176
+ function handleError(f, args) {
177
+ try {
178
+ return f.apply(this, args);
179
+ } catch (e) {
180
+ wasm.__wbindgen_export3(addHeapObject(e));
181
+ }
182
+ }
183
+
176
184
  function getArrayU8FromWasm0(ptr, len) {
177
185
  ptr = ptr >>> 0;
178
186
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
179
187
  }
180
188
 
181
- function dropObject(idx) {
182
- if (idx < 132) return;
183
- heap[idx] = heap_next;
184
- heap_next = idx;
185
- }
189
+ function dropObject(idx) {
190
+ if (idx < 132) return;
191
+ heap[idx] = heap_next;
192
+ heap_next = idx;
193
+ }
194
+
195
+ function takeObject(idx) {
196
+ const ret = getObject(idx);
197
+ dropObject(idx);
198
+ return ret;
199
+ }
200
+ /**
201
+ * Get the first tick index in the tick array that contains the specified tick index.
202
+ *
203
+ * # Parameters
204
+ * - `tick_index` - A i32 integer representing the tick integer
205
+ * - `tick_spacing` - A i32 integer representing the tick spacing
206
+ *
207
+ * # Returns
208
+ * - A i32 integer representing the first tick index in the tick array
209
+ */
210
+ exports.getTickArrayStartTickIndex = function(tick_index, tick_spacing) {
211
+ const ret = wasm.getTickArrayStartTickIndex(tick_index, tick_spacing);
212
+ return ret;
213
+ };
214
+
215
+ /**
216
+ * Derive the sqrt-price from a tick index. The precision of this method is only guarranted
217
+ * if tick is within the bounds of {max, min} tick-index.
218
+ *
219
+ * # Parameters
220
+ * - `tick_index` - A i32 integer representing the tick integer
221
+ *
222
+ * # Returns
223
+ * - `Ok`: A u128 Q32.64 representing the sqrt_price
224
+ */
225
+ exports.tickIndexToSqrtPrice = function(tick_index) {
226
+ const ret = wasm.tickIndexToSqrtPrice(tick_index);
227
+ return takeObject(ret);
228
+ };
229
+
230
+ /**
231
+ * Derive the tick index from a sqrt price. The precision of this method is only guarranted
232
+ * if tick is within the bounds of {max, min} tick-index.
233
+ *
234
+ * # Parameters
235
+ * - `sqrt_price` - A u128 integer representing the sqrt price
236
+ *
237
+ * # Returns
238
+ * - `Ok`: A i32 integer representing the tick integer
239
+ */
240
+ exports.sqrtPriceToTickIndex = function(sqrt_price) {
241
+ const ret = wasm.sqrtPriceToTickIndex(addHeapObject(sqrt_price));
242
+ return ret;
243
+ };
244
+
245
+ /**
246
+ * Get the initializable tick index.
247
+ * If the tick index is already initializable, it is returned as is.
248
+ *
249
+ * # Parameters
250
+ * - `tick_index` - A i32 integer representing the tick integer
251
+ * - `tick_spacing` - A i32 integer representing the tick spacing
252
+ * - `round_up` - A boolean value indicating if the supplied tick index should be rounded up. None will round to the nearest.
253
+ *
254
+ * # Returns
255
+ * - A i32 integer representing the previous initializable tick index
256
+ */
257
+ exports.getInitializableTickIndex = function(tick_index, tick_spacing, round_up) {
258
+ const ret = wasm.getInitializableTickIndex(tick_index, tick_spacing, isLikeNone(round_up) ? 0xFFFFFF : round_up ? 1 : 0);
259
+ return ret;
260
+ };
261
+
262
+ /**
263
+ * Get the previous initializable tick index.
264
+ *
265
+ * # Parameters
266
+ * - `tick_index` - A i32 integer representing the tick integer
267
+ * - `tick_spacing` - A i32 integer representing the tick spacing
268
+ *
269
+ * # Returns
270
+ * - A i32 integer representing the previous initializable tick index
271
+ */
272
+ exports.getPrevInitializableTickIndex = function(tick_index, tick_spacing) {
273
+ const ret = wasm.getPrevInitializableTickIndex(tick_index, tick_spacing);
274
+ return ret;
275
+ };
276
+
277
+ /**
278
+ * Get the next initializable tick index.
279
+ *
280
+ * # Parameters
281
+ * - `tick_index` - A i32 integer representing the tick integer
282
+ * - `tick_spacing` - A i32 integer representing the tick spacing
283
+ *
284
+ * # Returns
285
+ * - A i32 integer representing the next initializable tick index
286
+ */
287
+ exports.getNextInitializableTickIndex = function(tick_index, tick_spacing) {
288
+ const ret = wasm.getNextInitializableTickIndex(tick_index, tick_spacing);
289
+ return ret;
290
+ };
291
+
292
+ /**
293
+ * Check if a tick is in-bounds.
294
+ *
295
+ * # Parameters
296
+ * - `tick_index` - A i32 integer representing the tick integer
297
+ *
298
+ * # Returns
299
+ * - A boolean value indicating if the tick is in-bounds
300
+ */
301
+ exports.isTickIndexInBounds = function(tick_index) {
302
+ const ret = wasm.isTickIndexInBounds(tick_index);
303
+ return ret !== 0;
304
+ };
305
+
306
+ /**
307
+ * Check if a tick is initializable.
308
+ * A tick is initializable if it is divisible by the tick spacing.
309
+ *
310
+ * # Parameters
311
+ * - `tick_index` - A i32 integer representing the tick integer
312
+ * - `tick_spacing` - A i32 integer representing the tick spacing
313
+ *
314
+ * # Returns
315
+ * - A boolean value indicating if the tick is initializable
316
+ */
317
+ exports.isTickInitializable = function(tick_index, tick_spacing) {
318
+ const ret = wasm.isTickInitializable(tick_index, tick_spacing);
319
+ return ret !== 0;
320
+ };
321
+
322
+ /**
323
+ * Get the tick index for the inverse of the price that this tick represents.
324
+ * Eg: Consider tick i where Pb/Pa = 1.0001 ^ i
325
+ * inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i
326
+ *
327
+ * # Parameters
328
+ * - `tick_index` - A i32 integer representing the tick integer
329
+ *
330
+ * # Returns
331
+ * - A i32 integer representing the tick index for the inverse of the price
332
+ */
333
+ exports.invertTickIndex = function(tick_index) {
334
+ const ret = wasm.invertTickIndex(tick_index);
335
+ return ret;
336
+ };
337
+
338
+ /**
339
+ * Get the sqrt price for the inverse of the price that this tick represents.
340
+ * Because converting to a tick index and then back to a sqrt price is lossy,
341
+ * this function is clamped to the nearest tick index.
342
+ *
343
+ * # Parameters
344
+ * - `sqrt_price` - A u128 integer representing the sqrt price
345
+ *
346
+ * # Returns
347
+ * - A u128 integer representing the sqrt price for the inverse of the price
348
+ */
349
+ exports.invertSqrtPrice = function(sqrt_price) {
350
+ const ret = wasm.invertSqrtPrice(addHeapObject(sqrt_price));
351
+ return takeObject(ret);
352
+ };
353
+
354
+ /**
355
+ * Get the minimum and maximum tick index that can be initialized.
356
+ *
357
+ * # Parameters
358
+ * - `tick_spacing` - A i32 integer representing the tick spacing
359
+ *
360
+ * # Returns
361
+ * - A TickRange struct containing the lower and upper tick index
362
+ */
363
+ exports.getFullRangeTickIndexes = function(tick_spacing) {
364
+ const ret = wasm.getFullRangeTickIndexes(tick_spacing);
365
+ return takeObject(ret);
366
+ };
367
+
368
+ /**
369
+ * Order tick indexes in ascending order.
370
+ * If the lower tick index is greater than the upper tick index, the indexes are swapped.
371
+ * This is useful for ensuring that the lower tick index is always less than the upper tick index.
372
+ *
373
+ * # Parameters
374
+ * - `tick_index_1` - A i32 integer representing the first tick index
375
+ * - `tick_index_2` - A i32 integer representing the second tick index
376
+ *
377
+ * # Returns
378
+ * - A TickRange struct containing the lower and upper tick index
379
+ */
380
+ exports.orderTickIndexes = function(tick_index_1, tick_index_2) {
381
+ const ret = wasm.orderTickIndexes(tick_index_1, tick_index_2);
382
+ return takeObject(ret);
383
+ };
384
+
385
+ /**
386
+ * Check if a fusion_pool is a full-range only pool.
387
+ *
388
+ * # Parameters
389
+ * - `tick_spacing` - A u16 integer representing the tick spacing
390
+ *
391
+ * # Returns
392
+ * - A boolean value indicating if the fusion_pool is a full-range only pool
393
+ */
394
+ exports.isFullRangeOnly = function(tick_spacing) {
395
+ const ret = wasm.isFullRangeOnly(tick_spacing);
396
+ return ret !== 0;
397
+ };
398
+
399
+ /**
400
+ * Get the index of a tick in a tick array.
401
+ *
402
+ * # Parameters
403
+ * - `tick_index` - A i32 integer representing the tick index
404
+ * - `tick_array_start_index` - A i32 integer representing the start tick index of the tick array
405
+ * - `tick_spacing` - A u16 integer representing the tick spacing
406
+ *
407
+ * # Returns
408
+ * - A u32 integer representing the tick index in the tick array
409
+ */
410
+ exports.getTickIndexInArray = function(tick_index, tick_array_start_index, tick_spacing) {
411
+ try {
412
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
413
+ wasm.getTickIndexInArray(retptr, tick_index, tick_array_start_index, tick_spacing);
414
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
415
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
416
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
417
+ if (r2) {
418
+ throw takeObject(r1);
419
+ }
420
+ return r0 >>> 0;
421
+ } finally {
422
+ wasm.__wbindgen_add_to_stack_pointer(16);
423
+ }
424
+ };
425
+
426
+ /**
427
+ * Calculate the amount A delta between two sqrt_prices
428
+ *
429
+ * # Parameters
430
+ * - `sqrt_price_1`: The first square root price
431
+ * - `sqrt_price_2`: The second square root price
432
+ * - `liquidity`: The liquidity
433
+ * - `round_up`: Whether to round up or not
434
+ *
435
+ * # Returns
436
+ * - `u64`: The amount delta
437
+ */
438
+ exports.tryGetAmountDeltaA = function(sqrt_price_1, sqrt_price_2, liquidity, round_up) {
439
+ try {
440
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
441
+ wasm.tryGetAmountDeltaA(retptr, addHeapObject(sqrt_price_1), addHeapObject(sqrt_price_2), addHeapObject(liquidity), round_up);
442
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
443
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
444
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
445
+ if (r3) {
446
+ throw takeObject(r2);
447
+ }
448
+ return BigInt.asUintN(64, r0);
449
+ } finally {
450
+ wasm.__wbindgen_add_to_stack_pointer(16);
451
+ }
452
+ };
453
+
454
+ /**
455
+ * Calculate the amount B delta between two sqrt_prices
456
+ *
457
+ * # Parameters
458
+ * - `sqrt_price_1`: The first square root price
459
+ * - `sqrt_price_2`: The second square root price
460
+ * - `liquidity`: The liquidity
461
+ * - `round_up`: Whether to round up or not
462
+ *
463
+ * # Returns
464
+ * - `u64`: The amount delta
465
+ */
466
+ exports.tryGetAmountDeltaB = function(sqrt_price_1, sqrt_price_2, liquidity, round_up) {
467
+ try {
468
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
469
+ wasm.tryGetAmountDeltaB(retptr, addHeapObject(sqrt_price_1), addHeapObject(sqrt_price_2), addHeapObject(liquidity), round_up);
470
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
471
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
472
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
473
+ if (r3) {
474
+ throw takeObject(r2);
475
+ }
476
+ return BigInt.asUintN(64, r0);
477
+ } finally {
478
+ wasm.__wbindgen_add_to_stack_pointer(16);
479
+ }
480
+ };
481
+
482
+ /**
483
+ * Calculate the next square root price
484
+ *
485
+ * # Parameters
486
+ * - `current_sqrt_price`: The current square root price
487
+ * - `current_liquidity`: The current liquidity
488
+ * - `amount`: The amount
489
+ * - `specified_input`: Whether the input is specified
490
+ *
491
+ * # Returns
492
+ * - `u128`: The next square root price
493
+ */
494
+ exports.tryGetNextSqrtPriceFromA = function(current_sqrt_price, current_liquidity, amount, specified_input) {
495
+ try {
496
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
497
+ wasm.tryGetNextSqrtPriceFromA(retptr, addHeapObject(current_sqrt_price), addHeapObject(current_liquidity), amount, specified_input);
498
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
499
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
500
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
501
+ if (r2) {
502
+ throw takeObject(r1);
503
+ }
504
+ return takeObject(r0);
505
+ } finally {
506
+ wasm.__wbindgen_add_to_stack_pointer(16);
507
+ }
508
+ };
509
+
510
+ /**
511
+ * Calculate the next square root price
512
+ *
513
+ * # Parameters
514
+ * - `current_sqrt_price`: The current square root price
515
+ * - `current_liquidity`: The current liquidity
516
+ * - `amount`: The amount
517
+ * - `specified_input`: Whether the input is specified
518
+ *
519
+ * # Returns
520
+ * - `u128`: The next square root price
521
+ */
522
+ exports.tryGetNextSqrtPriceFromB = function(current_sqrt_price, current_liquidity, amount, specified_input) {
523
+ try {
524
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
525
+ wasm.tryGetNextSqrtPriceFromB(retptr, addHeapObject(current_sqrt_price), addHeapObject(current_liquidity), amount, specified_input);
526
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
527
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
528
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
529
+ if (r2) {
530
+ throw takeObject(r1);
531
+ }
532
+ return takeObject(r0);
533
+ } finally {
534
+ wasm.__wbindgen_add_to_stack_pointer(16);
535
+ }
536
+ };
537
+
538
+ /**
539
+ * Apply a transfer fee to an amount
540
+ * e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
541
+ * So the amount after fee will be 9900.
542
+ *
543
+ * # Parameters
544
+ * - `amount`: The amount to apply the fee to
545
+ * - `transfer_fee`: The transfer fee to apply
546
+ *
547
+ * # Returns
548
+ * - `u64`: The amount after the fee has been applied
549
+ */
550
+ exports.tryApplyTransferFee = function(amount, transfer_fee) {
551
+ try {
552
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
553
+ wasm.tryApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
554
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
555
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
556
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
557
+ if (r3) {
558
+ throw takeObject(r2);
559
+ }
560
+ return BigInt.asUintN(64, r0);
561
+ } finally {
562
+ wasm.__wbindgen_add_to_stack_pointer(16);
563
+ }
564
+ };
565
+
566
+ /**
567
+ * Reverse the application of a transfer fee to an amount
568
+ * e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
569
+ * So the amount before fee will be 10000.
570
+ *
571
+ * # Parameters
572
+ * - `amount`: The amount to reverse the fee from
573
+ * - `transfer_fee`: The transfer fee to reverse
574
+ *
575
+ * # Returns
576
+ * - `u64`: The amount before the fee has been applied
577
+ */
578
+ exports.tryReverseApplyTransferFee = function(amount, transfer_fee) {
579
+ try {
580
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
581
+ wasm.tryReverseApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
582
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
583
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
584
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
585
+ if (r3) {
586
+ throw takeObject(r2);
587
+ }
588
+ return BigInt.asUintN(64, r0);
589
+ } finally {
590
+ wasm.__wbindgen_add_to_stack_pointer(16);
591
+ }
592
+ };
593
+
594
+ /**
595
+ * Get the maximum amount with a slippage tolerance
596
+ * e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
597
+ *
598
+ * # Parameters
599
+ * - `amount`: The amount to apply the fee to
600
+ * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
601
+ *
602
+ * # Returns
603
+ * - `u64`: The maximum amount
604
+ */
605
+ exports.tryGetMaxAmountWithSlippageTolerance = function(amount, slippage_tolerance_bps) {
606
+ try {
607
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
608
+ wasm.tryGetMaxAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
609
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
610
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
611
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
612
+ if (r3) {
613
+ throw takeObject(r2);
614
+ }
615
+ return BigInt.asUintN(64, r0);
616
+ } finally {
617
+ wasm.__wbindgen_add_to_stack_pointer(16);
618
+ }
619
+ };
620
+
621
+ /**
622
+ * Get the minimum amount with a slippage tolerance
623
+ * e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
624
+ *
625
+ * # Parameters
626
+ * - `amount`: The amount to apply the fee to
627
+ * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
628
+ *
629
+ * # Returns
630
+ * - `u64`: The minimum amount
631
+ */
632
+ exports.tryGetMinAmountWithSlippageTolerance = function(amount, slippage_tolerance_bps) {
633
+ try {
634
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
635
+ wasm.tryGetMinAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
636
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
637
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
638
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
639
+ if (r3) {
640
+ throw takeObject(r2);
641
+ }
642
+ return BigInt.asUintN(64, r0);
643
+ } finally {
644
+ wasm.__wbindgen_add_to_stack_pointer(16);
645
+ }
646
+ };
647
+
648
+ /**
649
+ * Apply a swap fee to an amount
650
+ * e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
651
+ * So the amount after fee will be 9900.
652
+ *
653
+ * # Parameters
654
+ * - `amount`: The amount to apply the fee to
655
+ * - `fee_rate`: The fee rate to apply denominated in 1e6
656
+ *
657
+ * # Returns
658
+ * - `u64`: The amount after the fee has been applied
659
+ */
660
+ exports.tryApplySwapFee = function(amount, fee_rate) {
661
+ try {
662
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
663
+ wasm.tryApplySwapFee(retptr, amount, fee_rate);
664
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
665
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
666
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
667
+ if (r3) {
668
+ throw takeObject(r2);
669
+ }
670
+ return BigInt.asUintN(64, r0);
671
+ } finally {
672
+ wasm.__wbindgen_add_to_stack_pointer(16);
673
+ }
674
+ };
675
+
676
+ /**
677
+ * Reverse the application of a swap fee to an amount
678
+ * e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
679
+ * So the amount before fee will be 10000.
680
+ *
681
+ * # Parameters
682
+ * - `amount`: The amount to reverse the fee from
683
+ * - `fee_rate`: The fee rate to reverse denominated in 1e6
684
+ *
685
+ * # Returns
686
+ * - `u64`: The amount before the fee has been applied
687
+ */
688
+ exports.tryReverseApplySwapFee = function(amount, fee_rate) {
689
+ try {
690
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
691
+ wasm.tryReverseApplySwapFee(retptr, amount, fee_rate);
692
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
693
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
694
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
695
+ if (r3) {
696
+ throw takeObject(r2);
697
+ }
698
+ return BigInt.asUintN(64, r0);
699
+ } finally {
700
+ wasm.__wbindgen_add_to_stack_pointer(16);
701
+ }
702
+ };
703
+
704
+ /**
705
+ * Computes the limit order output amount by input amount.
706
+ * ### Parameters
707
+ * - `amount_in` - The input token amount of a limit order.
708
+ * - `a_to_b_order` - The limit order direction.
709
+ * - `tick_index` - The tick index of an order.
710
+ * - `fusion_pool` - The fusion_pool state.
711
+ */
712
+ exports.limitOrderQuoteByInputToken = function(amount_in, a_to_b_order, tick_index, fusion_pool) {
713
+ try {
714
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
715
+ wasm.limitOrderQuoteByInputToken(retptr, amount_in, a_to_b_order, tick_index, addHeapObject(fusion_pool));
716
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
717
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
718
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
719
+ if (r3) {
720
+ throw takeObject(r2);
721
+ }
722
+ return BigInt.asUintN(64, r0);
723
+ } finally {
724
+ wasm.__wbindgen_add_to_stack_pointer(16);
725
+ }
726
+ };
727
+
728
+ /**
729
+ * Computes the limit order input amount by output amount.
730
+ * ### Parameters
731
+ * - `amount_out` - The output token amount of a limit order.
732
+ * - `a_to_b_order` - The limit order direction.
733
+ * - `tick_index` - The tick index of an order.
734
+ * - `fusion_pool` - The fusion_pool state.
735
+ */
736
+ exports.limitOrderQuoteByOutputToken = function(amount_out, a_to_b_order, tick_index, fusion_pool) {
737
+ try {
738
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
739
+ wasm.limitOrderQuoteByOutputToken(retptr, amount_out, a_to_b_order, tick_index, addHeapObject(fusion_pool));
740
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
741
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
742
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
743
+ if (r3) {
744
+ throw takeObject(r2);
745
+ }
746
+ return BigInt.asUintN(64, r0);
747
+ } finally {
748
+ wasm.__wbindgen_add_to_stack_pointer(16);
749
+ }
750
+ };
751
+
752
+ /**
753
+ * Computes the limit order reward by input amount.
754
+ * ### Parameters
755
+ * - `amount_out` - The output token amount of a limit order (swap input).
756
+ * - `a_to_b_order` - The limit order direction.
757
+ * - `tick_index` - The tick index of an order.
758
+ * - `fusion_pool` - The fusion_pool state.
759
+ */
760
+ exports.limitOrderRewardByOutputToken = function(amount_out, fee_rate, protocol_fee_rate) {
761
+ try {
762
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
763
+ wasm.limitOrderRewardByOutputToken(retptr, amount_out, fee_rate, protocol_fee_rate);
764
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
765
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
766
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
767
+ if (r3) {
768
+ throw takeObject(r2);
769
+ }
770
+ return BigInt.asUintN(64, r0);
771
+ } finally {
772
+ wasm.__wbindgen_add_to_stack_pointer(16);
773
+ }
774
+ };
775
+
776
+ exports.decreaseLimitOrderQuote = function(fusion_pool, limit_order, tick, amount, transfer_fee_a, transfer_fee_b) {
777
+ try {
778
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
779
+ wasm.decreaseLimitOrderQuote(retptr, addHeapObject(fusion_pool), addHeapObject(limit_order), addHeapObject(tick), amount, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
780
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
781
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
782
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
783
+ if (r2) {
784
+ throw takeObject(r1);
785
+ }
786
+ return takeObject(r0);
787
+ } finally {
788
+ wasm.__wbindgen_add_to_stack_pointer(16);
789
+ }
790
+ };
791
+
792
+ /**
793
+ * Calculate the quote for decreasing liquidity
794
+ *
795
+ * # Parameters
796
+ * - `liquidity_delta` - The amount of liquidity to decrease
797
+ * - `slippage_tolerance` - The slippage tolerance in bps
798
+ * - `current_sqrt_price` - The current sqrt price of the pool
799
+ * - `tick_index_1` - The first tick index of the position
800
+ * - `tick_index_2` - The second tick index of the position
801
+ * - `transfer_fee_a` - The transfer fee for token A in bps
802
+ * - `transfer_fee_b` - The transfer fee for token B in bps
803
+ *
804
+ * # Returns
805
+ * - A DecreaseLiquidityQuote struct containing the estimated token amounts
806
+ */
807
+ exports.decreaseLiquidityQuote = function(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
808
+ try {
809
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
810
+ wasm.decreaseLiquidityQuote(retptr, addHeapObject(liquidity_delta), slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
811
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
812
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
813
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
814
+ if (r2) {
815
+ throw takeObject(r1);
816
+ }
817
+ return takeObject(r0);
818
+ } finally {
819
+ wasm.__wbindgen_add_to_stack_pointer(16);
820
+ }
821
+ };
822
+
823
+ /**
824
+ * Calculate the quote for decreasing liquidity given a token a amount
825
+ *
826
+ * # Parameters
827
+ * - `token_amount_a` - The amount of token a to decrease
828
+ * - `slippage_tolerance` - The slippage tolerance in bps
829
+ * - `current_sqrt_price` - The current sqrt price of the pool
830
+ * - `tick_index_1` - The first tick index of the position
831
+ * - `tick_index_2` - The second tick index of the position
832
+ * - `transfer_fee_a` - The transfer fee for token A in bps
833
+ * - `transfer_fee_b` - The transfer fee for token B in bps
834
+ *
835
+ * # Returns
836
+ * - A DecreaseLiquidityQuote struct containing the estimated token amounts
837
+ */
838
+ exports.decreaseLiquidityQuoteA = function(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
839
+ try {
840
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
841
+ wasm.decreaseLiquidityQuoteA(retptr, token_amount_a, slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
842
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
843
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
844
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
845
+ if (r2) {
846
+ throw takeObject(r1);
847
+ }
848
+ return takeObject(r0);
849
+ } finally {
850
+ wasm.__wbindgen_add_to_stack_pointer(16);
851
+ }
852
+ };
853
+
854
+ /**
855
+ * Calculate the quote for decreasing liquidity given a token b amount
856
+ *
857
+ * # Parameters
858
+ * - `token_amount_b` - The amount of token b to decrease
859
+ * - `slippage_tolerance` - The slippage tolerance in bps
860
+ * - `current_sqrt_price` - The current sqrt price of the pool
861
+ * - `tick_index_1` - The first tick index of the position
862
+ * - `tick_index_2` - The second tick index of the position
863
+ * - `transfer_fee_a` - The transfer fee for token A in bps
864
+ * - `transfer_fee_b` - The transfer fee for token B in bps
865
+ *
866
+ * # Returns
867
+ * - A DecreaseLiquidityQuote struct containing the estimated token amounts
868
+ */
869
+ exports.decreaseLiquidityQuoteB = function(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
870
+ try {
871
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
872
+ wasm.decreaseLiquidityQuoteB(retptr, token_amount_b, slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
873
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
874
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
875
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
876
+ if (r2) {
877
+ throw takeObject(r1);
878
+ }
879
+ return takeObject(r0);
880
+ } finally {
881
+ wasm.__wbindgen_add_to_stack_pointer(16);
882
+ }
883
+ };
884
+
885
+ /**
886
+ * Calculate the quote for increasing liquidity
887
+ *
888
+ * # Parameters
889
+ * - `liquidity_delta` - The amount of liquidity to increase
890
+ * - `slippage_tolerance` - The slippage tolerance in bps
891
+ * - `current_sqrt_price` - The current sqrt price of the pool
892
+ * - `tick_index_1` - The first tick index of the position
893
+ * - `tick_index_2` - The second tick index of the position
894
+ * - `transfer_fee_a` - The transfer fee for token A in bps
895
+ * - `transfer_fee_b` - The transfer fee for token B in bps
896
+ *
897
+ * # Returns
898
+ * - An IncreaseLiquidityQuote struct containing the estimated token amounts
899
+ */
900
+ exports.increaseLiquidityQuote = function(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
901
+ try {
902
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
903
+ wasm.increaseLiquidityQuote(retptr, addHeapObject(liquidity_delta), slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
904
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
905
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
906
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
907
+ if (r2) {
908
+ throw takeObject(r1);
909
+ }
910
+ return takeObject(r0);
911
+ } finally {
912
+ wasm.__wbindgen_add_to_stack_pointer(16);
913
+ }
914
+ };
915
+
916
+ /**
917
+ * Calculate the quote for increasing liquidity given a token a amount
918
+ *
919
+ * # Parameters
920
+ * - `token_amount_a` - The amount of token a to increase
921
+ * - `slippage_tolerance` - The slippage tolerance in bps
922
+ * - `current_sqrt_price` - The current sqrt price of the pool
923
+ * - `tick_index_1` - The first tick index of the position
924
+ * - `tick_index_2` - The second tick index of the position
925
+ * - `transfer_fee_a` - The transfer fee for token A in bps
926
+ * - `transfer_fee_b` - The transfer fee for token B in bps
927
+ *
928
+ * # Returns
929
+ * - An IncreaseLiquidityQuote struct containing the estimated token amounts
930
+ */
931
+ exports.increaseLiquidityQuoteA = function(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
932
+ try {
933
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
934
+ wasm.increaseLiquidityQuoteA(retptr, token_amount_a, slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
935
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
936
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
937
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
938
+ if (r2) {
939
+ throw takeObject(r1);
940
+ }
941
+ return takeObject(r0);
942
+ } finally {
943
+ wasm.__wbindgen_add_to_stack_pointer(16);
944
+ }
945
+ };
946
+
947
+ /**
948
+ * Calculate the quote for increasing liquidity given a token b amount
949
+ *
950
+ * # Parameters
951
+ * - `token_amount_b` - The amount of token b to increase
952
+ * - `slippage_tolerance` - The slippage tolerance in bps
953
+ * - `current_sqrt_price` - The current sqrt price of the pool
954
+ * - `tick_index_1` - The first tick index of the position
955
+ * - `tick_index_2` - The second tick index of the position
956
+ * - `transfer_fee_a` - The transfer fee for token A in bps
957
+ * - `transfer_fee_b` - The transfer fee for token B in bps
958
+ *
959
+ * # Returns
960
+ * - An IncreaseLiquidityQuote struct containing the estimated token amounts
961
+ */
962
+ exports.increaseLiquidityQuoteB = function(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
963
+ try {
964
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
965
+ wasm.increaseLiquidityQuoteB(retptr, token_amount_b, slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
966
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
967
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
968
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
969
+ if (r2) {
970
+ throw takeObject(r1);
971
+ }
972
+ return takeObject(r0);
973
+ } finally {
974
+ wasm.__wbindgen_add_to_stack_pointer(16);
975
+ }
976
+ };
977
+
978
+ exports.tryGetLiquidityFromA = function(token_delta_a, sqrt_price_lower, sqrt_price_upper) {
979
+ try {
980
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
981
+ wasm.tryGetLiquidityFromA(retptr, token_delta_a, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
982
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
983
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
984
+ var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
985
+ var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
986
+ if (r5) {
987
+ throw takeObject(r4);
988
+ }
989
+ return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
990
+ } finally {
991
+ wasm.__wbindgen_add_to_stack_pointer(32);
992
+ }
993
+ };
994
+
995
+ exports.tryGetTokenAFromLiquidity = function(liquidity_delta, sqrt_price_lower, sqrt_price_upper, round_up) {
996
+ try {
997
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
998
+ wasm.tryGetTokenAFromLiquidity(retptr, liquidity_delta, liquidity_delta >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
999
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1000
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1001
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1002
+ if (r3) {
1003
+ throw takeObject(r2);
1004
+ }
1005
+ return BigInt.asUintN(64, r0);
1006
+ } finally {
1007
+ wasm.__wbindgen_add_to_stack_pointer(16);
1008
+ }
1009
+ };
1010
+
1011
+ exports.tryGetLiquidityFromB = function(token_delta_b, sqrt_price_lower, sqrt_price_upper) {
1012
+ try {
1013
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
1014
+ wasm.tryGetLiquidityFromB(retptr, token_delta_b, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
1015
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1016
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
1017
+ var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
1018
+ var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
1019
+ if (r5) {
1020
+ throw takeObject(r4);
1021
+ }
1022
+ return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
1023
+ } finally {
1024
+ wasm.__wbindgen_add_to_stack_pointer(32);
1025
+ }
1026
+ };
1027
+
1028
+ exports.tryGetTokenBFromLiquidity = function(liquidity_delta, sqrt_price_lower, sqrt_price_upper, round_up) {
1029
+ try {
1030
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1031
+ wasm.tryGetTokenBFromLiquidity(retptr, liquidity_delta, liquidity_delta >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
1032
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1033
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1034
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1035
+ if (r3) {
1036
+ throw takeObject(r2);
1037
+ }
1038
+ return BigInt.asUintN(64, r0);
1039
+ } finally {
1040
+ wasm.__wbindgen_add_to_stack_pointer(16);
1041
+ }
1042
+ };
1043
+
1044
+ exports.tryGetTokenEstimatesFromLiquidity = function(liquidity_delta, current_sqrt_price, tick_lower_index, tick_upper_index, round_up) {
1045
+ try {
1046
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1047
+ wasm.tryGetTokenEstimatesFromLiquidity(retptr, liquidity_delta, liquidity_delta >> BigInt(64), current_sqrt_price, current_sqrt_price >> BigInt(64), tick_lower_index, tick_upper_index, round_up);
1048
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1049
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1050
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1051
+ if (r2) {
1052
+ throw takeObject(r1);
1053
+ }
1054
+ return takeObject(r0);
1055
+ } finally {
1056
+ wasm.__wbindgen_add_to_stack_pointer(16);
1057
+ }
1058
+ };
1059
+
1060
+ /**
1061
+ * Calculate fees owed for a position
1062
+ *
1063
+ * # Paramters
1064
+ * - `fusion_pool`: The fusion_pool state
1065
+ * - `position`: The position state
1066
+ * - `tick_lower`: The lower tick state
1067
+ * - `tick_upper`: The upper tick state
1068
+ * - `transfer_fee_a`: The transfer fee for token A
1069
+ * - `transfer_fee_b`: The transfer fee for token B
1070
+ *
1071
+ * # Returns
1072
+ * - `CollectFeesQuote`: The fees owed for token A and token B
1073
+ */
1074
+ exports.collectFeesQuote = function(fusion_pool, position, tick_lower, tick_upper, transfer_fee_a, transfer_fee_b) {
1075
+ try {
1076
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1077
+ wasm.collectFeesQuote(retptr, addHeapObject(fusion_pool), addHeapObject(position), addHeapObject(tick_lower), addHeapObject(tick_upper), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
1078
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1079
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1080
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1081
+ if (r2) {
1082
+ throw takeObject(r1);
1083
+ }
1084
+ return takeObject(r0);
1085
+ } finally {
1086
+ wasm.__wbindgen_add_to_stack_pointer(16);
1087
+ }
1088
+ };
1089
+
1090
+ exports.limitOrderFee = function(fusion_pool) {
1091
+ const ret = wasm.limitOrderFee(addHeapObject(fusion_pool));
1092
+ return ret;
1093
+ };
1094
+
1095
+ exports._TICK_ARRAY_SIZE = function() {
1096
+ const ret = wasm._TICK_ARRAY_SIZE();
1097
+ return ret >>> 0;
1098
+ };
1099
+
1100
+ exports._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD = function() {
1101
+ const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
1102
+ return ret;
1103
+ };
1104
+
1105
+ exports._MIN_TICK_INDEX = function() {
1106
+ const ret = wasm._MIN_TICK_INDEX();
1107
+ return ret;
1108
+ };
1109
+
1110
+ exports._MAX_TICK_INDEX = function() {
1111
+ const ret = wasm._MAX_TICK_INDEX();
1112
+ return ret;
1113
+ };
1114
+
1115
+ /**
1116
+ * Convert a price into a sqrt priceX64
1117
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1118
+ * Make sure to do these operations last and not to use the result for further calculations.
1119
+ *
1120
+ * # Parameters
1121
+ * * `price` - The price to convert
1122
+ * * `decimals_a` - The number of decimals of the base token
1123
+ * * `decimals_b` - The number of decimals of the quote token
1124
+ *
1125
+ * # Returns
1126
+ * * `u128` - The sqrt priceX64
1127
+ */
1128
+ exports.priceToSqrtPrice = function(price, decimals_a, decimals_b) {
1129
+ const ret = wasm.priceToSqrtPrice(price, decimals_a, decimals_b);
1130
+ return takeObject(ret);
1131
+ };
1132
+
1133
+ /**
1134
+ * Convert a sqrt priceX64 into a tick index
1135
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1136
+ * Make sure to do these operations last and not to use the result for further calculations.
1137
+ *
1138
+ * # Parameters
1139
+ * * `sqrt_price` - The sqrt priceX64 to convert
1140
+ * * `decimals_a` - The number of decimals of the base token
1141
+ * * `decimals_b` - The number of decimals of the quote token
1142
+ *
1143
+ * # Returns
1144
+ * * `f64` - The decimal price
1145
+ */
1146
+ exports.sqrtPriceToPrice = function(sqrt_price, decimals_a, decimals_b) {
1147
+ const ret = wasm.sqrtPriceToPrice(addHeapObject(sqrt_price), decimals_a, decimals_b);
1148
+ return ret;
1149
+ };
1150
+
1151
+ /**
1152
+ * Invert a price
1153
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1154
+ * Make sure to do these operations last and not to use the result for further calculations.
1155
+ *
1156
+ * # Parameters
1157
+ * * `price` - The price to invert
1158
+ * * `decimals_a` - The number of decimals of the base token
1159
+ * * `decimals_b` - The number of decimals of the quote token
1160
+ *
1161
+ * # Returns
1162
+ * * `f64` - The inverted price
1163
+ */
1164
+ exports.invertPrice = function(price, decimals_a, decimals_b) {
1165
+ const ret = wasm.invertPrice(price, decimals_a, decimals_b);
1166
+ return ret;
1167
+ };
1168
+
1169
+ /**
1170
+ * Convert a tick index into a price
1171
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1172
+ * Make sure to do these operations last and not to use the result for further calculations.
1173
+ *
1174
+ * # Parameters
1175
+ * * `tick_index` - The tick index to convert
1176
+ * * `decimals_a` - The number of decimals of the base token
1177
+ * * `decimals_b` - The number of decimals of the quote token
1178
+ *
1179
+ * # Returns
1180
+ * * `f64` - The decimal price
1181
+ */
1182
+ exports.tickIndexToPrice = function(tick_index, decimals_a, decimals_b) {
1183
+ const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
1184
+ return ret;
1185
+ };
1186
+
1187
+ /**
1188
+ * Convert a price into a tick index
1189
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1190
+ * Make sure to do these operations last and not to use the result for further calculations.
1191
+ *
1192
+ * # Parameters
1193
+ * * `price` - The price to convert
1194
+ * * `decimals_a` - The number of decimals of the base token
1195
+ * * `decimals_b` - The number of decimals of the quote token
1196
+ *
1197
+ * # Returns
1198
+ * * `i32` - The tick index
1199
+ */
1200
+ exports.priceToTickIndex = function(price, decimals_a, decimals_b) {
1201
+ const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
1202
+ return ret;
1203
+ };
1204
+
1205
+ exports._POSITION_BUNDLE_SIZE = function() {
1206
+ const ret = wasm._POSITION_BUNDLE_SIZE();
1207
+ return ret >>> 0;
1208
+ };
1209
+
1210
+ exports._TICK_ARRAY_NOT_EVENLY_SPACED = function() {
1211
+ try {
1212
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1213
+ wasm._TICK_ARRAY_NOT_EVENLY_SPACED(retptr);
1214
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1215
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1216
+ return getStringFromWasm0(r0, r1);
1217
+ } finally {
1218
+ wasm.__wbindgen_add_to_stack_pointer(16);
1219
+ }
1220
+ };
1221
+
1222
+ exports._TICK_INDEX_OUT_OF_BOUNDS = function() {
1223
+ try {
1224
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1225
+ wasm._TICK_INDEX_OUT_OF_BOUNDS(retptr);
1226
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1227
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1228
+ return getStringFromWasm0(r0, r1);
1229
+ } finally {
1230
+ wasm.__wbindgen_add_to_stack_pointer(16);
1231
+ }
1232
+ };
1233
+
1234
+ exports._INVALID_TICK_INDEX = function() {
1235
+ try {
1236
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1237
+ wasm._INVALID_TICK_INDEX(retptr);
1238
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1239
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1240
+ return getStringFromWasm0(r0, r1);
1241
+ } finally {
1242
+ wasm.__wbindgen_add_to_stack_pointer(16);
1243
+ }
1244
+ };
1245
+
1246
+ exports._ARITHMETIC_OVERFLOW = function() {
1247
+ try {
1248
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1249
+ wasm._ARITHMETIC_OVERFLOW(retptr);
1250
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1251
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1252
+ return getStringFromWasm0(r0, r1);
1253
+ } finally {
1254
+ wasm.__wbindgen_add_to_stack_pointer(16);
1255
+ }
1256
+ };
1257
+
1258
+ exports._AMOUNT_EXCEEDS_MAX_U64 = function() {
1259
+ try {
1260
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1261
+ wasm._AMOUNT_EXCEEDS_MAX_U64(retptr);
1262
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1263
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1264
+ return getStringFromWasm0(r0, r1);
1265
+ } finally {
1266
+ wasm.__wbindgen_add_to_stack_pointer(16);
1267
+ }
1268
+ };
1269
+
1270
+ exports._AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT = function() {
1271
+ try {
1272
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1273
+ wasm._AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT(retptr);
1274
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1275
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1276
+ return getStringFromWasm0(r0, r1);
1277
+ } finally {
1278
+ wasm.__wbindgen_add_to_stack_pointer(16);
1279
+ }
1280
+ };
1281
+
1282
+ exports._SQRT_PRICE_OUT_OF_BOUNDS = function() {
1283
+ try {
1284
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1285
+ wasm._SQRT_PRICE_OUT_OF_BOUNDS(retptr);
1286
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1287
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1288
+ return getStringFromWasm0(r0, r1);
1289
+ } finally {
1290
+ wasm.__wbindgen_add_to_stack_pointer(16);
1291
+ }
1292
+ };
1293
+
1294
+ exports._TICK_SEQUENCE_EMPTY = function() {
1295
+ try {
1296
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1297
+ wasm._TICK_SEQUENCE_EMPTY(retptr);
1298
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1299
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1300
+ return getStringFromWasm0(r0, r1);
1301
+ } finally {
1302
+ wasm.__wbindgen_add_to_stack_pointer(16);
1303
+ }
1304
+ };
1305
+
1306
+ exports._SQRT_PRICE_LIMIT_OUT_OF_BOUNDS = function() {
1307
+ try {
1308
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1309
+ wasm._SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(retptr);
1310
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1311
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1312
+ return getStringFromWasm0(r0, r1);
1313
+ } finally {
1314
+ wasm.__wbindgen_add_to_stack_pointer(16);
1315
+ }
1316
+ };
1317
+
1318
+ exports._INVALID_SQRT_PRICE_LIMIT_DIRECTION = function() {
1319
+ try {
1320
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1321
+ wasm._INVALID_SQRT_PRICE_LIMIT_DIRECTION(retptr);
1322
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1323
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1324
+ return getStringFromWasm0(r0, r1);
1325
+ } finally {
1326
+ wasm.__wbindgen_add_to_stack_pointer(16);
1327
+ }
1328
+ };
1329
+
1330
+ exports._ZERO_TRADABLE_AMOUNT = function() {
1331
+ try {
1332
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1333
+ wasm._ZERO_TRADABLE_AMOUNT(retptr);
1334
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1335
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1336
+ return getStringFromWasm0(r0, r1);
1337
+ } finally {
1338
+ wasm.__wbindgen_add_to_stack_pointer(16);
1339
+ }
1340
+ };
1341
+
1342
+ exports._INVALID_TIMESTAMP = function() {
1343
+ try {
1344
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1345
+ wasm._INVALID_TIMESTAMP(retptr);
1346
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1347
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1348
+ return getStringFromWasm0(r0, r1);
1349
+ } finally {
1350
+ wasm.__wbindgen_add_to_stack_pointer(16);
1351
+ }
1352
+ };
1353
+
1354
+ exports._INVALID_TRANSFER_FEE = function() {
1355
+ try {
1356
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1357
+ wasm._INVALID_TRANSFER_FEE(retptr);
1358
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1359
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1360
+ return getStringFromWasm0(r0, r1);
1361
+ } finally {
1362
+ wasm.__wbindgen_add_to_stack_pointer(16);
1363
+ }
1364
+ };
1365
+
1366
+ exports._INVALID_SLIPPAGE_TOLERANCE = function() {
1367
+ try {
1368
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1369
+ wasm._INVALID_SLIPPAGE_TOLERANCE(retptr);
1370
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1371
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1372
+ return getStringFromWasm0(r0, r1);
1373
+ } finally {
1374
+ wasm.__wbindgen_add_to_stack_pointer(16);
1375
+ }
1376
+ };
1377
+
1378
+ exports._TICK_INDEX_NOT_IN_ARRAY = function() {
1379
+ try {
1380
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1381
+ wasm._TICK_INDEX_NOT_IN_ARRAY(retptr);
1382
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1383
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1384
+ return getStringFromWasm0(r0, r1);
1385
+ } finally {
1386
+ wasm.__wbindgen_add_to_stack_pointer(16);
1387
+ }
1388
+ };
186
1389
 
187
- function takeObject(idx) {
188
- const ret = getObject(idx);
189
- dropObject(idx);
1390
+ exports._INVALID_TICK_ARRAY_SEQUENCE = function() {
1391
+ try {
1392
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1393
+ wasm._INVALID_TICK_ARRAY_SEQUENCE(retptr);
1394
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1395
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1396
+ return getStringFromWasm0(r0, r1);
1397
+ } finally {
1398
+ wasm.__wbindgen_add_to_stack_pointer(16);
1399
+ }
1400
+ };
1401
+
1402
+ exports._LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC = function() {
1403
+ try {
1404
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1405
+ wasm._LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC(retptr);
1406
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1407
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1408
+ return getStringFromWasm0(r0, r1);
1409
+ } finally {
1410
+ wasm.__wbindgen_add_to_stack_pointer(16);
1411
+ }
1412
+ };
1413
+
1414
+ exports._FEE_RATE_MUL_VALUE = function() {
1415
+ const ret = wasm._FEE_RATE_MUL_VALUE();
1416
+ return ret >>> 0;
1417
+ };
1418
+
1419
+ exports._MAX_PROTOCOL_FEE_RATE = function() {
1420
+ const ret = wasm._MAX_PROTOCOL_FEE_RATE();
190
1421
  return ret;
1422
+ };
1423
+
1424
+ exports._PROTOCOL_FEE_RATE_MUL_VALUE = function() {
1425
+ const ret = wasm._PROTOCOL_FEE_RATE_MUL_VALUE();
1426
+ return ret;
1427
+ };
1428
+
1429
+ function passArray8ToWasm0(arg, malloc) {
1430
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1431
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1432
+ WASM_VECTOR_LEN = arg.length;
1433
+ return ptr;
191
1434
  }
1435
+ /**
1436
+ * Get the first unoccupied position in a bundle
1437
+ *
1438
+ * # Arguments
1439
+ * * `bundle` - The bundle to check
1440
+ *
1441
+ * # Returns
1442
+ * * `u32` - The first unoccupied position (None if full)
1443
+ */
1444
+ exports.firstUnoccupiedPositionInBundle = function(bitmap) {
1445
+ const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
1446
+ const len0 = WASM_VECTOR_LEN;
1447
+ const ret = wasm.firstUnoccupiedPositionInBundle(ptr0, len0);
1448
+ return ret === 0x100000001 ? undefined : ret;
1449
+ };
1450
+
1451
+ /**
1452
+ * Check whether a position bundle is full
1453
+ * A position bundle can contain 256 positions
1454
+ *
1455
+ * # Arguments
1456
+ * * `bundle` - The bundle to check
1457
+ *
1458
+ * # Returns
1459
+ * * `bool` - Whether the bundle is full
1460
+ */
1461
+ exports.isPositionBundleFull = function(bitmap) {
1462
+ const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
1463
+ const len0 = WASM_VECTOR_LEN;
1464
+ const ret = wasm.isPositionBundleFull(ptr0, len0);
1465
+ return ret !== 0;
1466
+ };
1467
+
1468
+ /**
1469
+ * Check whether a position bundle is empty
1470
+ *
1471
+ * # Arguments
1472
+ * * `bundle` - The bundle to check
1473
+ *
1474
+ * # Returns
1475
+ * * `bool` - Whether the bundle is empty
1476
+ */
1477
+ exports.isPositionBundleEmpty = function(bitmap) {
1478
+ const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
1479
+ const len0 = WASM_VECTOR_LEN;
1480
+ const ret = wasm.isPositionBundleEmpty(ptr0, len0);
1481
+ return ret !== 0;
1482
+ };
1483
+
1484
+ /**
1485
+ * Check if a position is in range.
1486
+ * When a position is in range it is earning fees and rewards
1487
+ *
1488
+ * # Parameters
1489
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
1490
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
1491
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
1492
+ *
1493
+ * # Returns
1494
+ * - A boolean value indicating if the position is in range
1495
+ */
1496
+ exports.isPositionInRange = function(current_sqrt_price, tick_index_1, tick_index_2) {
1497
+ const ret = wasm.isPositionInRange(addHeapObject(current_sqrt_price), tick_index_1, tick_index_2);
1498
+ return ret !== 0;
1499
+ };
1500
+
1501
+ /**
1502
+ * Calculate the status of a position
1503
+ * The status can be one of three values:
1504
+ * - InRange: The position is in range
1505
+ * - BelowRange: The position is below the range
1506
+ * - AboveRange: The position is above the range
1507
+ *
1508
+ * # Parameters
1509
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
1510
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
1511
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
1512
+ *
1513
+ * # Returns
1514
+ * - A PositionStatus enum value indicating the status of the position
1515
+ */
1516
+ exports.positionStatus = function(current_sqrt_price, tick_index_1, tick_index_2) {
1517
+ const ret = wasm.positionStatus(addHeapObject(current_sqrt_price), tick_index_1, tick_index_2);
1518
+ return takeObject(ret);
1519
+ };
1520
+
1521
+ /**
1522
+ * Calculate the token_a / token_b ratio of a (ficticious) position
1523
+ *
1524
+ * # Parameters
1525
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
1526
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
1527
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
1528
+ *
1529
+ * # Returns
1530
+ * - A PositionRatio struct containing the ratio of token_a and token_b
1531
+ */
1532
+ exports.positionRatioX64 = function(current_sqrt_price, tick_index_1, tick_index_2) {
1533
+ const ret = wasm.positionRatioX64(addHeapObject(current_sqrt_price), tick_index_1, tick_index_2);
1534
+ return takeObject(ret);
1535
+ };
1536
+
1537
+ /**
1538
+ * Computes the exact input or output amount for a swap transaction.
1539
+ *
1540
+ * # Arguments
1541
+ * - `token_in`: The input token amount.
1542
+ * - `specified_token_a`: If `true`, the input token is token A. Otherwise, it is token B.
1543
+ * - `slippage_tolerance`: The slippage tolerance in basis points.
1544
+ * - `fusion_pool`: The fusion_pool state.
1545
+ * - `tick_arrays`: The tick arrays needed for the swap.
1546
+ * - `transfer_fee_a`: The transfer fee for token A.
1547
+ * - `transfer_fee_b`: The transfer fee for token B.
1548
+ *
1549
+ * # Returns
1550
+ * The exact input or output amount for the swap transaction.
1551
+ */
1552
+ exports.swapQuoteByInputToken = function(token_in, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
1553
+ try {
1554
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1555
+ wasm.swapQuoteByInputToken(retptr, token_in, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
1556
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1557
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1558
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1559
+ if (r2) {
1560
+ throw takeObject(r1);
1561
+ }
1562
+ return takeObject(r0);
1563
+ } finally {
1564
+ wasm.__wbindgen_add_to_stack_pointer(16);
1565
+ }
1566
+ };
1567
+
1568
+ /**
1569
+ * Computes the exact input or output amount for a swap transaction.
1570
+ *
1571
+ * # Arguments
1572
+ * - `token_out`: The output token amount.
1573
+ * - `specified_token_a`: If `true`, the output token is token A. Otherwise, it is token B.
1574
+ * - `slippage_tolerance`: The slippage tolerance in basis points.
1575
+ * - `fusion_pool`: The fusion_pool state.
1576
+ * - `tick_arrays`: The tick arrays needed for the swap.
1577
+ * - `transfer_fee_a`: The transfer fee for token A.
1578
+ * - `transfer_fee_b`: The transfer fee for token B.
1579
+ *
1580
+ * # Returns
1581
+ * The exact input or output amount for the swap transaction.
1582
+ */
1583
+ exports.swapQuoteByOutputToken = function(token_out, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
1584
+ try {
1585
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1586
+ wasm.swapQuoteByOutputToken(retptr, token_out, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
1587
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1588
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1589
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1590
+ if (r2) {
1591
+ throw takeObject(r1);
1592
+ }
1593
+ return takeObject(r0);
1594
+ } finally {
1595
+ wasm.__wbindgen_add_to_stack_pointer(16);
1596
+ }
1597
+ };
192
1598
 
193
1599
  exports._INVALID_ARGUMENTS = function() {
194
1600
  try {
@@ -202,6 +1608,73 @@ exports._INVALID_ARGUMENTS = function() {
202
1608
  }
203
1609
  };
204
1610
 
1611
+ /**
1612
+ * Spot position increase quote
1613
+ *
1614
+ * # Parameters
1615
+ * - `increase_amount`: Position total size in the collateral_token.
1616
+ * - `collateral_token`: Collateral token.
1617
+ * - `position_token`: Token of the position.
1618
+ * - `leverage`: Leverage (1.0 or higher).
1619
+ * - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
1620
+ * - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
1621
+ * - `fusion_pool`: Fusion pool.
1622
+ * - `tick_arrays`: Five tick arrays around the current pool price.
1623
+ *
1624
+ * # Returns
1625
+ * - `IncreaseSpotPositionQuoteResult`: quote result
1626
+ */
1627
+ exports.getIncreaseSpotPositionQuote = function(increase_amount, collateral_token, position_token, leverage, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
1628
+ try {
1629
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1630
+ wasm.getIncreaseSpotPositionQuote(retptr, increase_amount, addHeapObject(collateral_token), addHeapObject(position_token), leverage, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
1631
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1632
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1633
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1634
+ if (r2) {
1635
+ throw takeObject(r1);
1636
+ }
1637
+ return takeObject(r0);
1638
+ } finally {
1639
+ wasm.__wbindgen_add_to_stack_pointer(16);
1640
+ }
1641
+ };
1642
+
1643
+ /**
1644
+ * Spot position decrease quote
1645
+ *
1646
+ * # Parameters
1647
+ * - `increase_amount`: Position total size in the collateral_token.
1648
+ * - `collateral_token`: Collateral token.
1649
+ * - `position_token`: Token of the position.
1650
+ * - `leverage`: Leverage (1.0 or higher).
1651
+ * - `position_amount`: Existing position amount in the position_token.
1652
+ * - `position_debt`: Existing position debt in the token opposite to the position_token.
1653
+ * - `reduce_only`: Only allow reducing the existing position.
1654
+ * - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
1655
+ * - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
1656
+ * - `fusion_pool`: Fusion pool.
1657
+ * - `tick_arrays`: Five tick arrays around the current pool price.
1658
+ *
1659
+ * # Returns
1660
+ * - `DecreaseSpotPositionQuoteResult`: quote result
1661
+ */
1662
+ exports.getDecreaseSpotPositionQuote = function(decrease_amount, collateral_token, position_token, leverage, position_amount, position_debt, reduce_only, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
1663
+ try {
1664
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1665
+ wasm.getDecreaseSpotPositionQuote(retptr, decrease_amount, addHeapObject(collateral_token), addHeapObject(position_token), leverage, position_amount, position_debt, reduce_only, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
1666
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1667
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1668
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1669
+ if (r2) {
1670
+ throw takeObject(r1);
1671
+ }
1672
+ return takeObject(r0);
1673
+ } finally {
1674
+ wasm.__wbindgen_add_to_stack_pointer(16);
1675
+ }
1676
+ };
1677
+
205
1678
  /**
206
1679
  * Returns the liquidation price
207
1680
  *
@@ -230,11 +1703,52 @@ exports.getLiquidationPrice = function(position_token, amount, debt, liquidation
230
1703
  }
231
1704
  };
232
1705
 
1706
+ /**
1707
+ * Calculates the maximum tradable amount in the collateral token.
1708
+ *
1709
+ * # Parameters
1710
+ * - `collateral_token`: Collateral token.
1711
+ * - `available_balance`: Available wallet balance in the collateral_token.
1712
+ * - `leverage`: Leverage (1.0 or higher).
1713
+ * - `new_position_token`: Token of the new position.
1714
+ * - `position_token`: Token of the existing position. Should be set to new_position_token if position_amount is zero.
1715
+ * - `position_amount`: Existing position amount in the position_token.
1716
+ * - `position_debt`: Existing position debt in the token opposite to the position_token.
1717
+ * - `reduce_only`: Only allow reducing the existing position.///
1718
+ * - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
1719
+ * - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
1720
+ * - `fusion_pool`: Fusion pool.
1721
+ * - `tick_arrays`: Five tick arrays around the current pool price.
1722
+ *
1723
+ * # Returns
1724
+ * - `u64`: the maximum tradable amount
1725
+ */
1726
+ exports.getTradableAmount = function(collateral_token, available_balance, leverage, new_position_token, position_token, position_amount, position_debt, reduce_only, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
1727
+ try {
1728
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1729
+ wasm.getTradableAmount(retptr, addHeapObject(collateral_token), available_balance, leverage, addHeapObject(new_position_token), addHeapObject(position_token), position_amount, position_debt, reduce_only, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
1730
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1731
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1732
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1733
+ if (r3) {
1734
+ throw takeObject(r2);
1735
+ }
1736
+ return BigInt.asUintN(64, r0);
1737
+ } finally {
1738
+ wasm.__wbindgen_add_to_stack_pointer(16);
1739
+ }
1740
+ };
1741
+
233
1742
  exports.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
234
1743
  const ret = Error(getStringFromWasm0(arg0, arg1));
235
1744
  return addHeapObject(ret);
236
1745
  };
237
1746
 
1747
+ exports.__wbg_Number_bb48ca12f395cd08 = function(arg0) {
1748
+ const ret = Number(getObject(arg0));
1749
+ return ret;
1750
+ };
1751
+
238
1752
  exports.__wbg_String_eecc4a11987127d6 = function(arg0, arg1) {
239
1753
  const ret = String(getObject(arg1));
240
1754
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
@@ -243,6 +1757,13 @@ exports.__wbg_String_eecc4a11987127d6 = function(arg0, arg1) {
243
1757
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
244
1758
  };
245
1759
 
1760
+ exports.__wbg___wbindgen_bigint_get_as_i64_f3ebc5a755000afd = function(arg0, arg1) {
1761
+ const v = getObject(arg1);
1762
+ const ret = typeof(v) === 'bigint' ? v : undefined;
1763
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1764
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1765
+ };
1766
+
246
1767
  exports.__wbg___wbindgen_boolean_get_6d5a1ee65bab5f68 = function(arg0) {
247
1768
  const v = getObject(arg0);
248
1769
  const ret = typeof(v) === 'boolean' ? v : undefined;
@@ -257,6 +1778,21 @@ exports.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
257
1778
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
258
1779
  };
259
1780
 
1781
+ exports.__wbg___wbindgen_in_bb933bd9e1b3bc0f = function(arg0, arg1) {
1782
+ const ret = getObject(arg0) in getObject(arg1);
1783
+ return ret;
1784
+ };
1785
+
1786
+ exports.__wbg___wbindgen_is_bigint_cb320707dcd35f0b = function(arg0) {
1787
+ const ret = typeof(getObject(arg0)) === 'bigint';
1788
+ return ret;
1789
+ };
1790
+
1791
+ exports.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
1792
+ const ret = typeof(getObject(arg0)) === 'function';
1793
+ return ret;
1794
+ };
1795
+
260
1796
  exports.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
261
1797
  const val = getObject(arg0);
262
1798
  const ret = typeof(val) === 'object' && val !== null;
@@ -268,6 +1804,16 @@ exports.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
268
1804
  return ret;
269
1805
  };
270
1806
 
1807
+ exports.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
1808
+ const ret = getObject(arg0) === undefined;
1809
+ return ret;
1810
+ };
1811
+
1812
+ exports.__wbg___wbindgen_jsval_eq_6b13ab83478b1c50 = function(arg0, arg1) {
1813
+ const ret = getObject(arg0) === getObject(arg1);
1814
+ return ret;
1815
+ };
1816
+
271
1817
  exports.__wbg___wbindgen_jsval_loose_eq_b664b38a2f582147 = function(arg0, arg1) {
272
1818
  const ret = getObject(arg0) == getObject(arg1);
273
1819
  return ret;
@@ -280,6 +1826,11 @@ exports.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) {
280
1826
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
281
1827
  };
282
1828
 
1829
+ exports.__wbg___wbindgen_shr_5fb5dd3acf2615de = function(arg0, arg1) {
1830
+ const ret = getObject(arg0) >> getObject(arg1);
1831
+ return addHeapObject(ret);
1832
+ };
1833
+
283
1834
  exports.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) {
284
1835
  const obj = getObject(arg1);
285
1836
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -293,6 +1844,16 @@ exports.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
293
1844
  throw new Error(getStringFromWasm0(arg0, arg1));
294
1845
  };
295
1846
 
1847
+ exports.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
1848
+ const ret = getObject(arg0).call(getObject(arg1));
1849
+ return addHeapObject(ret);
1850
+ }, arguments) };
1851
+
1852
+ exports.__wbg_done_2042aa2670fb1db1 = function(arg0) {
1853
+ const ret = getObject(arg0).done;
1854
+ return ret;
1855
+ };
1856
+
296
1857
  exports.__wbg_entries_e171b586f8f6bdbf = function(arg0) {
297
1858
  const ret = Object.entries(getObject(arg0));
298
1859
  return addHeapObject(ret);
@@ -303,6 +1864,21 @@ exports.__wbg_get_7bed016f185add81 = function(arg0, arg1) {
303
1864
  return addHeapObject(ret);
304
1865
  };
305
1866
 
1867
+ exports.__wbg_get_efcb449f58ec27c2 = function() { return handleError(function (arg0, arg1) {
1868
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
1869
+ return addHeapObject(ret);
1870
+ }, arguments) };
1871
+
1872
+ exports.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
1873
+ const ret = getObject(arg0)[getObject(arg1)];
1874
+ return addHeapObject(ret);
1875
+ };
1876
+
1877
+ exports.__wbg_get_with_ref_key_6550b2c093d2eb18 = function(arg0, arg1) {
1878
+ const ret = getObject(arg0)[getObject(arg1)];
1879
+ return addHeapObject(ret);
1880
+ };
1881
+
306
1882
  exports.__wbg_instanceof_ArrayBuffer_70beb1189ca63b38 = function(arg0) {
307
1883
  let result;
308
1884
  try {
@@ -325,6 +1901,26 @@ exports.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) {
325
1901
  return ret;
326
1902
  };
327
1903
 
1904
+ exports.__wbg_isArray_643fafc484312e19 = function(arg0) {
1905
+ const ret = Array.isArray(getObject(arg0));
1906
+ return ret;
1907
+ };
1908
+
1909
+ exports.__wbg_isArray_96e0af9891d0945d = function(arg0) {
1910
+ const ret = Array.isArray(getObject(arg0));
1911
+ return ret;
1912
+ };
1913
+
1914
+ exports.__wbg_isSafeInteger_d216eda7911dde36 = function(arg0) {
1915
+ const ret = Number.isSafeInteger(getObject(arg0));
1916
+ return ret;
1917
+ };
1918
+
1919
+ exports.__wbg_iterator_e5822695327a3c39 = function() {
1920
+ const ret = Symbol.iterator;
1921
+ return addHeapObject(ret);
1922
+ };
1923
+
328
1924
  exports.__wbg_length_69bca3cb64fc8748 = function(arg0) {
329
1925
  const ret = getObject(arg0).length;
330
1926
  return ret;
@@ -335,21 +1931,69 @@ exports.__wbg_length_cdd215e10d9dd507 = function(arg0) {
335
1931
  return ret;
336
1932
  };
337
1933
 
1934
+ exports.__wbg_new_1acc0b6eea89d040 = function() {
1935
+ const ret = new Object();
1936
+ return addHeapObject(ret);
1937
+ };
1938
+
338
1939
  exports.__wbg_new_5a79be3ab53b8aa5 = function(arg0) {
339
1940
  const ret = new Uint8Array(getObject(arg0));
340
1941
  return addHeapObject(ret);
341
1942
  };
342
1943
 
1944
+ exports.__wbg_next_020810e0ae8ebcb0 = function() { return handleError(function (arg0) {
1945
+ const ret = getObject(arg0).next();
1946
+ return addHeapObject(ret);
1947
+ }, arguments) };
1948
+
1949
+ exports.__wbg_next_2c826fe5dfec6b6a = function(arg0) {
1950
+ const ret = getObject(arg0).next;
1951
+ return addHeapObject(ret);
1952
+ };
1953
+
343
1954
  exports.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
344
1955
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
345
1956
  };
346
1957
 
1958
+ exports.__wbg_set_3807d5f0bfc24aa7 = function(arg0, arg1, arg2) {
1959
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1960
+ };
1961
+
1962
+ exports.__wbg_value_692627309814bb8c = function(arg0) {
1963
+ const ret = getObject(arg0).value;
1964
+ return addHeapObject(ret);
1965
+ };
1966
+
347
1967
  exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
348
1968
  // Cast intrinsic for `Ref(String) -> Externref`.
349
1969
  const ret = getStringFromWasm0(arg0, arg1);
350
1970
  return addHeapObject(ret);
351
1971
  };
352
1972
 
1973
+ exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
1974
+ // Cast intrinsic for `U64 -> Externref`.
1975
+ const ret = BigInt.asUintN(64, arg0);
1976
+ return addHeapObject(ret);
1977
+ };
1978
+
1979
+ exports.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
1980
+ // Cast intrinsic for `I64 -> Externref`.
1981
+ const ret = arg0;
1982
+ return addHeapObject(ret);
1983
+ };
1984
+
1985
+ exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1986
+ // Cast intrinsic for `F64 -> Externref`.
1987
+ const ret = arg0;
1988
+ return addHeapObject(ret);
1989
+ };
1990
+
1991
+ exports.__wbindgen_cast_e7b45dd881f38ce3 = function(arg0, arg1) {
1992
+ // Cast intrinsic for `U128 -> Externref`.
1993
+ const ret = (BigInt.asUintN(64, arg0) | (BigInt.asUintN(64, arg1) << BigInt(64)));
1994
+ return addHeapObject(ret);
1995
+ };
1996
+
353
1997
  exports.__wbindgen_object_clone_ref = function(arg0) {
354
1998
  const ret = getObject(arg0);
355
1999
  return addHeapObject(ret);