@crypticdot/defituna-core 3.4.1 → 3.4.3

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.
@@ -252,448 +252,183 @@ function passArray8ToWasm0(arg, malloc) {
252
252
  WASM_VECTOR_LEN = arg.length;
253
253
  return ptr;
254
254
  }
255
+
256
+ exports._POSITION_BUNDLE_SIZE = function() {
257
+ const ret = wasm._POSITION_BUNDLE_SIZE();
258
+ return ret >>> 0;
259
+ };
260
+
261
+ exports._FEE_RATE_MUL_VALUE = function() {
262
+ const ret = wasm._FEE_RATE_MUL_VALUE();
263
+ return ret >>> 0;
264
+ };
265
+
266
+ exports._MAX_PROTOCOL_FEE_RATE = function() {
267
+ const ret = wasm._MAX_PROTOCOL_FEE_RATE();
268
+ return ret;
269
+ };
270
+
271
+ exports._PROTOCOL_FEE_RATE_MUL_VALUE = function() {
272
+ const ret = wasm._PROTOCOL_FEE_RATE_MUL_VALUE();
273
+ return ret;
274
+ };
275
+
276
+ exports._TICK_ARRAY_SIZE = function() {
277
+ const ret = wasm._TICK_ARRAY_SIZE();
278
+ return ret >>> 0;
279
+ };
280
+
281
+ exports._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD = function() {
282
+ const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
283
+ return ret;
284
+ };
285
+
286
+ exports._MIN_TICK_INDEX = function() {
287
+ const ret = wasm._MIN_TICK_INDEX();
288
+ return ret;
289
+ };
290
+
291
+ exports._MAX_TICK_INDEX = function() {
292
+ const ret = wasm._MAX_TICK_INDEX();
293
+ return ret;
294
+ };
295
+
255
296
  /**
256
- * Calculate the amount A delta between two sqrt_prices
297
+ * Get the first tick index in the tick array that contains the specified tick index.
257
298
  *
258
299
  * # Parameters
259
- * - `sqrt_price_1`: The first square root price
260
- * - `sqrt_price_2`: The second square root price
261
- * - `liquidity`: The liquidity
262
- * - `round_up`: Whether to round up or not
300
+ * - `tick_index` - A i32 integer representing the tick integer
301
+ * - `tick_spacing` - A i32 integer representing the tick spacing
263
302
  *
264
303
  * # Returns
265
- * - `u64`: The amount delta
304
+ * - A i32 integer representing the first tick index in the tick array
266
305
  */
