@crypticdot/defituna-core 3.3.6 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/defituna_core_js_bindings.d.ts +333 -311
- package/dist/browser/defituna_core_js_bindings_bg.js +520 -488
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +40 -39
- package/dist/nodejs/defituna_core_js_bindings.d.ts +333 -311
- package/dist/nodejs/defituna_core_js_bindings.js +520 -488
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +40 -39
- package/package.json +2 -2
|
@@ -262,232 +262,6 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
262
262
|
WASM_VECTOR_LEN = arg.length;
|
|
263
263
|
return ptr;
|
|
264
264
|
}
|
|
265
|
-
/**
|
|
266
|
-
* Get the first tick index in the tick array that contains the specified tick index.
|
|
267
|
-
*
|
|
268
|
-
* # Parameters
|
|
269
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
270
|
-
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
271
|
-
*
|
|
272
|
-
* # Returns
|
|
273
|
-
* - A i32 integer representing the first tick index in the tick array
|
|
274
|
-
*/
|
|
275
|
-
export function getTickArrayStartTickIndex(tick_index, tick_spacing) {
|
|
276
|
-
const ret = wasm.getTickArrayStartTickIndex(tick_index, tick_spacing);
|
|
277
|
-
return ret;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Derive the sqrt-price from a tick index. The precision of this method is only guarranted
|
|
282
|
-
* if tick is within the bounds of {max, min} tick-index.
|
|
283
|
-
*
|
|
284
|
-
* # Parameters
|
|
285
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
286
|
-
*
|
|
287
|
-
* # Returns
|
|
288
|
-
* - `Ok`: A u128 Q32.64 representing the sqrt_price
|
|
289
|
-
*/
|
|
290
|
-
export function tickIndexToSqrtPrice(tick_index) {
|
|
291
|
-
const ret = wasm.tickIndexToSqrtPrice(tick_index);
|
|
292
|
-
return takeObject(ret);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Derive the tick index from a sqrt price. The precision of this method is only guarranted
|
|
297
|
-
* if tick is within the bounds of {max, min} tick-index.
|
|
298
|
-
*
|
|
299
|
-
* # Parameters
|
|
300
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price
|
|
301
|
-
*
|
|
302
|
-
* # Returns
|
|
303
|
-
* - `Ok`: A i32 integer representing the tick integer
|
|
304
|
-
*/
|
|
305
|
-
export function sqrtPriceToTickIndex(sqrt_price) {
|
|
306
|
-
const ret = wasm.sqrtPriceToTickIndex(addHeapObject(sqrt_price));
|
|
307
|
-
return ret;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Get the initializable tick index.
|
|
312
|
-
* If the tick index is already initializable, it is returned as is.
|
|
313
|
-
*
|
|
314
|
-
* # Parameters
|
|
315
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
316
|
-
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
317
|
-
* - `round_up` - A boolean value indicating if the supplied tick index should be rounded up. None will round to the nearest.
|
|
318
|
-
*
|
|
319
|
-
* # Returns
|
|
320
|
-
* - A i32 integer representing the previous initializable tick index
|
|
321
|
-
*/
|
|
322
|
-
export function getInitializableTickIndex(tick_index, tick_spacing, round_up) {
|
|
323
|
-
const ret = wasm.getInitializableTickIndex(tick_index, tick_spacing, isLikeNone(round_up) ? 0xFFFFFF : round_up ? 1 : 0);
|
|
324
|
-
return ret;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Get the previous initializable tick index.
|
|
329
|
-
*
|
|
330
|
-
* # Parameters
|
|
331
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
332
|
-
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
333
|
-
*
|
|
334
|
-
* # Returns
|
|
335
|
-
* - A i32 integer representing the previous initializable tick index
|
|
336
|
-
*/
|
|
337
|
-
export function getPrevInitializableTickIndex(tick_index, tick_spacing) {
|
|
338
|
-
const ret = wasm.getPrevInitializableTickIndex(tick_index, tick_spacing);
|
|
339
|
-
return ret;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Get the next initializable tick index.
|
|
344
|
-
*
|
|
345
|
-
* # Parameters
|
|
346
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
347
|
-
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
348
|
-
*
|
|
349
|
-
* # Returns
|
|
350
|
-
* - A i32 integer representing the next initializable tick index
|
|
351
|
-
*/
|
|
352
|
-
export function getNextInitializableTickIndex(tick_index, tick_spacing) {
|
|
353
|
-
const ret = wasm.getNextInitializableTickIndex(tick_index, tick_spacing);
|
|
354
|
-
return ret;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Check if a tick is in-bounds.
|
|
359
|
-
*
|
|
360
|
-
* # Parameters
|
|
361
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
362
|
-
*
|
|
363
|
-
* # Returns
|
|
364
|
-
* - A boolean value indicating if the tick is in-bounds
|
|
365
|
-
*/
|
|
366
|
-
export function isTickIndexInBounds(tick_index) {
|
|
367
|
-
const ret = wasm.isTickIndexInBounds(tick_index);
|
|
368
|
-
return ret !== 0;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Check if a tick is initializable.
|
|
373
|
-
* A tick is initializable if it is divisible by the tick spacing.
|
|
374
|
-
*
|
|
375
|
-
* # Parameters
|
|
376
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
377
|
-
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
378
|
-
*
|
|
379
|
-
* # Returns
|
|
380
|
-
* - A boolean value indicating if the tick is initializable
|
|
381
|
-
*/
|
|
382
|
-
export function isTickInitializable(tick_index, tick_spacing) {
|
|
383
|
-
const ret = wasm.isTickInitializable(tick_index, tick_spacing);
|
|
384
|
-
return ret !== 0;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Get the tick index for the inverse of the price that this tick represents.
|
|
389
|
-
* Eg: Consider tick i where Pb/Pa = 1.0001 ^ i
|
|
390
|
-
* inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i
|
|
391
|
-
*
|
|
392
|
-
* # Parameters
|
|
393
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
394
|
-
*
|
|
395
|
-
* # Returns
|
|
396
|
-
* - A i32 integer representing the tick index for the inverse of the price
|
|
397
|
-
*/
|
|
398
|
-
export function invertTickIndex(tick_index) {
|
|
399
|
-
const ret = wasm.invertTickIndex(tick_index);
|
|
400
|
-
return ret;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Get the sqrt price for the inverse of the price that this tick represents.
|
|
405
|
-
* Because converting to a tick index and then back to a sqrt price is lossy,
|
|
406
|
-
* this function is clamped to the nearest tick index.
|
|
407
|
-
*
|
|
408
|
-
* # Parameters
|
|
409
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price
|
|
410
|
-
*
|
|
411
|
-
* # Returns
|
|
412
|
-
* - A u128 integer representing the sqrt price for the inverse of the price
|
|
413
|
-
*/
|
|
414
|
-
export function invertSqrtPrice(sqrt_price) {
|
|
415
|
-
const ret = wasm.invertSqrtPrice(addHeapObject(sqrt_price));
|
|
416
|
-
return takeObject(ret);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Get the minimum and maximum tick index that can be initialized.
|
|
421
|
-
*
|
|
422
|
-
* # Parameters
|
|
423
|
-
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
424
|
-
*
|
|
425
|
-
* # Returns
|
|
426
|
-
* - A TickRange struct containing the lower and upper tick index
|
|
427
|
-
*/
|
|
428
|
-
export function getFullRangeTickIndexes(tick_spacing) {
|
|
429
|
-
const ret = wasm.getFullRangeTickIndexes(tick_spacing);
|
|
430
|
-
return takeObject(ret);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* Order tick indexes in ascending order.
|
|
435
|
-
* If the lower tick index is greater than the upper tick index, the indexes are swapped.
|
|
436
|
-
* This is useful for ensuring that the lower tick index is always less than the upper tick index.
|
|
437
|
-
*
|
|
438
|
-
* # Parameters
|
|
439
|
-
* - `tick_index_1` - A i32 integer representing the first tick index
|
|
440
|
-
* - `tick_index_2` - A i32 integer representing the second tick index
|
|
441
|
-
*
|
|
442
|
-
* # Returns
|
|
443
|
-
* - A TickRange struct containing the lower and upper tick index
|
|
444
|
-
*/
|
|
445
|
-
export function orderTickIndexes(tick_index_1, tick_index_2) {
|
|
446
|
-
const ret = wasm.orderTickIndexes(tick_index_1, tick_index_2);
|
|
447
|
-
return takeObject(ret);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Check if a fusion_pool is a full-range only pool.
|
|
452
|
-
*
|
|
453
|
-
* # Parameters
|
|
454
|
-
* - `tick_spacing` - A u16 integer representing the tick spacing
|
|
455
|
-
*
|
|
456
|
-
* # Returns
|
|
457
|
-
* - A boolean value indicating if the fusion_pool is a full-range only pool
|
|
458
|
-
*/
|
|
459
|
-
export function isFullRangeOnly(tick_spacing) {
|
|
460
|
-
const ret = wasm.isFullRangeOnly(tick_spacing);
|
|
461
|
-
return ret !== 0;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Get the index of a tick in a tick array.
|
|
466
|
-
*
|
|
467
|
-
* # Parameters
|
|
468
|
-
* - `tick_index` - A i32 integer representing the tick index
|
|
469
|
-
* - `tick_array_start_index` - A i32 integer representing the start tick index of the tick array
|
|
470
|
-
* - `tick_spacing` - A u16 integer representing the tick spacing
|
|
471
|
-
*
|
|
472
|
-
* # Returns
|
|
473
|
-
* - A u32 integer representing the tick index in the tick array
|
|
474
|
-
*/
|
|
475
|
-
export function getTickIndexInArray(tick_index, tick_array_start_index, tick_spacing) {
|
|
476
|
-
try {
|
|
477
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
478
|
-
wasm.getTickIndexInArray(retptr, tick_index, tick_array_start_index, tick_spacing);
|
|
479
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
480
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
481
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
482
|
-
if (r2) {
|
|
483
|
-
throw takeObject(r1);
|
|
484
|
-
}
|
|
485
|
-
return r0 >>> 0;
|
|
486
|
-
} finally {
|
|
487
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
265
|
/**
|
|
492
266
|
* Calculate the amount A delta between two sqrt_prices
|
|
493
267
|
*
|
|
@@ -684,171 +458,344 @@ export function tryGetMaxAmountWithSlippageTolerance(amount, slippage_tolerance_
|
|
|
684
458
|
}
|
|
685
459
|
|
|
686
460
|
/**
|
|
687
|
-
* Get the minimum amount with a slippage tolerance
|
|
688
|
-
* e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
|
|
461
|
+
* Get the minimum amount with a slippage tolerance
|
|
462
|
+
* e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
|
|
463
|
+
*
|
|
464
|
+
* # Parameters
|
|
465
|
+
* - `amount`: The amount to apply the fee to
|
|
466
|
+
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
467
|
+
*
|
|
468
|
+
* # Returns
|
|
469
|
+
* - `u64`: The minimum amount
|
|
470
|
+
*/
|
|
471
|
+
export function tryGetMinAmountWithSlippageTolerance(amount, slippage_tolerance_bps) {
|
|
472
|
+
try {
|
|
473
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
474
|
+
wasm.tryGetMinAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
|
|
475
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
476
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
477
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
478
|
+
if (r3) {
|
|
479
|
+
throw takeObject(r2);
|
|
480
|
+
}
|
|
481
|
+
return BigInt.asUintN(64, r0);
|
|
482
|
+
} finally {
|
|
483
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Apply a swap fee to an amount
|
|
489
|
+
* e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
|
|
490
|
+
* So the amount after fee will be 9900.
|
|
491
|
+
*
|
|
492
|
+
* # Parameters
|
|
493
|
+
* - `amount`: The amount to apply the fee to
|
|
494
|
+
* - `fee_rate`: The fee rate to apply denominated in 1e6
|
|
495
|
+
*
|
|
496
|
+
* # Returns
|
|
497
|
+
* - `u64`: The amount after the fee has been applied
|
|
498
|
+
*/
|
|
499
|
+
export function tryApplySwapFee(amount, fee_rate) {
|
|
500
|
+
try {
|
|
501
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
502
|
+
wasm.tryApplySwapFee(retptr, amount, fee_rate);
|
|
503
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
504
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
505
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
506
|
+
if (r3) {
|
|
507
|
+
throw takeObject(r2);
|
|
508
|
+
}
|
|
509
|
+
return BigInt.asUintN(64, r0);
|
|
510
|
+
} finally {
|
|
511
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Reverse the application of a swap fee to an amount
|
|
517
|
+
* e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
|
|
518
|
+
* So the amount before fee will be 10000.
|
|
519
|
+
*
|
|
520
|
+
* # Parameters
|
|
521
|
+
* - `amount`: The amount to reverse the fee from
|
|
522
|
+
* - `fee_rate`: The fee rate to reverse denominated in 1e6
|
|
523
|
+
*
|
|
524
|
+
* # Returns
|
|
525
|
+
* - `u64`: The amount before the fee has been applied
|
|
526
|
+
*/
|
|
527
|
+
export function tryReverseApplySwapFee(amount, fee_rate) {
|
|
528
|
+
try {
|
|
529
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
530
|
+
wasm.tryReverseApplySwapFee(retptr, amount, fee_rate);
|
|
531
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
532
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
533
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
534
|
+
if (r3) {
|
|
535
|
+
throw takeObject(r2);
|
|
536
|
+
}
|
|
537
|
+
return BigInt.asUintN(64, r0);
|
|
538
|
+
} finally {
|
|
539
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export function _FEE_RATE_MUL_VALUE() {
|
|
544
|
+
const ret = wasm._FEE_RATE_MUL_VALUE();
|
|
545
|
+
return ret >>> 0;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
export function _MAX_PROTOCOL_FEE_RATE() {
|
|
549
|
+
const ret = wasm._MAX_PROTOCOL_FEE_RATE();
|
|
550
|
+
return ret;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
export function _PROTOCOL_FEE_RATE_MUL_VALUE() {
|
|
554
|
+
const ret = wasm._PROTOCOL_FEE_RATE_MUL_VALUE();
|
|
555
|
+
return ret;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export function _TICK_ARRAY_SIZE() {
|
|
559
|
+
const ret = wasm._TICK_ARRAY_SIZE();
|
|
560
|
+
return ret >>> 0;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD() {
|
|
564
|
+
const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
|
|
565
|
+
return ret;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
export function _MIN_TICK_INDEX() {
|
|
569
|
+
const ret = wasm._MIN_TICK_INDEX();
|
|
570
|
+
return ret;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
export function _MAX_TICK_INDEX() {
|
|
574
|
+
const ret = wasm._MAX_TICK_INDEX();
|
|
575
|
+
return ret;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Get the first tick index in the tick array that contains the specified tick index.
|
|
580
|
+
*
|
|
581
|
+
* # Parameters
|
|
582
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
583
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
584
|
+
*
|
|
585
|
+
* # Returns
|
|
586
|
+
* - A i32 integer representing the first tick index in the tick array
|
|
587
|
+
*/
|
|
588
|
+
export function getTickArrayStartTickIndex(tick_index, tick_spacing) {
|
|
589
|
+
const ret = wasm.getTickArrayStartTickIndex(tick_index, tick_spacing);
|
|
590
|
+
return ret;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Derive the sqrt-price from a tick index. The precision of this method is only guarranted
|
|
595
|
+
* if tick is within the bounds of {max, min} tick-index.
|
|
596
|
+
*
|
|
597
|
+
* # Parameters
|
|
598
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
599
|
+
*
|
|
600
|
+
* # Returns
|
|
601
|
+
* - `Ok`: A u128 Q32.64 representing the sqrt_price
|
|
602
|
+
*/
|
|
603
|
+
export function tickIndexToSqrtPrice(tick_index) {
|
|
604
|
+
const ret = wasm.tickIndexToSqrtPrice(tick_index);
|
|
605
|
+
return takeObject(ret);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Derive the tick index from a sqrt price. The precision of this method is only guarranted
|
|
610
|
+
* if tick is within the bounds of {max, min} tick-index.
|
|
611
|
+
*
|
|
612
|
+
* # Parameters
|
|
613
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price
|
|
614
|
+
*
|
|
615
|
+
* # Returns
|
|
616
|
+
* - `Ok`: A i32 integer representing the tick integer
|
|
617
|
+
*/
|
|
618
|
+
export function sqrtPriceToTickIndex(sqrt_price) {
|
|
619
|
+
const ret = wasm.sqrtPriceToTickIndex(addHeapObject(sqrt_price));
|
|
620
|
+
return ret;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Get the initializable tick index.
|
|
625
|
+
* If the tick index is already initializable, it is returned as is.
|
|
626
|
+
*
|
|
627
|
+
* # Parameters
|
|
628
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
629
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
630
|
+
* - `round_up` - A boolean value indicating if the supplied tick index should be rounded up. None will round to the nearest.
|
|
631
|
+
*
|
|
632
|
+
* # Returns
|
|
633
|
+
* - A i32 integer representing the previous initializable tick index
|
|
634
|
+
*/
|
|
635
|
+
export function getInitializableTickIndex(tick_index, tick_spacing, round_up) {
|
|
636
|
+
const ret = wasm.getInitializableTickIndex(tick_index, tick_spacing, isLikeNone(round_up) ? 0xFFFFFF : round_up ? 1 : 0);
|
|
637
|
+
return ret;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Get the previous initializable tick index.
|
|
642
|
+
*
|
|
643
|
+
* # Parameters
|
|
644
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
645
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
646
|
+
*
|
|
647
|
+
* # Returns
|
|
648
|
+
* - A i32 integer representing the previous initializable tick index
|
|
649
|
+
*/
|
|
650
|
+
export function getPrevInitializableTickIndex(tick_index, tick_spacing) {
|
|
651
|
+
const ret = wasm.getPrevInitializableTickIndex(tick_index, tick_spacing);
|
|
652
|
+
return ret;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Get the next initializable tick index.
|
|
657
|
+
*
|
|
658
|
+
* # Parameters
|
|
659
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
660
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
661
|
+
*
|
|
662
|
+
* # Returns
|
|
663
|
+
* - A i32 integer representing the next initializable tick index
|
|
664
|
+
*/
|
|
665
|
+
export function getNextInitializableTickIndex(tick_index, tick_spacing) {
|
|
666
|
+
const ret = wasm.getNextInitializableTickIndex(tick_index, tick_spacing);
|
|
667
|
+
return ret;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Check if a tick is in-bounds.
|
|
672
|
+
*
|
|
673
|
+
* # Parameters
|
|
674
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
675
|
+
*
|
|
676
|
+
* # Returns
|
|
677
|
+
* - A boolean value indicating if the tick is in-bounds
|
|
678
|
+
*/
|
|
679
|
+
export function isTickIndexInBounds(tick_index) {
|
|
680
|
+
const ret = wasm.isTickIndexInBounds(tick_index);
|
|
681
|
+
return ret !== 0;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Check if a tick is initializable.
|
|
686
|
+
* A tick is initializable if it is divisible by the tick spacing.
|
|
689
687
|
*
|
|
690
688
|
* # Parameters
|
|
691
|
-
* - `
|
|
692
|
-
* - `
|
|
689
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
690
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
693
691
|
*
|
|
694
692
|
* # Returns
|
|
695
|
-
* -
|
|
693
|
+
* - A boolean value indicating if the tick is initializable
|
|
696
694
|
*/
|
|
697
|
-
export function
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
wasm.tryGetMinAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
|
|
701
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
702
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
703
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
704
|
-
if (r3) {
|
|
705
|
-
throw takeObject(r2);
|
|
706
|
-
}
|
|
707
|
-
return BigInt.asUintN(64, r0);
|
|
708
|
-
} finally {
|
|
709
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
710
|
-
}
|
|
695
|
+
export function isTickInitializable(tick_index, tick_spacing) {
|
|
696
|
+
const ret = wasm.isTickInitializable(tick_index, tick_spacing);
|
|
697
|
+
return ret !== 0;
|
|
711
698
|
}
|
|
712
699
|
|
|
713
700
|
/**
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
*
|
|
701
|
+
* Get the tick index for the inverse of the price that this tick represents.
|
|
702
|
+
* Eg: Consider tick i where Pb/Pa = 1.0001 ^ i
|
|
703
|
+
* inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i
|
|
717
704
|
*
|
|
718
705
|
* # Parameters
|
|
719
|
-
* - `
|
|
720
|
-
* - `fee_rate`: The fee rate to apply denominated in 1e6
|
|
706
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
721
707
|
*
|
|
722
708
|
* # Returns
|
|
723
|
-
* -
|
|
709
|
+
* - A i32 integer representing the tick index for the inverse of the price
|
|
724
710
|
*/
|
|
725
|
-
export function
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
wasm.tryApplySwapFee(retptr, amount, fee_rate);
|
|
729
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
730
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
731
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
732
|
-
if (r3) {
|
|
733
|
-
throw takeObject(r2);
|
|
734
|
-
}
|
|
735
|
-
return BigInt.asUintN(64, r0);
|
|
736
|
-
} finally {
|
|
737
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
738
|
-
}
|
|
711
|
+
export function invertTickIndex(tick_index) {
|
|
712
|
+
const ret = wasm.invertTickIndex(tick_index);
|
|
713
|
+
return ret;
|
|
739
714
|
}
|
|
740
715
|
|
|
741
716
|
/**
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
*
|
|
717
|
+
* Get the sqrt price for the inverse of the price that this tick represents.
|
|
718
|
+
* Because converting to a tick index and then back to a sqrt price is lossy,
|
|
719
|
+
* this function is clamped to the nearest tick index.
|
|
745
720
|
*
|
|
746
721
|
* # Parameters
|
|
747
|
-
* - `
|
|
748
|
-
* - `fee_rate`: The fee rate to reverse denominated in 1e6
|
|
722
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price
|
|
749
723
|
*
|
|
750
724
|
* # Returns
|
|
751
|
-
* -
|
|
725
|
+
* - A u128 integer representing the sqrt price for the inverse of the price
|
|
752
726
|
*/
|
|
753
|
-
export function
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
wasm.tryReverseApplySwapFee(retptr, amount, fee_rate);
|
|
757
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
758
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
759
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
760
|
-
if (r3) {
|
|
761
|
-
throw takeObject(r2);
|
|
762
|
-
}
|
|
763
|
-
return BigInt.asUintN(64, r0);
|
|
764
|
-
} finally {
|
|
765
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
766
|
-
}
|
|
727
|
+
export function invertSqrtPrice(sqrt_price) {
|
|
728
|
+
const ret = wasm.invertSqrtPrice(addHeapObject(sqrt_price));
|
|
729
|
+
return takeObject(ret);
|
|
767
730
|
}
|
|
768
731
|
|
|
769
732
|
/**
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
* - `
|
|
774
|
-
*
|
|
775
|
-
*
|
|
733
|
+
* Get the minimum and maximum tick index that can be initialized.
|
|
734
|
+
*
|
|
735
|
+
* # Parameters
|
|
736
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
737
|
+
*
|
|
738
|
+
* # Returns
|
|
739
|
+
* - A TickRange struct containing the lower and upper tick index
|
|
776
740
|
*/
|
|
777
|
-
export function
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
wasm.limitOrderQuoteByInputToken(retptr, amount_in, a_to_b_order, tick_index, addHeapObject(fusion_pool));
|
|
781
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
782
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
783
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
784
|
-
if (r3) {
|
|
785
|
-
throw takeObject(r2);
|
|
786
|
-
}
|
|
787
|
-
return BigInt.asUintN(64, r0);
|
|
788
|
-
} finally {
|
|
789
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
790
|
-
}
|
|
741
|
+
export function getFullRangeTickIndexes(tick_spacing) {
|
|
742
|
+
const ret = wasm.getFullRangeTickIndexes(tick_spacing);
|
|
743
|
+
return takeObject(ret);
|
|
791
744
|
}
|
|
792
745
|
|
|
793
746
|
/**
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
* - `
|
|
747
|
+
* Order tick indexes in ascending order.
|
|
748
|
+
* If the lower tick index is greater than the upper tick index, the indexes are swapped.
|
|
749
|
+
* This is useful for ensuring that the lower tick index is always less than the upper tick index.
|
|
750
|
+
*
|
|
751
|
+
* # Parameters
|
|
752
|
+
* - `tick_index_1` - A i32 integer representing the first tick index
|
|
753
|
+
* - `tick_index_2` - A i32 integer representing the second tick index
|
|
754
|
+
*
|
|
755
|
+
* # Returns
|
|
756
|
+
* - A TickRange struct containing the lower and upper tick index
|
|
800
757
|
*/
|
|
801
|
-
export function
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
wasm.limitOrderQuoteByOutputToken(retptr, amount_out, a_to_b_order, tick_index, addHeapObject(fusion_pool));
|
|
805
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
806
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
807
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
808
|
-
if (r3) {
|
|
809
|
-
throw takeObject(r2);
|
|
810
|
-
}
|
|
811
|
-
return BigInt.asUintN(64, r0);
|
|
812
|
-
} finally {
|
|
813
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
814
|
-
}
|
|
758
|
+
export function orderTickIndexes(tick_index_1, tick_index_2) {
|
|
759
|
+
const ret = wasm.orderTickIndexes(tick_index_1, tick_index_2);
|
|
760
|
+
return takeObject(ret);
|
|
815
761
|
}
|
|
816
762
|
|
|
817
763
|
/**
|
|
818
|
-
*
|
|
819
|
-
*
|
|
820
|
-
*
|
|
821
|
-
* - `
|
|
822
|
-
*
|
|
823
|
-
*
|
|
764
|
+
* Check if a fusion_pool is a full-range only pool.
|
|
765
|
+
*
|
|
766
|
+
* # Parameters
|
|
767
|
+
* - `tick_spacing` - A u16 integer representing the tick spacing
|
|
768
|
+
*
|
|
769
|
+
* # Returns
|
|
770
|
+
* - A boolean value indicating if the fusion_pool is a full-range only pool
|
|
824
771
|
*/
|
|
825
|
-
export function
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
wasm.limitOrderRewardByOutputToken(retptr, amount_out, fee_rate, protocol_fee_rate);
|
|
829
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
830
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
831
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
832
|
-
if (r3) {
|
|
833
|
-
throw takeObject(r2);
|
|
834
|
-
}
|
|
835
|
-
return BigInt.asUintN(64, r0);
|
|
836
|
-
} finally {
|
|
837
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
838
|
-
}
|
|
772
|
+
export function isFullRangeOnly(tick_spacing) {
|
|
773
|
+
const ret = wasm.isFullRangeOnly(tick_spacing);
|
|
774
|
+
return ret !== 0;
|
|
839
775
|
}
|
|
840
776
|
|
|
841
|
-
|
|
777
|
+
/**
|
|
778
|
+
* Get the index of a tick in a tick array.
|
|
779
|
+
*
|
|
780
|
+
* # Parameters
|
|
781
|
+
* - `tick_index` - A i32 integer representing the tick index
|
|
782
|
+
* - `tick_array_start_index` - A i32 integer representing the start tick index of the tick array
|
|
783
|
+
* - `tick_spacing` - A u16 integer representing the tick spacing
|
|
784
|
+
*
|
|
785
|
+
* # Returns
|
|
786
|
+
* - A u32 integer representing the tick index in the tick array
|
|
787
|
+
*/
|
|
788
|
+
export function getTickIndexInArray(tick_index, tick_array_start_index, tick_spacing) {
|
|
842
789
|
try {
|
|
843
790
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
844
|
-
wasm.
|
|
791
|
+
wasm.getTickIndexInArray(retptr, tick_index, tick_array_start_index, tick_spacing);
|
|
845
792
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
846
793
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
847
794
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
848
795
|
if (r2) {
|
|
849
796
|
throw takeObject(r1);
|
|
850
797
|
}
|
|
851
|
-
return
|
|
798
|
+
return r0 >>> 0;
|
|
852
799
|
} finally {
|
|
853
800
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
854
801
|
}
|
|
@@ -1147,124 +1094,102 @@ export function collectFeesQuote(fusion_pool, position, tick_lower, tick_upper,
|
|
|
1147
1094
|
throw takeObject(r1);
|
|
1148
1095
|
}
|
|
1149
1096
|
return takeObject(r0);
|
|
1150
|
-
} finally {
|
|
1151
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
export function limitOrderFee(fusion_pool) {
|
|
1156
|
-
const ret = wasm.limitOrderFee(addHeapObject(fusion_pool));
|
|
1157
|
-
return ret;
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
export function _TICK_ARRAY_SIZE() {
|
|
1161
|
-
const ret = wasm._TICK_ARRAY_SIZE();
|
|
1162
|
-
return ret >>> 0;
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD() {
|
|
1166
|
-
const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
|
|
1167
|
-
return ret;
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
export function _MIN_TICK_INDEX() {
|
|
1171
|
-
const ret = wasm._MIN_TICK_INDEX();
|
|
1172
|
-
return ret;
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
export function _MAX_TICK_INDEX() {
|
|
1176
|
-
const ret = wasm._MAX_TICK_INDEX();
|
|
1177
|
-
return ret;
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
/**
|
|
1181
|
-
* Convert a price into a sqrt priceX64
|
|
1182
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1183
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1184
|
-
*
|
|
1185
|
-
* # Parameters
|
|
1186
|
-
* * `price` - The price to convert
|
|
1187
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1188
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1189
|
-
*
|
|
1190
|
-
* # Returns
|
|
1191
|
-
* * `u128` - The sqrt priceX64
|
|
1192
|
-
*/
|
|
1193
|
-
export function priceToSqrtPrice(price, decimals_a, decimals_b) {
|
|
1194
|
-
const ret = wasm.priceToSqrtPrice(price, decimals_a, decimals_b);
|
|
1195
|
-
return takeObject(ret);
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
/**
|
|
1199
|
-
* Convert a sqrt priceX64 into a tick index
|
|
1200
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1201
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1202
|
-
*
|
|
1203
|
-
* # Parameters
|
|
1204
|
-
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
1205
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1206
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1207
|
-
*
|
|
1208
|
-
* # Returns
|
|
1209
|
-
* * `f64` - The decimal price
|
|
1210
|
-
*/
|
|
1211
|
-
export function sqrtPriceToPrice(sqrt_price, decimals_a, decimals_b) {
|
|
1212
|
-
const ret = wasm.sqrtPriceToPrice(addHeapObject(sqrt_price), decimals_a, decimals_b);
|
|
1097
|
+
} finally {
|
|
1098
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
export function limitOrderFee(fusion_pool) {
|
|
1103
|
+
const ret = wasm.limitOrderFee(addHeapObject(fusion_pool));
|
|
1213
1104
|
return ret;
|
|
1214
1105
|
}
|
|
1215
1106
|
|
|
1216
1107
|
/**
|
|
1217
|
-
*
|
|
1218
|
-
*
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1224
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1225
|
-
*
|
|
1226
|
-
* # Returns
|
|
1227
|
-
* * `f64` - The inverted price
|
|
1108
|
+
* Computes the limit order output amount by input amount.
|
|
1109
|
+
* ### Parameters
|
|
1110
|
+
* - `amount_in` - The input token amount of a limit order.
|
|
1111
|
+
* - `a_to_b_order` - The limit order direction.
|
|
1112
|
+
* - `tick_index` - The tick index of an order.
|
|
1113
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
1228
1114
|
*/
|
|
1229
|
-
export function
|
|
1230
|
-
|
|
1231
|
-
|
|
1115
|
+
export function limitOrderQuoteByInputToken(amount_in, a_to_b_order, tick_index, fusion_pool) {
|
|
1116
|
+
try {
|
|
1117
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1118
|
+
wasm.limitOrderQuoteByInputToken(retptr, amount_in, a_to_b_order, tick_index, addHeapObject(fusion_pool));
|
|
1119
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1120
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1121
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1122
|
+
if (r3) {
|
|
1123
|
+
throw takeObject(r2);
|
|
1124
|
+
}
|
|
1125
|
+
return BigInt.asUintN(64, r0);
|
|
1126
|
+
} finally {
|
|
1127
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1128
|
+
}
|
|
1232
1129
|
}
|
|
1233
1130
|
|
|
1234
1131
|
/**
|
|
1235
|
-
*
|
|
1236
|
-
*
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1241
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1242
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1243
|
-
*
|
|
1244
|
-
* # Returns
|
|
1245
|
-
* * `f64` - The decimal price
|
|
1132
|
+
* Computes the limit order input amount by output amount.
|
|
1133
|
+
* ### Parameters
|
|
1134
|
+
* - `amount_out` - The output token amount of a limit order.
|
|
1135
|
+
* - `a_to_b_order` - The limit order direction.
|
|
1136
|
+
* - `tick_index` - The tick index of an order.
|
|
1137
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
1246
1138
|
*/
|
|
1247
|
-
export function
|
|
1248
|
-
|
|
1249
|
-
|
|
1139
|
+
export function limitOrderQuoteByOutputToken(amount_out, a_to_b_order, tick_index, fusion_pool) {
|
|
1140
|
+
try {
|
|
1141
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1142
|
+
wasm.limitOrderQuoteByOutputToken(retptr, amount_out, a_to_b_order, tick_index, addHeapObject(fusion_pool));
|
|
1143
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1144
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1145
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1146
|
+
if (r3) {
|
|
1147
|
+
throw takeObject(r2);
|
|
1148
|
+
}
|
|
1149
|
+
return BigInt.asUintN(64, r0);
|
|
1150
|
+
} finally {
|
|
1151
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1152
|
+
}
|
|
1250
1153
|
}
|
|
1251
1154
|
|
|
1252
1155
|
/**
|
|
1253
|
-
*
|
|
1254
|
-
*
|
|
1255
|
-
*
|
|
1256
|
-
*
|
|
1257
|
-
*
|
|
1258
|
-
*
|
|
1259
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1260
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1261
|
-
*
|
|
1262
|
-
* # Returns
|
|
1263
|
-
* * `i32` - The tick index
|
|
1156
|
+
* Computes the limit order reward by input amount.
|
|
1157
|
+
* ### Parameters
|
|
1158
|
+
* - `amount_out` - The output token amount of a limit order (swap input).
|
|
1159
|
+
* - `a_to_b_order` - The limit order direction.
|
|
1160
|
+
* - `tick_index` - The tick index of an order.
|
|
1161
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
1264
1162
|
*/
|
|
1265
|
-
export function
|
|
1266
|
-
|
|
1267
|
-
|
|
1163
|
+
export function limitOrderRewardByOutputToken(amount_out, fee_rate, protocol_fee_rate) {
|
|
1164
|
+
try {
|
|
1165
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1166
|
+
wasm.limitOrderRewardByOutputToken(retptr, amount_out, fee_rate, protocol_fee_rate);
|
|
1167
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1168
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1169
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1170
|
+
if (r3) {
|
|
1171
|
+
throw takeObject(r2);
|
|
1172
|
+
}
|
|
1173
|
+
return BigInt.asUintN(64, r0);
|
|
1174
|
+
} finally {
|
|
1175
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
export function decreaseLimitOrderQuote(fusion_pool, limit_order, tick, amount, transfer_fee_a, transfer_fee_b) {
|
|
1180
|
+
try {
|
|
1181
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1182
|
+
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));
|
|
1183
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1184
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1185
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1186
|
+
if (r2) {
|
|
1187
|
+
throw takeObject(r1);
|
|
1188
|
+
}
|
|
1189
|
+
return takeObject(r0);
|
|
1190
|
+
} finally {
|
|
1191
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1192
|
+
}
|
|
1268
1193
|
}
|
|
1269
1194
|
|
|
1270
1195
|
export function _POSITION_BUNDLE_SIZE() {
|
|
@@ -1476,21 +1401,6 @@ export function _LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC() {
|
|
|
1476
1401
|
}
|
|
1477
1402
|
}
|
|
1478
1403
|
|
|
1479
|
-
export function _FEE_RATE_MUL_VALUE() {
|
|
1480
|
-
const ret = wasm._FEE_RATE_MUL_VALUE();
|
|
1481
|
-
return ret >>> 0;
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
export function _MAX_PROTOCOL_FEE_RATE() {
|
|
1485
|
-
const ret = wasm._MAX_PROTOCOL_FEE_RATE();
|
|
1486
|
-
return ret;
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
export function _PROTOCOL_FEE_RATE_MUL_VALUE() {
|
|
1490
|
-
const ret = wasm._PROTOCOL_FEE_RATE_MUL_VALUE();
|
|
1491
|
-
return ret;
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
1404
|
/**
|
|
1495
1405
|
* Get the first unoccupied position in a bundle
|
|
1496
1406
|
*
|
|
@@ -1593,6 +1503,128 @@ export function positionRatioX64(current_sqrt_price, tick_index_1, tick_index_2)
|
|
|
1593
1503
|
return takeObject(ret);
|
|
1594
1504
|
}
|
|
1595
1505
|
|
|
1506
|
+
/**
|
|
1507
|
+
* Convert a price into a sqrt priceX64
|
|
1508
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1509
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1510
|
+
*
|
|
1511
|
+
* # Parameters
|
|
1512
|
+
* * `price` - The price to convert
|
|
1513
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1514
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1515
|
+
*
|
|
1516
|
+
* # Returns
|
|
1517
|
+
* * `u128` - The sqrt priceX64
|
|
1518
|
+
*/
|
|
1519
|
+
export function priceToSqrtPrice(price, decimals_a, decimals_b) {
|
|
1520
|
+
const ret = wasm.priceToSqrtPrice(price, decimals_a, decimals_b);
|
|
1521
|
+
return takeObject(ret);
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
/**
|
|
1525
|
+
* Convert a sqrt priceX64 into a tick index
|
|
1526
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1527
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1528
|
+
*
|
|
1529
|
+
* # Parameters
|
|
1530
|
+
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
1531
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1532
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1533
|
+
*
|
|
1534
|
+
* # Returns
|
|
1535
|
+
* * `f64` - The decimal price
|
|
1536
|
+
*/
|
|
1537
|
+
export function sqrtPriceToPrice(sqrt_price, decimals_a, decimals_b) {
|
|
1538
|
+
const ret = wasm.sqrtPriceToPrice(addHeapObject(sqrt_price), decimals_a, decimals_b);
|
|
1539
|
+
return ret;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
/**
|
|
1543
|
+
* Invert a price
|
|
1544
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1545
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1546
|
+
*
|
|
1547
|
+
* # Parameters
|
|
1548
|
+
* * `price` - The price to invert
|
|
1549
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1550
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1551
|
+
*
|
|
1552
|
+
* # Returns
|
|
1553
|
+
* * `f64` - The inverted price
|
|
1554
|
+
*/
|
|
1555
|
+
export function invertPrice(price, decimals_a, decimals_b) {
|
|
1556
|
+
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
1557
|
+
return ret;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* Convert a tick index into a price
|
|
1562
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1563
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1564
|
+
*
|
|
1565
|
+
* # Parameters
|
|
1566
|
+
* * `tick_index` - The tick index to convert
|
|
1567
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1568
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1569
|
+
*
|
|
1570
|
+
* # Returns
|
|
1571
|
+
* * `f64` - The decimal price
|
|
1572
|
+
*/
|
|
1573
|
+
export function tickIndexToPrice(tick_index, decimals_a, decimals_b) {
|
|
1574
|
+
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
1575
|
+
return ret;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
/**
|
|
1579
|
+
* Convert a price into a tick index
|
|
1580
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1581
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1582
|
+
*
|
|
1583
|
+
* # Parameters
|
|
1584
|
+
* * `price` - The price to convert
|
|
1585
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1586
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1587
|
+
*
|
|
1588
|
+
* # Returns
|
|
1589
|
+
* * `i32` - The tick index
|
|
1590
|
+
*/
|
|
1591
|
+
export function priceToTickIndex(price, decimals_a, decimals_b) {
|
|
1592
|
+
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
1593
|
+
return ret;
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* Computes the liquidation prices for an existing position.
|
|
1598
|
+
*
|
|
1599
|
+
* # Parameters
|
|
1600
|
+
* - `lower_tick_index`: The lower tick index of the position.
|
|
1601
|
+
* - `upper_tick_index`: The upper tick index of the position.
|
|
1602
|
+
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
1603
|
+
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
1604
|
+
* - `liquidity`: Liquidity of the position.
|
|
1605
|
+
* - `debt_a`: The amount of tokens A borrowed.
|
|
1606
|
+
* - `debt_b`: The amount of tokens B borrowed.
|
|
1607
|
+
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
1608
|
+
*
|
|
1609
|
+
* # Returns
|
|
1610
|
+
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
1611
|
+
*/
|
|
1612
|
+
export function getLpPositionLiquidationPrices(lower_tick_index, upper_tick_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
|
|
1613
|
+
try {
|
|
1614
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1615
|
+
wasm.getLpPositionLiquidationPrices(retptr, lower_tick_index, upper_tick_index, addHeapObject(liquidity), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
|
|
1616
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1617
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1618
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1619
|
+
if (r2) {
|
|
1620
|
+
throw takeObject(r1);
|
|
1621
|
+
}
|
|
1622
|
+
return takeObject(r0);
|
|
1623
|
+
} finally {
|
|
1624
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1596
1628
|
/**
|
|
1597
1629
|
* Computes the exact input or output amount for a swap transaction.
|
|
1598
1630
|
*
|
|
@@ -1721,10 +1753,10 @@ export function getDecreaseSpotPositionQuote(decrease_amount, collateral_token,
|
|
|
1721
1753
|
* # Returns
|
|
1722
1754
|
* - `f64`: Decimal liquidation price
|
|
1723
1755
|
*/
|
|
1724
|
-
export function
|
|
1756
|
+
export function getSpotPositionLiquidationPrice(position_token, amount, debt, liquidation_threshold) {
|
|
1725
1757
|
try {
|
|
1726
1758
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1727
|
-
wasm.
|
|
1759
|
+
wasm.getSpotPositionLiquidationPrice(retptr, position_token, amount, debt, liquidation_threshold);
|
|
1728
1760
|
var r0 = getDataViewMemory0().getFloat64(retptr + 8 * 0, true);
|
|
1729
1761
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1730
1762
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -1770,8 +1802,8 @@ export function getTradableAmount(collateral_token, available_balance, leverage,
|
|
|
1770
1802
|
}
|
|
1771
1803
|
}
|
|
1772
1804
|
|
|
1773
|
-
export function
|
|
1774
|
-
const ret = wasm.
|
|
1805
|
+
export function calculateTunaSpotPositionProtocolFee(collateral_token, borrowed_token, collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate) {
|
|
1806
|
+
const ret = wasm.calculateTunaSpotPositionProtocolFee(collateral_token, borrowed_token, collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate);
|
|
1775
1807
|
return takeObject(ret);
|
|
1776
1808
|
}
|
|
1777
1809
|
|
|
@@ -1818,16 +1850,16 @@ export function solana_program_init() {
|
|
|
1818
1850
|
wasm.solana_program_init();
|
|
1819
1851
|
}
|
|
1820
1852
|
|
|
1821
|
-
function
|
|
1822
|
-
wasm.
|
|
1853
|
+
function __wasm_bindgen_func_elem_3356(arg0, arg1, arg2) {
|
|
1854
|
+
wasm.__wasm_bindgen_func_elem_3356(arg0, arg1, addHeapObject(arg2));
|
|
1823
1855
|
}
|
|
1824
1856
|
|
|
1825
|
-
function
|
|
1826
|
-
wasm.
|
|
1857
|
+
function __wasm_bindgen_func_elem_3164(arg0, arg1) {
|
|
1858
|
+
wasm.__wasm_bindgen_func_elem_3164(arg0, arg1);
|
|
1827
1859
|
}
|
|
1828
1860
|
|
|
1829
|
-
function
|
|
1830
|
-
wasm.
|
|
1861
|
+
function __wasm_bindgen_func_elem_495(arg0, arg1, arg2, arg3) {
|
|
1862
|
+
wasm.__wasm_bindgen_func_elem_495(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
1831
1863
|
}
|
|
1832
1864
|
|
|
1833
1865
|
const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
|
|
@@ -2990,7 +3022,7 @@ export function __wbg_new_3c3d849046688a66(arg0, arg1) {
|
|
|
2990
3022
|
const a = state0.a;
|
|
2991
3023
|
state0.a = 0;
|
|
2992
3024
|
try {
|
|
2993
|
-
return
|
|
3025
|
+
return __wasm_bindgen_func_elem_495(a, state0.b, arg0, arg1);
|
|
2994
3026
|
} finally {
|
|
2995
3027
|
state0.a = a;
|
|
2996
3028
|
}
|
|
@@ -3246,9 +3278,15 @@ export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
|
|
|
3246
3278
|
return addHeapObject(ret);
|
|
3247
3279
|
};
|
|
3248
3280
|
|
|
3249
|
-
export function
|
|
3250
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
3251
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
3281
|
+
export function __wbindgen_cast_4765ab8ace056f92(arg0, arg1) {
|
|
3282
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 386, function: Function { arguments: [Externref], shim_idx: 381, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3283
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3375, __wasm_bindgen_func_elem_3356);
|
|
3284
|
+
return addHeapObject(ret);
|
|
3285
|
+
};
|
|
3286
|
+
|
|
3287
|
+
export function __wbindgen_cast_7727c787a531a20f(arg0, arg1) {
|
|
3288
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 347, function: Function { arguments: [], shim_idx: 348, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3289
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3160, __wasm_bindgen_func_elem_3164);
|
|
3252
3290
|
return addHeapObject(ret);
|
|
3253
3291
|
};
|
|
3254
3292
|
|
|
@@ -3270,12 +3308,6 @@ export function __wbindgen_cast_e7b45dd881f38ce3(arg0, arg1) {
|
|
|
3270
3308
|
return addHeapObject(ret);
|
|
3271
3309
|
};
|
|
3272
3310
|
|
|
3273
|
-
export function __wbindgen_cast_e9643297b4d6a498(arg0, arg1) {
|
|
3274
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx: 372, function: Function { arguments: [Externref], shim_idx: 383, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3275
|
-
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3285, __wasm_bindgen_func_elem_3312);
|
|
3276
|
-
return addHeapObject(ret);
|
|
3277
|
-
};
|
|
3278
|
-
|
|
3279
3311
|
export function __wbindgen_object_clone_ref(arg0) {
|
|
3280
3312
|
const ret = getObject(arg0);
|
|
3281
3313
|
return addHeapObject(ret);
|