@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
|
@@ -252,6 +252,204 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
252
252
|
WASM_VECTOR_LEN = arg.length;
|
|
253
253
|
return ptr;
|
|
254
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Get the first unoccupied position in a bundle
|
|
257
|
+
*
|
|
258
|
+
* # Arguments
|
|
259
|
+
* * `bundle` - The bundle to check
|
|
260
|
+
*
|
|
261
|
+
* # Returns
|
|
262
|
+
* * `u32` - The first unoccupied position (None if full)
|
|
263
|
+
*/
|
|
264
|
+
exports.firstUnoccupiedPositionInBundle = function(bitmap) {
|
|
265
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
266
|
+
const len0 = WASM_VECTOR_LEN;
|
|
267
|
+
const ret = wasm.firstUnoccupiedPositionInBundle(ptr0, len0);
|
|
268
|
+
return ret === 0x100000001 ? undefined : ret;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Check whether a position bundle is full
|
|
273
|
+
* A position bundle can contain 256 positions
|
|
274
|
+
*
|
|
275
|
+
* # Arguments
|
|
276
|
+
* * `bundle` - The bundle to check
|
|
277
|
+
*
|
|
278
|
+
* # Returns
|
|
279
|
+
* * `bool` - Whether the bundle is full
|
|
280
|
+
*/
|
|
281
|
+
exports.isPositionBundleFull = function(bitmap) {
|
|
282
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
283
|
+
const len0 = WASM_VECTOR_LEN;
|
|
284
|
+
const ret = wasm.isPositionBundleFull(ptr0, len0);
|
|
285
|
+
return ret !== 0;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Check whether a position bundle is empty
|
|
290
|
+
*
|
|
291
|
+
* # Arguments
|
|
292
|
+
* * `bundle` - The bundle to check
|
|
293
|
+
*
|
|
294
|
+
* # Returns
|
|
295
|
+
* * `bool` - Whether the bundle is empty
|
|
296
|
+
*/
|
|
297
|
+
exports.isPositionBundleEmpty = function(bitmap) {
|
|
298
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
299
|
+
const len0 = WASM_VECTOR_LEN;
|
|
300
|
+
const ret = wasm.isPositionBundleEmpty(ptr0, len0);
|
|
301
|
+
return ret !== 0;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Check if a position is in range.
|
|
306
|
+
* When a position is in range it is earning fees and rewards
|
|
307
|
+
*
|
|
308
|
+
* # Parameters
|
|
309
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
310
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
311
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
312
|
+
*
|
|
313
|
+
* # Returns
|
|
314
|
+
* - A boolean value indicating if the position is in range
|
|
315
|
+
*/
|
|
316
|
+
exports.isPositionInRange = function(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
317
|
+
const ret = wasm.isPositionInRange(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
318
|
+
return ret !== 0;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Calculate the status of a position
|
|
323
|
+
* The status can be one of three values:
|
|
324
|
+
* - InRange: The position is in range
|
|
325
|
+
* - BelowRange: The position is below the range
|
|
326
|
+
* - AboveRange: The position is above the range
|
|
327
|
+
*
|
|
328
|
+
* # Parameters
|
|
329
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
330
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
331
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
332
|
+
*
|
|
333
|
+
* # Returns
|
|
334
|
+
* - A PositionStatus enum value indicating the status of the position
|
|
335
|
+
*/
|
|
336
|
+
exports.positionStatus = function(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
337
|
+
const ret = wasm.positionStatus(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
338
|
+
return takeObject(ret);
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Calculate the token_a / token_b ratio of a (ficticious) position
|
|
343
|
+
*
|
|
344
|
+
* # Parameters
|
|
345
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
346
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
347
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
348
|
+
*
|
|
349
|
+
* # Returns
|
|
350
|
+
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
351
|
+
*/
|
|
352
|
+
exports.positionRatioX64 = function(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
353
|
+
const ret = wasm.positionRatioX64(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
354
|
+
return takeObject(ret);
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Convert a price into a sqrt priceX64
|
|
359
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
360
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
361
|
+
*
|
|
362
|
+
* # Parameters
|
|
363
|
+
* * `price` - The price to convert
|
|
364
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
365
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
366
|
+
*
|
|
367
|
+
* # Returns
|
|
368
|
+
* * `u128` - The sqrt priceX64
|
|
369
|
+
*/
|
|
370
|
+
exports.priceToSqrtPrice = function(price, decimals_a, decimals_b) {
|
|
371
|
+
try {
|
|
372
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
373
|
+
wasm.priceToSqrtPrice(retptr, price, decimals_a, decimals_b);
|
|
374
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
375
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
376
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
377
|
+
} finally {
|
|
378
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Convert a sqrt priceX64 into a tick index
|
|
384
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
385
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
386
|
+
*
|
|
387
|
+
* # Parameters
|
|
388
|
+
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
389
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
390
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
391
|
+
*
|
|
392
|
+
* # Returns
|
|
393
|
+
* * `f64` - The decimal price
|
|
394
|
+
*/
|
|
395
|
+
exports.sqrtPriceToPrice = function(sqrt_price, decimals_a, decimals_b) {
|
|
396
|
+
const ret = wasm.sqrtPriceToPrice(sqrt_price, sqrt_price >> BigInt(64), decimals_a, decimals_b);
|
|
397
|
+
return ret;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Invert a price
|
|
402
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
403
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
404
|
+
*
|
|
405
|
+
* # Parameters
|
|
406
|
+
* * `price` - The price to invert
|
|
407
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
408
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
409
|
+
*
|
|
410
|
+
* # Returns
|
|
411
|
+
* * `f64` - The inverted price
|
|
412
|
+
*/
|
|
413
|
+
exports.invertPrice = function(price, decimals_a, decimals_b) {
|
|
414
|
+
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
415
|
+
return ret;
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Convert a tick index into a price
|
|
420
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
421
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
422
|
+
*
|
|
423
|
+
* # Parameters
|
|
424
|
+
* * `tick_index` - The tick index to convert
|
|
425
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
426
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
427
|
+
*
|
|
428
|
+
* # Returns
|
|
429
|
+
* * `f64` - The decimal price
|
|
430
|
+
*/
|
|
431
|
+
exports.tickIndexToPrice = function(tick_index, decimals_a, decimals_b) {
|
|
432
|
+
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
433
|
+
return ret;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Convert a price into a tick index
|
|
438
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
439
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
440
|
+
*
|
|
441
|
+
* # Parameters
|
|
442
|
+
* * `price` - The price to convert
|
|
443
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
444
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
445
|
+
*
|
|
446
|
+
* # Returns
|
|
447
|
+
* * `i32` - The tick index
|
|
448
|
+
*/
|
|
449
|
+
exports.priceToTickIndex = function(price, decimals_a, decimals_b) {
|
|
450
|
+
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
451
|
+
return ret;
|
|
452
|
+
};
|
|
255
453
|
|
|
256
454
|
exports._POSITION_BUNDLE_SIZE = function() {
|
|
257
455
|
const ret = wasm._POSITION_BUNDLE_SIZE();
|
|
@@ -533,6 +731,105 @@ exports.getTickIndexInArray = function(tick_index, tick_array_start_index, tick_
|
|
|
533
731
|
}
|
|
534
732
|
};
|
|
535
733
|
|
|
734
|
+
exports.tryGetLiquidityFromAmountA = function(amount_a, sqrt_price_lower, sqrt_price_upper) {
|
|
735
|
+
try {
|
|
736
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
737
|
+
wasm.tryGetLiquidityFromAmountA(retptr, amount_a, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
738
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
739
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
740
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
741
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
742
|
+
if (r5) {
|
|
743
|
+
throw takeObject(r4);
|
|
744
|
+
}
|
|
745
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
746
|
+
} finally {
|
|
747
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
exports.tryGetAmountAFromLiquidity = function(liquidity, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
752
|
+
try {
|
|
753
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
754
|
+
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);
|
|
755
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
756
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
757
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
758
|
+
if (r3) {
|
|
759
|
+
throw takeObject(r2);
|
|
760
|
+
}
|
|
761
|
+
return BigInt.asUintN(64, r0);
|
|
762
|
+
} finally {
|
|
763
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
exports.tryGetLiquidityFromAmountB = function(amount_b, sqrt_price_lower, sqrt_price_upper) {
|
|
768
|
+
try {
|
|
769
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
770
|
+
wasm.tryGetLiquidityFromAmountB(retptr, amount_b, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
771
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
772
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
773
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
774
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
775
|
+
if (r5) {
|
|
776
|
+
throw takeObject(r4);
|
|
777
|
+
}
|
|
778
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
779
|
+
} finally {
|
|
780
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
exports.tryGetAmountBFromLiquidity = function(liquidity, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
785
|
+
try {
|
|
786
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
787
|
+
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);
|
|
788
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
789
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
790
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
791
|
+
if (r3) {
|
|
792
|
+
throw takeObject(r2);
|
|
793
|
+
}
|
|
794
|
+
return BigInt.asUintN(64, r0);
|
|
795
|
+
} finally {
|
|
796
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
exports.tryGetAmountsFromLiquidity = function(liquidity, sqrt_price, tick_lower_index, tick_upper_index, round_up) {
|
|
801
|
+
try {
|
|
802
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
803
|
+
wasm.tryGetAmountsFromLiquidity(retptr, liquidity, liquidity >> BigInt(64), sqrt_price, sqrt_price >> BigInt(64), tick_lower_index, tick_upper_index, round_up);
|
|
804
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
805
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
806
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
807
|
+
if (r2) {
|
|
808
|
+
throw takeObject(r1);
|
|
809
|
+
}
|
|
810
|
+
return takeObject(r0);
|
|
811
|
+
} finally {
|
|
812
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
exports.tryGetLiquidityFromAmounts = function(sqrt_price, sqrt_price_lower, sqrt_price_upper, amount_a, amount_b) {
|
|
817
|
+
try {
|
|
818
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
819
|
+
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);
|
|
820
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
821
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
822
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
823
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
824
|
+
if (r5) {
|
|
825
|
+
throw takeObject(r4);
|
|
826
|
+
}
|
|
827
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
828
|
+
} finally {
|
|
829
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
|
|
536
833
|
/**
|
|
537
834
|
* Calculate the quote for decreasing liquidity
|
|
538
835
|
*
|
|
@@ -671,171 +968,42 @@ exports.increaseLiquidityQuote = function(liquidity_delta, slippage_tolerance_bp
|
|
|
671
968
|
*
|
|
672
969
|
* # Returns
|
|
673
970
|
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
674
|
-
*/
|
|
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) {
|
|
676
|
-
try {
|
|
677
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
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));
|
|
679
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
680
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
681
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
682
|
-
if (r2) {
|
|
683
|
-
throw takeObject(r1);
|
|
684
|
-
}
|
|
685
|
-
return takeObject(r0);
|
|
686
|
-
} finally {
|
|
687
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
688
|
-
}
|
|
689
|
-
};
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* Calculate the quote for increasing liquidity given a token b amount
|
|
693
|
-
*
|
|
694
|
-
* # Parameters
|
|
695
|
-
* - `token_amount_b` - The amount of token b to increase
|
|
696
|
-
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
697
|
-
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
698
|
-
* - `tick_index_1` - The first tick index of the position
|
|
699
|
-
* - `tick_index_2` - The second tick index of the position
|
|
700
|
-
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
701
|
-
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
702
|
-
*
|
|
703
|
-
* # Returns
|
|
704
|
-
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
705
|
-
*/
|
|
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) {
|
|
707
|
-
try {
|
|
708
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
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));
|
|
710
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
711
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
712
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
713
|
-
if (r2) {
|
|
714
|
-
throw takeObject(r1);
|
|
715
|
-
}
|
|
716
|
-
return takeObject(r0);
|
|
717
|
-
} finally {
|
|
718
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
|
-
|
|
722
|
-
exports.tryGetLiquidityFromA = function(token_delta_a, sqrt_price_lower, sqrt_price_upper) {
|
|
723
|
-
try {
|
|
724
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
725
|
-
wasm.tryGetLiquidityFromA(retptr, token_delta_a, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
726
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
727
|
-
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
728
|
-
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
729
|
-
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
730
|
-
if (r5) {
|
|
731
|
-
throw takeObject(r4);
|
|
732
|
-
}
|
|
733
|
-
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
734
|
-
} finally {
|
|
735
|
-
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
736
|
-
}
|
|
737
|
-
};
|
|
738
|
-
|
|
739
|
-
exports.tryGetTokenAFromLiquidity = function(liquidity_delta, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
740
|
-
try {
|
|
741
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
742
|
-
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);
|
|
743
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
744
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
745
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
746
|
-
if (r3) {
|
|
747
|
-
throw takeObject(r2);
|
|
748
|
-
}
|
|
749
|
-
return BigInt.asUintN(64, r0);
|
|
750
|
-
} finally {
|
|
751
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
752
|
-
}
|
|
753
|
-
};
|
|
754
|
-
|
|
755
|
-
exports.tryGetLiquidityFromB = function(token_delta_b, sqrt_price_lower, sqrt_price_upper) {
|
|
756
|
-
try {
|
|
757
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
758
|
-
wasm.tryGetLiquidityFromB(retptr, token_delta_b, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
759
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
760
|
-
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
761
|
-
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
762
|
-
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
763
|
-
if (r5) {
|
|
764
|
-
throw takeObject(r4);
|
|
765
|
-
}
|
|
766
|
-
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
767
|
-
} finally {
|
|
768
|
-
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
769
|
-
}
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
exports.tryGetTokenBFromLiquidity = function(liquidity_delta, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
773
|
-
try {
|
|
774
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
775
|
-
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);
|
|
776
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
777
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
778
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
779
|
-
if (r3) {
|
|
780
|
-
throw takeObject(r2);
|
|
781
|
-
}
|
|
782
|
-
return BigInt.asUintN(64, r0);
|
|
783
|
-
} finally {
|
|
784
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
785
|
-
}
|
|
786
|
-
};
|
|
787
|
-
|
|
788
|
-
exports.tryGetAmountsFromLiquidity = function(liquidity_delta, current_sqrt_price, tick_lower_index, tick_upper_index, round_up) {
|
|
789
|
-
try {
|
|
790
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
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);
|
|
792
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
793
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
794
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
795
|
-
if (r2) {
|
|
796
|
-
throw takeObject(r1);
|
|
797
|
-
}
|
|
798
|
-
return takeObject(r0);
|
|
799
|
-
} finally {
|
|
800
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
801
|
-
}
|
|
802
|
-
};
|
|
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);
|
|
971
|
+
*/
|
|
972
|
+
exports.increaseLiquidityQuoteA = function(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
973
|
+
try {
|
|
974
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
975
|
+
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));
|
|
976
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
977
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
978
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
979
|
+
if (r2) {
|
|
980
|
+
throw takeObject(r1);
|
|
814
981
|
}
|
|
815
|
-
return (
|
|
982
|
+
return takeObject(r0);
|
|
816
983
|
} finally {
|
|
817
|
-
wasm.__wbindgen_add_to_stack_pointer(
|
|
984
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
818
985
|
}
|
|
819
986
|
};
|
|
820
987
|
|
|
821
988
|
/**
|
|
822
|
-
* Calculate
|
|
989
|
+
* Calculate the quote for increasing liquidity given a token b amount
|
|
823
990
|
*
|
|
824
|
-
* #
|
|
825
|
-
* - `
|
|
826
|
-
* - `
|
|
827
|
-
* - `
|
|
828
|
-
* - `
|
|
829
|
-
* - `
|
|
830
|
-
* - `
|
|
991
|
+
* # Parameters
|
|
992
|
+
* - `token_amount_b` - The amount of token b to increase
|
|
993
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
994
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
995
|
+
* - `tick_index_1` - The first tick index of the position
|
|
996
|
+
* - `tick_index_2` - The second tick index of the position
|
|
997
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
998
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
831
999
|
*
|
|
832
1000
|
* # Returns
|
|
833
|
-
* -
|
|
1001
|
+
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
834
1002
|
*/
|
|
835
|
-
exports.
|
|
1003
|
+
exports.increaseLiquidityQuoteB = function(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
836
1004
|
try {
|
|
837
1005
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
838
|
-
wasm.
|
|
1006
|
+
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));
|
|
839
1007
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
840
1008
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
841
1009
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -848,11 +1016,6 @@ exports.collectFeesQuote = function(fusion_pool, position, tick_lower, tick_uppe
|
|
|
848
1016
|
}
|
|
849
1017
|
};
|
|
850
1018
|
|
|
851
|
-
exports.limitOrderFee = function(fusion_pool) {
|
|
852
|
-
const ret = wasm.limitOrderFee(addHeapObject(fusion_pool));
|
|
853
|
-
return ret;
|
|
854
|
-
};
|
|
855
|
-
|
|
856
1019
|
/**
|
|
857
1020
|
* Calculate the amount A delta between two sqrt_prices
|
|
858
1021
|
*
|
|
@@ -1222,201 +1385,37 @@ exports.decreaseLimitOrderQuote = function(fusion_pool, limit_order, tick, amoun
|
|
|
1222
1385
|
};
|
|
1223
1386
|
|
|
1224
1387
|
/**
|
|
1225
|
-
*
|
|
1226
|
-
*
|
|
1227
|
-
* # Arguments
|
|
1228
|
-
* * `bundle` - The bundle to check
|
|
1229
|
-
*
|
|
1230
|
-
* # Returns
|
|
1231
|
-
* * `u32` - The first unoccupied position (None if full)
|
|
1232
|
-
*/
|
|
1233
|
-
exports.firstUnoccupiedPositionInBundle = function(bitmap) {
|
|
1234
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1235
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1236
|
-
const ret = wasm.firstUnoccupiedPositionInBundle(ptr0, len0);
|
|
1237
|
-
return ret === 0x100000001 ? undefined : ret;
|
|
1238
|
-
};
|
|
1239
|
-
|
|
1240
|
-
/**
|
|
1241
|
-
* Check whether a position bundle is full
|
|
1242
|
-
* A position bundle can contain 256 positions
|
|
1243
|
-
*
|
|
1244
|
-
* # Arguments
|
|
1245
|
-
* * `bundle` - The bundle to check
|
|
1246
|
-
*
|
|
1247
|
-
* # Returns
|
|
1248
|
-
* * `bool` - Whether the bundle is full
|
|
1249
|
-
*/
|
|
1250
|
-
exports.isPositionBundleFull = function(bitmap) {
|
|
1251
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1252
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1253
|
-
const ret = wasm.isPositionBundleFull(ptr0, len0);
|
|
1254
|
-
return ret !== 0;
|
|
1255
|
-
};
|
|
1256
|
-
|
|
1257
|
-
/**
|
|
1258
|
-
* Check whether a position bundle is empty
|
|
1259
|
-
*
|
|
1260
|
-
* # Arguments
|
|
1261
|
-
* * `bundle` - The bundle to check
|
|
1262
|
-
*
|
|
1263
|
-
* # Returns
|
|
1264
|
-
* * `bool` - Whether the bundle is empty
|
|
1265
|
-
*/
|
|
1266
|
-
exports.isPositionBundleEmpty = function(bitmap) {
|
|
1267
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1268
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1269
|
-
const ret = wasm.isPositionBundleEmpty(ptr0, len0);
|
|
1270
|
-
return ret !== 0;
|
|
1271
|
-
};
|
|
1272
|
-
|
|
1273
|
-
/**
|
|
1274
|
-
* Check if a position is in range.
|
|
1275
|
-
* When a position is in range it is earning fees and rewards
|
|
1276
|
-
*
|
|
1277
|
-
* # Parameters
|
|
1278
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1279
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1280
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1281
|
-
*
|
|
1282
|
-
* # Returns
|
|
1283
|
-
* - A boolean value indicating if the position is in range
|
|
1284
|
-
*/
|
|
1285
|
-
exports.isPositionInRange = function(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);
|
|
1287
|
-
return ret !== 0;
|
|
1288
|
-
};
|
|
1289
|
-
|
|
1290
|
-
/**
|
|
1291
|
-
* Calculate the status of a position
|
|
1292
|
-
* The status can be one of three values:
|
|
1293
|
-
* - InRange: The position is in range
|
|
1294
|
-
* - BelowRange: The position is below the range
|
|
1295
|
-
* - AboveRange: The position is above the range
|
|
1296
|
-
*
|
|
1297
|
-
* # Parameters
|
|
1298
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1299
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1300
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1301
|
-
*
|
|
1302
|
-
* # Returns
|
|
1303
|
-
* - A PositionStatus enum value indicating the status of the position
|
|
1304
|
-
*/
|
|
1305
|
-
exports.positionStatus = function(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);
|
|
1307
|
-
return takeObject(ret);
|
|
1308
|
-
};
|
|
1309
|
-
|
|
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.
|
|
1388
|
+
* Calculate fees owed for a position
|
|
1330
1389
|
*
|
|
1331
|
-
* #
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1390
|
+
* # Paramters
|
|
1391
|
+
* - `fusion_pool`: The fusion_pool state
|
|
1392
|
+
* - `position`: The position state
|
|
1393
|
+
* - `tick_lower`: The lower tick state
|
|
1394
|
+
* - `tick_upper`: The upper tick state
|
|
1395
|
+
* - `transfer_fee_a`: The transfer fee for token A
|
|
1396
|
+
* - `transfer_fee_b`: The transfer fee for token B
|
|
1335
1397
|
*
|
|
1336
1398
|
* # Returns
|
|
1337
|
-
*
|
|
1399
|
+
* - `CollectFeesQuote`: The fees owed for token A and token B
|
|
1338
1400
|
*/
|
|
1339
|
-
exports.
|
|
1401
|
+
exports.collectFeesQuote = function(fusion_pool, position, tick_lower, tick_upper, transfer_fee_a, transfer_fee_b) {
|
|
1340
1402
|
try {
|
|
1341
1403
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1342
|
-
wasm.
|
|
1343
|
-
var r0 = getDataViewMemory0().
|
|
1344
|
-
var
|
|
1345
|
-
|
|
1404
|
+
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));
|
|
1405
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1406
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1407
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1408
|
+
if (r2) {
|
|
1409
|
+
throw takeObject(r1);
|
|
1410
|
+
}
|
|
1411
|
+
return takeObject(r0);
|
|
1346
1412
|
} finally {
|
|
1347
1413
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1348
1414
|
}
|
|
1349
1415
|
};
|
|
1350
1416
|
|
|
1351
|
-
|
|
1352
|
-
|
|
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);
|
|
1417
|
+
exports.limitOrderFee = function(fusion_pool) {
|
|
1418
|
+
const ret = wasm.limitOrderFee(addHeapObject(fusion_pool));
|
|
1420
1419
|
return ret;
|
|
1421
1420
|
};
|
|
1422
1421
|
|
|
@@ -1540,6 +1539,18 @@ exports._INVALID_SQRT_PRICE_LIMIT_DIRECTION = function() {
|
|
|
1540
1539
|
}
|
|
1541
1540
|
};
|
|
1542
1541
|
|
|
1542
|
+
exports._INVALID_RANGE_BOUNDS = function() {
|
|
1543
|
+
try {
|
|
1544
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1545
|
+
wasm._INVALID_RANGE_BOUNDS(retptr);
|
|
1546
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1547
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1548
|
+
return getStringFromWasm0(r0, r1);
|
|
1549
|
+
} finally {
|
|
1550
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1551
|
+
}
|
|
1552
|
+
};
|
|
1553
|
+
|
|
1543
1554
|
exports._ZERO_TRADABLE_AMOUNT = function() {
|
|
1544
1555
|
try {
|
|
1545
1556
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|