267
- exports.tryGetAmountDeltaA = function(sqrt_price_1, sqrt_price_2, liquidity, round_up) {
268
- try {
269
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
270
- wasm.tryGetAmountDeltaA(retptr, addHeapObject(sqrt_price_1), addHeapObject(sqrt_price_2), addHeapObject(liquidity), round_up);
271
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
272
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
273
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
274
- if (r3) {
275
- throw takeObject(r2);
276
- }
277
- return BigInt.asUintN(64, r0);
278
- } finally {
279
- wasm.__wbindgen_add_to_stack_pointer(16);
280
- }
306
+ exports.getTickArrayStartTickIndex = function(tick_index, tick_spacing) {
307
+ const ret = wasm.getTickArrayStartTickIndex(tick_index, tick_spacing);
308
+ return ret;
281
309
  };
282
310
 
283
311
  /**
284
- * Calculate the amount B delta between two sqrt_prices
312
+ * Derive the sqrt-price from a tick index. The precision of this method is only guarranted
313
+ * if tick is within the bounds of {max, min} tick-index.
285
314
  *
286
315
  * # Parameters
287
- * - `sqrt_price_1`: The first square root price
288
- * - `sqrt_price_2`: The second square root price
289
- * - `liquidity`: The liquidity
290
- * - `round_up`: Whether to round up or not
316
+ * - `tick_index` - A i32 integer representing the tick integer
291
317
  *
292
318
  * # Returns
293
- * - `u64`: The amount delta
319
+ * - `Ok`: A u128 Q32.64 representing the sqrt_price
294
320
  */
295
- exports.tryGetAmountDeltaB = function(sqrt_price_1, sqrt_price_2, liquidity, round_up) {
321
+ exports.tickIndexToSqrtPrice = function(tick_index) {
296
322
  try {
297
323
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
298
- wasm.tryGetAmountDeltaB(retptr, addHeapObject(sqrt_price_1), addHeapObject(sqrt_price_2), addHeapObject(liquidity), round_up);
324
+ wasm.tickIndexToSqrtPrice(retptr, tick_index);
299
325
  var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
300
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
301
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
302
- if (r3) {
303
- throw takeObject(r2);
304
- }
305
- return BigInt.asUintN(64, r0);
326
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
327
+ return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
306
328
  } finally {
307
329
  wasm.__wbindgen_add_to_stack_pointer(16);
308
330
  }
309
331
  };
310
332
 
311
333
  /**
312
- * Calculate the next square root price
334
+ * Derive the tick index from a sqrt price. The precision of this method is only guarranted
335
+ * if tick is within the bounds of {max, min} tick-index.
313
336
  *
314
337
  * # Parameters
315
- * - `current_sqrt_price`: The current square root price
316
- * - `current_liquidity`: The current liquidity
317
- * - `amount`: The amount
318
- * - `specified_input`: Whether the input is specified
338
+ * - `sqrt_price` - A u128 integer representing the sqrt price
319
339
  *
320
340
  * # Returns
321
- * - `u128`: The next square root price
341
+ * - `Ok`: A i32 integer representing the tick integer
322
342
  */
323
- exports.tryGetNextSqrtPriceFromA = function(current_sqrt_price, current_liquidity, amount, specified_input) {
324
- try {
325
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
326
- wasm.tryGetNextSqrtPriceFromA(retptr, addHeapObject(current_sqrt_price), addHeapObject(current_liquidity), amount, specified_input);
327
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
328
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
329
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
330
- if (r2) {
331
- throw takeObject(r1);
332
- }
333
- return takeObject(r0);
334
- } finally {
335
- wasm.__wbindgen_add_to_stack_pointer(16);
336
- }
343
+ exports.sqrtPriceToTickIndex = function(sqrt_price) {
344
+ const ret = wasm.sqrtPriceToTickIndex(sqrt_price, sqrt_price >> BigInt(64));
345
+ return ret;
337
346
  };
338
347
 
339
348
  /**
340
- * Calculate the next square root price
349
+ * Get the initializable tick index.
350
+ * If the tick index is already initializable, it is returned as is.
341
351
  *
342
352
  * # Parameters
343
- * - `current_sqrt_price`: The current square root price
344
- * - `current_liquidity`: The current liquidity
345
- * - `amount`: The amount
346
- * - `specified_input`: Whether the input is specified
353
+ * - `tick_index` - A i32 integer representing the tick integer
354
+ * - `tick_spacing` - A i32 integer representing the tick spacing
355
+ * - `round_up` - A boolean value indicating if the supplied tick index should be rounded up. None will round to the nearest.
347
356
  *
348
357
  * # Returns
349
- * - `u128`: The next square root price
358
+ * - A i32 integer representing the previous initializable tick index
350
359
  */
351
- exports.tryGetNextSqrtPriceFromB = function(current_sqrt_price, current_liquidity, amount, specified_input) {
352
- try {
353
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
354
- wasm.tryGetNextSqrtPriceFromB(retptr, addHeapObject(current_sqrt_price), addHeapObject(current_liquidity), amount, specified_input);
355
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
356
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
357
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
358
- if (r2) {
359
- throw takeObject(r1);
360
- }
361
- return takeObject(r0);
362
- } finally {
363
- wasm.__wbindgen_add_to_stack_pointer(16);
364
- }
360
+ exports.getInitializableTickIndex = function(tick_index, tick_spacing, round_up) {
361
+ const ret = wasm.getInitializableTickIndex(tick_index, tick_spacing, isLikeNone(round_up) ? 0xFFFFFF : round_up ? 1 : 0);
362
+ return ret;
365
363
  };
366
364
 
367
365
  /**
368
- * Apply a transfer fee to an amount
369
- * e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
370
- * So the amount after fee will be 9900.
366
+ * Get the previous initializable tick index.
371
367
  *
372
368
  * # Parameters
373
- * - `amount`: The amount to apply the fee to
374
- * - `transfer_fee`: The transfer fee to apply
369
+ * - `tick_index` - A i32 integer representing the tick integer
370
+ * - `tick_spacing` - A i32 integer representing the tick spacing
375
371
  *
376
372
  * # Returns
377
- * - `u64`: The amount after the fee has been applied
373
+ * - A i32 integer representing the previous initializable tick index
378
374
  */
379
- exports.tryApplyTransferFee = function(amount, transfer_fee) {
380
- try {
381
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
382
- wasm.tryApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
383
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
384
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
385
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
386
- if (r3) {
387
- throw takeObject(r2);
388
- }
389
- return BigInt.asUintN(64, r0);
390
- } finally {
391
- wasm.__wbindgen_add_to_stack_pointer(16);
392
- }
375
+ exports.getPrevInitializableTickIndex = function(tick_index, tick_spacing) {
376
+ const ret = wasm.getPrevInitializableTickIndex(tick_index, tick_spacing);
377
+ return ret;
393
378
  };
394
379
 
395
380
  /**
396
- * Reverse the application of a transfer fee to an amount
397
- * e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
398
- * So the amount before fee will be 10000.
381
+ * Get the next initializable tick index.
399
382
  *
400
383
  * # Parameters
401
- * - `amount`: The amount to reverse the fee from
402
- * - `transfer_fee`: The transfer fee to reverse
384
+ * - `tick_index` - A i32 integer representing the tick integer
385
+ * - `tick_spacing` - A i32 integer representing the tick spacing
403
386
  *
404
387
  * # Returns
405
- * - `u64`: The amount before the fee has been applied
388
+ * - A i32 integer representing the next initializable tick index
406
389
  */
407
- exports.tryReverseApplyTransferFee = function(amount, transfer_fee) {
408
- try {
409
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
410
- wasm.tryReverseApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
411
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
412
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
413
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
414
- if (r3) {
415
- throw takeObject(r2);
416
- }
417
- return BigInt.asUintN(64, r0);
418
- } finally {
419
- wasm.__wbindgen_add_to_stack_pointer(16);
420
- }
390
+ exports.getNextInitializableTickIndex = function(tick_index, tick_spacing) {
391
+ const ret = wasm.getNextInitializableTickIndex(tick_index, tick_spacing);
392
+ return ret;
421
393
  };
422
394
 
423
395
  /**
424
- * Get the maximum amount with a slippage tolerance
425
- * e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
396
+ * Check if a tick is in-bounds.
426
397
  *
427
398
  * # Parameters
428
- * - `amount`: The amount to apply the fee to
429
- * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
399
+ * - `tick_index` - A i32 integer representing the tick integer
430
400
  *
431
401
  * # Returns
432
- * - `u64`: The maximum amount
402
+ * - A boolean value indicating if the tick is in-bounds
433
403
  */
434
- exports.tryGetMaxAmountWithSlippageTolerance = function(amount, slippage_tolerance_bps) {
435
- try {
436
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
437
- wasm.tryGetMaxAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
438
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
439
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
440
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
441
- if (r3) {
442
- throw takeObject(r2);
443
- }
444
- return BigInt.asUintN(64, r0);
445
- } finally {
446
- wasm.__wbindgen_add_to_stack_pointer(16);
447
- }
404
+ exports.isTickIndexInBounds = function(tick_index) {
405
+ const ret = wasm.isTickIndexInBounds(tick_index);
406
+ return ret !== 0;
448
407
  };
449
408
 
450
409
  /**
451
- * Get the minimum amount with a slippage tolerance
452
- * e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
410
+ * Check if a tick is initializable.
411
+ * A tick is initializable if it is divisible by the tick spacing.
453
412
  *
454
413
  * # Parameters
455
- * - `amount`: The amount to apply the fee to
456
- * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
414
+ * - `tick_index` - A i32 integer representing the tick integer
415
+ * - `tick_spacing` - A i32 integer representing the tick spacing
457
416
  *
458
417
  * # Returns
459
- * - `u64`: The minimum amount
418
+ * - A boolean value indicating if the tick is initializable
460
419
  */
461
- exports.tryGetMinAmountWithSlippageTolerance = function(amount, slippage_tolerance_bps) {
462
- try {
463
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
464
- wasm.tryGetMinAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
465
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
466
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
467
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
468
- if (r3) {
469
- throw takeObject(r2);
470
- }
471
- return BigInt.asUintN(64, r0);
472
- } finally {
473
- wasm.__wbindgen_add_to_stack_pointer(16);
474
- }
420
+ exports.isTickInitializable = function(tick_index, tick_spacing) {
421
+ const ret = wasm.isTickInitializable(tick_index, tick_spacing);
422
+ return ret !== 0;
475
423
  };
476
424
 
477
425
  /**
478
- * Apply a swap fee to an amount
479
- * e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
480
- * So the amount after fee will be 9900.
426
+ * Get the tick index for the inverse of the price that this tick represents.
427
+ * Eg: Consider tick i where Pb/Pa = 1.0001 ^ i
428
+ * inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i
481
429
  *
482
430
  * # Parameters
483
- * - `amount`: The amount to apply the fee to
484
- * - `fee_rate`: The fee rate to apply denominated in 1e6
485
- *
486
- * # Returns
487
- * - `u64`: The amount after the fee has been applied
488
- */
489
- exports.tryApplySwapFee = function(amount, fee_rate) {
490
- try {
491
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
492
- wasm.tryApplySwapFee(retptr, amount, fee_rate);
493
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
494
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
495
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
496
- if (r3) {
497
- throw takeObject(r2);
498
- }
499
- return BigInt.asUintN(64, r0);
500
- } finally {
501
- wasm.__wbindgen_add_to_stack_pointer(16);
502
- }
503
- };
504
-
505
- /**
506
- * Reverse the application of a swap fee to an amount
507
- * e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
508
- * So the amount before fee will be 10000.
509
- *
510
- * # Parameters
511
- * - `amount`: The amount to reverse the fee from
512
- * - `fee_rate`: The fee rate to reverse denominated in 1e6
513
- *
514
- * # Returns
515
- * - `u64`: The amount before the fee has been applied
516
- */
517
- exports.tryReverseApplySwapFee = function(amount, fee_rate) {
518
- try {
519
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
520
- wasm.tryReverseApplySwapFee(retptr, amount, fee_rate);
521
- var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
522
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
523
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
524
- if (r3) {
525
- throw takeObject(r2);
526
- }
527
- return BigInt.asUintN(64, r0);
528
- } finally {
529
- wasm.__wbindgen_add_to_stack_pointer(16);
530
- }
531
- };
532
-
533
- exports._FEE_RATE_MUL_VALUE = function() {
534
- const ret = wasm._FEE_RATE_MUL_VALUE();
535
- return ret >>> 0;
536
- };
537
-
538
- exports._MAX_PROTOCOL_FEE_RATE = function() {
539
- const ret = wasm._MAX_PROTOCOL_FEE_RATE();
540
- return ret;
541
- };
542
-
543
- exports._PROTOCOL_FEE_RATE_MUL_VALUE = function() {
544
- const ret = wasm._PROTOCOL_FEE_RATE_MUL_VALUE();
545
- return ret;
546
- };
547
-
548
- exports._TICK_ARRAY_SIZE = function() {
549
- const ret = wasm._TICK_ARRAY_SIZE();
550
- return ret >>> 0;
551
- };
552
-
553
- exports._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD = function() {
554
- const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
555
- return ret;
556
- };
557
-
558
- exports._MIN_TICK_INDEX = function() {
559
- const ret = wasm._MIN_TICK_INDEX();
560
- return ret;
561
- };
562
-
563
- exports._MAX_TICK_INDEX = function() {
564
- const ret = wasm._MAX_TICK_INDEX();
565
- return ret;
566
- };
567
-
568
- /**
569
- * Get the first tick index in the tick array that contains the specified tick index.
570
- *
571
- * # Parameters
572
- * - `tick_index` - A i32 integer representing the tick integer
573
- * - `tick_spacing` - A i32 integer representing the tick spacing
574
- *
575
- * # Returns
576
- * - A i32 integer representing the first tick index in the tick array
577
- */
578
- exports.getTickArrayStartTickIndex = function(tick_index, tick_spacing) {
579
- const ret = wasm.getTickArrayStartTickIndex(tick_index, tick_spacing);
580
- return ret;
581
- };
582
-
583
- /**
584
- * Derive the sqrt-price from a tick index. The precision of this method is only guarranted
585
- * if tick is within the bounds of {max, min} tick-index.
586
- *
587
- * # Parameters
588
- * - `tick_index` - A i32 integer representing the tick integer
589
- *
590
- * # Returns
591
- * - `Ok`: A u128 Q32.64 representing the sqrt_price
592
- */
593
- exports.tickIndexToSqrtPrice = function(tick_index) {
594
- const ret = wasm.tickIndexToSqrtPrice(tick_index);
595
- return takeObject(ret);
596
- };
597
-
598
- /**
599
- * Derive the tick index from a sqrt price. The precision of this method is only guarranted
600
- * if tick is within the bounds of {max, min} tick-index.
601
- *
602
- * # Parameters
603
- * - `sqrt_price` - A u128 integer representing the sqrt price
604
- *
605
- * # Returns
606
- * - `Ok`: A i32 integer representing the tick integer
607
- */
608
- exports.sqrtPriceToTickIndex = function(sqrt_price) {
609
- const ret = wasm.sqrtPriceToTickIndex(addHeapObject(sqrt_price));
610
- return ret;
611
- };
612
-
613
- /**
614
- * Get the initializable tick index.
615
- * If the tick index is already initializable, it is returned as is.
616
- *
617
- * # Parameters
618
- * - `tick_index` - A i32 integer representing the tick integer
619
- * - `tick_spacing` - A i32 integer representing the tick spacing
620
- * - `round_up` - A boolean value indicating if the supplied tick index should be rounded up. None will round to the nearest.
621
- *
622
- * # Returns
623
- * - A i32 integer representing the previous initializable tick index
624
- */
625
- exports.getInitializableTickIndex = function(tick_index, tick_spacing, round_up) {
626
- const ret = wasm.getInitializableTickIndex(tick_index, tick_spacing, isLikeNone(round_up) ? 0xFFFFFF : round_up ? 1 : 0);
627
- return ret;
628
- };
629
-
630
- /**
631
- * Get the previous initializable tick index.
632
- *
633
- * # Parameters
634
- * - `tick_index` - A i32 integer representing the tick integer
635
- * - `tick_spacing` - A i32 integer representing the tick spacing
636
- *
637
- * # Returns
638
- * - A i32 integer representing the previous initializable tick index
639
- */
640
- exports.getPrevInitializableTickIndex = function(tick_index, tick_spacing) {
641
- const ret = wasm.getPrevInitializableTickIndex(tick_index, tick_spacing);
642
- return ret;
643
- };
644
-
645
- /**
646
- * Get the next initializable tick index.
647
- *
648
- * # Parameters
649
- * - `tick_index` - A i32 integer representing the tick integer
650
- * - `tick_spacing` - A i32 integer representing the tick spacing
651
- *
652
- * # Returns
653
- * - A i32 integer representing the next initializable tick index
654
- */
655
- exports.getNextInitializableTickIndex = function(tick_index, tick_spacing) {
656
- const ret = wasm.getNextInitializableTickIndex(tick_index, tick_spacing);
657
- return ret;
658
- };
659
-
660
- /**
661
- * Check if a tick is in-bounds.
662
- *
663
- * # Parameters
664
- * - `tick_index` - A i32 integer representing the tick integer
665
- *
666
- * # Returns
667
- * - A boolean value indicating if the tick is in-bounds
668
- */
669
- exports.isTickIndexInBounds = function(tick_index) {
670
- const ret = wasm.isTickIndexInBounds(tick_index);
671
- return ret !== 0;
672
- };
673
-
674
- /**
675
- * Check if a tick is initializable.
676
- * A tick is initializable if it is divisible by the tick spacing.
677
- *
678
- * # Parameters
679
- * - `tick_index` - A i32 integer representing the tick integer
680
- * - `tick_spacing` - A i32 integer representing the tick spacing
681
- *
682
- * # Returns
683
- * - A boolean value indicating if the tick is initializable
684
- */
685
- exports.isTickInitializable = function(tick_index, tick_spacing) {
686
- const ret = wasm.isTickInitializable(tick_index, tick_spacing);
687
- return ret !== 0;
688
- };
689
-
690
- /**
691
- * Get the tick index for the inverse of the price that this tick represents.
692
- * Eg: Consider tick i where Pb/Pa = 1.0001 ^ i
693
- * inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i
694
- *
695
- * # Parameters
696
- * - `tick_index` - A i32 integer representing the tick integer
431
+ * - `tick_index` - A i32 integer representing the tick integer
697
432
  *
698
433
  * # Returns
699
434
  * - A i32 integer representing the tick index for the inverse of the price
@@ -715,8 +450,15 @@ exports.invertTickIndex = function(tick_index) {
715
450
  * - A u128 integer representing the sqrt price for the inverse of the price
716
451
  */
717
452
  exports.invertSqrtPrice = function(sqrt_price) {
718
- const ret = wasm.invertSqrtPrice(addHeapObject(sqrt_price));
719
- return takeObject(ret);
453
+ try {
454
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
455
+ wasm.invertSqrtPrice(retptr, sqrt_price, sqrt_price >> BigInt(64));
456
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
457
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
458
+ return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
459
+ } finally {
460
+ wasm.__wbindgen_add_to_stack_pointer(16);
461
+ }
720
462
  };
721
463
 
722
464
  /**
@@ -809,7 +551,7 @@ exports.getTickIndexInArray = function(tick_index, tick_array_start_index, tick_
809
551
  exports.decreaseLiquidityQuote = function(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
810
552
  try {
811
553
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
812
- 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));
554
+ wasm.decreaseLiquidityQuote(retptr, liquidity_delta, liquidity_delta >> BigInt(64), slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
813
555
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
814
556
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
815
557
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -840,7 +582,7 @@ exports.decreaseLiquidityQuote = function(liquidity_delta, slippage_tolerance_bp
840
582
  exports.decreaseLiquidityQuoteA = function(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
841
583
  try {
842
584
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
843
- 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));
585
+ wasm.decreaseLiquidityQuoteA(retptr, token_amount_a, slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
844
586
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
845
587
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
846
588
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -871,7 +613,7 @@ exports.decreaseLiquidityQuoteA = function(token_amount_a, slippage_tolerance_bp
871
613
  exports.decreaseLiquidityQuoteB = function(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
872
614
  try {
873
615
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
874
- 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));
616
+ wasm.decreaseLiquidityQuoteB(retptr, token_amount_b, slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
875
617
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
876
618
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
877
619
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -902,7 +644,7 @@ exports.decreaseLiquidityQuoteB = function(token_amount_b, slippage_tolerance_bp
902
644
  exports.increaseLiquidityQuote = function(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
903
645
  try {
904
646
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
905
- 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));
647
+ wasm.increaseLiquidityQuote(retptr, liquidity_delta, liquidity_delta >> BigInt(64), slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
906
648
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
907
649
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
908
650
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -933,7 +675,7 @@ exports.increaseLiquidityQuote = function(liquidity_delta, slippage_tolerance_bp
933
675
  exports.increaseLiquidityQuoteA = function(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
934
676
  try {
935
677
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
936
- 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));
678
+ wasm.increaseLiquidityQuoteA(retptr, token_amount_a, slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
937
679
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
938
680
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
939
681
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -964,7 +706,7 @@ exports.increaseLiquidityQuoteA = function(token_amount_a, slippage_tolerance_bp
964
706
  exports.increaseLiquidityQuoteB = function(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
965
707
  try {
966
708
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
967
- 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));
709
+ wasm.increaseLiquidityQuoteB(retptr, token_amount_b, slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
968
710
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
969
711
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
970
712
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1043,10 +785,10 @@ exports.tryGetTokenBFromLiquidity = function(liquidity_delta, sqrt_price_lower,
1043
785
  }
1044
786
  };
1045
787
 
1046
- exports.tryGetTokenEstimatesFromLiquidity = function(liquidity_delta, current_sqrt_price, tick_lower_index, tick_upper_index, round_up) {
788
+ exports.tryGetAmountsFromLiquidity = function(liquidity_delta, current_sqrt_price, tick_lower_index, tick_upper_index, round_up) {
1047
789
  try {
1048
790
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1049
- 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);
791
+ wasm.tryGetAmountsFromLiquidity(retptr, liquidity_delta, liquidity_delta >> BigInt(64), current_sqrt_price, current_sqrt_price >> BigInt(64), tick_lower_index, tick_upper_index, round_up);
1050
792
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1051
793
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1052
794
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1059,6 +801,23 @@ exports.tryGetTokenEstimatesFromLiquidity = function(liquidity_delta, current_sq
1059
801
  }
1060
802
  };
1061
803
 
804
+ exports.tryGetLiquidityFromAmounts = function(sqrt_price, sqrt_price_a_x64, sqrt_price_b_x64, amount_a, amount_b) {
805
+ try {
806
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
807
+ wasm.tryGetLiquidityFromAmounts(retptr, sqrt_price, sqrt_price >> BigInt(64), sqrt_price_a_x64, sqrt_price_a_x64 >> BigInt(64), sqrt_price_b_x64, sqrt_price_b_x64 >> BigInt(64), amount_a, amount_b);
808
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
809
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
810
+ var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
811
+ var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
812
+ if (r5) {
813
+ throw takeObject(r4);
814
+ }
815
+ return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
816
+ } finally {
817
+ wasm.__wbindgen_add_to_stack_pointer(32);
818
+ }
819
+ };
820
+
1062
821
  /**
1063
822
  * Calculate fees owed for a position
1064
823
  *
@@ -1095,17 +854,21 @@ exports.limitOrderFee = function(fusion_pool) {
1095
854
  };
1096
855
 
1097
856
  /**
1098
- * Computes the limit order output amount by input amount.
1099
- * ### Parameters
1100
- * - `amount_in` - The input token amount of a limit order.
1101
- * - `a_to_b_order` - The limit order direction.
1102
- * - `tick_index` - The tick index of an order.
1103
- * - `fusion_pool` - The fusion_pool state.
857
+ * Calculate the amount A delta between two sqrt_prices
858
+ *
859
+ * # Parameters
860
+ * - `sqrt_price_1`: The first square root price
861
+ * - `sqrt_price_2`: The second square root price
862
+ * - `liquidity`: The liquidity
863
+ * - `round_up`: Whether to round up or not
864
+ *
865
+ * # Returns
866
+ * - `u64`: The amount delta
1104
867
  */
1105
- exports.limitOrderQuoteByInputToken = function(amount_in, a_to_b_order, tick_index, fusion_pool) {
868
+ exports.tryGetAmountDeltaA = function(sqrt_price_1, sqrt_price_2, liquidity, round_up) {
1106
869
  try {
1107
870
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1108
- wasm.limitOrderQuoteByInputToken(retptr, amount_in, a_to_b_order, tick_index, addHeapObject(fusion_pool));
871
+ wasm.tryGetAmountDeltaA(retptr, sqrt_price_1, sqrt_price_1 >> BigInt(64), sqrt_price_2, sqrt_price_2 >> BigInt(64), liquidity, liquidity >> BigInt(64), round_up);
1109
872
  var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1110
873
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1111
874
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
@@ -1119,17 +882,21 @@ exports.limitOrderQuoteByInputToken = function(amount_in, a_to_b_order, tick_ind
1119
882
  };
1120
883
 
1121
884
  /**
1122
- * Computes the limit order input amount by output amount.
1123
- * ### Parameters
1124
- * - `amount_out` - The output token amount of a limit order.
1125
- * - `a_to_b_order` - The limit order direction.
1126
- * - `tick_index` - The tick index of an order.
1127
- * - `fusion_pool` - The fusion_pool state.
885
+ * Calculate the amount B delta between two sqrt_prices
886
+ *
887
+ * # Parameters
888
+ * - `sqrt_price_1`: The first square root price
889
+ * - `sqrt_price_2`: The second square root price
890
+ * - `liquidity`: The liquidity
891
+ * - `round_up`: Whether to round up or not
892
+ *
893
+ * # Returns
894
+ * - `u64`: The amount delta
1128
895
  */
1129
- exports.limitOrderQuoteByOutputToken = function(amount_out, a_to_b_order, tick_index, fusion_pool) {
896
+ exports.tryGetAmountDeltaB = function(sqrt_price_1, sqrt_price_2, liquidity, round_up) {
1130
897
  try {
1131
898
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1132
- wasm.limitOrderQuoteByOutputToken(retptr, amount_out, a_to_b_order, tick_index, addHeapObject(fusion_pool));
899
+ wasm.tryGetAmountDeltaB(retptr, sqrt_price_1, sqrt_price_1 >> BigInt(64), sqrt_price_2, sqrt_price_2 >> BigInt(64), liquidity, liquidity >> BigInt(64), round_up);
1133
900
  var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1134
901
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1135
902
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
@@ -1143,249 +910,312 @@ exports.limitOrderQuoteByOutputToken = function(amount_out, a_to_b_order, tick_i
1143
910
  };
1144
911
 
1145
912
  /**
1146
- * Computes the limit order reward by input amount.
1147
- * ### Parameters
1148
- * - `amount_out` - The output token amount of a limit order (swap input).
1149
- * - `a_to_b_order` - The limit order direction.
1150
- * - `tick_index` - The tick index of an order.
1151
- * - `fusion_pool` - The fusion_pool state.
913
+ * Calculate the next square root price
914
+ *
915
+ * # Parameters
916
+ * - `current_sqrt_price`: The current square root price
917
+ * - `current_liquidity`: The current liquidity
918
+ * - `amount`: The amount
919
+ * - `specified_input`: Whether the input is specified
920
+ *
921
+ * # Returns
922
+ * - `u128`: The next square root price
1152
923
  */
1153
- exports.limitOrderRewardByOutputToken = function(amount_out, fee_rate, protocol_fee_rate) {
924
+ exports.tryGetNextSqrtPriceFromA = function(current_sqrt_price, current_liquidity, amount, specified_input) {
1154
925
  try {
1155
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1156
- wasm.limitOrderRewardByOutputToken(retptr, amount_out, fee_rate, protocol_fee_rate);
926
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
927
+ wasm.tryGetNextSqrtPriceFromA(retptr, current_sqrt_price, current_sqrt_price >> BigInt(64), current_liquidity, current_liquidity >> BigInt(64), amount, specified_input);
1157
928
  var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1158
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1159
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1160
- if (r3) {
1161
- throw takeObject(r2);
929
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
930
+ var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
931
+ var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
932
+ if (r5) {
933
+ throw takeObject(r4);
1162
934
  }
1163
- return BigInt.asUintN(64, r0);
935
+ return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
1164
936
  } finally {
1165
- wasm.__wbindgen_add_to_stack_pointer(16);
937
+ wasm.__wbindgen_add_to_stack_pointer(32);
1166
938
  }
1167
939
  };
1168
940
 
1169
- exports.decreaseLimitOrderQuote = function(fusion_pool, limit_order, tick, amount, transfer_fee_a, transfer_fee_b) {
941
+ /**
942
+ * Calculate the next square root price
943
+ *
944
+ * # Parameters
945
+ * - `current_sqrt_price`: The current square root price
946
+ * - `current_liquidity`: The current liquidity
947
+ * - `amount`: The amount
948
+ * - `specified_input`: Whether the input is specified
949
+ *
950
+ * # Returns
951
+ * - `u128`: The next square root price
952
+ */
953
+ exports.tryGetNextSqrtPriceFromB = function(current_sqrt_price, current_liquidity, amount, specified_input) {
1170
954
  try {
1171
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1172
- 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));
1173
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1174
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1175
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1176
- if (r2) {
1177
- throw takeObject(r1);
955
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
956
+ wasm.tryGetNextSqrtPriceFromB(retptr, current_sqrt_price, current_sqrt_price >> BigInt(64), current_liquidity, current_liquidity >> BigInt(64), amount, specified_input);
957
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
958
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
959
+ var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
960
+ var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
961
+ if (r5) {
962
+ throw takeObject(r4);
1178
963
  }
1179
- return takeObject(r0);
1180
- } finally {
1181
- wasm.__wbindgen_add_to_stack_pointer(16);
1182
- }
1183
- };
1184
-
1185
- exports._POSITION_BUNDLE_SIZE = function() {
1186
- const ret = wasm._POSITION_BUNDLE_SIZE();
1187
- return ret >>> 0;
1188
- };
1189
-
1190
- exports._TICK_ARRAY_NOT_EVENLY_SPACED = function() {
1191
- try {
1192
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1193
- wasm._TICK_ARRAY_NOT_EVENLY_SPACED(retptr);
1194
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1195
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1196
- return getStringFromWasm0(r0, r1);
1197
- } finally {
1198
- wasm.__wbindgen_add_to_stack_pointer(16);
1199
- }
1200
- };
1201
-
1202
- exports._TICK_INDEX_OUT_OF_BOUNDS = function() {
1203
- try {
1204
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1205
- wasm._TICK_INDEX_OUT_OF_BOUNDS(retptr);
1206
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1207
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1208
- return getStringFromWasm0(r0, r1);
1209
- } finally {
1210
- wasm.__wbindgen_add_to_stack_pointer(16);
1211
- }
1212
- };
1213
-
1214
- exports._INVALID_TICK_INDEX = function() {
1215
- try {
1216
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1217
- wasm._INVALID_TICK_INDEX(retptr);
1218
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1219
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1220
- return getStringFromWasm0(r0, r1);
1221
- } finally {
1222
- wasm.__wbindgen_add_to_stack_pointer(16);
1223
- }
1224
- };
1225
-
1226
- exports._ARITHMETIC_OVERFLOW = function() {
1227
- try {
1228
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1229
- wasm._ARITHMETIC_OVERFLOW(retptr);
1230
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1231
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1232
- return getStringFromWasm0(r0, r1);
1233
- } finally {
1234
- wasm.__wbindgen_add_to_stack_pointer(16);
1235
- }
1236
- };
1237
-
1238
- exports._AMOUNT_EXCEEDS_MAX_U64 = function() {
1239
- try {
1240
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1241
- wasm._AMOUNT_EXCEEDS_MAX_U64(retptr);
1242
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1243
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1244
- return getStringFromWasm0(r0, r1);
1245
- } finally {
1246
- wasm.__wbindgen_add_to_stack_pointer(16);
1247
- }
1248
- };
1249
-
1250
- exports._AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT = function() {
1251
- try {
1252
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1253
- wasm._AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT(retptr);
1254
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1255
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1256
- return getStringFromWasm0(r0, r1);
1257
- } finally {
1258
- wasm.__wbindgen_add_to_stack_pointer(16);
1259
- }
1260
- };
1261
-
1262
- exports._SQRT_PRICE_OUT_OF_BOUNDS = function() {
1263
- try {
1264
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1265
- wasm._SQRT_PRICE_OUT_OF_BOUNDS(retptr);
1266
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1267
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1268
- return getStringFromWasm0(r0, r1);
964
+ return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
1269
965
  } finally {
1270
- wasm.__wbindgen_add_to_stack_pointer(16);
966
+ wasm.__wbindgen_add_to_stack_pointer(32);
1271
967
  }
1272
968
  };
1273
969
 
1274
- exports._TICK_SEQUENCE_EMPTY = function() {
970
+ /**
971
+ * Apply a transfer fee to an amount
972
+ * e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
973
+ * So the amount after fee will be 9900.
974
+ *
975
+ * # Parameters
976
+ * - `amount`: The amount to apply the fee to
977
+ * - `transfer_fee`: The transfer fee to apply
978
+ *
979
+ * # Returns
980
+ * - `u64`: The amount after the fee has been applied
981
+ */
982
+ exports.tryApplyTransferFee = function(amount, transfer_fee) {
1275
983
  try {
1276
984
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1277
- wasm._TICK_SEQUENCE_EMPTY(retptr);
1278
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1279
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1280
- return getStringFromWasm0(r0, r1);
985
+ wasm.tryApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
986
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
987
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
988
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
989
+ if (r3) {
990
+ throw takeObject(r2);
991
+ }
992
+ return BigInt.asUintN(64, r0);
1281
993
  } finally {
1282
994
  wasm.__wbindgen_add_to_stack_pointer(16);
1283
995
  }
1284
996
  };
1285
997
 
1286
- exports._SQRT_PRICE_LIMIT_OUT_OF_BOUNDS = function() {
998
+ /**
999
+ * Reverse the application of a transfer fee to an amount
1000
+ * e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
1001
+ * So the amount before fee will be 10000.
1002
+ *
1003
+ * # Parameters
1004
+ * - `amount`: The amount to reverse the fee from
1005
+ * - `transfer_fee`: The transfer fee to reverse
1006
+ *
1007
+ * # Returns
1008
+ * - `u64`: The amount before the fee has been applied
1009
+ */
1010
+ exports.tryReverseApplyTransferFee = function(amount, transfer_fee) {
1287
1011
  try {
1288
1012
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1289
- wasm._SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(retptr);
1290
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1291
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1292
- return getStringFromWasm0(r0, r1);
1013
+ wasm.tryReverseApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
1014
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1015
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1016
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1017
+ if (r3) {
1018
+ throw takeObject(r2);
1019
+ }
1020
+ return BigInt.asUintN(64, r0);
1293
1021
  } finally {
1294
1022
  wasm.__wbindgen_add_to_stack_pointer(16);
1295
1023
  }
1296
1024
  };
1297
1025
 
1298
- exports._INVALID_SQRT_PRICE_LIMIT_DIRECTION = function() {
1026
+ /**
1027
+ * Get the maximum amount with a slippage tolerance
1028
+ * e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
1029
+ *
1030
+ * # Parameters
1031
+ * - `amount`: The amount to apply the fee to
1032
+ * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
1033
+ *
1034
+ * # Returns
1035
+ * - `u64`: The maximum amount
1036
+ */
1037
+ exports.tryGetMaxAmountWithSlippageTolerance = function(amount, slippage_tolerance_bps) {
1299
1038
  try {
1300
1039
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1301
- wasm._INVALID_SQRT_PRICE_LIMIT_DIRECTION(retptr);
1302
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1303
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1304
- return getStringFromWasm0(r0, r1);
1040
+ wasm.tryGetMaxAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
1041
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1042
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1043
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1044
+ if (r3) {
1045
+ throw takeObject(r2);
1046
+ }
1047
+ return BigInt.asUintN(64, r0);
1305
1048
  } finally {
1306
1049
  wasm.__wbindgen_add_to_stack_pointer(16);
1307
1050
  }
1308
1051
  };
1309
1052
 
1310
- exports._ZERO_TRADABLE_AMOUNT = function() {
1053
+ /**
1054
+ * Get the minimum amount with a slippage tolerance
1055
+ * e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
1056
+ *
1057
+ * # Parameters
1058
+ * - `amount`: The amount to apply the fee to
1059
+ * - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
1060
+ *
1061
+ * # Returns
1062
+ * - `u64`: The minimum amount
1063
+ */
1064
+ exports.tryGetMinAmountWithSlippageTolerance = function(amount, slippage_tolerance_bps) {
1311
1065
  try {
1312
1066
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1313
- wasm._ZERO_TRADABLE_AMOUNT(retptr);
1314
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1315
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1316
- return getStringFromWasm0(r0, r1);
1067
+ wasm.tryGetMinAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
1068
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1069
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1070
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1071
+ if (r3) {
1072
+ throw takeObject(r2);
1073
+ }
1074
+ return BigInt.asUintN(64, r0);
1317
1075
  } finally {
1318
1076
  wasm.__wbindgen_add_to_stack_pointer(16);
1319
1077
  }
1320
1078
  };
1321
1079
 
1322
- exports._INVALID_TIMESTAMP = function() {
1080
+ /**
1081
+ * Apply a swap fee to an amount
1082
+ * e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
1083
+ * So the amount after fee will be 9900.
1084
+ *
1085
+ * # Parameters
1086
+ * - `amount`: The amount to apply the fee to
1087
+ * - `fee_rate`: The fee rate to apply denominated in 1e6
1088
+ *
1089
+ * # Returns
1090
+ * - `u64`: The amount after the fee has been applied
1091
+ */
1092
+ exports.tryApplySwapFee = function(amount, fee_rate) {
1323
1093
  try {
1324
1094
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1325
- wasm._INVALID_TIMESTAMP(retptr);
1326
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1327
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1328
- return getStringFromWasm0(r0, r1);
1095
+ wasm.tryApplySwapFee(retptr, amount, fee_rate);
1096
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1097
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1098
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1099
+ if (r3) {
1100
+ throw takeObject(r2);
1101
+ }
1102
+ return BigInt.asUintN(64, r0);
1329
1103
  } finally {
1330
1104
  wasm.__wbindgen_add_to_stack_pointer(16);
1331
1105
  }
1332
1106
  };
1333
1107
 
1334
- exports._INVALID_TRANSFER_FEE = function() {
1108
+ /**
1109
+ * Reverse the application of a swap fee to an amount
1110
+ * e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
1111
+ * So the amount before fee will be 10000.
1112
+ *
1113
+ * # Parameters
1114
+ * - `amount`: The amount to reverse the fee from
1115
+ * - `fee_rate`: The fee rate to reverse denominated in 1e6
1116
+ *
1117
+ * # Returns
1118
+ * - `u64`: The amount before the fee has been applied
1119
+ */
1120
+ exports.tryReverseApplySwapFee = function(amount, fee_rate) {
1335
1121
  try {
1336
1122
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1337
- wasm._INVALID_TRANSFER_FEE(retptr);
1338
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1339
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1340
- return getStringFromWasm0(r0, r1);
1123
+ wasm.tryReverseApplySwapFee(retptr, amount, fee_rate);
1124
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1125
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1126
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1127
+ if (r3) {
1128
+ throw takeObject(r2);
1129
+ }
1130
+ return BigInt.asUintN(64, r0);
1341
1131
  } finally {
1342
1132
  wasm.__wbindgen_add_to_stack_pointer(16);
1343
1133
  }
1344
1134
  };
1345
1135
 
1346
- exports._INVALID_SLIPPAGE_TOLERANCE = function() {
1136
+ /**
1137
+ * Computes the limit order output amount by input amount.
1138
+ * ### Parameters
1139
+ * - `amount_in` - The input token amount of a limit order.
1140
+ * - `a_to_b_order` - The limit order direction.
1141
+ * - `tick_index` - The tick index of an order.
1142
+ * - `fusion_pool` - The fusion_pool state.
1143
+ */
1144
+ exports.limitOrderQuoteByInputToken = function(amount_in, a_to_b_order, tick_index, fusion_pool) {
1347
1145
  try {
1348
1146
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1349
- wasm._INVALID_SLIPPAGE_TOLERANCE(retptr);
1350
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1351
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1352
- return getStringFromWasm0(r0, r1);
1147
+ wasm.limitOrderQuoteByInputToken(retptr, amount_in, a_to_b_order, tick_index, addHeapObject(fusion_pool));
1148
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1149
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1150
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1151
+ if (r3) {
1152
+ throw takeObject(r2);
1153
+ }
1154
+ return BigInt.asUintN(64, r0);
1353
1155
  } finally {
1354
1156
  wasm.__wbindgen_add_to_stack_pointer(16);
1355
1157
  }
1356
1158
  };
1357
1159
 
1358
- exports._TICK_INDEX_NOT_IN_ARRAY = function() {
1160
+ /**
1161
+ * Computes the limit order input amount by output amount.
1162
+ * ### Parameters
1163
+ * - `amount_out` - The output token amount of a limit order.
1164
+ * - `a_to_b_order` - The limit order direction.
1165
+ * - `tick_index` - The tick index of an order.
1166
+ * - `fusion_pool` - The fusion_pool state.
1167
+ */
1168
+ exports.limitOrderQuoteByOutputToken = function(amount_out, a_to_b_order, tick_index, fusion_pool) {
1359
1169
  try {
1360
1170
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1361
- wasm._TICK_INDEX_NOT_IN_ARRAY(retptr);
1362
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1363
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1364
- return getStringFromWasm0(r0, r1);
1171
+ wasm.limitOrderQuoteByOutputToken(retptr, amount_out, a_to_b_order, tick_index, addHeapObject(fusion_pool));
1172
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1173
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1174
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1175
+ if (r3) {
1176
+ throw takeObject(r2);
1177
+ }
1178
+ return BigInt.asUintN(64, r0);
1365
1179
  } finally {
1366
1180
  wasm.__wbindgen_add_to_stack_pointer(16);
1367
1181
  }
1368
1182
  };
1369
1183
 
1370
- exports._INVALID_TICK_ARRAY_SEQUENCE = function() {
1184
+ /**
1185
+ * Computes the limit order reward by input amount.
1186
+ * ### Parameters
1187
+ * - `amount_out` - The output token amount of a limit order (swap input).
1188
+ * - `a_to_b_order` - The limit order direction.
1189
+ * - `tick_index` - The tick index of an order.
1190
+ * - `fusion_pool` - The fusion_pool state.
1191
+ */
1192
+ exports.limitOrderRewardByOutputToken = function(amount_out, fee_rate, protocol_fee_rate) {
1371
1193
  try {
1372
1194
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1373
- wasm._INVALID_TICK_ARRAY_SEQUENCE(retptr);
1374
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1375
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1376
- return getStringFromWasm0(r0, r1);
1195
+ wasm.limitOrderRewardByOutputToken(retptr, amount_out, fee_rate, protocol_fee_rate);
1196
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1197
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1198
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1199
+ if (r3) {
1200
+ throw takeObject(r2);
1201
+ }
1202
+ return BigInt.asUintN(64, r0);
1377
1203
  } finally {
1378
1204
  wasm.__wbindgen_add_to_stack_pointer(16);
1379
1205
  }
1380
1206
  };
1381
1207
 
1382
- exports._LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC = function() {
1208
+ exports.decreaseLimitOrderQuote = function(fusion_pool, limit_order, tick, amount, transfer_fee_a, transfer_fee_b) {
1383
1209
  try {
1384
1210
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1385
- wasm._LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC(retptr);
1211
+ 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));
1386
1212
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1387
1213
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1388
- return getStringFromWasm0(r0, r1);
1214
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1215
+ if (r2) {
1216
+ throw takeObject(r1);
1217
+ }
1218
+ return takeObject(r0);
1389
1219
  } finally {
1390
1220
  wasm.__wbindgen_add_to_stack_pointer(16);
1391
1221
  }
@@ -1453,7 +1283,7 @@ exports.isPositionBundleEmpty = function(bitmap) {
1453
1283
  * - A boolean value indicating if the position is in range
1454
1284
  */
1455
1285
  exports.isPositionInRange = function(current_sqrt_price, tick_index_1, tick_index_2) {
1456
- const ret = wasm.isPositionInRange(addHeapObject(current_sqrt_price), tick_index_1, tick_index_2);
1286
+ const ret = wasm.isPositionInRange(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
1457
1287
  return ret !== 0;
1458
1288
  };
1459
1289
 
@@ -1473,143 +1303,322 @@ exports.isPositionInRange = function(current_sqrt_price, tick_index_1, tick_inde
1473
1303
  * - A PositionStatus enum value indicating the status of the position
1474
1304
  */
1475
1305
  exports.positionStatus = function(current_sqrt_price, tick_index_1, tick_index_2) {
1476
- const ret = wasm.positionStatus(addHeapObject(current_sqrt_price), tick_index_1, tick_index_2);
1306
+ const ret = wasm.positionStatus(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
1477
1307
  return takeObject(ret);
1478
1308
  };
1479
1309
 
1480
- /**
1481
- * Calculate the token_a / token_b ratio of a (ficticious) position
1482
- *
1483
- * # Parameters
1484
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
1485
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
1486
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
1487
- *
1488
- * # Returns
1489
- * - A PositionRatio struct containing the ratio of token_a and token_b
1490
- */
1491
- exports.positionRatioX64 = function(current_sqrt_price, tick_index_1, tick_index_2) {
1492
- const ret = wasm.positionRatioX64(addHeapObject(current_sqrt_price), tick_index_1, tick_index_2);
1493
- return takeObject(ret);
1310
+ /**
1311
+ * Calculate the token_a / token_b ratio of a (ficticious) position
1312
+ *
1313
+ * # Parameters
1314
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
1315
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
1316
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
1317
+ *
1318
+ * # Returns
1319
+ * - A PositionRatio struct containing the ratio of token_a and token_b
1320
+ */
1321
+ exports.positionRatioX64 = function(current_sqrt_price, tick_index_1, tick_index_2) {
1322
+ const ret = wasm.positionRatioX64(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
1323
+ return takeObject(ret);
1324
+ };
1325
+
1326
+ /**
1327
+ * Convert a price into a sqrt priceX64
1328
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1329
+ * Make sure to do these operations last and not to use the result for further calculations.
1330
+ *
1331
+ * # Parameters
1332
+ * * `price` - The price to convert
1333
+ * * `decimals_a` - The number of decimals of the base token
1334
+ * * `decimals_b` - The number of decimals of the quote token
1335
+ *
1336
+ * # Returns
1337
+ * * `u128` - The sqrt priceX64
1338
+ */
1339
+ exports.priceToSqrtPrice = function(price, decimals_a, decimals_b) {
1340
+ try {
1341
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1342
+ wasm.priceToSqrtPrice(retptr, price, decimals_a, decimals_b);
1343
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
1344
+ var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
1345
+ return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
1346
+ } finally {
1347
+ wasm.__wbindgen_add_to_stack_pointer(16);
1348
+ }
1349
+ };
1350
+
1351
+ /**
1352
+ * Convert a sqrt priceX64 into a tick index
1353
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1354
+ * Make sure to do these operations last and not to use the result for further calculations.
1355
+ *
1356
+ * # Parameters
1357
+ * * `sqrt_price` - The sqrt priceX64 to convert
1358
+ * * `decimals_a` - The number of decimals of the base token
1359
+ * * `decimals_b` - The number of decimals of the quote token
1360
+ *
1361
+ * # Returns
1362
+ * * `f64` - The decimal price
1363
+ */
1364
+ exports.sqrtPriceToPrice = function(sqrt_price, decimals_a, decimals_b) {
1365
+ const ret = wasm.sqrtPriceToPrice(sqrt_price, sqrt_price >> BigInt(64), decimals_a, decimals_b);
1366
+ return ret;
1367
+ };
1368
+
1369
+ /**
1370
+ * Invert a price
1371
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1372
+ * Make sure to do these operations last and not to use the result for further calculations.
1373
+ *
1374
+ * # Parameters
1375
+ * * `price` - The price to invert
1376
+ * * `decimals_a` - The number of decimals of the base token
1377
+ * * `decimals_b` - The number of decimals of the quote token
1378
+ *
1379
+ * # Returns
1380
+ * * `f64` - The inverted price
1381
+ */
1382
+ exports.invertPrice = function(price, decimals_a, decimals_b) {
1383
+ const ret = wasm.invertPrice(price, decimals_a, decimals_b);
1384
+ return ret;
1385
+ };
1386
+
1387
+ /**
1388
+ * Convert a tick index into a price
1389
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1390
+ * Make sure to do these operations last and not to use the result for further calculations.
1391
+ *
1392
+ * # Parameters
1393
+ * * `tick_index` - The tick index to convert
1394
+ * * `decimals_a` - The number of decimals of the base token
1395
+ * * `decimals_b` - The number of decimals of the quote token
1396
+ *
1397
+ * # Returns
1398
+ * * `f64` - The decimal price
1399
+ */
1400
+ exports.tickIndexToPrice = function(tick_index, decimals_a, decimals_b) {
1401
+ const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
1402
+ return ret;
1403
+ };
1404
+
1405
+ /**
1406
+ * Convert a price into a tick index
1407
+ * IMPORTANT: floating point operations can reduce the precision of the result.
1408
+ * Make sure to do these operations last and not to use the result for further calculations.
1409
+ *
1410
+ * # Parameters
1411
+ * * `price` - The price to convert
1412
+ * * `decimals_a` - The number of decimals of the base token
1413
+ * * `decimals_b` - The number of decimals of the quote token
1414
+ *
1415
+ * # Returns
1416
+ * * `i32` - The tick index
1417
+ */
1418
+ exports.priceToTickIndex = function(price, decimals_a, decimals_b) {
1419
+ const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
1420
+ return ret;
1421
+ };
1422
+
1423
+ exports._TICK_ARRAY_NOT_EVENLY_SPACED = function() {
1424
+ try {
1425
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1426
+ wasm._TICK_ARRAY_NOT_EVENLY_SPACED(retptr);
1427
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1428
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1429
+ return getStringFromWasm0(r0, r1);
1430
+ } finally {
1431
+ wasm.__wbindgen_add_to_stack_pointer(16);
1432
+ }
1433
+ };
1434
+
1435
+ exports._TICK_INDEX_OUT_OF_BOUNDS = function() {
1436
+ try {
1437
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1438
+ wasm._TICK_INDEX_OUT_OF_BOUNDS(retptr);
1439
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1440
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1441
+ return getStringFromWasm0(r0, r1);
1442
+ } finally {
1443
+ wasm.__wbindgen_add_to_stack_pointer(16);
1444
+ }
1445
+ };
1446
+
1447
+ exports._INVALID_TICK_INDEX = function() {
1448
+ try {
1449
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1450
+ wasm._INVALID_TICK_INDEX(retptr);
1451
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1452
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1453
+ return getStringFromWasm0(r0, r1);
1454
+ } finally {
1455
+ wasm.__wbindgen_add_to_stack_pointer(16);
1456
+ }
1457
+ };
1458
+
1459
+ exports._ARITHMETIC_OVERFLOW = function() {
1460
+ try {
1461
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1462
+ wasm._ARITHMETIC_OVERFLOW(retptr);
1463
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1464
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1465
+ return getStringFromWasm0(r0, r1);
1466
+ } finally {
1467
+ wasm.__wbindgen_add_to_stack_pointer(16);
1468
+ }
1469
+ };
1470
+
1471
+ exports._AMOUNT_EXCEEDS_MAX_U64 = function() {
1472
+ try {
1473
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1474
+ wasm._AMOUNT_EXCEEDS_MAX_U64(retptr);
1475
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1476
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1477
+ return getStringFromWasm0(r0, r1);
1478
+ } finally {
1479
+ wasm.__wbindgen_add_to_stack_pointer(16);
1480
+ }
1481
+ };
1482
+
1483
+ exports._AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT = function() {
1484
+ try {
1485
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1486
+ wasm._AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT(retptr);
1487
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1488
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1489
+ return getStringFromWasm0(r0, r1);
1490
+ } finally {
1491
+ wasm.__wbindgen_add_to_stack_pointer(16);
1492
+ }
1493
+ };
1494
+
1495
+ exports._SQRT_PRICE_OUT_OF_BOUNDS = function() {
1496
+ try {
1497
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1498
+ wasm._SQRT_PRICE_OUT_OF_BOUNDS(retptr);
1499
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1500
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1501
+ return getStringFromWasm0(r0, r1);
1502
+ } finally {
1503
+ wasm.__wbindgen_add_to_stack_pointer(16);
1504
+ }
1505
+ };
1506
+
1507
+ exports._TICK_SEQUENCE_EMPTY = function() {
1508
+ try {
1509
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1510
+ wasm._TICK_SEQUENCE_EMPTY(retptr);
1511
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1512
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1513
+ return getStringFromWasm0(r0, r1);
1514
+ } finally {
1515
+ wasm.__wbindgen_add_to_stack_pointer(16);
1516
+ }
1517
+ };
1518
+
1519
+ exports._SQRT_PRICE_LIMIT_OUT_OF_BOUNDS = function() {
1520
+ try {
1521
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1522
+ wasm._SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(retptr);
1523
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1524
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1525
+ return getStringFromWasm0(r0, r1);
1526
+ } finally {
1527
+ wasm.__wbindgen_add_to_stack_pointer(16);
1528
+ }
1529
+ };
1530
+
1531
+ exports._INVALID_SQRT_PRICE_LIMIT_DIRECTION = function() {
1532
+ try {
1533
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1534
+ wasm._INVALID_SQRT_PRICE_LIMIT_DIRECTION(retptr);
1535
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1536
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1537
+ return getStringFromWasm0(r0, r1);
1538
+ } finally {
1539
+ wasm.__wbindgen_add_to_stack_pointer(16);
1540
+ }
1494
1541
  };
1495
1542
 
1496
- /**
1497
- * Convert a price into a sqrt priceX64
1498
- * IMPORTANT: floating point operations can reduce the precision of the result.
1499
- * Make sure to do these operations last and not to use the result for further calculations.
1500
- *
1501
- * # Parameters
1502
- * * `price` - The price to convert
1503
- * * `decimals_a` - The number of decimals of the base token
1504
- * * `decimals_b` - The number of decimals of the quote token
1505
- *
1506
- * # Returns
1507
- * * `u128` - The sqrt priceX64
1508
- */
1509
- exports.priceToSqrtPrice = function(price, decimals_a, decimals_b) {
1510
- const ret = wasm.priceToSqrtPrice(price, decimals_a, decimals_b);
1511
- return takeObject(ret);
1543
+ exports._ZERO_TRADABLE_AMOUNT = function() {
1544
+ try {
1545
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1546
+ wasm._ZERO_TRADABLE_AMOUNT(retptr);
1547
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1548
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1549
+ return getStringFromWasm0(r0, r1);
1550
+ } finally {
1551
+ wasm.__wbindgen_add_to_stack_pointer(16);
1552
+ }
1512
1553
  };
1513
1554
 
1514
- /**
1515
- * Convert a sqrt priceX64 into a tick index
1516
- * IMPORTANT: floating point operations can reduce the precision of the result.
1517
- * Make sure to do these operations last and not to use the result for further calculations.
1518
- *
1519
- * # Parameters
1520
- * * `sqrt_price` - The sqrt priceX64 to convert
1521
- * * `decimals_a` - The number of decimals of the base token
1522
- * * `decimals_b` - The number of decimals of the quote token
1523
- *
1524
- * # Returns
1525
- * * `f64` - The decimal price
1526
- */
1527
- exports.sqrtPriceToPrice = function(sqrt_price, decimals_a, decimals_b) {
1528
- const ret = wasm.sqrtPriceToPrice(addHeapObject(sqrt_price), decimals_a, decimals_b);
1529
- return ret;
1555
+ exports._INVALID_TIMESTAMP = function() {
1556
+ try {
1557
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1558
+ wasm._INVALID_TIMESTAMP(retptr);
1559
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1560
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1561
+ return getStringFromWasm0(r0, r1);
1562
+ } finally {
1563
+ wasm.__wbindgen_add_to_stack_pointer(16);
1564
+ }
1530
1565
  };
1531
1566
 
1532
- /**
1533
- * Invert a price
1534
- * IMPORTANT: floating point operations can reduce the precision of the result.
1535
- * Make sure to do these operations last and not to use the result for further calculations.
1536
- *
1537
- * # Parameters
1538
- * * `price` - The price to invert
1539
- * * `decimals_a` - The number of decimals of the base token
1540
- * * `decimals_b` - The number of decimals of the quote token
1541
- *
1542
- * # Returns
1543
- * * `f64` - The inverted price
1544
- */
1545
- exports.invertPrice = function(price, decimals_a, decimals_b) {
1546
- const ret = wasm.invertPrice(price, decimals_a, decimals_b);
1547
- return ret;
1567
+ exports._INVALID_TRANSFER_FEE = function() {
1568
+ try {
1569
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1570
+ wasm._INVALID_TRANSFER_FEE(retptr);
1571
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1572
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1573
+ return getStringFromWasm0(r0, r1);
1574
+ } finally {
1575
+ wasm.__wbindgen_add_to_stack_pointer(16);
1576
+ }
1548
1577
  };
1549
1578
 
1550
- /**
1551
- * Convert a tick index into a price
1552
- * IMPORTANT: floating point operations can reduce the precision of the result.
1553
- * Make sure to do these operations last and not to use the result for further calculations.
1554
- *
1555
- * # Parameters
1556
- * * `tick_index` - The tick index to convert
1557
- * * `decimals_a` - The number of decimals of the base token
1558
- * * `decimals_b` - The number of decimals of the quote token
1559
- *
1560
- * # Returns
1561
- * * `f64` - The decimal price
1562
- */
1563
- exports.tickIndexToPrice = function(tick_index, decimals_a, decimals_b) {
1564
- const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
1565
- return ret;
1579
+ exports._INVALID_SLIPPAGE_TOLERANCE = function() {
1580
+ try {
1581
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1582
+ wasm._INVALID_SLIPPAGE_TOLERANCE(retptr);
1583
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1584
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1585
+ return getStringFromWasm0(r0, r1);
1586
+ } finally {
1587
+ wasm.__wbindgen_add_to_stack_pointer(16);
1588
+ }
1566
1589
  };
1567
1590
 
1568
- /**
1569
- * Convert a price into a tick index
1570
- * IMPORTANT: floating point operations can reduce the precision of the result.
1571
- * Make sure to do these operations last and not to use the result for further calculations.
1572
- *
1573
- * # Parameters
1574
- * * `price` - The price to convert
1575
- * * `decimals_a` - The number of decimals of the base token
1576
- * * `decimals_b` - The number of decimals of the quote token
1577
- *
1578
- * # Returns
1579
- * * `i32` - The tick index
1580
- */
1581
- exports.priceToTickIndex = function(price, decimals_a, decimals_b) {
1582
- const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
1583
- return ret;
1591
+ exports._TICK_INDEX_NOT_IN_ARRAY = function() {
1592
+ try {
1593
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1594
+ wasm._TICK_INDEX_NOT_IN_ARRAY(retptr);
1595
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1596
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1597
+ return getStringFromWasm0(r0, r1);
1598
+ } finally {
1599
+ wasm.__wbindgen_add_to_stack_pointer(16);
1600
+ }
1584
1601
  };
1585
1602
 
1586
- /**
1587
- * Computes the liquidation prices for an existing position.
1588
- *
1589
- * # Parameters
1590
- * - `lower_tick_index`: The lower tick index of the position.
1591
- * - `upper_tick_index`: The upper tick index of the position.
1592
- * - `leftovers_a`: The amount of leftovers A in the position.
1593
- * - `leftovers_a`: The amount of leftovers B in the position.
1594
- * - `liquidity`: Liquidity of the position.
1595
- * - `debt_a`: The amount of tokens A borrowed.
1596
- * - `debt_b`: The amount of tokens B borrowed.
1597
- * - `liquidation_threshold`: The liquidation threshold of the market.
1598
- *
1599
- * # Returns
1600
- * - `LiquidationPrices`: An object containing lower/upper liquidation prices.
1601
- */
1602
- exports.getLpPositionLiquidationPrices = function(lower_tick_index, upper_tick_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
1603
+ exports._INVALID_TICK_ARRAY_SEQUENCE = function() {
1603
1604
  try {
1604
1605
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1605
- wasm.getLpPositionLiquidationPrices(retptr, lower_tick_index, upper_tick_index, addHeapObject(liquidity), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
1606
+ wasm._INVALID_TICK_ARRAY_SEQUENCE(retptr);
1606
1607
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1607
1608
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1608
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1609
- if (r2) {
1610
- throw takeObject(r1);
1611
- }
1612
- return takeObject(r0);
1609
+ return getStringFromWasm0(r0, r1);
1610
+ } finally {
1611
+ wasm.__wbindgen_add_to_stack_pointer(16);
1612
+ }
1613
+ };
1614
+
1615
+ exports._LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC = function() {
1616
+ try {
1617
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1618
+ wasm._LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC(retptr);
1619
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1620
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1621
+ return getStringFromWasm0(r0, r1);
1613
1622
  } finally {
1614
1623
  wasm.__wbindgen_add_to_stack_pointer(16);
1615
1624
  }
@@ -1677,6 +1686,64 @@ exports.swapQuoteByOutputToken = function(token_out, specified_token_a, slippage
1677
1686
  }
1678
1687
  };
1679
1688
 
1689
+ /**
1690
+ * Computes the liquidation prices for an existing position.
1691
+ *
1692
+ * # Parameters
1693
+ * - `tick_lower_index`: The lower tick index of the position.
1694
+ * - `tick_upper_index`: The upper tick index of the position.
1695
+ * - `leftovers_a`: The amount of leftovers A in the position.
1696
+ * - `leftovers_a`: The amount of leftovers B in the position.
1697
+ * - `liquidity`: Liquidity of the position.
1698
+ * - `debt_a`: The amount of tokens A borrowed.
1699
+ * - `debt_b`: The amount of tokens B borrowed.
1700
+ * - `liquidation_threshold`: The liquidation threshold of the market.
1701
+ *
1702
+ * # Returns
1703
+ * - `LiquidationPrices`: An object containing lower/upper liquidation prices.
1704
+ */
1705
+ exports.getLpPositionLiquidationPrices = function(tick_lower_index, tick_upper_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
1706
+ try {
1707
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1708
+ wasm.getLpPositionLiquidationPrices(retptr, tick_lower_index, tick_upper_index, liquidity, liquidity >> BigInt(64), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
1709
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1710
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1711
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1712
+ if (r2) {
1713
+ throw takeObject(r1);
1714
+ }
1715
+ return takeObject(r0);
1716
+ } finally {
1717
+ wasm.__wbindgen_add_to_stack_pointer(16);
1718
+ }
1719
+ };
1720
+
1721
+ exports.getIncreaseLpPositionQuote = function(args) {
1722
+ try {
1723
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1724
+ wasm.getIncreaseLpPositionQuote(retptr, addHeapObject(args));
1725
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1726
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1727
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1728
+ if (r2) {
1729
+ throw takeObject(r1);
1730
+ }
1731
+ return takeObject(r0);
1732
+ } finally {
1733
+ wasm.__wbindgen_add_to_stack_pointer(16);
1734
+ }
1735
+ };
1736
+
1737
+ exports._HUNDRED_PERCENT = function() {
1738
+ const ret = wasm._HUNDRED_PERCENT();
1739
+ return ret >>> 0;
1740
+ };
1741
+
1742
+ exports._COMPUTED_AMOUNT = function() {
1743
+ const ret = wasm._COMPUTED_AMOUNT();
1744
+ return BigInt.asUintN(64, ret);
1745
+ };
1746
+
1680
1747
  /**
1681
1748
  * Spot position increase quote
1682
1749
  *
@@ -1797,6 +1864,11 @@ exports.calculateTunaSpotPositionProtocolFee = function(collateral_token, borrow
1797
1864
  return takeObject(ret);
1798
1865
  };
1799
1866
 
1867
+ exports.calculateTunaProtocolFee = function(collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate) {
1868
+ const ret = wasm.calculateTunaProtocolFee(collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate);
1869
+ return BigInt.asUintN(64, ret);
1870
+ };
1871
+
1800
1872
  exports._INVALID_ARGUMENTS = function() {
1801
1873
  try {
1802
1874
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
@@ -1840,12 +1912,12 @@ exports.solana_program_init = function() {
1840
1912
  wasm.solana_program_init();
1841
1913
  };
1842
1914
 
1843
- function __wasm_bindgen_func_elem_3356(arg0, arg1, arg2) {
1844
- wasm.__wasm_bindgen_func_elem_3356(arg0, arg1, addHeapObject(arg2));
1915
+ function __wasm_bindgen_func_elem_2634(arg0, arg1, arg2) {
1916
+ wasm.__wasm_bindgen_func_elem_2634(arg0, arg1, addHeapObject(arg2));
1845
1917
  }
1846
1918
 
1847
- function __wasm_bindgen_func_elem_3164(arg0, arg1) {
1848
- wasm.__wasm_bindgen_func_elem_3164(arg0, arg1);
1919
+ function __wasm_bindgen_func_elem_3207(arg0, arg1) {
1920
+ wasm.__wasm_bindgen_func_elem_3207(arg0, arg1);
1849
1921
  }
1850
1922
 
1851
1923
  function __wasm_bindgen_func_elem_495(arg0, arg1, arg2, arg3) {
@@ -3272,27 +3344,27 @@ exports.__wbg_warn_1d74dddbe2fd1dbb = function(arg0) {
3272
3344
  console.warn(getObject(arg0));
3273
3345
  };
3274
3346
 
3275
- exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
3276
- // Cast intrinsic for `Ref(String) -> Externref`.
3277
- const ret = getStringFromWasm0(arg0, arg1);
3347
+ exports.__wbindgen_cast_0660a350899916ec = function(arg0, arg1) {
3348
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 360, function: Function { arguments: [], shim_idx: 361, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3349
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3203, __wasm_bindgen_func_elem_3207);
3278
3350
  return addHeapObject(ret);
3279
3351
  };
3280
3352
 
3281
- exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
3282
- // Cast intrinsic for `U64 -> Externref`.
3283
- const ret = BigInt.asUintN(64, arg0);
3353
+ exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
3354
+ // Cast intrinsic for `Ref(String) -> Externref`.
3355
+ const ret = getStringFromWasm0(arg0, arg1);
3284
3356
  return addHeapObject(ret);
3285
3357
  };
3286
3358
 
3287
- exports.__wbindgen_cast_4765ab8ace056f92 = function(arg0, arg1) {
3288
- // Cast intrinsic for `Closure(Closure { dtor_idx: 386, function: Function { arguments: [Externref], shim_idx: 381, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3289
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3375, __wasm_bindgen_func_elem_3356);
3359
+ exports.__wbindgen_cast_2e5f7f1574aa20c6 = function(arg0, arg1) {
3360
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 232, function: Function { arguments: [Externref], shim_idx: 227, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3361
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_2653, __wasm_bindgen_func_elem_2634);
3290
3362
  return addHeapObject(ret);
3291
3363
  };
3292
3364
 
3293
- exports.__wbindgen_cast_7727c787a531a20f = function(arg0, arg1) {
3294
- // Cast intrinsic for `Closure(Closure { dtor_idx: 347, function: Function { arguments: [], shim_idx: 348, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3295
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3160, __wasm_bindgen_func_elem_3164);
3365
+ exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
3366
+ // Cast intrinsic for `U64 -> Externref`.
3367
+ const ret = BigInt.asUintN(64, arg0);
3296
3368
  return addHeapObject(ret);
3297
3369
  };
3298
3370