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