@crypticdot/defituna-core 3.4.6 → 3.4.7
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 +174 -174
- package/dist/browser/defituna_core_js_bindings_bg.js +443 -442
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +10 -10
- package/dist/nodejs/defituna_core_js_bindings.d.ts +174 -174
- package/dist/nodejs/defituna_core_js_bindings.js +443 -442
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +10 -10
- package/package.json +2 -2
|
@@ -252,204 +252,6 @@ 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
|
-
};
|
|
453
255
|
|
|
454
256
|
exports._POSITION_BUNDLE_SIZE = function() {
|
|
455
257
|
const ret = wasm._POSITION_BUNDLE_SIZE();
|
|
@@ -694,47 +496,449 @@ exports.orderTickIndexes = function(tick_index_1, tick_index_2) {
|
|
|
694
496
|
* Check if a fusion_pool is a full-range only pool.
|
|
695
497
|
*
|
|
696
498
|
* # Parameters
|
|
697
|
-
* - `tick_spacing` - A u16 integer representing the tick spacing
|
|
499
|
+
* - `tick_spacing` - A u16 integer representing the tick spacing
|
|
500
|
+
*
|
|
501
|
+
* # Returns
|
|
502
|
+
* - A boolean value indicating if the fusion_pool is a full-range only pool
|
|
503
|
+
*/
|
|
504
|
+
exports.isFullRangeOnly = function(tick_spacing) {
|
|
505
|
+
const ret = wasm.isFullRangeOnly(tick_spacing);
|
|
506
|
+
return ret !== 0;
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Get the index of a tick in a tick array.
|
|
511
|
+
*
|
|
512
|
+
* # Parameters
|
|
513
|
+
* - `tick_index` - A i32 integer representing the tick index
|
|
514
|
+
* - `tick_array_start_index` - A i32 integer representing the start tick index of the tick array
|
|
515
|
+
* - `tick_spacing` - A u16 integer representing the tick spacing
|
|
516
|
+
*
|
|
517
|
+
* # Returns
|
|
518
|
+
* - A u32 integer representing the tick index in the tick array
|
|
519
|
+
*/
|
|
520
|
+
exports.getTickIndexInArray = function(tick_index, tick_array_start_index, tick_spacing) {
|
|
521
|
+
try {
|
|
522
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
523
|
+
wasm.getTickIndexInArray(retptr, tick_index, tick_array_start_index, tick_spacing);
|
|
524
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
525
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
526
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
527
|
+
if (r2) {
|
|
528
|
+
throw takeObject(r1);
|
|
529
|
+
}
|
|
530
|
+
return r0 >>> 0;
|
|
531
|
+
} finally {
|
|
532
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Calculate the quote for decreasing liquidity
|
|
538
|
+
*
|
|
539
|
+
* # Parameters
|
|
540
|
+
* - `liquidity_delta` - The amount of liquidity to decrease
|
|
541
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
542
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
543
|
+
* - `tick_index_1` - The first tick index of the position
|
|
544
|
+
* - `tick_index_2` - The second tick index of the position
|
|
545
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
546
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
547
|
+
*
|
|
548
|
+
* # Returns
|
|
549
|
+
* - A DecreaseLiquidityQuote struct containing the estimated token amounts
|
|
550
|
+
*/
|
|
551
|
+
exports.decreaseLiquidityQuote = function(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
552
|
+
try {
|
|
553
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
554
|
+
wasm.decreaseLiquidityQuote(retptr, liquidity_delta, liquidity_delta >> BigInt(64), slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
555
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
556
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
557
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
558
|
+
if (r2) {
|
|
559
|
+
throw takeObject(r1);
|
|
560
|
+
}
|
|
561
|
+
return takeObject(r0);
|
|
562
|
+
} finally {
|
|
563
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Calculate the quote for decreasing liquidity given a token a amount
|
|
569
|
+
*
|
|
570
|
+
* # Parameters
|
|
571
|
+
* - `token_amount_a` - The amount of token a to decrease
|
|
572
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
573
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
574
|
+
* - `tick_index_1` - The first tick index of the position
|
|
575
|
+
* - `tick_index_2` - The second tick index of the position
|
|
576
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
577
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
578
|
+
*
|
|
579
|
+
* # Returns
|
|
580
|
+
* - A DecreaseLiquidityQuote struct containing the estimated token amounts
|
|
581
|
+
*/
|
|
582
|
+
exports.decreaseLiquidityQuoteA = function(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
583
|
+
try {
|
|
584
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
585
|
+
wasm.decreaseLiquidityQuoteA(retptr, token_amount_a, slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
586
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
587
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
588
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
589
|
+
if (r2) {
|
|
590
|
+
throw takeObject(r1);
|
|
591
|
+
}
|
|
592
|
+
return takeObject(r0);
|
|
593
|
+
} finally {
|
|
594
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Calculate the quote for decreasing liquidity given a token b amount
|
|
600
|
+
*
|
|
601
|
+
* # Parameters
|
|
602
|
+
* - `token_amount_b` - The amount of token b to decrease
|
|
603
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
604
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
605
|
+
* - `tick_index_1` - The first tick index of the position
|
|
606
|
+
* - `tick_index_2` - The second tick index of the position
|
|
607
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
608
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
609
|
+
*
|
|
610
|
+
* # Returns
|
|
611
|
+
* - A DecreaseLiquidityQuote struct containing the estimated token amounts
|
|
612
|
+
*/
|
|
613
|
+
exports.decreaseLiquidityQuoteB = function(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
614
|
+
try {
|
|
615
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
616
|
+
wasm.decreaseLiquidityQuoteB(retptr, token_amount_b, slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
617
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
618
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
619
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
620
|
+
if (r2) {
|
|
621
|
+
throw takeObject(r1);
|
|
622
|
+
}
|
|
623
|
+
return takeObject(r0);
|
|
624
|
+
} finally {
|
|
625
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Calculate the quote for increasing liquidity
|
|
631
|
+
*
|
|
632
|
+
* # Parameters
|
|
633
|
+
* - `liquidity_delta` - The amount of liquidity to increase
|
|
634
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
635
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
636
|
+
* - `tick_index_1` - The first tick index of the position
|
|
637
|
+
* - `tick_index_2` - The second tick index of the position
|
|
638
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
639
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
640
|
+
*
|
|
641
|
+
* # Returns
|
|
642
|
+
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
643
|
+
*/
|
|
644
|
+
exports.increaseLiquidityQuote = function(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
645
|
+
try {
|
|
646
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
647
|
+
wasm.increaseLiquidityQuote(retptr, liquidity_delta, liquidity_delta >> BigInt(64), slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
648
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
649
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
650
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
651
|
+
if (r2) {
|
|
652
|
+
throw takeObject(r1);
|
|
653
|
+
}
|
|
654
|
+
return takeObject(r0);
|
|
655
|
+
} finally {
|
|
656
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Calculate the quote for increasing liquidity given a token a amount
|
|
662
|
+
*
|
|
663
|
+
* # Parameters
|
|
664
|
+
* - `token_amount_a` - The amount of token a to increase
|
|
665
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
666
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
667
|
+
* - `tick_index_1` - The first tick index of the position
|
|
668
|
+
* - `tick_index_2` - The second tick index of the position
|
|
669
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
670
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
671
|
+
*
|
|
672
|
+
* # Returns
|
|
673
|
+
* - 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
|
+
/**
|
|
723
|
+
* Get the first unoccupied position in a bundle
|
|
724
|
+
*
|
|
725
|
+
* # Arguments
|
|
726
|
+
* * `bundle` - The bundle to check
|
|
727
|
+
*
|
|
728
|
+
* # Returns
|
|
729
|
+
* * `u32` - The first unoccupied position (None if full)
|
|
730
|
+
*/
|
|
731
|
+
exports.firstUnoccupiedPositionInBundle = function(bitmap) {
|
|
732
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
733
|
+
const len0 = WASM_VECTOR_LEN;
|
|
734
|
+
const ret = wasm.firstUnoccupiedPositionInBundle(ptr0, len0);
|
|
735
|
+
return ret === 0x100000001 ? undefined : ret;
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Check whether a position bundle is full
|
|
740
|
+
* A position bundle can contain 256 positions
|
|
741
|
+
*
|
|
742
|
+
* # Arguments
|
|
743
|
+
* * `bundle` - The bundle to check
|
|
744
|
+
*
|
|
745
|
+
* # Returns
|
|
746
|
+
* * `bool` - Whether the bundle is full
|
|
747
|
+
*/
|
|
748
|
+
exports.isPositionBundleFull = function(bitmap) {
|
|
749
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
750
|
+
const len0 = WASM_VECTOR_LEN;
|
|
751
|
+
const ret = wasm.isPositionBundleFull(ptr0, len0);
|
|
752
|
+
return ret !== 0;
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Check whether a position bundle is empty
|
|
757
|
+
*
|
|
758
|
+
* # Arguments
|
|
759
|
+
* * `bundle` - The bundle to check
|
|
760
|
+
*
|
|
761
|
+
* # Returns
|
|
762
|
+
* * `bool` - Whether the bundle is empty
|
|
763
|
+
*/
|
|
764
|
+
exports.isPositionBundleEmpty = function(bitmap) {
|
|
765
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
766
|
+
const len0 = WASM_VECTOR_LEN;
|
|
767
|
+
const ret = wasm.isPositionBundleEmpty(ptr0, len0);
|
|
768
|
+
return ret !== 0;
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Check if a position is in range.
|
|
773
|
+
* When a position is in range it is earning fees and rewards
|
|
774
|
+
*
|
|
775
|
+
* # Parameters
|
|
776
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
777
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
778
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
779
|
+
*
|
|
780
|
+
* # Returns
|
|
781
|
+
* - A boolean value indicating if the position is in range
|
|
782
|
+
*/
|
|
783
|
+
exports.isPositionInRange = function(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
784
|
+
const ret = wasm.isPositionInRange(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
785
|
+
return ret !== 0;
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Calculate the status of a position
|
|
790
|
+
* The status can be one of three values:
|
|
791
|
+
* - InRange: The position is in range
|
|
792
|
+
* - BelowRange: The position is below the range
|
|
793
|
+
* - AboveRange: The position is above the range
|
|
794
|
+
*
|
|
795
|
+
* # Parameters
|
|
796
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
797
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
798
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
799
|
+
*
|
|
800
|
+
* # Returns
|
|
801
|
+
* - A PositionStatus enum value indicating the status of the position
|
|
802
|
+
*/
|
|
803
|
+
exports.positionStatus = function(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
804
|
+
const ret = wasm.positionStatus(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
805
|
+
return takeObject(ret);
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Calculate the token_a / token_b ratio of a (ficticious) position
|
|
810
|
+
*
|
|
811
|
+
* # Parameters
|
|
812
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
813
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
814
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
815
|
+
*
|
|
816
|
+
* # Returns
|
|
817
|
+
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
818
|
+
*/
|
|
819
|
+
exports.positionRatioX64 = function(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
820
|
+
const ret = wasm.positionRatioX64(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
821
|
+
return takeObject(ret);
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Convert a price into a sqrt priceX64
|
|
826
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
827
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
828
|
+
*
|
|
829
|
+
* # Parameters
|
|
830
|
+
* * `price` - The price to convert
|
|
831
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
832
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
833
|
+
*
|
|
834
|
+
* # Returns
|
|
835
|
+
* * `u128` - The sqrt priceX64
|
|
836
|
+
*/
|
|
837
|
+
exports.priceToSqrtPrice = function(price, decimals_a, decimals_b) {
|
|
838
|
+
try {
|
|
839
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
840
|
+
wasm.priceToSqrtPrice(retptr, price, decimals_a, decimals_b);
|
|
841
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
842
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
843
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
844
|
+
} finally {
|
|
845
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Convert a sqrt priceX64 into a tick index
|
|
851
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
852
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
853
|
+
*
|
|
854
|
+
* # Parameters
|
|
855
|
+
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
856
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
857
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
858
|
+
*
|
|
859
|
+
* # Returns
|
|
860
|
+
* * `f64` - The decimal price
|
|
861
|
+
*/
|
|
862
|
+
exports.sqrtPriceToPrice = function(sqrt_price, decimals_a, decimals_b) {
|
|
863
|
+
const ret = wasm.sqrtPriceToPrice(sqrt_price, sqrt_price >> BigInt(64), decimals_a, decimals_b);
|
|
864
|
+
return ret;
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Invert a price
|
|
869
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
870
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
871
|
+
*
|
|
872
|
+
* # Parameters
|
|
873
|
+
* * `price` - The price to invert
|
|
874
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
875
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
876
|
+
*
|
|
877
|
+
* # Returns
|
|
878
|
+
* * `f64` - The inverted price
|
|
879
|
+
*/
|
|
880
|
+
exports.invertPrice = function(price, decimals_a, decimals_b) {
|
|
881
|
+
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
882
|
+
return ret;
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Convert a tick index into a price
|
|
887
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
888
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
889
|
+
*
|
|
890
|
+
* # Parameters
|
|
891
|
+
* * `tick_index` - The tick index to convert
|
|
892
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
893
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
698
894
|
*
|
|
699
895
|
* # Returns
|
|
700
|
-
*
|
|
896
|
+
* * `f64` - The decimal price
|
|
701
897
|
*/
|
|
702
|
-
exports.
|
|
703
|
-
const ret = wasm.
|
|
704
|
-
return ret
|
|
898
|
+
exports.tickIndexToPrice = function(tick_index, decimals_a, decimals_b) {
|
|
899
|
+
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
900
|
+
return ret;
|
|
705
901
|
};
|
|
706
902
|
|
|
707
903
|
/**
|
|
708
|
-
*
|
|
904
|
+
* Convert a price into a tick index
|
|
905
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
906
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
709
907
|
*
|
|
710
908
|
* # Parameters
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
909
|
+
* * `price` - The price to convert
|
|
910
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
911
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
714
912
|
*
|
|
715
913
|
* # Returns
|
|
716
|
-
*
|
|
914
|
+
* * `i32` - The tick index
|
|
717
915
|
*/
|
|
718
|
-
exports.
|
|
916
|
+
exports.priceToTickIndex = function(price, decimals_a, decimals_b) {
|
|
917
|
+
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
918
|
+
return ret;
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
exports.getLiquidityFromAmountA = function(amount_a, sqrt_price_lower, sqrt_price_upper) {
|
|
719
922
|
try {
|
|
720
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-
|
|
721
|
-
wasm.
|
|
722
|
-
var r0 = getDataViewMemory0().
|
|
723
|
-
var
|
|
724
|
-
var
|
|
725
|
-
|
|
726
|
-
|
|
923
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
924
|
+
wasm.getLiquidityFromAmountA(retptr, amount_a, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
925
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
926
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
927
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
928
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
929
|
+
if (r5) {
|
|
930
|
+
throw takeObject(r4);
|
|
727
931
|
}
|
|
728
|
-
return r0
|
|
932
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
729
933
|
} finally {
|
|
730
|
-
wasm.__wbindgen_add_to_stack_pointer(
|
|
934
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
731
935
|
}
|
|
732
936
|
};
|
|
733
937
|
|
|
734
|
-
exports.
|
|
938
|
+
exports.getLiquidityFromAmountB = function(amount_b, sqrt_price_lower, sqrt_price_upper) {
|
|
735
939
|
try {
|
|
736
940
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
737
|
-
wasm.
|
|
941
|
+
wasm.getLiquidityFromAmountB(retptr, amount_b, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
738
942
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
739
943
|
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
740
944
|
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
@@ -748,10 +952,10 @@ exports.tryGetLiquidityFromAmountA = function(amount_a, sqrt_price_lower, sqrt_p
|
|
|
748
952
|
}
|
|
749
953
|
};
|
|
750
954
|
|
|
751
|
-
exports.
|
|
955
|
+
exports.getAmountAFromLiquidity = function(liquidity, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
752
956
|
try {
|
|
753
957
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
754
|
-
wasm.
|
|
958
|
+
wasm.getAmountAFromLiquidity(retptr, liquidity, liquidity >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
755
959
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
756
960
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
757
961
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -764,27 +968,10 @@ exports.tryGetAmountAFromLiquidity = function(liquidity, sqrt_price_lower, sqrt_
|
|
|
764
968
|
}
|
|
765
969
|
};
|
|
766
970
|
|
|
767
|
-
exports.
|
|
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) {
|
|
971
|
+
exports.getAmountBFromLiquidity = function(liquidity, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
785
972
|
try {
|
|
786
973
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
787
|
-
wasm.
|
|
974
|
+
wasm.getAmountBFromLiquidity(retptr, liquidity, liquidity >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
788
975
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
789
976
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
790
977
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -797,10 +984,10 @@ exports.tryGetAmountBFromLiquidity = function(liquidity, sqrt_price_lower, sqrt_
|
|
|
797
984
|
}
|
|
798
985
|
};
|
|
799
986
|
|
|
800
|
-
exports.
|
|
987
|
+
exports.getAmountsFromLiquidity = function(liquidity, sqrt_price, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
801
988
|
try {
|
|
802
989
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
803
|
-
wasm.
|
|
990
|
+
wasm.getAmountsFromLiquidity(retptr, liquidity, liquidity >> BigInt(64), sqrt_price, sqrt_price >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
804
991
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
805
992
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
806
993
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -813,10 +1000,10 @@ exports.tryGetAmountsFromLiquidity = function(liquidity, sqrt_price, tick_lower_
|
|
|
813
1000
|
}
|
|
814
1001
|
};
|
|
815
1002
|
|
|
816
|
-
exports.
|
|
1003
|
+
exports.getLiquidityFromAmounts = function(sqrt_price, sqrt_price_lower, sqrt_price_upper, amount_a, amount_b) {
|
|
817
1004
|
try {
|
|
818
1005
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
819
|
-
wasm.
|
|
1006
|
+
wasm.getLiquidityFromAmounts(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
1007
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
821
1008
|
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
822
1009
|
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
@@ -830,192 +1017,6 @@ exports.tryGetLiquidityFromAmounts = function(sqrt_price, sqrt_price_lower, sqrt
|
|
|
830
1017
|
}
|
|
831
1018
|
};
|
|
832
1019
|
|
|
833
|
-
/**
|
|
834
|
-
* Calculate the quote for decreasing liquidity
|
|
835
|
-
*
|
|
836
|
-
* # Parameters
|
|
837
|
-
* - `liquidity_delta` - The amount of liquidity to decrease
|
|
838
|
-
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
839
|
-
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
840
|
-
* - `tick_index_1` - The first tick index of the position
|
|
841
|
-
* - `tick_index_2` - The second tick index of the position
|
|
842
|
-
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
843
|
-
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
844
|
-
*
|
|
845
|
-
* # Returns
|
|
846
|
-
* - A DecreaseLiquidityQuote struct containing the estimated token amounts
|
|
847
|
-
*/
|
|
848
|
-
exports.decreaseLiquidityQuote = function(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
849
|
-
try {
|
|
850
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
851
|
-
wasm.decreaseLiquidityQuote(retptr, liquidity_delta, liquidity_delta >> BigInt(64), slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
852
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
853
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
854
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
855
|
-
if (r2) {
|
|
856
|
-
throw takeObject(r1);
|
|
857
|
-
}
|
|
858
|
-
return takeObject(r0);
|
|
859
|
-
} finally {
|
|
860
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
861
|
-
}
|
|
862
|
-
};
|
|
863
|
-
|
|
864
|
-
/**
|
|
865
|
-
* Calculate the quote for decreasing liquidity given a token a amount
|
|
866
|
-
*
|
|
867
|
-
* # Parameters
|
|
868
|
-
* - `token_amount_a` - The amount of token a to decrease
|
|
869
|
-
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
870
|
-
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
871
|
-
* - `tick_index_1` - The first tick index of the position
|
|
872
|
-
* - `tick_index_2` - The second tick index of the position
|
|
873
|
-
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
874
|
-
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
875
|
-
*
|
|
876
|
-
* # Returns
|
|
877
|
-
* - A DecreaseLiquidityQuote struct containing the estimated token amounts
|
|
878
|
-
*/
|
|
879
|
-
exports.decreaseLiquidityQuoteA = function(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
880
|
-
try {
|
|
881
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
882
|
-
wasm.decreaseLiquidityQuoteA(retptr, token_amount_a, slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
883
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
884
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
885
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
886
|
-
if (r2) {
|
|
887
|
-
throw takeObject(r1);
|
|
888
|
-
}
|
|
889
|
-
return takeObject(r0);
|
|
890
|
-
} finally {
|
|
891
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
892
|
-
}
|
|
893
|
-
};
|
|
894
|
-
|
|
895
|
-
/**
|
|
896
|
-
* Calculate the quote for decreasing liquidity given a token b amount
|
|
897
|
-
*
|
|
898
|
-
* # Parameters
|
|
899
|
-
* - `token_amount_b` - The amount of token b to decrease
|
|
900
|
-
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
901
|
-
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
902
|
-
* - `tick_index_1` - The first tick index of the position
|
|
903
|
-
* - `tick_index_2` - The second tick index of the position
|
|
904
|
-
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
905
|
-
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
906
|
-
*
|
|
907
|
-
* # Returns
|
|
908
|
-
* - A DecreaseLiquidityQuote struct containing the estimated token amounts
|
|
909
|
-
*/
|
|
910
|
-
exports.decreaseLiquidityQuoteB = function(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
911
|
-
try {
|
|
912
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
913
|
-
wasm.decreaseLiquidityQuoteB(retptr, token_amount_b, slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
914
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
915
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
916
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
917
|
-
if (r2) {
|
|
918
|
-
throw takeObject(r1);
|
|
919
|
-
}
|
|
920
|
-
return takeObject(r0);
|
|
921
|
-
} finally {
|
|
922
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
|
-
|
|
926
|
-
/**
|
|
927
|
-
* Calculate the quote for increasing liquidity
|
|
928
|
-
*
|
|
929
|
-
* # Parameters
|
|
930
|
-
* - `liquidity_delta` - The amount of liquidity to increase
|
|
931
|
-
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
932
|
-
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
933
|
-
* - `tick_index_1` - The first tick index of the position
|
|
934
|
-
* - `tick_index_2` - The second tick index of the position
|
|
935
|
-
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
936
|
-
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
937
|
-
*
|
|
938
|
-
* # Returns
|
|
939
|
-
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
940
|
-
*/
|
|
941
|
-
exports.increaseLiquidityQuote = function(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
942
|
-
try {
|
|
943
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
944
|
-
wasm.increaseLiquidityQuote(retptr, liquidity_delta, liquidity_delta >> BigInt(64), slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
945
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
946
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
947
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
948
|
-
if (r2) {
|
|
949
|
-
throw takeObject(r1);
|
|
950
|
-
}
|
|
951
|
-
return takeObject(r0);
|
|
952
|
-
} finally {
|
|
953
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
954
|
-
}
|
|
955
|
-
};
|
|
956
|
-
|
|
957
|
-
/**
|
|
958
|
-
* Calculate the quote for increasing liquidity given a token a amount
|
|
959
|
-
*
|
|
960
|
-
* # Parameters
|
|
961
|
-
* - `token_amount_a` - The amount of token a to increase
|
|
962
|
-
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
963
|
-
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
964
|
-
* - `tick_index_1` - The first tick index of the position
|
|
965
|
-
* - `tick_index_2` - The second tick index of the position
|
|
966
|
-
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
967
|
-
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
968
|
-
*
|
|
969
|
-
* # Returns
|
|
970
|
-
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
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);
|
|
981
|
-
}
|
|
982
|
-
return takeObject(r0);
|
|
983
|
-
} finally {
|
|
984
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
985
|
-
}
|
|
986
|
-
};
|
|
987
|
-
|
|
988
|
-
/**
|
|
989
|
-
* Calculate the quote for increasing liquidity given a token b amount
|
|
990
|
-
*
|
|
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
|
|
999
|
-
*
|
|
1000
|
-
* # Returns
|
|
1001
|
-
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
1002
|
-
*/
|
|
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) {
|
|
1004
|
-
try {
|
|
1005
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
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));
|
|
1007
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1008
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1009
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1010
|
-
if (r2) {
|
|
1011
|
-
throw takeObject(r1);
|
|
1012
|
-
}
|
|
1013
|
-
return takeObject(r0);
|
|
1014
|
-
} finally {
|
|
1015
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1016
|
-
}
|
|
1017
|
-
};
|
|
1018
|
-
|
|
1019
1020
|
/**
|
|
1020
1021
|
* Calculate the amount A delta between two sqrt_prices
|
|
1021
1022
|
*
|
|
@@ -1987,12 +1988,12 @@ exports.solana_program_init = function() {
|
|
|
1987
1988
|
wasm.solana_program_init();
|
|
1988
1989
|
};
|
|
1989
1990
|
|
|
1990
|
-
function
|
|
1991
|
-
wasm.
|
|
1991
|
+
function __wasm_bindgen_func_elem_3153(arg0, arg1) {
|
|
1992
|
+
wasm.__wasm_bindgen_func_elem_3153(arg0, arg1);
|
|
1992
1993
|
}
|
|
1993
1994
|
|
|
1994
|
-
function
|
|
1995
|
-
wasm.
|
|
1995
|
+
function __wasm_bindgen_func_elem_3259(arg0, arg1, arg2) {
|
|
1996
|
+
wasm.__wasm_bindgen_func_elem_3259(arg0, arg1, addHeapObject(arg2));
|
|
1996
1997
|
}
|
|
1997
1998
|
|
|
1998
1999
|
function __wasm_bindgen_func_elem_494(arg0, arg1, arg2, arg3) {
|
|
@@ -3431,15 +3432,9 @@ exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
|
3431
3432
|
return addHeapObject(ret);
|
|
3432
3433
|
};
|
|
3433
3434
|
|
|
3434
|
-
exports.__wbindgen_cast_49dae81bf02b4884 = function(arg0, arg1) {
|
|
3435
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx: 369, function: Function { arguments: [Externref], shim_idx: 380, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3436
|
-
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3261, __wasm_bindgen_func_elem_3288);
|
|
3437
|
-
return addHeapObject(ret);
|
|
3438
|
-
};
|
|
3439
|
-
|
|
3440
3435
|
exports.__wbindgen_cast_7879599246031d81 = function(arg0, arg1) {
|
|
3441
3436
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 343, function: Function { arguments: [], shim_idx: 344, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3442
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
3437
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3149, __wasm_bindgen_func_elem_3153);
|
|
3443
3438
|
return addHeapObject(ret);
|
|
3444
3439
|
};
|
|
3445
3440
|
|
|
@@ -3455,6 +3450,12 @@ exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
|
3455
3450
|
return addHeapObject(ret);
|
|
3456
3451
|
};
|
|
3457
3452
|
|
|
3453
|
+
exports.__wbindgen_cast_e346b65485039441 = function(arg0, arg1) {
|
|
3454
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 355, function: Function { arguments: [Externref], shim_idx: 366, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3455
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3232, __wasm_bindgen_func_elem_3259);
|
|
3456
|
+
return addHeapObject(ret);
|
|
3457
|
+
};
|
|
3458
|
+
|
|
3458
3459
|
exports.__wbindgen_cast_e7b45dd881f38ce3 = function(arg0, arg1) {
|
|
3459
3460
|
// Cast intrinsic for `U128 -> Externref`.
|
|
3460
3461
|
const ret = (BigInt.asUintN(64, arg0) | (BigInt.asUintN(64, arg1) << BigInt(64)));
|