@crypticdot/defituna-core 3.4.5 → 3.4.6
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 +202 -201
- package/dist/browser/defituna_core_js_bindings_bg.js +353 -342
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +26 -25
- package/dist/nodejs/defituna_core_js_bindings.d.ts +202 -201
- package/dist/nodejs/defituna_core_js_bindings.js +353 -342
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +26 -25
- package/package.json +2 -2
|
@@ -262,6 +262,204 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
262
262
|
WASM_VECTOR_LEN = arg.length;
|
|
263
263
|
return ptr;
|
|
264
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Get the first unoccupied position in a bundle
|
|
267
|
+
*
|
|
268
|
+
* # Arguments
|
|
269
|
+
* * `bundle` - The bundle to check
|
|
270
|
+
*
|
|
271
|
+
* # Returns
|
|
272
|
+
* * `u32` - The first unoccupied position (None if full)
|
|
273
|
+
*/
|
|
274
|
+
export function firstUnoccupiedPositionInBundle(bitmap) {
|
|
275
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
276
|
+
const len0 = WASM_VECTOR_LEN;
|
|
277
|
+
const ret = wasm.firstUnoccupiedPositionInBundle(ptr0, len0);
|
|
278
|
+
return ret === 0x100000001 ? undefined : ret;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Check whether a position bundle is full
|
|
283
|
+
* A position bundle can contain 256 positions
|
|
284
|
+
*
|
|
285
|
+
* # Arguments
|
|
286
|
+
* * `bundle` - The bundle to check
|
|
287
|
+
*
|
|
288
|
+
* # Returns
|
|
289
|
+
* * `bool` - Whether the bundle is full
|
|
290
|
+
*/
|
|
291
|
+
export function isPositionBundleFull(bitmap) {
|
|
292
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
293
|
+
const len0 = WASM_VECTOR_LEN;
|
|
294
|
+
const ret = wasm.isPositionBundleFull(ptr0, len0);
|
|
295
|
+
return ret !== 0;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Check whether a position bundle is empty
|
|
300
|
+
*
|
|
301
|
+
* # Arguments
|
|
302
|
+
* * `bundle` - The bundle to check
|
|
303
|
+
*
|
|
304
|
+
* # Returns
|
|
305
|
+
* * `bool` - Whether the bundle is empty
|
|
306
|
+
*/
|
|
307
|
+
export function isPositionBundleEmpty(bitmap) {
|
|
308
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
309
|
+
const len0 = WASM_VECTOR_LEN;
|
|
310
|
+
const ret = wasm.isPositionBundleEmpty(ptr0, len0);
|
|
311
|
+
return ret !== 0;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Check if a position is in range.
|
|
316
|
+
* When a position is in range it is earning fees and rewards
|
|
317
|
+
*
|
|
318
|
+
* # Parameters
|
|
319
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
320
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
321
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
322
|
+
*
|
|
323
|
+
* # Returns
|
|
324
|
+
* - A boolean value indicating if the position is in range
|
|
325
|
+
*/
|
|
326
|
+
export function isPositionInRange(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
327
|
+
const ret = wasm.isPositionInRange(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
328
|
+
return ret !== 0;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Calculate the status of a position
|
|
333
|
+
* The status can be one of three values:
|
|
334
|
+
* - InRange: The position is in range
|
|
335
|
+
* - BelowRange: The position is below the range
|
|
336
|
+
* - AboveRange: The position is above the range
|
|
337
|
+
*
|
|
338
|
+
* # Parameters
|
|
339
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
340
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
341
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
342
|
+
*
|
|
343
|
+
* # Returns
|
|
344
|
+
* - A PositionStatus enum value indicating the status of the position
|
|
345
|
+
*/
|
|
346
|
+
export function positionStatus(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
347
|
+
const ret = wasm.positionStatus(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
348
|
+
return takeObject(ret);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Calculate the token_a / token_b ratio of a (ficticious) position
|
|
353
|
+
*
|
|
354
|
+
* # Parameters
|
|
355
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
356
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
357
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
358
|
+
*
|
|
359
|
+
* # Returns
|
|
360
|
+
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
361
|
+
*/
|
|
362
|
+
export function positionRatioX64(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
363
|
+
const ret = wasm.positionRatioX64(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
364
|
+
return takeObject(ret);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Convert a price into a sqrt priceX64
|
|
369
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
370
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
371
|
+
*
|
|
372
|
+
* # Parameters
|
|
373
|
+
* * `price` - The price to convert
|
|
374
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
375
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
376
|
+
*
|
|
377
|
+
* # Returns
|
|
378
|
+
* * `u128` - The sqrt priceX64
|
|
379
|
+
*/
|
|
380
|
+
export function priceToSqrtPrice(price, decimals_a, decimals_b) {
|
|
381
|
+
try {
|
|
382
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
383
|
+
wasm.priceToSqrtPrice(retptr, price, decimals_a, decimals_b);
|
|
384
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
385
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
386
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
387
|
+
} finally {
|
|
388
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Convert a sqrt priceX64 into a tick index
|
|
394
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
395
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
396
|
+
*
|
|
397
|
+
* # Parameters
|
|
398
|
+
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
399
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
400
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
401
|
+
*
|
|
402
|
+
* # Returns
|
|
403
|
+
* * `f64` - The decimal price
|
|
404
|
+
*/
|
|
405
|
+
export function sqrtPriceToPrice(sqrt_price, decimals_a, decimals_b) {
|
|
406
|
+
const ret = wasm.sqrtPriceToPrice(sqrt_price, sqrt_price >> BigInt(64), decimals_a, decimals_b);
|
|
407
|
+
return ret;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Invert a price
|
|
412
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
413
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
414
|
+
*
|
|
415
|
+
* # Parameters
|
|
416
|
+
* * `price` - The price to invert
|
|
417
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
418
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
419
|
+
*
|
|
420
|
+
* # Returns
|
|
421
|
+
* * `f64` - The inverted price
|
|
422
|
+
*/
|
|
423
|
+
export function invertPrice(price, decimals_a, decimals_b) {
|
|
424
|
+
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
425
|
+
return ret;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Convert a tick index into a price
|
|
430
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
431
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
432
|
+
*
|
|
433
|
+
* # Parameters
|
|
434
|
+
* * `tick_index` - The tick index to convert
|
|
435
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
436
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
437
|
+
*
|
|
438
|
+
* # Returns
|
|
439
|
+
* * `f64` - The decimal price
|
|
440
|
+
*/
|
|
441
|
+
export function tickIndexToPrice(tick_index, decimals_a, decimals_b) {
|
|
442
|
+
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
443
|
+
return ret;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Convert a price into a tick index
|
|
448
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
449
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
450
|
+
*
|
|
451
|
+
* # Parameters
|
|
452
|
+
* * `price` - The price to convert
|
|
453
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
454
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
455
|
+
*
|
|
456
|
+
* # Returns
|
|
457
|
+
* * `i32` - The tick index
|
|
458
|
+
*/
|
|
459
|
+
export function priceToTickIndex(price, decimals_a, decimals_b) {
|
|
460
|
+
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
461
|
+
return ret;
|
|
462
|
+
}
|
|
265
463
|
|
|
266
464
|
export function _POSITION_BUNDLE_SIZE() {
|
|
267
465
|
const ret = wasm._POSITION_BUNDLE_SIZE();
|
|
@@ -543,6 +741,105 @@ export function getTickIndexInArray(tick_index, tick_array_start_index, tick_spa
|
|
|
543
741
|
}
|
|
544
742
|
}
|
|
545
743
|
|
|
744
|
+
export function tryGetLiquidityFromAmountA(amount_a, sqrt_price_lower, sqrt_price_upper) {
|
|
745
|
+
try {
|
|
746
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
747
|
+
wasm.tryGetLiquidityFromAmountA(retptr, amount_a, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
748
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
749
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
750
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
751
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
752
|
+
if (r5) {
|
|
753
|
+
throw takeObject(r4);
|
|
754
|
+
}
|
|
755
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
756
|
+
} finally {
|
|
757
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
export function tryGetAmountAFromLiquidity(liquidity, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
762
|
+
try {
|
|
763
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
764
|
+
wasm.tryGetAmountAFromLiquidity(retptr, liquidity, liquidity >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
765
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
766
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
767
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
768
|
+
if (r3) {
|
|
769
|
+
throw takeObject(r2);
|
|
770
|
+
}
|
|
771
|
+
return BigInt.asUintN(64, r0);
|
|
772
|
+
} finally {
|
|
773
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
export function tryGetLiquidityFromAmountB(amount_b, sqrt_price_lower, sqrt_price_upper) {
|
|
778
|
+
try {
|
|
779
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
780
|
+
wasm.tryGetLiquidityFromAmountB(retptr, amount_b, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
781
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
782
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
783
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
784
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
785
|
+
if (r5) {
|
|
786
|
+
throw takeObject(r4);
|
|
787
|
+
}
|
|
788
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
789
|
+
} finally {
|
|
790
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
export function tryGetAmountBFromLiquidity(liquidity, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
795
|
+
try {
|
|
796
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
797
|
+
wasm.tryGetAmountBFromLiquidity(retptr, liquidity, liquidity >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
798
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
799
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
800
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
801
|
+
if (r3) {
|
|
802
|
+
throw takeObject(r2);
|
|
803
|
+
}
|
|
804
|
+
return BigInt.asUintN(64, r0);
|
|
805
|
+
} finally {
|
|
806
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
export function tryGetAmountsFromLiquidity(liquidity, sqrt_price, tick_lower_index, tick_upper_index, round_up) {
|
|
811
|
+
try {
|
|
812
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
813
|
+
wasm.tryGetAmountsFromLiquidity(retptr, liquidity, liquidity >> BigInt(64), sqrt_price, sqrt_price >> BigInt(64), tick_lower_index, tick_upper_index, round_up);
|
|
814
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
815
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
816
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
817
|
+
if (r2) {
|
|
818
|
+
throw takeObject(r1);
|
|
819
|
+
}
|
|
820
|
+
return takeObject(r0);
|
|
821
|
+
} finally {
|
|
822
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
export function tryGetLiquidityFromAmounts(sqrt_price, sqrt_price_lower, sqrt_price_upper, amount_a, amount_b) {
|
|
827
|
+
try {
|
|
828
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
829
|
+
wasm.tryGetLiquidityFromAmounts(retptr, sqrt_price, sqrt_price >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), amount_a, amount_b);
|
|
830
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
831
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
832
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
833
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
834
|
+
if (r5) {
|
|
835
|
+
throw takeObject(r4);
|
|
836
|
+
}
|
|
837
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
838
|
+
} finally {
|
|
839
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
546
843
|
/**
|
|
547
844
|
* Calculate the quote for decreasing liquidity
|
|
548
845
|
*
|
|
@@ -681,171 +978,42 @@ export function increaseLiquidityQuote(liquidity_delta, slippage_tolerance_bps,
|
|
|
681
978
|
*
|
|
682
979
|
* # Returns
|
|
683
980
|
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
684
|
-
*/
|
|
685
|
-
export function increaseLiquidityQuoteA(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
686
|
-
try {
|
|
687
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
688
|
-
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));
|
|
689
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
690
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
691
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
692
|
-
if (r2) {
|
|
693
|
-
throw takeObject(r1);
|
|
694
|
-
}
|
|
695
|
-
return takeObject(r0);
|
|
696
|
-
} finally {
|
|
697
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Calculate the quote for increasing liquidity given a token b amount
|
|
703
|
-
*
|
|
704
|
-
* # Parameters
|
|
705
|
-
* - `token_amount_b` - The amount of token b to increase
|
|
706
|
-
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
707
|
-
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
708
|
-
* - `tick_index_1` - The first tick index of the position
|
|
709
|
-
* - `tick_index_2` - The second tick index of the position
|
|
710
|
-
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
711
|
-
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
712
|
-
*
|
|
713
|
-
* # Returns
|
|
714
|
-
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
715
|
-
*/
|
|
716
|
-
export function increaseLiquidityQuoteB(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
717
|
-
try {
|
|
718
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
719
|
-
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));
|
|
720
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
721
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
722
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
723
|
-
if (r2) {
|
|
724
|
-
throw takeObject(r1);
|
|
725
|
-
}
|
|
726
|
-
return takeObject(r0);
|
|
727
|
-
} finally {
|
|
728
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
export function tryGetLiquidityFromA(token_delta_a, sqrt_price_lower, sqrt_price_upper) {
|
|
733
|
-
try {
|
|
734
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
735
|
-
wasm.tryGetLiquidityFromA(retptr, token_delta_a, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
736
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
737
|
-
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
738
|
-
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
739
|
-
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
740
|
-
if (r5) {
|
|
741
|
-
throw takeObject(r4);
|
|
742
|
-
}
|
|
743
|
-
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
744
|
-
} finally {
|
|
745
|
-
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
export function tryGetTokenAFromLiquidity(liquidity_delta, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
750
|
-
try {
|
|
751
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
752
|
-
wasm.tryGetTokenAFromLiquidity(retptr, liquidity_delta, liquidity_delta >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
753
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
754
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
755
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
756
|
-
if (r3) {
|
|
757
|
-
throw takeObject(r2);
|
|
758
|
-
}
|
|
759
|
-
return BigInt.asUintN(64, r0);
|
|
760
|
-
} finally {
|
|
761
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
export function tryGetLiquidityFromB(token_delta_b, sqrt_price_lower, sqrt_price_upper) {
|
|
766
|
-
try {
|
|
767
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
768
|
-
wasm.tryGetLiquidityFromB(retptr, token_delta_b, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
769
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
770
|
-
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
771
|
-
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
772
|
-
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
773
|
-
if (r5) {
|
|
774
|
-
throw takeObject(r4);
|
|
775
|
-
}
|
|
776
|
-
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
777
|
-
} finally {
|
|
778
|
-
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
export function tryGetTokenBFromLiquidity(liquidity_delta, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
783
|
-
try {
|
|
784
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
785
|
-
wasm.tryGetTokenBFromLiquidity(retptr, liquidity_delta, liquidity_delta >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
786
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
787
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
788
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
789
|
-
if (r3) {
|
|
790
|
-
throw takeObject(r2);
|
|
791
|
-
}
|
|
792
|
-
return BigInt.asUintN(64, r0);
|
|
793
|
-
} finally {
|
|
794
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
export function tryGetAmountsFromLiquidity(liquidity_delta, current_sqrt_price, tick_lower_index, tick_upper_index, round_up) {
|
|
799
|
-
try {
|
|
800
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
801
|
-
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);
|
|
802
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
803
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
804
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
805
|
-
if (r2) {
|
|
806
|
-
throw takeObject(r1);
|
|
807
|
-
}
|
|
808
|
-
return takeObject(r0);
|
|
809
|
-
} finally {
|
|
810
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
export function tryGetLiquidityFromAmounts(sqrt_price, sqrt_price_a_x64, sqrt_price_b_x64, amount_a, amount_b) {
|
|
815
|
-
try {
|
|
816
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
817
|
-
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);
|
|
818
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
819
|
-
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
820
|
-
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
821
|
-
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
822
|
-
if (r5) {
|
|
823
|
-
throw takeObject(r4);
|
|
981
|
+
*/
|
|
982
|
+
export function increaseLiquidityQuoteA(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
983
|
+
try {
|
|
984
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
985
|
+
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));
|
|
986
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
987
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
988
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
989
|
+
if (r2) {
|
|
990
|
+
throw takeObject(r1);
|
|
824
991
|
}
|
|
825
|
-
return (
|
|
992
|
+
return takeObject(r0);
|
|
826
993
|
} finally {
|
|
827
|
-
wasm.__wbindgen_add_to_stack_pointer(
|
|
994
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
828
995
|
}
|
|
829
996
|
}
|
|
830
997
|
|
|
831
998
|
/**
|
|
832
|
-
* Calculate
|
|
999
|
+
* Calculate the quote for increasing liquidity given a token b amount
|
|
833
1000
|
*
|
|
834
|
-
* #
|
|
835
|
-
* - `
|
|
836
|
-
* - `
|
|
837
|
-
* - `
|
|
838
|
-
* - `
|
|
839
|
-
* - `
|
|
840
|
-
* - `
|
|
1001
|
+
* # Parameters
|
|
1002
|
+
* - `token_amount_b` - The amount of token b to increase
|
|
1003
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
1004
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
1005
|
+
* - `tick_index_1` - The first tick index of the position
|
|
1006
|
+
* - `tick_index_2` - The second tick index of the position
|
|
1007
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
1008
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
841
1009
|
*
|
|
842
1010
|
* # Returns
|
|
843
|
-
* -
|
|
1011
|
+
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
844
1012
|
*/
|
|
845
|
-
export function
|
|
1013
|
+
export function increaseLiquidityQuoteB(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
846
1014
|
try {
|
|
847
1015
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
848
|
-
wasm.
|
|
1016
|
+
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));
|
|
849
1017
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
850
1018
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
851
1019
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -858,11 +1026,6 @@ export function collectFeesQuote(fusion_pool, position, tick_lower, tick_upper,
|
|
|
858
1026
|
}
|
|
859
1027
|
}
|
|
860
1028
|
|
|
861
|
-
export function limitOrderFee(fusion_pool) {
|
|
862
|
-
const ret = wasm.limitOrderFee(addHeapObject(fusion_pool));
|
|
863
|
-
return ret;
|
|
864
|
-
}
|
|
865
|
-
|
|
866
1029
|
/**
|
|
867
1030
|
* Calculate the amount A delta between two sqrt_prices
|
|
868
1031
|
*
|
|
@@ -1232,201 +1395,37 @@ export function decreaseLimitOrderQuote(fusion_pool, limit_order, tick, amount,
|
|
|
1232
1395
|
}
|
|
1233
1396
|
|
|
1234
1397
|
/**
|
|
1235
|
-
*
|
|
1236
|
-
*
|
|
1237
|
-
* # Arguments
|
|
1238
|
-
* * `bundle` - The bundle to check
|
|
1239
|
-
*
|
|
1240
|
-
* # Returns
|
|
1241
|
-
* * `u32` - The first unoccupied position (None if full)
|
|
1242
|
-
*/
|
|
1243
|
-
export function firstUnoccupiedPositionInBundle(bitmap) {
|
|
1244
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1245
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1246
|
-
const ret = wasm.firstUnoccupiedPositionInBundle(ptr0, len0);
|
|
1247
|
-
return ret === 0x100000001 ? undefined : ret;
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
/**
|
|
1251
|
-
* Check whether a position bundle is full
|
|
1252
|
-
* A position bundle can contain 256 positions
|
|
1253
|
-
*
|
|
1254
|
-
* # Arguments
|
|
1255
|
-
* * `bundle` - The bundle to check
|
|
1256
|
-
*
|
|
1257
|
-
* # Returns
|
|
1258
|
-
* * `bool` - Whether the bundle is full
|
|
1259
|
-
*/
|
|
1260
|
-
export function isPositionBundleFull(bitmap) {
|
|
1261
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1262
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1263
|
-
const ret = wasm.isPositionBundleFull(ptr0, len0);
|
|
1264
|
-
return ret !== 0;
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
/**
|
|
1268
|
-
* Check whether a position bundle is empty
|
|
1269
|
-
*
|
|
1270
|
-
* # Arguments
|
|
1271
|
-
* * `bundle` - The bundle to check
|
|
1272
|
-
*
|
|
1273
|
-
* # Returns
|
|
1274
|
-
* * `bool` - Whether the bundle is empty
|
|
1275
|
-
*/
|
|
1276
|
-
export function isPositionBundleEmpty(bitmap) {
|
|
1277
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1278
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1279
|
-
const ret = wasm.isPositionBundleEmpty(ptr0, len0);
|
|
1280
|
-
return ret !== 0;
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
/**
|
|
1284
|
-
* Check if a position is in range.
|
|
1285
|
-
* When a position is in range it is earning fees and rewards
|
|
1286
|
-
*
|
|
1287
|
-
* # Parameters
|
|
1288
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1289
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1290
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1291
|
-
*
|
|
1292
|
-
* # Returns
|
|
1293
|
-
* - A boolean value indicating if the position is in range
|
|
1294
|
-
*/
|
|
1295
|
-
export function isPositionInRange(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1296
|
-
const ret = wasm.isPositionInRange(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
1297
|
-
return ret !== 0;
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
/**
|
|
1301
|
-
* Calculate the status of a position
|
|
1302
|
-
* The status can be one of three values:
|
|
1303
|
-
* - InRange: The position is in range
|
|
1304
|
-
* - BelowRange: The position is below the range
|
|
1305
|
-
* - AboveRange: The position is above the range
|
|
1306
|
-
*
|
|
1307
|
-
* # Parameters
|
|
1308
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1309
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1310
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1311
|
-
*
|
|
1312
|
-
* # Returns
|
|
1313
|
-
* - A PositionStatus enum value indicating the status of the position
|
|
1314
|
-
*/
|
|
1315
|
-
export function positionStatus(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1316
|
-
const ret = wasm.positionStatus(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
1317
|
-
return takeObject(ret);
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
/**
|
|
1321
|
-
* Calculate the token_a / token_b ratio of a (ficticious) position
|
|
1322
|
-
*
|
|
1323
|
-
* # Parameters
|
|
1324
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1325
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1326
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1327
|
-
*
|
|
1328
|
-
* # Returns
|
|
1329
|
-
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
1330
|
-
*/
|
|
1331
|
-
export function positionRatioX64(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1332
|
-
const ret = wasm.positionRatioX64(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
1333
|
-
return takeObject(ret);
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
/**
|
|
1337
|
-
* Convert a price into a sqrt priceX64
|
|
1338
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1339
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1398
|
+
* Calculate fees owed for a position
|
|
1340
1399
|
*
|
|
1341
|
-
* #
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
1400
|
+
* # Paramters
|
|
1401
|
+
* - `fusion_pool`: The fusion_pool state
|
|
1402
|
+
* - `position`: The position state
|
|
1403
|
+
* - `tick_lower`: The lower tick state
|
|
1404
|
+
* - `tick_upper`: The upper tick state
|
|
1405
|
+
* - `transfer_fee_a`: The transfer fee for token A
|
|
1406
|
+
* - `transfer_fee_b`: The transfer fee for token B
|
|
1345
1407
|
*
|
|
1346
1408
|
* # Returns
|
|
1347
|
-
*
|
|
1409
|
+
* - `CollectFeesQuote`: The fees owed for token A and token B
|
|
1348
1410
|
*/
|
|
1349
|
-
export function
|
|
1411
|
+
export function collectFeesQuote(fusion_pool, position, tick_lower, tick_upper, transfer_fee_a, transfer_fee_b) {
|
|
1350
1412
|
try {
|
|
1351
1413
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1352
|
-
wasm.
|
|
1353
|
-
var r0 = getDataViewMemory0().
|
|
1354
|
-
var
|
|
1355
|
-
|
|
1414
|
+
wasm.collectFeesQuote(retptr, addHeapObject(fusion_pool), addHeapObject(position), addHeapObject(tick_lower), addHeapObject(tick_upper), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1415
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1416
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1417
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1418
|
+
if (r2) {
|
|
1419
|
+
throw takeObject(r1);
|
|
1420
|
+
}
|
|
1421
|
+
return takeObject(r0);
|
|
1356
1422
|
} finally {
|
|
1357
1423
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1358
1424
|
}
|
|
1359
1425
|
}
|
|
1360
1426
|
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1364
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1365
|
-
*
|
|
1366
|
-
* # Parameters
|
|
1367
|
-
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
1368
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1369
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1370
|
-
*
|
|
1371
|
-
* # Returns
|
|
1372
|
-
* * `f64` - The decimal price
|
|
1373
|
-
*/
|
|
1374
|
-
export function sqrtPriceToPrice(sqrt_price, decimals_a, decimals_b) {
|
|
1375
|
-
const ret = wasm.sqrtPriceToPrice(sqrt_price, sqrt_price >> BigInt(64), decimals_a, decimals_b);
|
|
1376
|
-
return ret;
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
/**
|
|
1380
|
-
* Invert a price
|
|
1381
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1382
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1383
|
-
*
|
|
1384
|
-
* # Parameters
|
|
1385
|
-
* * `price` - The price to invert
|
|
1386
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1387
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1388
|
-
*
|
|
1389
|
-
* # Returns
|
|
1390
|
-
* * `f64` - The inverted price
|
|
1391
|
-
*/
|
|
1392
|
-
export function invertPrice(price, decimals_a, decimals_b) {
|
|
1393
|
-
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
1394
|
-
return ret;
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
/**
|
|
1398
|
-
* Convert a tick index into a price
|
|
1399
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1400
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1401
|
-
*
|
|
1402
|
-
* # Parameters
|
|
1403
|
-
* * `tick_index` - The tick index to convert
|
|
1404
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1405
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1406
|
-
*
|
|
1407
|
-
* # Returns
|
|
1408
|
-
* * `f64` - The decimal price
|
|
1409
|
-
*/
|
|
1410
|
-
export function tickIndexToPrice(tick_index, decimals_a, decimals_b) {
|
|
1411
|
-
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
1412
|
-
return ret;
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
/**
|
|
1416
|
-
* Convert a price into a tick index
|
|
1417
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1418
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1419
|
-
*
|
|
1420
|
-
* # Parameters
|
|
1421
|
-
* * `price` - The price to convert
|
|
1422
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
1423
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
1424
|
-
*
|
|
1425
|
-
* # Returns
|
|
1426
|
-
* * `i32` - The tick index
|
|
1427
|
-
*/
|
|
1428
|
-
export function priceToTickIndex(price, decimals_a, decimals_b) {
|
|
1429
|
-
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
1427
|
+
export function limitOrderFee(fusion_pool) {
|
|
1428
|
+
const ret = wasm.limitOrderFee(addHeapObject(fusion_pool));
|
|
1430
1429
|
return ret;
|
|
1431
1430
|
}
|
|
1432
1431
|
|
|
@@ -1550,6 +1549,18 @@ export function _INVALID_SQRT_PRICE_LIMIT_DIRECTION() {
|
|
|
1550
1549
|
}
|
|
1551
1550
|
}
|
|
1552
1551
|
|
|
1552
|
+
export function _INVALID_RANGE_BOUNDS() {
|
|
1553
|
+
try {
|
|
1554
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1555
|
+
wasm._INVALID_RANGE_BOUNDS(retptr);
|
|
1556
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1557
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1558
|
+
return getStringFromWasm0(r0, r1);
|
|
1559
|
+
} finally {
|
|
1560
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1553
1564
|
export function _ZERO_TRADABLE_AMOUNT() {
|
|
1554
1565
|
try {
|
|
1555
1566
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|