@crypticdot/defituna-core 3.4.1 → 3.4.3
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 +243 -203
- package/dist/browser/defituna_core_js_bindings_bg.js +764 -692
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +42 -37
- package/dist/nodejs/defituna_core_js_bindings.d.ts +243 -203
- package/dist/nodejs/defituna_core_js_bindings.js +764 -692
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +42 -37
- package/package.json +2 -2
|
@@ -262,448 +262,183 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
262
262
|
WASM_VECTOR_LEN = arg.length;
|
|
263
263
|
return ptr;
|
|
264
264
|
}
|
|
265
|
+
|
|
266
|
+
export function _POSITION_BUNDLE_SIZE() {
|
|
267
|
+
const ret = wasm._POSITION_BUNDLE_SIZE();
|
|
268
|
+
return ret >>> 0;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function _FEE_RATE_MUL_VALUE() {
|
|
272
|
+
const ret = wasm._FEE_RATE_MUL_VALUE();
|
|
273
|
+
return ret >>> 0;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export function _MAX_PROTOCOL_FEE_RATE() {
|
|
277
|
+
const ret = wasm._MAX_PROTOCOL_FEE_RATE();
|
|
278
|
+
return ret;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export function _PROTOCOL_FEE_RATE_MUL_VALUE() {
|
|
282
|
+
const ret = wasm._PROTOCOL_FEE_RATE_MUL_VALUE();
|
|
283
|
+
return ret;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export function _TICK_ARRAY_SIZE() {
|
|
287
|
+
const ret = wasm._TICK_ARRAY_SIZE();
|
|
288
|
+
return ret >>> 0;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD() {
|
|
292
|
+
const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
|
|
293
|
+
return ret;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function _MIN_TICK_INDEX() {
|
|
297
|
+
const ret = wasm._MIN_TICK_INDEX();
|
|
298
|
+
return ret;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export function _MAX_TICK_INDEX() {
|
|
302
|
+
const ret = wasm._MAX_TICK_INDEX();
|
|
303
|
+
return ret;
|
|
304
|
+
}
|
|
305
|
+
|
|
265
306
|
/**
|
|
266
|
-
*
|
|
307
|
+
* Get the first tick index in the tick array that contains the specified tick index.
|
|
267
308
|
*
|
|
268
309
|
* # Parameters
|
|
269
|
-
* - `
|
|
270
|
-
* - `
|
|
271
|
-
* - `liquidity`: The liquidity
|
|
272
|
-
* - `round_up`: Whether to round up or not
|
|
310
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
311
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
273
312
|
*
|
|
274
313
|
* # Returns
|
|
275
|
-
* -
|
|
314
|
+
* - A i32 integer representing the first tick index in the tick array
|
|
276
315
|
*/
|
|
277
|
-
export function
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
wasm.tryGetAmountDeltaA(retptr, addHeapObject(sqrt_price_1), addHeapObject(sqrt_price_2), addHeapObject(liquidity), round_up);
|
|
281
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
282
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
283
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
284
|
-
if (r3) {
|
|
285
|
-
throw takeObject(r2);
|
|
286
|
-
}
|
|
287
|
-
return BigInt.asUintN(64, r0);
|
|
288
|
-
} finally {
|
|
289
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
290
|
-
}
|
|
316
|
+
export function getTickArrayStartTickIndex(tick_index, tick_spacing) {
|
|
317
|
+
const ret = wasm.getTickArrayStartTickIndex(tick_index, tick_spacing);
|
|
318
|
+
return ret;
|
|
291
319
|
}
|
|
292
320
|
|
|
293
321
|
/**
|
|
294
|
-
*
|
|
322
|
+
* Derive the sqrt-price from a tick index. The precision of this method is only guarranted
|
|
323
|
+
* if tick is within the bounds of {max, min} tick-index.
|
|
295
324
|
*
|
|
296
325
|
* # Parameters
|
|
297
|
-
* - `
|
|
298
|
-
* - `sqrt_price_2`: The second square root price
|
|
299
|
-
* - `liquidity`: The liquidity
|
|
300
|
-
* - `round_up`: Whether to round up or not
|
|
326
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
301
327
|
*
|
|
302
328
|
* # Returns
|
|
303
|
-
* - `
|
|
329
|
+
* - `Ok`: A u128 Q32.64 representing the sqrt_price
|
|
304
330
|
*/
|
|
305
|
-
export function
|
|
331
|
+
export function tickIndexToSqrtPrice(tick_index) {
|
|
306
332
|
try {
|
|
307
333
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
308
|
-
wasm.
|
|
334
|
+
wasm.tickIndexToSqrtPrice(retptr, tick_index);
|
|
309
335
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
310
|
-
var r2 = getDataViewMemory0().
|
|
311
|
-
|
|
312
|
-
if (r3) {
|
|
313
|
-
throw takeObject(r2);
|
|
314
|
-
}
|
|
315
|
-
return BigInt.asUintN(64, r0);
|
|
336
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
337
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
316
338
|
} finally {
|
|
317
339
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
318
340
|
}
|
|
319
341
|
}
|
|
320
342
|
|
|
321
343
|
/**
|
|
322
|
-
*
|
|
344
|
+
* Derive the tick index from a sqrt price. The precision of this method is only guarranted
|
|
345
|
+
* if tick is within the bounds of {max, min} tick-index.
|
|
323
346
|
*
|
|
324
347
|
* # Parameters
|
|
325
|
-
* - `
|
|
326
|
-
* - `current_liquidity`: The current liquidity
|
|
327
|
-
* - `amount`: The amount
|
|
328
|
-
* - `specified_input`: Whether the input is specified
|
|
348
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price
|
|
329
349
|
*
|
|
330
350
|
* # Returns
|
|
331
|
-
* - `
|
|
351
|
+
* - `Ok`: A i32 integer representing the tick integer
|
|
332
352
|
*/
|
|
333
|
-
export function
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
wasm.tryGetNextSqrtPriceFromA(retptr, addHeapObject(current_sqrt_price), addHeapObject(current_liquidity), amount, specified_input);
|
|
337
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
338
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
339
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
340
|
-
if (r2) {
|
|
341
|
-
throw takeObject(r1);
|
|
342
|
-
}
|
|
343
|
-
return takeObject(r0);
|
|
344
|
-
} finally {
|
|
345
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
346
|
-
}
|
|
353
|
+
export function sqrtPriceToTickIndex(sqrt_price) {
|
|
354
|
+
const ret = wasm.sqrtPriceToTickIndex(sqrt_price, sqrt_price >> BigInt(64));
|
|
355
|
+
return ret;
|
|
347
356
|
}
|
|
348
357
|
|
|
349
358
|
/**
|
|
350
|
-
*
|
|
359
|
+
* Get the initializable tick index.
|
|
360
|
+
* If the tick index is already initializable, it is returned as is.
|
|
351
361
|
*
|
|
352
362
|
* # Parameters
|
|
353
|
-
* - `
|
|
354
|
-
* - `
|
|
355
|
-
* - `
|
|
356
|
-
* - `specified_input`: Whether the input is specified
|
|
363
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
364
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
365
|
+
* - `round_up` - A boolean value indicating if the supplied tick index should be rounded up. None will round to the nearest.
|
|
357
366
|
*
|
|
358
367
|
* # Returns
|
|
359
|
-
* -
|
|
368
|
+
* - A i32 integer representing the previous initializable tick index
|
|
360
369
|
*/
|
|
361
|
-
export function
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
wasm.tryGetNextSqrtPriceFromB(retptr, addHeapObject(current_sqrt_price), addHeapObject(current_liquidity), amount, specified_input);
|
|
365
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
366
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
367
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
368
|
-
if (r2) {
|
|
369
|
-
throw takeObject(r1);
|
|
370
|
-
}
|
|
371
|
-
return takeObject(r0);
|
|
372
|
-
} finally {
|
|
373
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
374
|
-
}
|
|
370
|
+
export function getInitializableTickIndex(tick_index, tick_spacing, round_up) {
|
|
371
|
+
const ret = wasm.getInitializableTickIndex(tick_index, tick_spacing, isLikeNone(round_up) ? 0xFFFFFF : round_up ? 1 : 0);
|
|
372
|
+
return ret;
|
|
375
373
|
}
|
|
376
374
|
|
|
377
375
|
/**
|
|
378
|
-
*
|
|
379
|
-
* e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
|
|
380
|
-
* So the amount after fee will be 9900.
|
|
376
|
+
* Get the previous initializable tick index.
|
|
381
377
|
*
|
|
382
378
|
* # Parameters
|
|
383
|
-
* - `
|
|
384
|
-
* - `
|
|
379
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
380
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
385
381
|
*
|
|
386
382
|
* # Returns
|
|
387
|
-
* -
|
|
383
|
+
* - A i32 integer representing the previous initializable tick index
|
|
388
384
|
*/
|
|
389
|
-
export function
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
wasm.tryApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
|
|
393
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
394
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
395
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
396
|
-
if (r3) {
|
|
397
|
-
throw takeObject(r2);
|
|
398
|
-
}
|
|
399
|
-
return BigInt.asUintN(64, r0);
|
|
400
|
-
} finally {
|
|
401
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
402
|
-
}
|
|
385
|
+
export function getPrevInitializableTickIndex(tick_index, tick_spacing) {
|
|
386
|
+
const ret = wasm.getPrevInitializableTickIndex(tick_index, tick_spacing);
|
|
387
|
+
return ret;
|
|
403
388
|
}
|
|
404
389
|
|
|
405
390
|
/**
|
|
406
|
-
*
|
|
407
|
-
* e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
|
|
408
|
-
* So the amount before fee will be 10000.
|
|
391
|
+
* Get the next initializable tick index.
|
|
409
392
|
*
|
|
410
393
|
* # Parameters
|
|
411
|
-
* - `
|
|
412
|
-
* - `
|
|
394
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
395
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
413
396
|
*
|
|
414
397
|
* # Returns
|
|
415
|
-
* -
|
|
398
|
+
* - A i32 integer representing the next initializable tick index
|
|
416
399
|
*/
|
|
417
|
-
export function
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
wasm.tryReverseApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
|
|
421
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
422
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
423
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
424
|
-
if (r3) {
|
|
425
|
-
throw takeObject(r2);
|
|
426
|
-
}
|
|
427
|
-
return BigInt.asUintN(64, r0);
|
|
428
|
-
} finally {
|
|
429
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
430
|
-
}
|
|
400
|
+
export function getNextInitializableTickIndex(tick_index, tick_spacing) {
|
|
401
|
+
const ret = wasm.getNextInitializableTickIndex(tick_index, tick_spacing);
|
|
402
|
+
return ret;
|
|
431
403
|
}
|
|
432
404
|
|
|
433
405
|
/**
|
|
434
|
-
*
|
|
435
|
-
* e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
|
|
406
|
+
* Check if a tick is in-bounds.
|
|
436
407
|
*
|
|
437
408
|
* # Parameters
|
|
438
|
-
* - `
|
|
439
|
-
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
409
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
440
410
|
*
|
|
441
411
|
* # Returns
|
|
442
|
-
* -
|
|
412
|
+
* - A boolean value indicating if the tick is in-bounds
|
|
443
413
|
*/
|
|
444
|
-
export function
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
wasm.tryGetMaxAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
|
|
448
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
449
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
450
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
451
|
-
if (r3) {
|
|
452
|
-
throw takeObject(r2);
|
|
453
|
-
}
|
|
454
|
-
return BigInt.asUintN(64, r0);
|
|
455
|
-
} finally {
|
|
456
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
457
|
-
}
|
|
414
|
+
export function isTickIndexInBounds(tick_index) {
|
|
415
|
+
const ret = wasm.isTickIndexInBounds(tick_index);
|
|
416
|
+
return ret !== 0;
|
|
458
417
|
}
|
|
459
418
|
|
|
460
419
|
/**
|
|
461
|
-
*
|
|
462
|
-
*
|
|
420
|
+
* Check if a tick is initializable.
|
|
421
|
+
* A tick is initializable if it is divisible by the tick spacing.
|
|
463
422
|
*
|
|
464
423
|
* # Parameters
|
|
465
|
-
* - `
|
|
466
|
-
* - `
|
|
424
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
425
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
467
426
|
*
|
|
468
427
|
* # Returns
|
|
469
|
-
* -
|
|
428
|
+
* - A boolean value indicating if the tick is initializable
|
|
470
429
|
*/
|
|
471
|
-
export function
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
wasm.tryGetMinAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
|
|
475
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
476
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
477
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
478
|
-
if (r3) {
|
|
479
|
-
throw takeObject(r2);
|
|
480
|
-
}
|
|
481
|
-
return BigInt.asUintN(64, r0);
|
|
482
|
-
} finally {
|
|
483
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
484
|
-
}
|
|
430
|
+
export function isTickInitializable(tick_index, tick_spacing) {
|
|
431
|
+
const ret = wasm.isTickInitializable(tick_index, tick_spacing);
|
|
432
|
+
return ret !== 0;
|
|
485
433
|
}
|
|
486
434
|
|
|
487
435
|
/**
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
436
|
+
* Get the tick index for the inverse of the price that this tick represents.
|
|
437
|
+
* Eg: Consider tick i where Pb/Pa = 1.0001 ^ i
|
|
438
|
+
* inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i
|
|
491
439
|
*
|
|
492
440
|
* # Parameters
|
|
493
|
-
* - `
|
|
494
|
-
* - `fee_rate`: The fee rate to apply denominated in 1e6
|
|
495
|
-
*
|
|
496
|
-
* # Returns
|
|
497
|
-
* - `u64`: The amount after the fee has been applied
|
|
498
|
-
*/
|
|
499
|
-
export function tryApplySwapFee(amount, fee_rate) {
|
|
500
|
-
try {
|
|
501
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
502
|
-
wasm.tryApplySwapFee(retptr, amount, fee_rate);
|
|
503
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
504
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
505
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
506
|
-
if (r3) {
|
|
507
|
-
throw takeObject(r2);
|
|
508
|
-
}
|
|
509
|
-
return BigInt.asUintN(64, r0);
|
|
510
|
-
} finally {
|
|
511
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Reverse the application of a swap fee to an amount
|
|
517
|
-
* e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
|
|
518
|
-
* So the amount before fee will be 10000.
|
|
519
|
-
*
|
|
520
|
-
* # Parameters
|
|
521
|
-
* - `amount`: The amount to reverse the fee from
|
|
522
|
-
* - `fee_rate`: The fee rate to reverse denominated in 1e6
|
|
523
|
-
*
|
|
524
|
-
* # Returns
|
|
525
|
-
* - `u64`: The amount before the fee has been applied
|
|
526
|
-
*/
|
|
527
|
-
export function tryReverseApplySwapFee(amount, fee_rate) {
|
|
528
|
-
try {
|
|
529
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
530
|
-
wasm.tryReverseApplySwapFee(retptr, amount, fee_rate);
|
|
531
|
-
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
532
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
533
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
534
|
-
if (r3) {
|
|
535
|
-
throw takeObject(r2);
|
|
536
|
-
}
|
|
537
|
-
return BigInt.asUintN(64, r0);
|
|
538
|
-
} finally {
|
|
539
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
export function _FEE_RATE_MUL_VALUE() {
|
|
544
|
-
const ret = wasm._FEE_RATE_MUL_VALUE();
|
|
545
|
-
return ret >>> 0;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
export function _MAX_PROTOCOL_FEE_RATE() {
|
|
549
|
-
const ret = wasm._MAX_PROTOCOL_FEE_RATE();
|
|
550
|
-
return ret;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
export function _PROTOCOL_FEE_RATE_MUL_VALUE() {
|
|
554
|
-
const ret = wasm._PROTOCOL_FEE_RATE_MUL_VALUE();
|
|
555
|
-
return ret;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
export function _TICK_ARRAY_SIZE() {
|
|
559
|
-
const ret = wasm._TICK_ARRAY_SIZE();
|
|
560
|
-
return ret >>> 0;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD() {
|
|
564
|
-
const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
|
|
565
|
-
return ret;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
export function _MIN_TICK_INDEX() {
|
|
569
|
-
const ret = wasm._MIN_TICK_INDEX();
|
|
570
|
-
return ret;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
export function _MAX_TICK_INDEX() {
|
|
574
|
-
const ret = wasm._MAX_TICK_INDEX();
|
|
575
|
-
return ret;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* Get the first tick index in the tick array that contains the specified tick index.
|
|
580
|
-
*
|
|
581
|
-
* # Parameters
|
|
582
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
583
|
-
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
584
|
-
*
|
|
585
|
-
* # Returns
|
|
586
|
-
* - A i32 integer representing the first tick index in the tick array
|
|
587
|
-
*/
|
|
588
|
-
export function getTickArrayStartTickIndex(tick_index, tick_spacing) {
|
|
589
|
-
const ret = wasm.getTickArrayStartTickIndex(tick_index, tick_spacing);
|
|
590
|
-
return ret;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
* Derive the sqrt-price from a tick index. The precision of this method is only guarranted
|
|
595
|
-
* if tick is within the bounds of {max, min} tick-index.
|
|
596
|
-
*
|
|
597
|
-
* # Parameters
|
|
598
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
599
|
-
*
|
|
600
|
-
* # Returns
|
|
601
|
-
* - `Ok`: A u128 Q32.64 representing the sqrt_price
|
|
602
|
-
*/
|
|
603
|
-
export function tickIndexToSqrtPrice(tick_index) {
|
|
604
|
-
const ret = wasm.tickIndexToSqrtPrice(tick_index);
|
|
605
|
-
return takeObject(ret);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* Derive the tick index from a sqrt price. The precision of this method is only guarranted
|
|
610
|
-
* if tick is within the bounds of {max, min} tick-index.
|
|
611
|
-
*
|
|
612
|
-
* # Parameters
|
|
613
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price
|
|
614
|
-
*
|
|
615
|
-
* # Returns
|
|
616
|
-
* - `Ok`: A i32 integer representing the tick integer
|
|
617
|
-
*/
|
|
618
|
-
export function sqrtPriceToTickIndex(sqrt_price) {
|
|
619
|
-
const ret = wasm.sqrtPriceToTickIndex(addHeapObject(sqrt_price));
|
|
620
|
-
return ret;
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
/**
|
|
624
|
-
* Get the initializable tick index.
|
|
625
|
-
* If the tick index is already initializable, it is returned as is.
|
|
626
|
-
*
|
|
627
|
-
* # Parameters
|
|
628
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
629
|
-
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
630
|
-
* - `round_up` - A boolean value indicating if the supplied tick index should be rounded up. None will round to the nearest.
|
|
631
|
-
*
|
|
632
|
-
* # Returns
|
|
633
|
-
* - A i32 integer representing the previous initializable tick index
|
|
634
|
-
*/
|
|
635
|
-
export function getInitializableTickIndex(tick_index, tick_spacing, round_up) {
|
|
636
|
-
const ret = wasm.getInitializableTickIndex(tick_index, tick_spacing, isLikeNone(round_up) ? 0xFFFFFF : round_up ? 1 : 0);
|
|
637
|
-
return ret;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Get the previous initializable tick index.
|
|
642
|
-
*
|
|
643
|
-
* # Parameters
|
|
644
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
645
|
-
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
646
|
-
*
|
|
647
|
-
* # Returns
|
|
648
|
-
* - A i32 integer representing the previous initializable tick index
|
|
649
|
-
*/
|
|
650
|
-
export function getPrevInitializableTickIndex(tick_index, tick_spacing) {
|
|
651
|
-
const ret = wasm.getPrevInitializableTickIndex(tick_index, tick_spacing);
|
|
652
|
-
return ret;
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* Get the next initializable tick index.
|
|
657
|
-
*
|
|
658
|
-
* # Parameters
|
|
659
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
660
|
-
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
661
|
-
*
|
|
662
|
-
* # Returns
|
|
663
|
-
* - A i32 integer representing the next initializable tick index
|
|
664
|
-
*/
|
|
665
|
-
export function getNextInitializableTickIndex(tick_index, tick_spacing) {
|
|
666
|
-
const ret = wasm.getNextInitializableTickIndex(tick_index, tick_spacing);
|
|
667
|
-
return ret;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
/**
|
|
671
|
-
* Check if a tick is in-bounds.
|
|
672
|
-
*
|
|
673
|
-
* # Parameters
|
|
674
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
675
|
-
*
|
|
676
|
-
* # Returns
|
|
677
|
-
* - A boolean value indicating if the tick is in-bounds
|
|
678
|
-
*/
|
|
679
|
-
export function isTickIndexInBounds(tick_index) {
|
|
680
|
-
const ret = wasm.isTickIndexInBounds(tick_index);
|
|
681
|
-
return ret !== 0;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
/**
|
|
685
|
-
* Check if a tick is initializable.
|
|
686
|
-
* A tick is initializable if it is divisible by the tick spacing.
|
|
687
|
-
*
|
|
688
|
-
* # Parameters
|
|
689
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
690
|
-
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
691
|
-
*
|
|
692
|
-
* # Returns
|
|
693
|
-
* - A boolean value indicating if the tick is initializable
|
|
694
|
-
*/
|
|
695
|
-
export function isTickInitializable(tick_index, tick_spacing) {
|
|
696
|
-
const ret = wasm.isTickInitializable(tick_index, tick_spacing);
|
|
697
|
-
return ret !== 0;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/**
|
|
701
|
-
* Get the tick index for the inverse of the price that this tick represents.
|
|
702
|
-
* Eg: Consider tick i where Pb/Pa = 1.0001 ^ i
|
|
703
|
-
* inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i
|
|
704
|
-
*
|
|
705
|
-
* # Parameters
|
|
706
|
-
* - `tick_index` - A i32 integer representing the tick integer
|
|
441
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
707
442
|
*
|
|
708
443
|
* # Returns
|
|
709
444
|
* - A i32 integer representing the tick index for the inverse of the price
|
|
@@ -725,8 +460,15 @@ export function invertTickIndex(tick_index) {
|
|
|
725
460
|
* - A u128 integer representing the sqrt price for the inverse of the price
|
|
726
461
|
*/
|
|
727
462
|
export function invertSqrtPrice(sqrt_price) {
|
|
728
|
-
|
|
729
|
-
|
|
463
|
+
try {
|
|
464
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
465
|
+
wasm.invertSqrtPrice(retptr, sqrt_price, sqrt_price >> BigInt(64));
|
|
466
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
467
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
468
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
469
|
+
} finally {
|
|
470
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
471
|
+
}
|
|
730
472
|
}
|
|
731
473
|
|
|
732
474
|
/**
|
|
@@ -819,7 +561,7 @@ export function getTickIndexInArray(tick_index, tick_array_start_index, tick_spa
|
|
|
819
561
|
export function decreaseLiquidityQuote(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
820
562
|
try {
|
|
821
563
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
822
|
-
wasm.decreaseLiquidityQuote(retptr,
|
|
564
|
+
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));
|
|
823
565
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
824
566
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
825
567
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -850,7 +592,7 @@ export function decreaseLiquidityQuote(liquidity_delta, slippage_tolerance_bps,
|
|
|
850
592
|
export function decreaseLiquidityQuoteA(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
851
593
|
try {
|
|
852
594
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
853
|
-
wasm.decreaseLiquidityQuoteA(retptr, token_amount_a, slippage_tolerance_bps,
|
|
595
|
+
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));
|
|
854
596
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
855
597
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
856
598
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -881,7 +623,7 @@ export function decreaseLiquidityQuoteA(token_amount_a, slippage_tolerance_bps,
|
|
|
881
623
|
export function decreaseLiquidityQuoteB(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
882
624
|
try {
|
|
883
625
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
884
|
-
wasm.decreaseLiquidityQuoteB(retptr, token_amount_b, slippage_tolerance_bps,
|
|
626
|
+
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));
|
|
885
627
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
886
628
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
887
629
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -912,7 +654,7 @@ export function decreaseLiquidityQuoteB(token_amount_b, slippage_tolerance_bps,
|
|
|
912
654
|
export function increaseLiquidityQuote(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
913
655
|
try {
|
|
914
656
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
915
|
-
wasm.increaseLiquidityQuote(retptr,
|
|
657
|
+
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));
|
|
916
658
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
917
659
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
918
660
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -943,7 +685,7 @@ export function increaseLiquidityQuote(liquidity_delta, slippage_tolerance_bps,
|
|
|
943
685
|
export function increaseLiquidityQuoteA(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
944
686
|
try {
|
|
945
687
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
946
|
-
wasm.increaseLiquidityQuoteA(retptr, token_amount_a, slippage_tolerance_bps,
|
|
688
|
+
wasm.increaseLiquidityQuoteA(retptr, token_amount_a, slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
947
689
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
948
690
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
949
691
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -974,7 +716,7 @@ export function increaseLiquidityQuoteA(token_amount_a, slippage_tolerance_bps,
|
|
|
974
716
|
export function increaseLiquidityQuoteB(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
975
717
|
try {
|
|
976
718
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
977
|
-
wasm.increaseLiquidityQuoteB(retptr, token_amount_b, slippage_tolerance_bps,
|
|
719
|
+
wasm.increaseLiquidityQuoteB(retptr, token_amount_b, slippage_tolerance_bps, current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
978
720
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
979
721
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
980
722
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1053,10 +795,10 @@ export function tryGetTokenBFromLiquidity(liquidity_delta, sqrt_price_lower, sqr
|
|
|
1053
795
|
}
|
|
1054
796
|
}
|
|
1055
797
|
|
|
1056
|
-
export function
|
|
798
|
+
export function tryGetAmountsFromLiquidity(liquidity_delta, current_sqrt_price, tick_lower_index, tick_upper_index, round_up) {
|
|
1057
799
|
try {
|
|
1058
800
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1059
|
-
wasm.
|
|
801
|
+
wasm.tryGetAmountsFromLiquidity(retptr, liquidity_delta, liquidity_delta >> BigInt(64), current_sqrt_price, current_sqrt_price >> BigInt(64), tick_lower_index, tick_upper_index, round_up);
|
|
1060
802
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1061
803
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1062
804
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1069,6 +811,23 @@ export function tryGetTokenEstimatesFromLiquidity(liquidity_delta, current_sqrt_
|
|
|
1069
811
|
}
|
|
1070
812
|
}
|
|
1071
813
|
|
|
814
|
+
export function tryGetLiquidityFromAmounts(sqrt_price, sqrt_price_a_x64, sqrt_price_b_x64, amount_a, amount_b) {
|
|
815
|
+
try {
|
|
816
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
817
|
+
wasm.tryGetLiquidityFromAmounts(retptr, sqrt_price, sqrt_price >> BigInt(64), sqrt_price_a_x64, sqrt_price_a_x64 >> BigInt(64), sqrt_price_b_x64, sqrt_price_b_x64 >> BigInt(64), amount_a, amount_b);
|
|
818
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
819
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
820
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
821
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
822
|
+
if (r5) {
|
|
823
|
+
throw takeObject(r4);
|
|
824
|
+
}
|
|
825
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
826
|
+
} finally {
|
|
827
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
|
|
1072
831
|
/**
|
|
1073
832
|
* Calculate fees owed for a position
|
|
1074
833
|
*
|
|
@@ -1105,17 +864,21 @@ export function limitOrderFee(fusion_pool) {
|
|
|
1105
864
|
}
|
|
1106
865
|
|
|
1107
866
|
/**
|
|
1108
|
-
*
|
|
1109
|
-
*
|
|
1110
|
-
*
|
|
1111
|
-
* - `
|
|
1112
|
-
* - `
|
|
1113
|
-
* - `
|
|
867
|
+
* Calculate the amount A delta between two sqrt_prices
|
|
868
|
+
*
|
|
869
|
+
* # Parameters
|
|
870
|
+
* - `sqrt_price_1`: The first square root price
|
|
871
|
+
* - `sqrt_price_2`: The second square root price
|
|
872
|
+
* - `liquidity`: The liquidity
|
|
873
|
+
* - `round_up`: Whether to round up or not
|
|
874
|
+
*
|
|
875
|
+
* # Returns
|
|
876
|
+
* - `u64`: The amount delta
|
|
1114
877
|
*/
|
|
1115
|
-
export function
|
|
878
|
+
export function tryGetAmountDeltaA(sqrt_price_1, sqrt_price_2, liquidity, round_up) {
|
|
1116
879
|
try {
|
|
1117
880
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1118
|
-
wasm.
|
|
881
|
+
wasm.tryGetAmountDeltaA(retptr, sqrt_price_1, sqrt_price_1 >> BigInt(64), sqrt_price_2, sqrt_price_2 >> BigInt(64), liquidity, liquidity >> BigInt(64), round_up);
|
|
1119
882
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1120
883
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1121
884
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -1129,17 +892,21 @@ export function limitOrderQuoteByInputToken(amount_in, a_to_b_order, tick_index,
|
|
|
1129
892
|
}
|
|
1130
893
|
|
|
1131
894
|
/**
|
|
1132
|
-
*
|
|
1133
|
-
*
|
|
1134
|
-
*
|
|
1135
|
-
* - `
|
|
1136
|
-
* - `
|
|
1137
|
-
* - `
|
|
895
|
+
* Calculate the amount B delta between two sqrt_prices
|
|
896
|
+
*
|
|
897
|
+
* # Parameters
|
|
898
|
+
* - `sqrt_price_1`: The first square root price
|
|
899
|
+
* - `sqrt_price_2`: The second square root price
|
|
900
|
+
* - `liquidity`: The liquidity
|
|
901
|
+
* - `round_up`: Whether to round up or not
|
|
902
|
+
*
|
|
903
|
+
* # Returns
|
|
904
|
+
* - `u64`: The amount delta
|
|
1138
905
|
*/
|
|
1139
|
-
export function
|
|
906
|
+
export function tryGetAmountDeltaB(sqrt_price_1, sqrt_price_2, liquidity, round_up) {
|
|
1140
907
|
try {
|
|
1141
908
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1142
|
-
wasm.
|
|
909
|
+
wasm.tryGetAmountDeltaB(retptr, sqrt_price_1, sqrt_price_1 >> BigInt(64), sqrt_price_2, sqrt_price_2 >> BigInt(64), liquidity, liquidity >> BigInt(64), round_up);
|
|
1143
910
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1144
911
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1145
912
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
@@ -1153,249 +920,312 @@ export function limitOrderQuoteByOutputToken(amount_out, a_to_b_order, tick_inde
|
|
|
1153
920
|
}
|
|
1154
921
|
|
|
1155
922
|
/**
|
|
1156
|
-
*
|
|
1157
|
-
*
|
|
1158
|
-
*
|
|
1159
|
-
* - `
|
|
1160
|
-
* - `
|
|
1161
|
-
* - `
|
|
923
|
+
* Calculate the next square root price
|
|
924
|
+
*
|
|
925
|
+
* # Parameters
|
|
926
|
+
* - `current_sqrt_price`: The current square root price
|
|
927
|
+
* - `current_liquidity`: The current liquidity
|
|
928
|
+
* - `amount`: The amount
|
|
929
|
+
* - `specified_input`: Whether the input is specified
|
|
930
|
+
*
|
|
931
|
+
* # Returns
|
|
932
|
+
* - `u128`: The next square root price
|
|
1162
933
|
*/
|
|
1163
|
-
export function
|
|
934
|
+
export function tryGetNextSqrtPriceFromA(current_sqrt_price, current_liquidity, amount, specified_input) {
|
|
1164
935
|
try {
|
|
1165
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-
|
|
1166
|
-
wasm.
|
|
936
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
937
|
+
wasm.tryGetNextSqrtPriceFromA(retptr, current_sqrt_price, current_sqrt_price >> BigInt(64), current_liquidity, current_liquidity >> BigInt(64), amount, specified_input);
|
|
1167
938
|
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1168
|
-
var r2 = getDataViewMemory0().
|
|
1169
|
-
var
|
|
1170
|
-
|
|
1171
|
-
|
|
939
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
940
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
941
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
942
|
+
if (r5) {
|
|
943
|
+
throw takeObject(r4);
|
|
1172
944
|
}
|
|
1173
|
-
return BigInt.asUintN(64, r0);
|
|
945
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
1174
946
|
} finally {
|
|
1175
|
-
wasm.__wbindgen_add_to_stack_pointer(
|
|
947
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
1176
948
|
}
|
|
1177
949
|
}
|
|
1178
950
|
|
|
1179
|
-
|
|
951
|
+
/**
|
|
952
|
+
* Calculate the next square root price
|
|
953
|
+
*
|
|
954
|
+
* # Parameters
|
|
955
|
+
* - `current_sqrt_price`: The current square root price
|
|
956
|
+
* - `current_liquidity`: The current liquidity
|
|
957
|
+
* - `amount`: The amount
|
|
958
|
+
* - `specified_input`: Whether the input is specified
|
|
959
|
+
*
|
|
960
|
+
* # Returns
|
|
961
|
+
* - `u128`: The next square root price
|
|
962
|
+
*/
|
|
963
|
+
export function tryGetNextSqrtPriceFromB(current_sqrt_price, current_liquidity, amount, specified_input) {
|
|
1180
964
|
try {
|
|
1181
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-
|
|
1182
|
-
wasm.
|
|
1183
|
-
var r0 = getDataViewMemory0().
|
|
1184
|
-
var
|
|
1185
|
-
var
|
|
1186
|
-
|
|
1187
|
-
|
|
965
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
966
|
+
wasm.tryGetNextSqrtPriceFromB(retptr, current_sqrt_price, current_sqrt_price >> BigInt(64), current_liquidity, current_liquidity >> BigInt(64), amount, specified_input);
|
|
967
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
968
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
969
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
970
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
971
|
+
if (r5) {
|
|
972
|
+
throw takeObject(r4);
|
|
1188
973
|
}
|
|
1189
|
-
return
|
|
1190
|
-
} finally {
|
|
1191
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
export function _POSITION_BUNDLE_SIZE() {
|
|
1196
|
-
const ret = wasm._POSITION_BUNDLE_SIZE();
|
|
1197
|
-
return ret >>> 0;
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
export function _TICK_ARRAY_NOT_EVENLY_SPACED() {
|
|
1201
|
-
try {
|
|
1202
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1203
|
-
wasm._TICK_ARRAY_NOT_EVENLY_SPACED(retptr);
|
|
1204
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1205
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1206
|
-
return getStringFromWasm0(r0, r1);
|
|
1207
|
-
} finally {
|
|
1208
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
export function _TICK_INDEX_OUT_OF_BOUNDS() {
|
|
1213
|
-
try {
|
|
1214
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1215
|
-
wasm._TICK_INDEX_OUT_OF_BOUNDS(retptr);
|
|
1216
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1217
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1218
|
-
return getStringFromWasm0(r0, r1);
|
|
1219
|
-
} finally {
|
|
1220
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
export function _INVALID_TICK_INDEX() {
|
|
1225
|
-
try {
|
|
1226
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1227
|
-
wasm._INVALID_TICK_INDEX(retptr);
|
|
1228
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1229
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1230
|
-
return getStringFromWasm0(r0, r1);
|
|
1231
|
-
} finally {
|
|
1232
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
export function _ARITHMETIC_OVERFLOW() {
|
|
1237
|
-
try {
|
|
1238
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1239
|
-
wasm._ARITHMETIC_OVERFLOW(retptr);
|
|
1240
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1241
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1242
|
-
return getStringFromWasm0(r0, r1);
|
|
1243
|
-
} finally {
|
|
1244
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
export function _AMOUNT_EXCEEDS_MAX_U64() {
|
|
1249
|
-
try {
|
|
1250
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1251
|
-
wasm._AMOUNT_EXCEEDS_MAX_U64(retptr);
|
|
1252
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1253
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1254
|
-
return getStringFromWasm0(r0, r1);
|
|
1255
|
-
} finally {
|
|
1256
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
export function _AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT() {
|
|
1261
|
-
try {
|
|
1262
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1263
|
-
wasm._AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT(retptr);
|
|
1264
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1265
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1266
|
-
return getStringFromWasm0(r0, r1);
|
|
1267
|
-
} finally {
|
|
1268
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
export function _SQRT_PRICE_OUT_OF_BOUNDS() {
|
|
1273
|
-
try {
|
|
1274
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1275
|
-
wasm._SQRT_PRICE_OUT_OF_BOUNDS(retptr);
|
|
1276
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1277
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1278
|
-
return getStringFromWasm0(r0, r1);
|
|
974
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
1279
975
|
} finally {
|
|
1280
|
-
wasm.__wbindgen_add_to_stack_pointer(
|
|
976
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
1281
977
|
}
|
|
1282
978
|
}
|
|
1283
979
|
|
|
1284
|
-
|
|
980
|
+
/**
|
|
981
|
+
* Apply a transfer fee to an amount
|
|
982
|
+
* e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
|
|
983
|
+
* So the amount after fee will be 9900.
|
|
984
|
+
*
|
|
985
|
+
* # Parameters
|
|
986
|
+
* - `amount`: The amount to apply the fee to
|
|
987
|
+
* - `transfer_fee`: The transfer fee to apply
|
|
988
|
+
*
|
|
989
|
+
* # Returns
|
|
990
|
+
* - `u64`: The amount after the fee has been applied
|
|
991
|
+
*/
|
|
992
|
+
export function tryApplyTransferFee(amount, transfer_fee) {
|
|
1285
993
|
try {
|
|
1286
994
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1287
|
-
wasm.
|
|
1288
|
-
var r0 = getDataViewMemory0().
|
|
1289
|
-
var
|
|
1290
|
-
|
|
995
|
+
wasm.tryApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
|
|
996
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
997
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
998
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
999
|
+
if (r3) {
|
|
1000
|
+
throw takeObject(r2);
|
|
1001
|
+
}
|
|
1002
|
+
return BigInt.asUintN(64, r0);
|
|
1291
1003
|
} finally {
|
|
1292
1004
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1293
1005
|
}
|
|
1294
1006
|
}
|
|
1295
1007
|
|
|
1296
|
-
|
|
1008
|
+
/**
|
|
1009
|
+
* Reverse the application of a transfer fee to an amount
|
|
1010
|
+
* e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
|
|
1011
|
+
* So the amount before fee will be 10000.
|
|
1012
|
+
*
|
|
1013
|
+
* # Parameters
|
|
1014
|
+
* - `amount`: The amount to reverse the fee from
|
|
1015
|
+
* - `transfer_fee`: The transfer fee to reverse
|
|
1016
|
+
*
|
|
1017
|
+
* # Returns
|
|
1018
|
+
* - `u64`: The amount before the fee has been applied
|
|
1019
|
+
*/
|
|
1020
|
+
export function tryReverseApplyTransferFee(amount, transfer_fee) {
|
|
1297
1021
|
try {
|
|
1298
1022
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1299
|
-
wasm.
|
|
1300
|
-
var r0 = getDataViewMemory0().
|
|
1301
|
-
var
|
|
1302
|
-
|
|
1023
|
+
wasm.tryReverseApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
|
|
1024
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1025
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1026
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1027
|
+
if (r3) {
|
|
1028
|
+
throw takeObject(r2);
|
|
1029
|
+
}
|
|
1030
|
+
return BigInt.asUintN(64, r0);
|
|
1303
1031
|
} finally {
|
|
1304
1032
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1305
1033
|
}
|
|
1306
1034
|
}
|
|
1307
1035
|
|
|
1308
|
-
|
|
1036
|
+
/**
|
|
1037
|
+
* Get the maximum amount with a slippage tolerance
|
|
1038
|
+
* e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
|
|
1039
|
+
*
|
|
1040
|
+
* # Parameters
|
|
1041
|
+
* - `amount`: The amount to apply the fee to
|
|
1042
|
+
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
1043
|
+
*
|
|
1044
|
+
* # Returns
|
|
1045
|
+
* - `u64`: The maximum amount
|
|
1046
|
+
*/
|
|
1047
|
+
export function tryGetMaxAmountWithSlippageTolerance(amount, slippage_tolerance_bps) {
|
|
1309
1048
|
try {
|
|
1310
1049
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1311
|
-
wasm.
|
|
1312
|
-
var r0 = getDataViewMemory0().
|
|
1313
|
-
var
|
|
1314
|
-
|
|
1050
|
+
wasm.tryGetMaxAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
|
|
1051
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1052
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1053
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1054
|
+
if (r3) {
|
|
1055
|
+
throw takeObject(r2);
|
|
1056
|
+
}
|
|
1057
|
+
return BigInt.asUintN(64, r0);
|
|
1315
1058
|
} finally {
|
|
1316
1059
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1317
1060
|
}
|
|
1318
1061
|
}
|
|
1319
1062
|
|
|
1320
|
-
|
|
1063
|
+
/**
|
|
1064
|
+
* Get the minimum amount with a slippage tolerance
|
|
1065
|
+
* e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
|
|
1066
|
+
*
|
|
1067
|
+
* # Parameters
|
|
1068
|
+
* - `amount`: The amount to apply the fee to
|
|
1069
|
+
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
1070
|
+
*
|
|
1071
|
+
* # Returns
|
|
1072
|
+
* - `u64`: The minimum amount
|
|
1073
|
+
*/
|
|
1074
|
+
export function tryGetMinAmountWithSlippageTolerance(amount, slippage_tolerance_bps) {
|
|
1321
1075
|
try {
|
|
1322
1076
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1323
|
-
wasm.
|
|
1324
|
-
var r0 = getDataViewMemory0().
|
|
1325
|
-
var
|
|
1326
|
-
|
|
1077
|
+
wasm.tryGetMinAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
|
|
1078
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1079
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1080
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1081
|
+
if (r3) {
|
|
1082
|
+
throw takeObject(r2);
|
|
1083
|
+
}
|
|
1084
|
+
return BigInt.asUintN(64, r0);
|
|
1327
1085
|
} finally {
|
|
1328
1086
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1329
1087
|
}
|
|
1330
1088
|
}
|
|
1331
1089
|
|
|
1332
|
-
|
|
1090
|
+
/**
|
|
1091
|
+
* Apply a swap fee to an amount
|
|
1092
|
+
* e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
|
|
1093
|
+
* So the amount after fee will be 9900.
|
|
1094
|
+
*
|
|
1095
|
+
* # Parameters
|
|
1096
|
+
* - `amount`: The amount to apply the fee to
|
|
1097
|
+
* - `fee_rate`: The fee rate to apply denominated in 1e6
|
|
1098
|
+
*
|
|
1099
|
+
* # Returns
|
|
1100
|
+
* - `u64`: The amount after the fee has been applied
|
|
1101
|
+
*/
|
|
1102
|
+
export function tryApplySwapFee(amount, fee_rate) {
|
|
1333
1103
|
try {
|
|
1334
1104
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1335
|
-
wasm.
|
|
1336
|
-
var r0 = getDataViewMemory0().
|
|
1337
|
-
var
|
|
1338
|
-
|
|
1105
|
+
wasm.tryApplySwapFee(retptr, amount, fee_rate);
|
|
1106
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1107
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1108
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1109
|
+
if (r3) {
|
|
1110
|
+
throw takeObject(r2);
|
|
1111
|
+
}
|
|
1112
|
+
return BigInt.asUintN(64, r0);
|
|
1339
1113
|
} finally {
|
|
1340
1114
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1341
1115
|
}
|
|
1342
1116
|
}
|
|
1343
1117
|
|
|
1344
|
-
|
|
1118
|
+
/**
|
|
1119
|
+
* Reverse the application of a swap fee to an amount
|
|
1120
|
+
* e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
|
|
1121
|
+
* So the amount before fee will be 10000.
|
|
1122
|
+
*
|
|
1123
|
+
* # Parameters
|
|
1124
|
+
* - `amount`: The amount to reverse the fee from
|
|
1125
|
+
* - `fee_rate`: The fee rate to reverse denominated in 1e6
|
|
1126
|
+
*
|
|
1127
|
+
* # Returns
|
|
1128
|
+
* - `u64`: The amount before the fee has been applied
|
|
1129
|
+
*/
|
|
1130
|
+
export function tryReverseApplySwapFee(amount, fee_rate) {
|
|
1345
1131
|
try {
|
|
1346
1132
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1347
|
-
wasm.
|
|
1348
|
-
var r0 = getDataViewMemory0().
|
|
1349
|
-
var
|
|
1350
|
-
|
|
1133
|
+
wasm.tryReverseApplySwapFee(retptr, amount, fee_rate);
|
|
1134
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1135
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1136
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1137
|
+
if (r3) {
|
|
1138
|
+
throw takeObject(r2);
|
|
1139
|
+
}
|
|
1140
|
+
return BigInt.asUintN(64, r0);
|
|
1351
1141
|
} finally {
|
|
1352
1142
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1353
1143
|
}
|
|
1354
1144
|
}
|
|
1355
1145
|
|
|
1356
|
-
|
|
1146
|
+
/**
|
|
1147
|
+
* Computes the limit order output amount by input amount.
|
|
1148
|
+
* ### Parameters
|
|
1149
|
+
* - `amount_in` - The input token amount of a limit order.
|
|
1150
|
+
* - `a_to_b_order` - The limit order direction.
|
|
1151
|
+
* - `tick_index` - The tick index of an order.
|
|
1152
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
1153
|
+
*/
|
|
1154
|
+
export function limitOrderQuoteByInputToken(amount_in, a_to_b_order, tick_index, fusion_pool) {
|
|
1357
1155
|
try {
|
|
1358
1156
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1359
|
-
wasm.
|
|
1360
|
-
var r0 = getDataViewMemory0().
|
|
1361
|
-
var
|
|
1362
|
-
|
|
1157
|
+
wasm.limitOrderQuoteByInputToken(retptr, amount_in, a_to_b_order, tick_index, addHeapObject(fusion_pool));
|
|
1158
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1159
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1160
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1161
|
+
if (r3) {
|
|
1162
|
+
throw takeObject(r2);
|
|
1163
|
+
}
|
|
1164
|
+
return BigInt.asUintN(64, r0);
|
|
1363
1165
|
} finally {
|
|
1364
1166
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1365
1167
|
}
|
|
1366
1168
|
}
|
|
1367
1169
|
|
|
1368
|
-
|
|
1170
|
+
/**
|
|
1171
|
+
* Computes the limit order input amount by output amount.
|
|
1172
|
+
* ### Parameters
|
|
1173
|
+
* - `amount_out` - The output token amount of a limit order.
|
|
1174
|
+
* - `a_to_b_order` - The limit order direction.
|
|
1175
|
+
* - `tick_index` - The tick index of an order.
|
|
1176
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
1177
|
+
*/
|
|
1178
|
+
export function limitOrderQuoteByOutputToken(amount_out, a_to_b_order, tick_index, fusion_pool) {
|
|
1369
1179
|
try {
|
|
1370
1180
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1371
|
-
wasm.
|
|
1372
|
-
var r0 = getDataViewMemory0().
|
|
1373
|
-
var
|
|
1374
|
-
|
|
1181
|
+
wasm.limitOrderQuoteByOutputToken(retptr, amount_out, a_to_b_order, tick_index, addHeapObject(fusion_pool));
|
|
1182
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1183
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1184
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1185
|
+
if (r3) {
|
|
1186
|
+
throw takeObject(r2);
|
|
1187
|
+
}
|
|
1188
|
+
return BigInt.asUintN(64, r0);
|
|
1375
1189
|
} finally {
|
|
1376
1190
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1377
1191
|
}
|
|
1378
1192
|
}
|
|
1379
1193
|
|
|
1380
|
-
|
|
1194
|
+
/**
|
|
1195
|
+
* Computes the limit order reward by input amount.
|
|
1196
|
+
* ### Parameters
|
|
1197
|
+
* - `amount_out` - The output token amount of a limit order (swap input).
|
|
1198
|
+
* - `a_to_b_order` - The limit order direction.
|
|
1199
|
+
* - `tick_index` - The tick index of an order.
|
|
1200
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
1201
|
+
*/
|
|
1202
|
+
export function limitOrderRewardByOutputToken(amount_out, fee_rate, protocol_fee_rate) {
|
|
1381
1203
|
try {
|
|
1382
1204
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1383
|
-
wasm.
|
|
1384
|
-
var r0 = getDataViewMemory0().
|
|
1385
|
-
var
|
|
1386
|
-
|
|
1205
|
+
wasm.limitOrderRewardByOutputToken(retptr, amount_out, fee_rate, protocol_fee_rate);
|
|
1206
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1207
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1208
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1209
|
+
if (r3) {
|
|
1210
|
+
throw takeObject(r2);
|
|
1211
|
+
}
|
|
1212
|
+
return BigInt.asUintN(64, r0);
|
|
1387
1213
|
} finally {
|
|
1388
1214
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1389
1215
|
}
|
|
1390
1216
|
}
|
|
1391
1217
|
|
|
1392
|
-
export function
|
|
1218
|
+
export function decreaseLimitOrderQuote(fusion_pool, limit_order, tick, amount, transfer_fee_a, transfer_fee_b) {
|
|
1393
1219
|
try {
|
|
1394
1220
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1395
|
-
wasm.
|
|
1221
|
+
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));
|
|
1396
1222
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1397
1223
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1398
|
-
|
|
1224
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1225
|
+
if (r2) {
|
|
1226
|
+
throw takeObject(r1);
|
|
1227
|
+
}
|
|
1228
|
+
return takeObject(r0);
|
|
1399
1229
|
} finally {
|
|
1400
1230
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1401
1231
|
}
|
|
@@ -1463,7 +1293,7 @@ export function isPositionBundleEmpty(bitmap) {
|
|
|
1463
1293
|
* - A boolean value indicating if the position is in range
|
|
1464
1294
|
*/
|
|
1465
1295
|
export function isPositionInRange(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1466
|
-
const ret = wasm.isPositionInRange(
|
|
1296
|
+
const ret = wasm.isPositionInRange(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
1467
1297
|
return ret !== 0;
|
|
1468
1298
|
}
|
|
1469
1299
|
|
|
@@ -1483,143 +1313,322 @@ export function isPositionInRange(current_sqrt_price, tick_index_1, tick_index_2
|
|
|
1483
1313
|
* - A PositionStatus enum value indicating the status of the position
|
|
1484
1314
|
*/
|
|
1485
1315
|
export function positionStatus(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1486
|
-
const ret = wasm.positionStatus(
|
|
1316
|
+
const ret = wasm.positionStatus(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
1487
1317
|
return takeObject(ret);
|
|
1488
1318
|
}
|
|
1489
1319
|
|
|
1490
|
-
/**
|
|
1491
|
-
* Calculate the token_a / token_b ratio of a (ficticious) position
|
|
1492
|
-
*
|
|
1493
|
-
* # Parameters
|
|
1494
|
-
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1495
|
-
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1496
|
-
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1497
|
-
*
|
|
1498
|
-
* # Returns
|
|
1499
|
-
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
1500
|
-
*/
|
|
1501
|
-
export function positionRatioX64(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1502
|
-
const ret = wasm.positionRatioX64(
|
|
1503
|
-
return takeObject(ret);
|
|
1320
|
+
/**
|
|
1321
|
+
* Calculate the token_a / token_b ratio of a (ficticious) position
|
|
1322
|
+
*
|
|
1323
|
+
* # Parameters
|
|
1324
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1325
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1326
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1327
|
+
*
|
|
1328
|
+
* # Returns
|
|
1329
|
+
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
1330
|
+
*/
|
|
1331
|
+
export function positionRatioX64(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1332
|
+
const ret = wasm.positionRatioX64(current_sqrt_price, current_sqrt_price >> BigInt(64), tick_index_1, tick_index_2);
|
|
1333
|
+
return takeObject(ret);
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
/**
|
|
1337
|
+
* Convert a price into a sqrt priceX64
|
|
1338
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1339
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1340
|
+
*
|
|
1341
|
+
* # Parameters
|
|
1342
|
+
* * `price` - The price to convert
|
|
1343
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1344
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1345
|
+
*
|
|
1346
|
+
* # Returns
|
|
1347
|
+
* * `u128` - The sqrt priceX64
|
|
1348
|
+
*/
|
|
1349
|
+
export function priceToSqrtPrice(price, decimals_a, decimals_b) {
|
|
1350
|
+
try {
|
|
1351
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1352
|
+
wasm.priceToSqrtPrice(retptr, price, decimals_a, decimals_b);
|
|
1353
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1354
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
1355
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
1356
|
+
} finally {
|
|
1357
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Convert a sqrt priceX64 into a tick index
|
|
1363
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1364
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1365
|
+
*
|
|
1366
|
+
* # Parameters
|
|
1367
|
+
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
1368
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1369
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1370
|
+
*
|
|
1371
|
+
* # Returns
|
|
1372
|
+
* * `f64` - The decimal price
|
|
1373
|
+
*/
|
|
1374
|
+
export function sqrtPriceToPrice(sqrt_price, decimals_a, decimals_b) {
|
|
1375
|
+
const ret = wasm.sqrtPriceToPrice(sqrt_price, sqrt_price >> BigInt(64), decimals_a, decimals_b);
|
|
1376
|
+
return ret;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* Invert a price
|
|
1381
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1382
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1383
|
+
*
|
|
1384
|
+
* # Parameters
|
|
1385
|
+
* * `price` - The price to invert
|
|
1386
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1387
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1388
|
+
*
|
|
1389
|
+
* # Returns
|
|
1390
|
+
* * `f64` - The inverted price
|
|
1391
|
+
*/
|
|
1392
|
+
export function invertPrice(price, decimals_a, decimals_b) {
|
|
1393
|
+
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
1394
|
+
return ret;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* Convert a tick index into a price
|
|
1399
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1400
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1401
|
+
*
|
|
1402
|
+
* # Parameters
|
|
1403
|
+
* * `tick_index` - The tick index to convert
|
|
1404
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1405
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1406
|
+
*
|
|
1407
|
+
* # Returns
|
|
1408
|
+
* * `f64` - The decimal price
|
|
1409
|
+
*/
|
|
1410
|
+
export function tickIndexToPrice(tick_index, decimals_a, decimals_b) {
|
|
1411
|
+
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
1412
|
+
return ret;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
/**
|
|
1416
|
+
* Convert a price into a tick index
|
|
1417
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1418
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1419
|
+
*
|
|
1420
|
+
* # Parameters
|
|
1421
|
+
* * `price` - The price to convert
|
|
1422
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1423
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1424
|
+
*
|
|
1425
|
+
* # Returns
|
|
1426
|
+
* * `i32` - The tick index
|
|
1427
|
+
*/
|
|
1428
|
+
export function priceToTickIndex(price, decimals_a, decimals_b) {
|
|
1429
|
+
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
1430
|
+
return ret;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
export function _TICK_ARRAY_NOT_EVENLY_SPACED() {
|
|
1434
|
+
try {
|
|
1435
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1436
|
+
wasm._TICK_ARRAY_NOT_EVENLY_SPACED(retptr);
|
|
1437
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1438
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1439
|
+
return getStringFromWasm0(r0, r1);
|
|
1440
|
+
} finally {
|
|
1441
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
export function _TICK_INDEX_OUT_OF_BOUNDS() {
|
|
1446
|
+
try {
|
|
1447
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1448
|
+
wasm._TICK_INDEX_OUT_OF_BOUNDS(retptr);
|
|
1449
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1450
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1451
|
+
return getStringFromWasm0(r0, r1);
|
|
1452
|
+
} finally {
|
|
1453
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
export function _INVALID_TICK_INDEX() {
|
|
1458
|
+
try {
|
|
1459
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1460
|
+
wasm._INVALID_TICK_INDEX(retptr);
|
|
1461
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1462
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1463
|
+
return getStringFromWasm0(r0, r1);
|
|
1464
|
+
} finally {
|
|
1465
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
export function _ARITHMETIC_OVERFLOW() {
|
|
1470
|
+
try {
|
|
1471
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1472
|
+
wasm._ARITHMETIC_OVERFLOW(retptr);
|
|
1473
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1474
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1475
|
+
return getStringFromWasm0(r0, r1);
|
|
1476
|
+
} finally {
|
|
1477
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
export function _AMOUNT_EXCEEDS_MAX_U64() {
|
|
1482
|
+
try {
|
|
1483
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1484
|
+
wasm._AMOUNT_EXCEEDS_MAX_U64(retptr);
|
|
1485
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1486
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1487
|
+
return getStringFromWasm0(r0, r1);
|
|
1488
|
+
} finally {
|
|
1489
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
export function _AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT() {
|
|
1494
|
+
try {
|
|
1495
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1496
|
+
wasm._AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT(retptr);
|
|
1497
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1498
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1499
|
+
return getStringFromWasm0(r0, r1);
|
|
1500
|
+
} finally {
|
|
1501
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
export function _SQRT_PRICE_OUT_OF_BOUNDS() {
|
|
1506
|
+
try {
|
|
1507
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1508
|
+
wasm._SQRT_PRICE_OUT_OF_BOUNDS(retptr);
|
|
1509
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1510
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1511
|
+
return getStringFromWasm0(r0, r1);
|
|
1512
|
+
} finally {
|
|
1513
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
export function _TICK_SEQUENCE_EMPTY() {
|
|
1518
|
+
try {
|
|
1519
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1520
|
+
wasm._TICK_SEQUENCE_EMPTY(retptr);
|
|
1521
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1522
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1523
|
+
return getStringFromWasm0(r0, r1);
|
|
1524
|
+
} finally {
|
|
1525
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
export function _SQRT_PRICE_LIMIT_OUT_OF_BOUNDS() {
|
|
1530
|
+
try {
|
|
1531
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1532
|
+
wasm._SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(retptr);
|
|
1533
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1534
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1535
|
+
return getStringFromWasm0(r0, r1);
|
|
1536
|
+
} finally {
|
|
1537
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
export function _INVALID_SQRT_PRICE_LIMIT_DIRECTION() {
|
|
1542
|
+
try {
|
|
1543
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1544
|
+
wasm._INVALID_SQRT_PRICE_LIMIT_DIRECTION(retptr);
|
|
1545
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1546
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1547
|
+
return getStringFromWasm0(r0, r1);
|
|
1548
|
+
} finally {
|
|
1549
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1550
|
+
}
|
|
1504
1551
|
}
|
|
1505
1552
|
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
*
|
|
1511
|
-
*
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
* # Returns
|
|
1517
|
-
* * `u128` - The sqrt priceX64
|
|
1518
|
-
*/
|
|
1519
|
-
export function priceToSqrtPrice(price, decimals_a, decimals_b) {
|
|
1520
|
-
const ret = wasm.priceToSqrtPrice(price, decimals_a, decimals_b);
|
|
1521
|
-
return takeObject(ret);
|
|
1553
|
+
export function _ZERO_TRADABLE_AMOUNT() {
|
|
1554
|
+
try {
|
|
1555
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1556
|
+
wasm._ZERO_TRADABLE_AMOUNT(retptr);
|
|
1557
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1558
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1559
|
+
return getStringFromWasm0(r0, r1);
|
|
1560
|
+
} finally {
|
|
1561
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1562
|
+
}
|
|
1522
1563
|
}
|
|
1523
1564
|
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
*
|
|
1529
|
-
*
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
* # Returns
|
|
1535
|
-
* * `f64` - The decimal price
|
|
1536
|
-
*/
|
|
1537
|
-
export function sqrtPriceToPrice(sqrt_price, decimals_a, decimals_b) {
|
|
1538
|
-
const ret = wasm.sqrtPriceToPrice(addHeapObject(sqrt_price), decimals_a, decimals_b);
|
|
1539
|
-
return ret;
|
|
1565
|
+
export function _INVALID_TIMESTAMP() {
|
|
1566
|
+
try {
|
|
1567
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1568
|
+
wasm._INVALID_TIMESTAMP(retptr);
|
|
1569
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1570
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1571
|
+
return getStringFromWasm0(r0, r1);
|
|
1572
|
+
} finally {
|
|
1573
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1574
|
+
}
|
|
1540
1575
|
}
|
|
1541
1576
|
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
*
|
|
1547
|
-
*
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
* # Returns
|
|
1553
|
-
* * `f64` - The inverted price
|
|
1554
|
-
*/
|
|
1555
|
-
export function invertPrice(price, decimals_a, decimals_b) {
|
|
1556
|
-
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
1557
|
-
return ret;
|
|
1577
|
+
export function _INVALID_TRANSFER_FEE() {
|
|
1578
|
+
try {
|
|
1579
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1580
|
+
wasm._INVALID_TRANSFER_FEE(retptr);
|
|
1581
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1582
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1583
|
+
return getStringFromWasm0(r0, r1);
|
|
1584
|
+
} finally {
|
|
1585
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1586
|
+
}
|
|
1558
1587
|
}
|
|
1559
1588
|
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
*
|
|
1565
|
-
*
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
* # Returns
|
|
1571
|
-
* * `f64` - The decimal price
|
|
1572
|
-
*/
|
|
1573
|
-
export function tickIndexToPrice(tick_index, decimals_a, decimals_b) {
|
|
1574
|
-
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
1575
|
-
return ret;
|
|
1589
|
+
export function _INVALID_SLIPPAGE_TOLERANCE() {
|
|
1590
|
+
try {
|
|
1591
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1592
|
+
wasm._INVALID_SLIPPAGE_TOLERANCE(retptr);
|
|
1593
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1594
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1595
|
+
return getStringFromWasm0(r0, r1);
|
|
1596
|
+
} finally {
|
|
1597
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1598
|
+
}
|
|
1576
1599
|
}
|
|
1577
1600
|
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
*
|
|
1583
|
-
*
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
* # Returns
|
|
1589
|
-
* * `i32` - The tick index
|
|
1590
|
-
*/
|
|
1591
|
-
export function priceToTickIndex(price, decimals_a, decimals_b) {
|
|
1592
|
-
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
1593
|
-
return ret;
|
|
1601
|
+
export function _TICK_INDEX_NOT_IN_ARRAY() {
|
|
1602
|
+
try {
|
|
1603
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1604
|
+
wasm._TICK_INDEX_NOT_IN_ARRAY(retptr);
|
|
1605
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1606
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1607
|
+
return getStringFromWasm0(r0, r1);
|
|
1608
|
+
} finally {
|
|
1609
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1610
|
+
}
|
|
1594
1611
|
}
|
|
1595
1612
|
|
|
1596
|
-
|
|
1597
|
-
* Computes the liquidation prices for an existing position.
|
|
1598
|
-
*
|
|
1599
|
-
* # Parameters
|
|
1600
|
-
* - `lower_tick_index`: The lower tick index of the position.
|
|
1601
|
-
* - `upper_tick_index`: The upper tick index of the position.
|
|
1602
|
-
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
1603
|
-
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
1604
|
-
* - `liquidity`: Liquidity of the position.
|
|
1605
|
-
* - `debt_a`: The amount of tokens A borrowed.
|
|
1606
|
-
* - `debt_b`: The amount of tokens B borrowed.
|
|
1607
|
-
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
1608
|
-
*
|
|
1609
|
-
* # Returns
|
|
1610
|
-
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
1611
|
-
*/
|
|
1612
|
-
export function getLpPositionLiquidationPrices(lower_tick_index, upper_tick_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
|
|
1613
|
+
export function _INVALID_TICK_ARRAY_SEQUENCE() {
|
|
1613
1614
|
try {
|
|
1614
1615
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1615
|
-
wasm.
|
|
1616
|
+
wasm._INVALID_TICK_ARRAY_SEQUENCE(retptr);
|
|
1616
1617
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1617
1618
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1619
|
+
return getStringFromWasm0(r0, r1);
|
|
1620
|
+
} finally {
|
|
1621
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
export function _LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC() {
|
|
1626
|
+
try {
|
|
1627
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1628
|
+
wasm._LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC(retptr);
|
|
1629
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1630
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1631
|
+
return getStringFromWasm0(r0, r1);
|
|
1623
1632
|
} finally {
|
|
1624
1633
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1625
1634
|
}
|
|
@@ -1687,6 +1696,64 @@ export function swapQuoteByOutputToken(token_out, specified_token_a, slippage_to
|
|
|
1687
1696
|
}
|
|
1688
1697
|
}
|
|
1689
1698
|
|
|
1699
|
+
/**
|
|
1700
|
+
* Computes the liquidation prices for an existing position.
|
|
1701
|
+
*
|
|
1702
|
+
* # Parameters
|
|
1703
|
+
* - `tick_lower_index`: The lower tick index of the position.
|
|
1704
|
+
* - `tick_upper_index`: The upper tick index of the position.
|
|
1705
|
+
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
1706
|
+
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
1707
|
+
* - `liquidity`: Liquidity of the position.
|
|
1708
|
+
* - `debt_a`: The amount of tokens A borrowed.
|
|
1709
|
+
* - `debt_b`: The amount of tokens B borrowed.
|
|
1710
|
+
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
1711
|
+
*
|
|
1712
|
+
* # Returns
|
|
1713
|
+
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
1714
|
+
*/
|
|
1715
|
+
export function getLpPositionLiquidationPrices(tick_lower_index, tick_upper_index, liquidity, leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold) {
|
|
1716
|
+
try {
|
|
1717
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1718
|
+
wasm.getLpPositionLiquidationPrices(retptr, tick_lower_index, tick_upper_index, liquidity, liquidity >> BigInt(64), leftovers_a, leftovers_b, debt_a, debt_b, liquidation_threshold);
|
|
1719
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1720
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1721
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1722
|
+
if (r2) {
|
|
1723
|
+
throw takeObject(r1);
|
|
1724
|
+
}
|
|
1725
|
+
return takeObject(r0);
|
|
1726
|
+
} finally {
|
|
1727
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
export function getIncreaseLpPositionQuote(args) {
|
|
1732
|
+
try {
|
|
1733
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1734
|
+
wasm.getIncreaseLpPositionQuote(retptr, addHeapObject(args));
|
|
1735
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1736
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1737
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1738
|
+
if (r2) {
|
|
1739
|
+
throw takeObject(r1);
|
|
1740
|
+
}
|
|
1741
|
+
return takeObject(r0);
|
|
1742
|
+
} finally {
|
|
1743
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
export function _HUNDRED_PERCENT() {
|
|
1748
|
+
const ret = wasm._HUNDRED_PERCENT();
|
|
1749
|
+
return ret >>> 0;
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
export function _COMPUTED_AMOUNT() {
|
|
1753
|
+
const ret = wasm._COMPUTED_AMOUNT();
|
|
1754
|
+
return BigInt.asUintN(64, ret);
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1690
1757
|
/**
|
|
1691
1758
|
* Spot position increase quote
|
|
1692
1759
|
*
|
|
@@ -1807,6 +1874,11 @@ export function calculateTunaSpotPositionProtocolFee(collateral_token, borrowed_
|
|
|
1807
1874
|
return takeObject(ret);
|
|
1808
1875
|
}
|
|
1809
1876
|
|
|
1877
|
+
export function calculateTunaProtocolFee(collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate) {
|
|
1878
|
+
const ret = wasm.calculateTunaProtocolFee(collateral, borrow, protocol_fee_rate_on_collateral, protocol_fee_rate);
|
|
1879
|
+
return BigInt.asUintN(64, ret);
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1810
1882
|
export function _INVALID_ARGUMENTS() {
|
|
1811
1883
|
try {
|
|
1812
1884
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
@@ -1850,12 +1922,12 @@ export function solana_program_init() {
|
|
|
1850
1922
|
wasm.solana_program_init();
|
|
1851
1923
|
}
|
|
1852
1924
|
|
|
1853
|
-
function
|
|
1854
|
-
wasm.
|
|
1925
|
+
function __wasm_bindgen_func_elem_3207(arg0, arg1) {
|
|
1926
|
+
wasm.__wasm_bindgen_func_elem_3207(arg0, arg1);
|
|
1855
1927
|
}
|
|
1856
1928
|
|
|
1857
|
-
function
|
|
1858
|
-
wasm.
|
|
1929
|
+
function __wasm_bindgen_func_elem_2634(arg0, arg1, arg2) {
|
|
1930
|
+
wasm.__wasm_bindgen_func_elem_2634(arg0, arg1, addHeapObject(arg2));
|
|
1859
1931
|
}
|
|
1860
1932
|
|
|
1861
1933
|
function __wasm_bindgen_func_elem_495(arg0, arg1, arg2, arg3) {
|
|
@@ -3266,27 +3338,27 @@ export function __wbg_warn_1d74dddbe2fd1dbb(arg0) {
|
|
|
3266
3338
|
console.warn(getObject(arg0));
|
|
3267
3339
|
};
|
|
3268
3340
|
|
|
3269
|
-
export function
|
|
3270
|
-
// Cast intrinsic for `
|
|
3271
|
-
const ret =
|
|
3341
|
+
export function __wbindgen_cast_0660a350899916ec(arg0, arg1) {
|
|
3342
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 360, function: Function { arguments: [], shim_idx: 361, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3343
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3203, __wasm_bindgen_func_elem_3207);
|
|
3272
3344
|
return addHeapObject(ret);
|
|
3273
3345
|
};
|
|
3274
3346
|
|
|
3275
|
-
export function
|
|
3276
|
-
// Cast intrinsic for `
|
|
3277
|
-
const ret =
|
|
3347
|
+
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
3348
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
3349
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
3278
3350
|
return addHeapObject(ret);
|
|
3279
3351
|
};
|
|
3280
3352
|
|
|
3281
|
-
export function
|
|
3282
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
3283
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
3353
|
+
export function __wbindgen_cast_2e5f7f1574aa20c6(arg0, arg1) {
|
|
3354
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 232, function: Function { arguments: [Externref], shim_idx: 227, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3355
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_2653, __wasm_bindgen_func_elem_2634);
|
|
3284
3356
|
return addHeapObject(ret);
|
|
3285
3357
|
};
|
|
3286
3358
|
|
|
3287
|
-
export function
|
|
3288
|
-
// Cast intrinsic for `
|
|
3289
|
-
const ret =
|
|
3359
|
+
export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
|
|
3360
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
3361
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
3290
3362
|
return addHeapObject(ret);
|
|
3291
3363
|
};
|
|
3292
3364
|
|