@crypticdot/defituna-core 3.1.0 → 3.2.0
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 +831 -0
- package/dist/browser/defituna_core_js_bindings_bg.js +1651 -7
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +83 -0
- package/dist/nodejs/defituna_core_js_bindings.d.ts +831 -0
- package/dist/nodejs/defituna_core_js_bindings.js +1652 -8
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +83 -0
- package/package.json +3 -2
|
@@ -183,23 +183,1429 @@ function debugString(val) {
|
|
|
183
183
|
return className;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
function handleError(f, args) {
|
|
187
|
+
try {
|
|
188
|
+
return f.apply(this, args);
|
|
189
|
+
} catch (e) {
|
|
190
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
186
194
|
function getArrayU8FromWasm0(ptr, len) {
|
|
187
195
|
ptr = ptr >>> 0;
|
|
188
196
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
189
197
|
}
|
|
190
198
|
|
|
191
|
-
function dropObject(idx) {
|
|
192
|
-
if (idx < 132) return;
|
|
193
|
-
heap[idx] = heap_next;
|
|
194
|
-
heap_next = idx;
|
|
199
|
+
function dropObject(idx) {
|
|
200
|
+
if (idx < 132) return;
|
|
201
|
+
heap[idx] = heap_next;
|
|
202
|
+
heap_next = idx;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function takeObject(idx) {
|
|
206
|
+
const ret = getObject(idx);
|
|
207
|
+
dropObject(idx);
|
|
208
|
+
return ret;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Get the first tick index in the tick array that contains the specified tick index.
|
|
212
|
+
*
|
|
213
|
+
* # Parameters
|
|
214
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
215
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
216
|
+
*
|
|
217
|
+
* # Returns
|
|
218
|
+
* - A i32 integer representing the first tick index in the tick array
|
|
219
|
+
*/
|
|
220
|
+
export function getTickArrayStartTickIndex(tick_index, tick_spacing) {
|
|
221
|
+
const ret = wasm.getTickArrayStartTickIndex(tick_index, tick_spacing);
|
|
222
|
+
return ret;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Derive the sqrt-price from a tick index. The precision of this method is only guarranted
|
|
227
|
+
* if tick is within the bounds of {max, min} tick-index.
|
|
228
|
+
*
|
|
229
|
+
* # Parameters
|
|
230
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
231
|
+
*
|
|
232
|
+
* # Returns
|
|
233
|
+
* - `Ok`: A u128 Q32.64 representing the sqrt_price
|
|
234
|
+
*/
|
|
235
|
+
export function tickIndexToSqrtPrice(tick_index) {
|
|
236
|
+
const ret = wasm.tickIndexToSqrtPrice(tick_index);
|
|
237
|
+
return takeObject(ret);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Derive the tick index from a sqrt price. The precision of this method is only guarranted
|
|
242
|
+
* if tick is within the bounds of {max, min} tick-index.
|
|
243
|
+
*
|
|
244
|
+
* # Parameters
|
|
245
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price
|
|
246
|
+
*
|
|
247
|
+
* # Returns
|
|
248
|
+
* - `Ok`: A i32 integer representing the tick integer
|
|
249
|
+
*/
|
|
250
|
+
export function sqrtPriceToTickIndex(sqrt_price) {
|
|
251
|
+
const ret = wasm.sqrtPriceToTickIndex(addHeapObject(sqrt_price));
|
|
252
|
+
return ret;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Get the initializable tick index.
|
|
257
|
+
* If the tick index is already initializable, it is returned as is.
|
|
258
|
+
*
|
|
259
|
+
* # Parameters
|
|
260
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
261
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
262
|
+
* - `round_up` - A boolean value indicating if the supplied tick index should be rounded up. None will round to the nearest.
|
|
263
|
+
*
|
|
264
|
+
* # Returns
|
|
265
|
+
* - A i32 integer representing the previous initializable tick index
|
|
266
|
+
*/
|
|
267
|
+
export function getInitializableTickIndex(tick_index, tick_spacing, round_up) {
|
|
268
|
+
const ret = wasm.getInitializableTickIndex(tick_index, tick_spacing, isLikeNone(round_up) ? 0xFFFFFF : round_up ? 1 : 0);
|
|
269
|
+
return ret;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Get the previous initializable tick index.
|
|
274
|
+
*
|
|
275
|
+
* # Parameters
|
|
276
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
277
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
278
|
+
*
|
|
279
|
+
* # Returns
|
|
280
|
+
* - A i32 integer representing the previous initializable tick index
|
|
281
|
+
*/
|
|
282
|
+
export function getPrevInitializableTickIndex(tick_index, tick_spacing) {
|
|
283
|
+
const ret = wasm.getPrevInitializableTickIndex(tick_index, tick_spacing);
|
|
284
|
+
return ret;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Get the next initializable tick index.
|
|
289
|
+
*
|
|
290
|
+
* # Parameters
|
|
291
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
292
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
293
|
+
*
|
|
294
|
+
* # Returns
|
|
295
|
+
* - A i32 integer representing the next initializable tick index
|
|
296
|
+
*/
|
|
297
|
+
export function getNextInitializableTickIndex(tick_index, tick_spacing) {
|
|
298
|
+
const ret = wasm.getNextInitializableTickIndex(tick_index, tick_spacing);
|
|
299
|
+
return ret;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Check if a tick is in-bounds.
|
|
304
|
+
*
|
|
305
|
+
* # Parameters
|
|
306
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
307
|
+
*
|
|
308
|
+
* # Returns
|
|
309
|
+
* - A boolean value indicating if the tick is in-bounds
|
|
310
|
+
*/
|
|
311
|
+
export function isTickIndexInBounds(tick_index) {
|
|
312
|
+
const ret = wasm.isTickIndexInBounds(tick_index);
|
|
313
|
+
return ret !== 0;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Check if a tick is initializable.
|
|
318
|
+
* A tick is initializable if it is divisible by the tick spacing.
|
|
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 boolean value indicating if the tick is initializable
|
|
326
|
+
*/
|
|
327
|
+
export function isTickInitializable(tick_index, tick_spacing) {
|
|
328
|
+
const ret = wasm.isTickInitializable(tick_index, tick_spacing);
|
|
329
|
+
return ret !== 0;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Get the tick index for the inverse of the price that this tick represents.
|
|
334
|
+
* Eg: Consider tick i where Pb/Pa = 1.0001 ^ i
|
|
335
|
+
* inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i
|
|
336
|
+
*
|
|
337
|
+
* # Parameters
|
|
338
|
+
* - `tick_index` - A i32 integer representing the tick integer
|
|
339
|
+
*
|
|
340
|
+
* # Returns
|
|
341
|
+
* - A i32 integer representing the tick index for the inverse of the price
|
|
342
|
+
*/
|
|
343
|
+
export function invertTickIndex(tick_index) {
|
|
344
|
+
const ret = wasm.invertTickIndex(tick_index);
|
|
345
|
+
return ret;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Get the sqrt price for the inverse of the price that this tick represents.
|
|
350
|
+
* Because converting to a tick index and then back to a sqrt price is lossy,
|
|
351
|
+
* this function is clamped to the nearest tick index.
|
|
352
|
+
*
|
|
353
|
+
* # Parameters
|
|
354
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price
|
|
355
|
+
*
|
|
356
|
+
* # Returns
|
|
357
|
+
* - A u128 integer representing the sqrt price for the inverse of the price
|
|
358
|
+
*/
|
|
359
|
+
export function invertSqrtPrice(sqrt_price) {
|
|
360
|
+
const ret = wasm.invertSqrtPrice(addHeapObject(sqrt_price));
|
|
361
|
+
return takeObject(ret);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Get the minimum and maximum tick index that can be initialized.
|
|
366
|
+
*
|
|
367
|
+
* # Parameters
|
|
368
|
+
* - `tick_spacing` - A i32 integer representing the tick spacing
|
|
369
|
+
*
|
|
370
|
+
* # Returns
|
|
371
|
+
* - A TickRange struct containing the lower and upper tick index
|
|
372
|
+
*/
|
|
373
|
+
export function getFullRangeTickIndexes(tick_spacing) {
|
|
374
|
+
const ret = wasm.getFullRangeTickIndexes(tick_spacing);
|
|
375
|
+
return takeObject(ret);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Order tick indexes in ascending order.
|
|
380
|
+
* If the lower tick index is greater than the upper tick index, the indexes are swapped.
|
|
381
|
+
* This is useful for ensuring that the lower tick index is always less than the upper tick index.
|
|
382
|
+
*
|
|
383
|
+
* # Parameters
|
|
384
|
+
* - `tick_index_1` - A i32 integer representing the first tick index
|
|
385
|
+
* - `tick_index_2` - A i32 integer representing the second tick index
|
|
386
|
+
*
|
|
387
|
+
* # Returns
|
|
388
|
+
* - A TickRange struct containing the lower and upper tick index
|
|
389
|
+
*/
|
|
390
|
+
export function orderTickIndexes(tick_index_1, tick_index_2) {
|
|
391
|
+
const ret = wasm.orderTickIndexes(tick_index_1, tick_index_2);
|
|
392
|
+
return takeObject(ret);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Check if a fusion_pool is a full-range only pool.
|
|
397
|
+
*
|
|
398
|
+
* # Parameters
|
|
399
|
+
* - `tick_spacing` - A u16 integer representing the tick spacing
|
|
400
|
+
*
|
|
401
|
+
* # Returns
|
|
402
|
+
* - A boolean value indicating if the fusion_pool is a full-range only pool
|
|
403
|
+
*/
|
|
404
|
+
export function isFullRangeOnly(tick_spacing) {
|
|
405
|
+
const ret = wasm.isFullRangeOnly(tick_spacing);
|
|
406
|
+
return ret !== 0;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Get the index of a tick in a tick array.
|
|
411
|
+
*
|
|
412
|
+
* # Parameters
|
|
413
|
+
* - `tick_index` - A i32 integer representing the tick index
|
|
414
|
+
* - `tick_array_start_index` - A i32 integer representing the start tick index of the tick array
|
|
415
|
+
* - `tick_spacing` - A u16 integer representing the tick spacing
|
|
416
|
+
*
|
|
417
|
+
* # Returns
|
|
418
|
+
* - A u32 integer representing the tick index in the tick array
|
|
419
|
+
*/
|
|
420
|
+
export function getTickIndexInArray(tick_index, tick_array_start_index, tick_spacing) {
|
|
421
|
+
try {
|
|
422
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
423
|
+
wasm.getTickIndexInArray(retptr, tick_index, tick_array_start_index, tick_spacing);
|
|
424
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
425
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
426
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
427
|
+
if (r2) {
|
|
428
|
+
throw takeObject(r1);
|
|
429
|
+
}
|
|
430
|
+
return r0 >>> 0;
|
|
431
|
+
} finally {
|
|
432
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Calculate the amount A delta between two sqrt_prices
|
|
438
|
+
*
|
|
439
|
+
* # Parameters
|
|
440
|
+
* - `sqrt_price_1`: The first square root price
|
|
441
|
+
* - `sqrt_price_2`: The second square root price
|
|
442
|
+
* - `liquidity`: The liquidity
|
|
443
|
+
* - `round_up`: Whether to round up or not
|
|
444
|
+
*
|
|
445
|
+
* # Returns
|
|
446
|
+
* - `u64`: The amount delta
|
|
447
|
+
*/
|
|
448
|
+
export function tryGetAmountDeltaA(sqrt_price_1, sqrt_price_2, liquidity, round_up) {
|
|
449
|
+
try {
|
|
450
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
451
|
+
wasm.tryGetAmountDeltaA(retptr, addHeapObject(sqrt_price_1), addHeapObject(sqrt_price_2), addHeapObject(liquidity), round_up);
|
|
452
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
453
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
454
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
455
|
+
if (r3) {
|
|
456
|
+
throw takeObject(r2);
|
|
457
|
+
}
|
|
458
|
+
return BigInt.asUintN(64, r0);
|
|
459
|
+
} finally {
|
|
460
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Calculate the amount B delta between two sqrt_prices
|
|
466
|
+
*
|
|
467
|
+
* # Parameters
|
|
468
|
+
* - `sqrt_price_1`: The first square root price
|
|
469
|
+
* - `sqrt_price_2`: The second square root price
|
|
470
|
+
* - `liquidity`: The liquidity
|
|
471
|
+
* - `round_up`: Whether to round up or not
|
|
472
|
+
*
|
|
473
|
+
* # Returns
|
|
474
|
+
* - `u64`: The amount delta
|
|
475
|
+
*/
|
|
476
|
+
export function tryGetAmountDeltaB(sqrt_price_1, sqrt_price_2, liquidity, round_up) {
|
|
477
|
+
try {
|
|
478
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
479
|
+
wasm.tryGetAmountDeltaB(retptr, addHeapObject(sqrt_price_1), addHeapObject(sqrt_price_2), addHeapObject(liquidity), round_up);
|
|
480
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
481
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
482
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
483
|
+
if (r3) {
|
|
484
|
+
throw takeObject(r2);
|
|
485
|
+
}
|
|
486
|
+
return BigInt.asUintN(64, r0);
|
|
487
|
+
} finally {
|
|
488
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Calculate the next square root price
|
|
494
|
+
*
|
|
495
|
+
* # Parameters
|
|
496
|
+
* - `current_sqrt_price`: The current square root price
|
|
497
|
+
* - `current_liquidity`: The current liquidity
|
|
498
|
+
* - `amount`: The amount
|
|
499
|
+
* - `specified_input`: Whether the input is specified
|
|
500
|
+
*
|
|
501
|
+
* # Returns
|
|
502
|
+
* - `u128`: The next square root price
|
|
503
|
+
*/
|
|
504
|
+
export function tryGetNextSqrtPriceFromA(current_sqrt_price, current_liquidity, amount, specified_input) {
|
|
505
|
+
try {
|
|
506
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
507
|
+
wasm.tryGetNextSqrtPriceFromA(retptr, addHeapObject(current_sqrt_price), addHeapObject(current_liquidity), amount, specified_input);
|
|
508
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
509
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
510
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
511
|
+
if (r2) {
|
|
512
|
+
throw takeObject(r1);
|
|
513
|
+
}
|
|
514
|
+
return takeObject(r0);
|
|
515
|
+
} finally {
|
|
516
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Calculate the next square root price
|
|
522
|
+
*
|
|
523
|
+
* # Parameters
|
|
524
|
+
* - `current_sqrt_price`: The current square root price
|
|
525
|
+
* - `current_liquidity`: The current liquidity
|
|
526
|
+
* - `amount`: The amount
|
|
527
|
+
* - `specified_input`: Whether the input is specified
|
|
528
|
+
*
|
|
529
|
+
* # Returns
|
|
530
|
+
* - `u128`: The next square root price
|
|
531
|
+
*/
|
|
532
|
+
export function tryGetNextSqrtPriceFromB(current_sqrt_price, current_liquidity, amount, specified_input) {
|
|
533
|
+
try {
|
|
534
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
535
|
+
wasm.tryGetNextSqrtPriceFromB(retptr, addHeapObject(current_sqrt_price), addHeapObject(current_liquidity), amount, specified_input);
|
|
536
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
537
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
538
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
539
|
+
if (r2) {
|
|
540
|
+
throw takeObject(r1);
|
|
541
|
+
}
|
|
542
|
+
return takeObject(r0);
|
|
543
|
+
} finally {
|
|
544
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Apply a transfer fee to an amount
|
|
550
|
+
* e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
|
|
551
|
+
* So the amount after fee will be 9900.
|
|
552
|
+
*
|
|
553
|
+
* # Parameters
|
|
554
|
+
* - `amount`: The amount to apply the fee to
|
|
555
|
+
* - `transfer_fee`: The transfer fee to apply
|
|
556
|
+
*
|
|
557
|
+
* # Returns
|
|
558
|
+
* - `u64`: The amount after the fee has been applied
|
|
559
|
+
*/
|
|
560
|
+
export function tryApplyTransferFee(amount, transfer_fee) {
|
|
561
|
+
try {
|
|
562
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
563
|
+
wasm.tryApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
|
|
564
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
565
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
566
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
567
|
+
if (r3) {
|
|
568
|
+
throw takeObject(r2);
|
|
569
|
+
}
|
|
570
|
+
return BigInt.asUintN(64, r0);
|
|
571
|
+
} finally {
|
|
572
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Reverse the application of a transfer fee to an amount
|
|
578
|
+
* e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
|
|
579
|
+
* So the amount before fee will be 10000.
|
|
580
|
+
*
|
|
581
|
+
* # Parameters
|
|
582
|
+
* - `amount`: The amount to reverse the fee from
|
|
583
|
+
* - `transfer_fee`: The transfer fee to reverse
|
|
584
|
+
*
|
|
585
|
+
* # Returns
|
|
586
|
+
* - `u64`: The amount before the fee has been applied
|
|
587
|
+
*/
|
|
588
|
+
export function tryReverseApplyTransferFee(amount, transfer_fee) {
|
|
589
|
+
try {
|
|
590
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
591
|
+
wasm.tryReverseApplyTransferFee(retptr, amount, addHeapObject(transfer_fee));
|
|
592
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
593
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
594
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
595
|
+
if (r3) {
|
|
596
|
+
throw takeObject(r2);
|
|
597
|
+
}
|
|
598
|
+
return BigInt.asUintN(64, r0);
|
|
599
|
+
} finally {
|
|
600
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Get the maximum amount with a slippage tolerance
|
|
606
|
+
* e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
|
|
607
|
+
*
|
|
608
|
+
* # Parameters
|
|
609
|
+
* - `amount`: The amount to apply the fee to
|
|
610
|
+
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
611
|
+
*
|
|
612
|
+
* # Returns
|
|
613
|
+
* - `u64`: The maximum amount
|
|
614
|
+
*/
|
|
615
|
+
export function tryGetMaxAmountWithSlippageTolerance(amount, slippage_tolerance_bps) {
|
|
616
|
+
try {
|
|
617
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
618
|
+
wasm.tryGetMaxAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
|
|
619
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
620
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
621
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
622
|
+
if (r3) {
|
|
623
|
+
throw takeObject(r2);
|
|
624
|
+
}
|
|
625
|
+
return BigInt.asUintN(64, r0);
|
|
626
|
+
} finally {
|
|
627
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Get the minimum amount with a slippage tolerance
|
|
633
|
+
* e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
|
|
634
|
+
*
|
|
635
|
+
* # Parameters
|
|
636
|
+
* - `amount`: The amount to apply the fee to
|
|
637
|
+
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
638
|
+
*
|
|
639
|
+
* # Returns
|
|
640
|
+
* - `u64`: The minimum amount
|
|
641
|
+
*/
|
|
642
|
+
export function tryGetMinAmountWithSlippageTolerance(amount, slippage_tolerance_bps) {
|
|
643
|
+
try {
|
|
644
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
645
|
+
wasm.tryGetMinAmountWithSlippageTolerance(retptr, amount, slippage_tolerance_bps);
|
|
646
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
647
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
648
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
649
|
+
if (r3) {
|
|
650
|
+
throw takeObject(r2);
|
|
651
|
+
}
|
|
652
|
+
return BigInt.asUintN(64, r0);
|
|
653
|
+
} finally {
|
|
654
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Apply a swap fee to an amount
|
|
660
|
+
* e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
|
|
661
|
+
* So the amount after fee will be 9900.
|
|
662
|
+
*
|
|
663
|
+
* # Parameters
|
|
664
|
+
* - `amount`: The amount to apply the fee to
|
|
665
|
+
* - `fee_rate`: The fee rate to apply denominated in 1e6
|
|
666
|
+
*
|
|
667
|
+
* # Returns
|
|
668
|
+
* - `u64`: The amount after the fee has been applied
|
|
669
|
+
*/
|
|
670
|
+
export function tryApplySwapFee(amount, fee_rate) {
|
|
671
|
+
try {
|
|
672
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
673
|
+
wasm.tryApplySwapFee(retptr, amount, fee_rate);
|
|
674
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
675
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
676
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
677
|
+
if (r3) {
|
|
678
|
+
throw takeObject(r2);
|
|
679
|
+
}
|
|
680
|
+
return BigInt.asUintN(64, r0);
|
|
681
|
+
} finally {
|
|
682
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Reverse the application of a swap fee to an amount
|
|
688
|
+
* e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
|
|
689
|
+
* So the amount before fee will be 10000.
|
|
690
|
+
*
|
|
691
|
+
* # Parameters
|
|
692
|
+
* - `amount`: The amount to reverse the fee from
|
|
693
|
+
* - `fee_rate`: The fee rate to reverse denominated in 1e6
|
|
694
|
+
*
|
|
695
|
+
* # Returns
|
|
696
|
+
* - `u64`: The amount before the fee has been applied
|
|
697
|
+
*/
|
|
698
|
+
export function tryReverseApplySwapFee(amount, fee_rate) {
|
|
699
|
+
try {
|
|
700
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
701
|
+
wasm.tryReverseApplySwapFee(retptr, amount, fee_rate);
|
|
702
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
703
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
704
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
705
|
+
if (r3) {
|
|
706
|
+
throw takeObject(r2);
|
|
707
|
+
}
|
|
708
|
+
return BigInt.asUintN(64, r0);
|
|
709
|
+
} finally {
|
|
710
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Computes the limit order output amount by input amount.
|
|
716
|
+
* ### Parameters
|
|
717
|
+
* - `amount_in` - The input token amount of a limit order.
|
|
718
|
+
* - `a_to_b_order` - The limit order direction.
|
|
719
|
+
* - `tick_index` - The tick index of an order.
|
|
720
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
721
|
+
*/
|
|
722
|
+
export function limitOrderQuoteByInputToken(amount_in, a_to_b_order, tick_index, fusion_pool) {
|
|
723
|
+
try {
|
|
724
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
725
|
+
wasm.limitOrderQuoteByInputToken(retptr, amount_in, a_to_b_order, tick_index, addHeapObject(fusion_pool));
|
|
726
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
727
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
728
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
729
|
+
if (r3) {
|
|
730
|
+
throw takeObject(r2);
|
|
731
|
+
}
|
|
732
|
+
return BigInt.asUintN(64, r0);
|
|
733
|
+
} finally {
|
|
734
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Computes the limit order input amount by output amount.
|
|
740
|
+
* ### Parameters
|
|
741
|
+
* - `amount_out` - The output token amount of a limit order.
|
|
742
|
+
* - `a_to_b_order` - The limit order direction.
|
|
743
|
+
* - `tick_index` - The tick index of an order.
|
|
744
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
745
|
+
*/
|
|
746
|
+
export function limitOrderQuoteByOutputToken(amount_out, a_to_b_order, tick_index, fusion_pool) {
|
|
747
|
+
try {
|
|
748
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
749
|
+
wasm.limitOrderQuoteByOutputToken(retptr, amount_out, a_to_b_order, tick_index, addHeapObject(fusion_pool));
|
|
750
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
751
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
752
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
753
|
+
if (r3) {
|
|
754
|
+
throw takeObject(r2);
|
|
755
|
+
}
|
|
756
|
+
return BigInt.asUintN(64, r0);
|
|
757
|
+
} finally {
|
|
758
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Computes the limit order reward by input amount.
|
|
764
|
+
* ### Parameters
|
|
765
|
+
* - `amount_out` - The output token amount of a limit order (swap input).
|
|
766
|
+
* - `a_to_b_order` - The limit order direction.
|
|
767
|
+
* - `tick_index` - The tick index of an order.
|
|
768
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
769
|
+
*/
|
|
770
|
+
export function limitOrderRewardByOutputToken(amount_out, fee_rate, protocol_fee_rate) {
|
|
771
|
+
try {
|
|
772
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
773
|
+
wasm.limitOrderRewardByOutputToken(retptr, amount_out, fee_rate, protocol_fee_rate);
|
|
774
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
775
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
776
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
777
|
+
if (r3) {
|
|
778
|
+
throw takeObject(r2);
|
|
779
|
+
}
|
|
780
|
+
return BigInt.asUintN(64, r0);
|
|
781
|
+
} finally {
|
|
782
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
export function decreaseLimitOrderQuote(fusion_pool, limit_order, tick, amount, transfer_fee_a, transfer_fee_b) {
|
|
787
|
+
try {
|
|
788
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
789
|
+
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));
|
|
790
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
791
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
792
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
793
|
+
if (r2) {
|
|
794
|
+
throw takeObject(r1);
|
|
795
|
+
}
|
|
796
|
+
return takeObject(r0);
|
|
797
|
+
} finally {
|
|
798
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Calculate the quote for decreasing liquidity
|
|
804
|
+
*
|
|
805
|
+
* # Parameters
|
|
806
|
+
* - `liquidity_delta` - The amount of liquidity to decrease
|
|
807
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
808
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
809
|
+
* - `tick_index_1` - The first tick index of the position
|
|
810
|
+
* - `tick_index_2` - The second tick index of the position
|
|
811
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
812
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
813
|
+
*
|
|
814
|
+
* # Returns
|
|
815
|
+
* - A DecreaseLiquidityQuote struct containing the estimated token amounts
|
|
816
|
+
*/
|
|
817
|
+
export function decreaseLiquidityQuote(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
818
|
+
try {
|
|
819
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
820
|
+
wasm.decreaseLiquidityQuote(retptr, addHeapObject(liquidity_delta), slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
821
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
822
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
823
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
824
|
+
if (r2) {
|
|
825
|
+
throw takeObject(r1);
|
|
826
|
+
}
|
|
827
|
+
return takeObject(r0);
|
|
828
|
+
} finally {
|
|
829
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Calculate the quote for decreasing liquidity given a token a amount
|
|
835
|
+
*
|
|
836
|
+
* # Parameters
|
|
837
|
+
* - `token_amount_a` - The amount of token a to decrease
|
|
838
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
839
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
840
|
+
* - `tick_index_1` - The first tick index of the position
|
|
841
|
+
* - `tick_index_2` - The second tick index of the position
|
|
842
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
843
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
844
|
+
*
|
|
845
|
+
* # Returns
|
|
846
|
+
* - A DecreaseLiquidityQuote struct containing the estimated token amounts
|
|
847
|
+
*/
|
|
848
|
+
export function decreaseLiquidityQuoteA(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
849
|
+
try {
|
|
850
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
851
|
+
wasm.decreaseLiquidityQuoteA(retptr, token_amount_a, slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
852
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
853
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
854
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
855
|
+
if (r2) {
|
|
856
|
+
throw takeObject(r1);
|
|
857
|
+
}
|
|
858
|
+
return takeObject(r0);
|
|
859
|
+
} finally {
|
|
860
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* Calculate the quote for decreasing liquidity given a token b amount
|
|
866
|
+
*
|
|
867
|
+
* # Parameters
|
|
868
|
+
* - `token_amount_b` - The amount of token b to decrease
|
|
869
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
870
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
871
|
+
* - `tick_index_1` - The first tick index of the position
|
|
872
|
+
* - `tick_index_2` - The second tick index of the position
|
|
873
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
874
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
875
|
+
*
|
|
876
|
+
* # Returns
|
|
877
|
+
* - A DecreaseLiquidityQuote struct containing the estimated token amounts
|
|
878
|
+
*/
|
|
879
|
+
export function decreaseLiquidityQuoteB(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
880
|
+
try {
|
|
881
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
882
|
+
wasm.decreaseLiquidityQuoteB(retptr, token_amount_b, slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
883
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
884
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
885
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
886
|
+
if (r2) {
|
|
887
|
+
throw takeObject(r1);
|
|
888
|
+
}
|
|
889
|
+
return takeObject(r0);
|
|
890
|
+
} finally {
|
|
891
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Calculate the quote for increasing liquidity
|
|
897
|
+
*
|
|
898
|
+
* # Parameters
|
|
899
|
+
* - `liquidity_delta` - The amount of liquidity to increase
|
|
900
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
901
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
902
|
+
* - `tick_index_1` - The first tick index of the position
|
|
903
|
+
* - `tick_index_2` - The second tick index of the position
|
|
904
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
905
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
906
|
+
*
|
|
907
|
+
* # Returns
|
|
908
|
+
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
909
|
+
*/
|
|
910
|
+
export function increaseLiquidityQuote(liquidity_delta, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
911
|
+
try {
|
|
912
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
913
|
+
wasm.increaseLiquidityQuote(retptr, addHeapObject(liquidity_delta), slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
914
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
915
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
916
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
917
|
+
if (r2) {
|
|
918
|
+
throw takeObject(r1);
|
|
919
|
+
}
|
|
920
|
+
return takeObject(r0);
|
|
921
|
+
} finally {
|
|
922
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Calculate the quote for increasing liquidity given a token a amount
|
|
928
|
+
*
|
|
929
|
+
* # Parameters
|
|
930
|
+
* - `token_amount_a` - The amount of token a to increase
|
|
931
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
932
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
933
|
+
* - `tick_index_1` - The first tick index of the position
|
|
934
|
+
* - `tick_index_2` - The second tick index of the position
|
|
935
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
936
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
937
|
+
*
|
|
938
|
+
* # Returns
|
|
939
|
+
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
940
|
+
*/
|
|
941
|
+
export function increaseLiquidityQuoteA(token_amount_a, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
942
|
+
try {
|
|
943
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
944
|
+
wasm.increaseLiquidityQuoteA(retptr, token_amount_a, slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
945
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
946
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
947
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
948
|
+
if (r2) {
|
|
949
|
+
throw takeObject(r1);
|
|
950
|
+
}
|
|
951
|
+
return takeObject(r0);
|
|
952
|
+
} finally {
|
|
953
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Calculate the quote for increasing liquidity given a token b amount
|
|
959
|
+
*
|
|
960
|
+
* # Parameters
|
|
961
|
+
* - `token_amount_b` - The amount of token b to increase
|
|
962
|
+
* - `slippage_tolerance` - The slippage tolerance in bps
|
|
963
|
+
* - `current_sqrt_price` - The current sqrt price of the pool
|
|
964
|
+
* - `tick_index_1` - The first tick index of the position
|
|
965
|
+
* - `tick_index_2` - The second tick index of the position
|
|
966
|
+
* - `transfer_fee_a` - The transfer fee for token A in bps
|
|
967
|
+
* - `transfer_fee_b` - The transfer fee for token B in bps
|
|
968
|
+
*
|
|
969
|
+
* # Returns
|
|
970
|
+
* - An IncreaseLiquidityQuote struct containing the estimated token amounts
|
|
971
|
+
*/
|
|
972
|
+
export function increaseLiquidityQuoteB(token_amount_b, slippage_tolerance_bps, current_sqrt_price, tick_index_1, tick_index_2, transfer_fee_a, transfer_fee_b) {
|
|
973
|
+
try {
|
|
974
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
975
|
+
wasm.increaseLiquidityQuoteB(retptr, token_amount_b, slippage_tolerance_bps, addHeapObject(current_sqrt_price), tick_index_1, tick_index_2, isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
976
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
977
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
978
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
979
|
+
if (r2) {
|
|
980
|
+
throw takeObject(r1);
|
|
981
|
+
}
|
|
982
|
+
return takeObject(r0);
|
|
983
|
+
} finally {
|
|
984
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
export function tryGetLiquidityFromA(token_delta_a, sqrt_price_lower, sqrt_price_upper) {
|
|
989
|
+
try {
|
|
990
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
991
|
+
wasm.tryGetLiquidityFromA(retptr, token_delta_a, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
992
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
993
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
994
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
995
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
996
|
+
if (r5) {
|
|
997
|
+
throw takeObject(r4);
|
|
998
|
+
}
|
|
999
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
1000
|
+
} finally {
|
|
1001
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
export function tryGetTokenAFromLiquidity(liquidity_delta, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
1006
|
+
try {
|
|
1007
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1008
|
+
wasm.tryGetTokenAFromLiquidity(retptr, liquidity_delta, liquidity_delta >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
1009
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1010
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1011
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1012
|
+
if (r3) {
|
|
1013
|
+
throw takeObject(r2);
|
|
1014
|
+
}
|
|
1015
|
+
return BigInt.asUintN(64, r0);
|
|
1016
|
+
} finally {
|
|
1017
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
export function tryGetLiquidityFromB(token_delta_b, sqrt_price_lower, sqrt_price_upper) {
|
|
1022
|
+
try {
|
|
1023
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-32);
|
|
1024
|
+
wasm.tryGetLiquidityFromB(retptr, token_delta_b, sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64));
|
|
1025
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1026
|
+
var r2 = getDataViewMemory0().getBigInt64(retptr + 8 * 1, true);
|
|
1027
|
+
var r4 = getDataViewMemory0().getInt32(retptr + 4 * 4, true);
|
|
1028
|
+
var r5 = getDataViewMemory0().getInt32(retptr + 4 * 5, true);
|
|
1029
|
+
if (r5) {
|
|
1030
|
+
throw takeObject(r4);
|
|
1031
|
+
}
|
|
1032
|
+
return (BigInt.asUintN(64, r0) | (BigInt.asUintN(64, r2) << BigInt(64)));
|
|
1033
|
+
} finally {
|
|
1034
|
+
wasm.__wbindgen_add_to_stack_pointer(32);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
export function tryGetTokenBFromLiquidity(liquidity_delta, sqrt_price_lower, sqrt_price_upper, round_up) {
|
|
1039
|
+
try {
|
|
1040
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1041
|
+
wasm.tryGetTokenBFromLiquidity(retptr, liquidity_delta, liquidity_delta >> BigInt(64), sqrt_price_lower, sqrt_price_lower >> BigInt(64), sqrt_price_upper, sqrt_price_upper >> BigInt(64), round_up);
|
|
1042
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1043
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1044
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1045
|
+
if (r3) {
|
|
1046
|
+
throw takeObject(r2);
|
|
1047
|
+
}
|
|
1048
|
+
return BigInt.asUintN(64, r0);
|
|
1049
|
+
} finally {
|
|
1050
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
export function tryGetTokenEstimatesFromLiquidity(liquidity_delta, current_sqrt_price, tick_lower_index, tick_upper_index, round_up) {
|
|
1055
|
+
try {
|
|
1056
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1057
|
+
wasm.tryGetTokenEstimatesFromLiquidity(retptr, liquidity_delta, liquidity_delta >> BigInt(64), current_sqrt_price, current_sqrt_price >> BigInt(64), tick_lower_index, tick_upper_index, round_up);
|
|
1058
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1059
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1060
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1061
|
+
if (r2) {
|
|
1062
|
+
throw takeObject(r1);
|
|
1063
|
+
}
|
|
1064
|
+
return takeObject(r0);
|
|
1065
|
+
} finally {
|
|
1066
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* Calculate fees owed for a position
|
|
1072
|
+
*
|
|
1073
|
+
* # Paramters
|
|
1074
|
+
* - `fusion_pool`: The fusion_pool state
|
|
1075
|
+
* - `position`: The position state
|
|
1076
|
+
* - `tick_lower`: The lower tick state
|
|
1077
|
+
* - `tick_upper`: The upper tick state
|
|
1078
|
+
* - `transfer_fee_a`: The transfer fee for token A
|
|
1079
|
+
* - `transfer_fee_b`: The transfer fee for token B
|
|
1080
|
+
*
|
|
1081
|
+
* # Returns
|
|
1082
|
+
* - `CollectFeesQuote`: The fees owed for token A and token B
|
|
1083
|
+
*/
|
|
1084
|
+
export function collectFeesQuote(fusion_pool, position, tick_lower, tick_upper, transfer_fee_a, transfer_fee_b) {
|
|
1085
|
+
try {
|
|
1086
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1087
|
+
wasm.collectFeesQuote(retptr, addHeapObject(fusion_pool), addHeapObject(position), addHeapObject(tick_lower), addHeapObject(tick_upper), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1088
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1089
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1090
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1091
|
+
if (r2) {
|
|
1092
|
+
throw takeObject(r1);
|
|
1093
|
+
}
|
|
1094
|
+
return takeObject(r0);
|
|
1095
|
+
} finally {
|
|
1096
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
export function limitOrderFee(fusion_pool) {
|
|
1101
|
+
const ret = wasm.limitOrderFee(addHeapObject(fusion_pool));
|
|
1102
|
+
return ret;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
export function _TICK_ARRAY_SIZE() {
|
|
1106
|
+
const ret = wasm._TICK_ARRAY_SIZE();
|
|
1107
|
+
return ret >>> 0;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD() {
|
|
1111
|
+
const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
|
|
1112
|
+
return ret;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
export function _MIN_TICK_INDEX() {
|
|
1116
|
+
const ret = wasm._MIN_TICK_INDEX();
|
|
1117
|
+
return ret;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
export function _MAX_TICK_INDEX() {
|
|
1121
|
+
const ret = wasm._MAX_TICK_INDEX();
|
|
1122
|
+
return ret;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Convert a price into a sqrt priceX64
|
|
1127
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1128
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1129
|
+
*
|
|
1130
|
+
* # Parameters
|
|
1131
|
+
* * `price` - The price to convert
|
|
1132
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1133
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1134
|
+
*
|
|
1135
|
+
* # Returns
|
|
1136
|
+
* * `u128` - The sqrt priceX64
|
|
1137
|
+
*/
|
|
1138
|
+
export function priceToSqrtPrice(price, decimals_a, decimals_b) {
|
|
1139
|
+
const ret = wasm.priceToSqrtPrice(price, decimals_a, decimals_b);
|
|
1140
|
+
return takeObject(ret);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Convert a sqrt priceX64 into a tick index
|
|
1145
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1146
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1147
|
+
*
|
|
1148
|
+
* # Parameters
|
|
1149
|
+
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
1150
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1151
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1152
|
+
*
|
|
1153
|
+
* # Returns
|
|
1154
|
+
* * `f64` - The decimal price
|
|
1155
|
+
*/
|
|
1156
|
+
export function sqrtPriceToPrice(sqrt_price, decimals_a, decimals_b) {
|
|
1157
|
+
const ret = wasm.sqrtPriceToPrice(addHeapObject(sqrt_price), decimals_a, decimals_b);
|
|
1158
|
+
return ret;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Invert a price
|
|
1163
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1164
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1165
|
+
*
|
|
1166
|
+
* # Parameters
|
|
1167
|
+
* * `price` - The price to invert
|
|
1168
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1169
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1170
|
+
*
|
|
1171
|
+
* # Returns
|
|
1172
|
+
* * `f64` - The inverted price
|
|
1173
|
+
*/
|
|
1174
|
+
export function invertPrice(price, decimals_a, decimals_b) {
|
|
1175
|
+
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
1176
|
+
return ret;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* Convert a tick index into a price
|
|
1181
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1182
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1183
|
+
*
|
|
1184
|
+
* # Parameters
|
|
1185
|
+
* * `tick_index` - The tick index to convert
|
|
1186
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1187
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1188
|
+
*
|
|
1189
|
+
* # Returns
|
|
1190
|
+
* * `f64` - The decimal price
|
|
1191
|
+
*/
|
|
1192
|
+
export function tickIndexToPrice(tick_index, decimals_a, decimals_b) {
|
|
1193
|
+
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
1194
|
+
return ret;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Convert a price into a tick index
|
|
1199
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
1200
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
1201
|
+
*
|
|
1202
|
+
* # Parameters
|
|
1203
|
+
* * `price` - The price to convert
|
|
1204
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
1205
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
1206
|
+
*
|
|
1207
|
+
* # Returns
|
|
1208
|
+
* * `i32` - The tick index
|
|
1209
|
+
*/
|
|
1210
|
+
export function priceToTickIndex(price, decimals_a, decimals_b) {
|
|
1211
|
+
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
1212
|
+
return ret;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
export function _POSITION_BUNDLE_SIZE() {
|
|
1216
|
+
const ret = wasm._POSITION_BUNDLE_SIZE();
|
|
1217
|
+
return ret >>> 0;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
export function _TICK_ARRAY_NOT_EVENLY_SPACED() {
|
|
1221
|
+
try {
|
|
1222
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1223
|
+
wasm._TICK_ARRAY_NOT_EVENLY_SPACED(retptr);
|
|
1224
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1225
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1226
|
+
return getStringFromWasm0(r0, r1);
|
|
1227
|
+
} finally {
|
|
1228
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
export function _TICK_INDEX_OUT_OF_BOUNDS() {
|
|
1233
|
+
try {
|
|
1234
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1235
|
+
wasm._TICK_INDEX_OUT_OF_BOUNDS(retptr);
|
|
1236
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1237
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1238
|
+
return getStringFromWasm0(r0, r1);
|
|
1239
|
+
} finally {
|
|
1240
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
export function _INVALID_TICK_INDEX() {
|
|
1245
|
+
try {
|
|
1246
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1247
|
+
wasm._INVALID_TICK_INDEX(retptr);
|
|
1248
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1249
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1250
|
+
return getStringFromWasm0(r0, r1);
|
|
1251
|
+
} finally {
|
|
1252
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
export function _ARITHMETIC_OVERFLOW() {
|
|
1257
|
+
try {
|
|
1258
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1259
|
+
wasm._ARITHMETIC_OVERFLOW(retptr);
|
|
1260
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1261
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1262
|
+
return getStringFromWasm0(r0, r1);
|
|
1263
|
+
} finally {
|
|
1264
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
export function _AMOUNT_EXCEEDS_MAX_U64() {
|
|
1269
|
+
try {
|
|
1270
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1271
|
+
wasm._AMOUNT_EXCEEDS_MAX_U64(retptr);
|
|
1272
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1273
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1274
|
+
return getStringFromWasm0(r0, r1);
|
|
1275
|
+
} finally {
|
|
1276
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
export function _AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT() {
|
|
1281
|
+
try {
|
|
1282
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1283
|
+
wasm._AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT(retptr);
|
|
1284
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1285
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1286
|
+
return getStringFromWasm0(r0, r1);
|
|
1287
|
+
} finally {
|
|
1288
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
export function _SQRT_PRICE_OUT_OF_BOUNDS() {
|
|
1293
|
+
try {
|
|
1294
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1295
|
+
wasm._SQRT_PRICE_OUT_OF_BOUNDS(retptr);
|
|
1296
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1297
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1298
|
+
return getStringFromWasm0(r0, r1);
|
|
1299
|
+
} finally {
|
|
1300
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
export function _TICK_SEQUENCE_EMPTY() {
|
|
1305
|
+
try {
|
|
1306
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1307
|
+
wasm._TICK_SEQUENCE_EMPTY(retptr);
|
|
1308
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1309
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1310
|
+
return getStringFromWasm0(r0, r1);
|
|
1311
|
+
} finally {
|
|
1312
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
export function _SQRT_PRICE_LIMIT_OUT_OF_BOUNDS() {
|
|
1317
|
+
try {
|
|
1318
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1319
|
+
wasm._SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(retptr);
|
|
1320
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1321
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1322
|
+
return getStringFromWasm0(r0, r1);
|
|
1323
|
+
} finally {
|
|
1324
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
export function _INVALID_SQRT_PRICE_LIMIT_DIRECTION() {
|
|
1329
|
+
try {
|
|
1330
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1331
|
+
wasm._INVALID_SQRT_PRICE_LIMIT_DIRECTION(retptr);
|
|
1332
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1333
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1334
|
+
return getStringFromWasm0(r0, r1);
|
|
1335
|
+
} finally {
|
|
1336
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
export function _ZERO_TRADABLE_AMOUNT() {
|
|
1341
|
+
try {
|
|
1342
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1343
|
+
wasm._ZERO_TRADABLE_AMOUNT(retptr);
|
|
1344
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1345
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1346
|
+
return getStringFromWasm0(r0, r1);
|
|
1347
|
+
} finally {
|
|
1348
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
export function _INVALID_TIMESTAMP() {
|
|
1353
|
+
try {
|
|
1354
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1355
|
+
wasm._INVALID_TIMESTAMP(retptr);
|
|
1356
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1357
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1358
|
+
return getStringFromWasm0(r0, r1);
|
|
1359
|
+
} finally {
|
|
1360
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
export function _INVALID_TRANSFER_FEE() {
|
|
1365
|
+
try {
|
|
1366
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1367
|
+
wasm._INVALID_TRANSFER_FEE(retptr);
|
|
1368
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1369
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1370
|
+
return getStringFromWasm0(r0, r1);
|
|
1371
|
+
} finally {
|
|
1372
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
export function _INVALID_SLIPPAGE_TOLERANCE() {
|
|
1377
|
+
try {
|
|
1378
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1379
|
+
wasm._INVALID_SLIPPAGE_TOLERANCE(retptr);
|
|
1380
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1381
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1382
|
+
return getStringFromWasm0(r0, r1);
|
|
1383
|
+
} finally {
|
|
1384
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1385
|
+
}
|
|
195
1386
|
}
|
|
196
1387
|
|
|
197
|
-
function
|
|
198
|
-
|
|
199
|
-
|
|
1388
|
+
export function _TICK_INDEX_NOT_IN_ARRAY() {
|
|
1389
|
+
try {
|
|
1390
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1391
|
+
wasm._TICK_INDEX_NOT_IN_ARRAY(retptr);
|
|
1392
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1393
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1394
|
+
return getStringFromWasm0(r0, r1);
|
|
1395
|
+
} finally {
|
|
1396
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
export function _INVALID_TICK_ARRAY_SEQUENCE() {
|
|
1401
|
+
try {
|
|
1402
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1403
|
+
wasm._INVALID_TICK_ARRAY_SEQUENCE(retptr);
|
|
1404
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1405
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1406
|
+
return getStringFromWasm0(r0, r1);
|
|
1407
|
+
} finally {
|
|
1408
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
export function _LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC() {
|
|
1413
|
+
try {
|
|
1414
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1415
|
+
wasm._LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC(retptr);
|
|
1416
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1417
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1418
|
+
return getStringFromWasm0(r0, r1);
|
|
1419
|
+
} finally {
|
|
1420
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
export function _FEE_RATE_MUL_VALUE() {
|
|
1425
|
+
const ret = wasm._FEE_RATE_MUL_VALUE();
|
|
1426
|
+
return ret >>> 0;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
export function _MAX_PROTOCOL_FEE_RATE() {
|
|
1430
|
+
const ret = wasm._MAX_PROTOCOL_FEE_RATE();
|
|
200
1431
|
return ret;
|
|
201
1432
|
}
|
|
202
1433
|
|
|
1434
|
+
export function _PROTOCOL_FEE_RATE_MUL_VALUE() {
|
|
1435
|
+
const ret = wasm._PROTOCOL_FEE_RATE_MUL_VALUE();
|
|
1436
|
+
return ret;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
1440
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1441
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1442
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1443
|
+
return ptr;
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* Get the first unoccupied position in a bundle
|
|
1447
|
+
*
|
|
1448
|
+
* # Arguments
|
|
1449
|
+
* * `bundle` - The bundle to check
|
|
1450
|
+
*
|
|
1451
|
+
* # Returns
|
|
1452
|
+
* * `u32` - The first unoccupied position (None if full)
|
|
1453
|
+
*/
|
|
1454
|
+
export function firstUnoccupiedPositionInBundle(bitmap) {
|
|
1455
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1456
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1457
|
+
const ret = wasm.firstUnoccupiedPositionInBundle(ptr0, len0);
|
|
1458
|
+
return ret === 0x100000001 ? undefined : ret;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Check whether a position bundle is full
|
|
1463
|
+
* A position bundle can contain 256 positions
|
|
1464
|
+
*
|
|
1465
|
+
* # Arguments
|
|
1466
|
+
* * `bundle` - The bundle to check
|
|
1467
|
+
*
|
|
1468
|
+
* # Returns
|
|
1469
|
+
* * `bool` - Whether the bundle is full
|
|
1470
|
+
*/
|
|
1471
|
+
export function isPositionBundleFull(bitmap) {
|
|
1472
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1473
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1474
|
+
const ret = wasm.isPositionBundleFull(ptr0, len0);
|
|
1475
|
+
return ret !== 0;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* Check whether a position bundle is empty
|
|
1480
|
+
*
|
|
1481
|
+
* # Arguments
|
|
1482
|
+
* * `bundle` - The bundle to check
|
|
1483
|
+
*
|
|
1484
|
+
* # Returns
|
|
1485
|
+
* * `bool` - Whether the bundle is empty
|
|
1486
|
+
*/
|
|
1487
|
+
export function isPositionBundleEmpty(bitmap) {
|
|
1488
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export);
|
|
1489
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1490
|
+
const ret = wasm.isPositionBundleEmpty(ptr0, len0);
|
|
1491
|
+
return ret !== 0;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* Check if a position is in range.
|
|
1496
|
+
* When a position is in range it is earning fees and rewards
|
|
1497
|
+
*
|
|
1498
|
+
* # Parameters
|
|
1499
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1500
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1501
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1502
|
+
*
|
|
1503
|
+
* # Returns
|
|
1504
|
+
* - A boolean value indicating if the position is in range
|
|
1505
|
+
*/
|
|
1506
|
+
export function isPositionInRange(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1507
|
+
const ret = wasm.isPositionInRange(addHeapObject(current_sqrt_price), tick_index_1, tick_index_2);
|
|
1508
|
+
return ret !== 0;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
/**
|
|
1512
|
+
* Calculate the status of a position
|
|
1513
|
+
* The status can be one of three values:
|
|
1514
|
+
* - InRange: The position is in range
|
|
1515
|
+
* - BelowRange: The position is below the range
|
|
1516
|
+
* - AboveRange: The position is above the range
|
|
1517
|
+
*
|
|
1518
|
+
* # Parameters
|
|
1519
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1520
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1521
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1522
|
+
*
|
|
1523
|
+
* # Returns
|
|
1524
|
+
* - A PositionStatus enum value indicating the status of the position
|
|
1525
|
+
*/
|
|
1526
|
+
export function positionStatus(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1527
|
+
const ret = wasm.positionStatus(addHeapObject(current_sqrt_price), tick_index_1, tick_index_2);
|
|
1528
|
+
return takeObject(ret);
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
/**
|
|
1532
|
+
* Calculate the token_a / token_b ratio of a (ficticious) position
|
|
1533
|
+
*
|
|
1534
|
+
* # Parameters
|
|
1535
|
+
* - `sqrt_price` - A u128 integer representing the sqrt price of the pool
|
|
1536
|
+
* - `tick_index_1` - A i32 integer representing the first tick index of the position
|
|
1537
|
+
* - `tick_index_2` - A i32 integer representing the second tick index of the position
|
|
1538
|
+
*
|
|
1539
|
+
* # Returns
|
|
1540
|
+
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
1541
|
+
*/
|
|
1542
|
+
export function positionRatioX64(current_sqrt_price, tick_index_1, tick_index_2) {
|
|
1543
|
+
const ret = wasm.positionRatioX64(addHeapObject(current_sqrt_price), tick_index_1, tick_index_2);
|
|
1544
|
+
return takeObject(ret);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* Computes the exact input or output amount for a swap transaction.
|
|
1549
|
+
*
|
|
1550
|
+
* # Arguments
|
|
1551
|
+
* - `token_in`: The input token amount.
|
|
1552
|
+
* - `specified_token_a`: If `true`, the input token is token A. Otherwise, it is token B.
|
|
1553
|
+
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
1554
|
+
* - `fusion_pool`: The fusion_pool state.
|
|
1555
|
+
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
1556
|
+
* - `transfer_fee_a`: The transfer fee for token A.
|
|
1557
|
+
* - `transfer_fee_b`: The transfer fee for token B.
|
|
1558
|
+
*
|
|
1559
|
+
* # Returns
|
|
1560
|
+
* The exact input or output amount for the swap transaction.
|
|
1561
|
+
*/
|
|
1562
|
+
export function swapQuoteByInputToken(token_in, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
|
|
1563
|
+
try {
|
|
1564
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1565
|
+
wasm.swapQuoteByInputToken(retptr, token_in, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1566
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1567
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1568
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1569
|
+
if (r2) {
|
|
1570
|
+
throw takeObject(r1);
|
|
1571
|
+
}
|
|
1572
|
+
return takeObject(r0);
|
|
1573
|
+
} finally {
|
|
1574
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
/**
|
|
1579
|
+
* Computes the exact input or output amount for a swap transaction.
|
|
1580
|
+
*
|
|
1581
|
+
* # Arguments
|
|
1582
|
+
* - `token_out`: The output token amount.
|
|
1583
|
+
* - `specified_token_a`: If `true`, the output token is token A. Otherwise, it is token B.
|
|
1584
|
+
* - `slippage_tolerance`: The slippage tolerance in basis points.
|
|
1585
|
+
* - `fusion_pool`: The fusion_pool state.
|
|
1586
|
+
* - `tick_arrays`: The tick arrays needed for the swap.
|
|
1587
|
+
* - `transfer_fee_a`: The transfer fee for token A.
|
|
1588
|
+
* - `transfer_fee_b`: The transfer fee for token B.
|
|
1589
|
+
*
|
|
1590
|
+
* # Returns
|
|
1591
|
+
* The exact input or output amount for the swap transaction.
|
|
1592
|
+
*/
|
|
1593
|
+
export function swapQuoteByOutputToken(token_out, specified_token_a, slippage_tolerance_bps, fusion_pool, tick_arrays, transfer_fee_a, transfer_fee_b) {
|
|
1594
|
+
try {
|
|
1595
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1596
|
+
wasm.swapQuoteByOutputToken(retptr, token_out, specified_token_a, slippage_tolerance_bps, addHeapObject(fusion_pool), addHeapObject(tick_arrays), isLikeNone(transfer_fee_a) ? 0 : addHeapObject(transfer_fee_a), isLikeNone(transfer_fee_b) ? 0 : addHeapObject(transfer_fee_b));
|
|
1597
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1598
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1599
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1600
|
+
if (r2) {
|
|
1601
|
+
throw takeObject(r1);
|
|
1602
|
+
}
|
|
1603
|
+
return takeObject(r0);
|
|
1604
|
+
} finally {
|
|
1605
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
|
|
203
1609
|
export function _INVALID_ARGUMENTS() {
|
|
204
1610
|
try {
|
|
205
1611
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
@@ -212,6 +1618,73 @@ export function _INVALID_ARGUMENTS() {
|
|
|
212
1618
|
}
|
|
213
1619
|
}
|
|
214
1620
|
|
|
1621
|
+
/**
|
|
1622
|
+
* Spot position increase quote
|
|
1623
|
+
*
|
|
1624
|
+
* # Parameters
|
|
1625
|
+
* - `increase_amount`: Position total size in the collateral_token.
|
|
1626
|
+
* - `collateral_token`: Collateral token.
|
|
1627
|
+
* - `position_token`: Token of the position.
|
|
1628
|
+
* - `leverage`: Leverage (1.0 or higher).
|
|
1629
|
+
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1630
|
+
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1631
|
+
* - `fusion_pool`: Fusion pool.
|
|
1632
|
+
* - `tick_arrays`: Five tick arrays around the current pool price.
|
|
1633
|
+
*
|
|
1634
|
+
* # Returns
|
|
1635
|
+
* - `IncreaseSpotPositionQuoteResult`: quote result
|
|
1636
|
+
*/
|
|
1637
|
+
export function getIncreaseSpotPositionQuote(increase_amount, collateral_token, position_token, leverage, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1638
|
+
try {
|
|
1639
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1640
|
+
wasm.getIncreaseSpotPositionQuote(retptr, increase_amount, addHeapObject(collateral_token), addHeapObject(position_token), leverage, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
|
|
1641
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1642
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1643
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1644
|
+
if (r2) {
|
|
1645
|
+
throw takeObject(r1);
|
|
1646
|
+
}
|
|
1647
|
+
return takeObject(r0);
|
|
1648
|
+
} finally {
|
|
1649
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
/**
|
|
1654
|
+
* Spot position decrease quote
|
|
1655
|
+
*
|
|
1656
|
+
* # Parameters
|
|
1657
|
+
* - `increase_amount`: Position total size in the collateral_token.
|
|
1658
|
+
* - `collateral_token`: Collateral token.
|
|
1659
|
+
* - `position_token`: Token of the position.
|
|
1660
|
+
* - `leverage`: Leverage (1.0 or higher).
|
|
1661
|
+
* - `position_amount`: Existing position amount in the position_token.
|
|
1662
|
+
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
1663
|
+
* - `reduce_only`: Only allow reducing the existing position.
|
|
1664
|
+
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1665
|
+
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1666
|
+
* - `fusion_pool`: Fusion pool.
|
|
1667
|
+
* - `tick_arrays`: Five tick arrays around the current pool price.
|
|
1668
|
+
*
|
|
1669
|
+
* # Returns
|
|
1670
|
+
* - `DecreaseSpotPositionQuoteResult`: quote result
|
|
1671
|
+
*/
|
|
1672
|
+
export function getDecreaseSpotPositionQuote(decrease_amount, collateral_token, position_token, leverage, position_amount, position_debt, reduce_only, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1673
|
+
try {
|
|
1674
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1675
|
+
wasm.getDecreaseSpotPositionQuote(retptr, decrease_amount, addHeapObject(collateral_token), addHeapObject(position_token), leverage, position_amount, position_debt, reduce_only, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
|
|
1676
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1677
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1678
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1679
|
+
if (r2) {
|
|
1680
|
+
throw takeObject(r1);
|
|
1681
|
+
}
|
|
1682
|
+
return takeObject(r0);
|
|
1683
|
+
} finally {
|
|
1684
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
|
|
215
1688
|
/**
|
|
216
1689
|
* Returns the liquidation price
|
|
217
1690
|
*
|
|
@@ -240,11 +1713,52 @@ export function getLiquidationPrice(position_token, amount, debt, liquidation_th
|
|
|
240
1713
|
}
|
|
241
1714
|
}
|
|
242
1715
|
|
|
1716
|
+
/**
|
|
1717
|
+
* Calculates the maximum tradable amount in the collateral token.
|
|
1718
|
+
*
|
|
1719
|
+
* # Parameters
|
|
1720
|
+
* - `collateral_token`: Collateral token.
|
|
1721
|
+
* - `available_balance`: Available wallet balance in the collateral_token.
|
|
1722
|
+
* - `leverage`: Leverage (1.0 or higher).
|
|
1723
|
+
* - `new_position_token`: Token of the new position.
|
|
1724
|
+
* - `position_token`: Token of the existing position. Should be set to new_position_token if position_amount is zero.
|
|
1725
|
+
* - `position_amount`: Existing position amount in the position_token.
|
|
1726
|
+
* - `position_debt`: Existing position debt in the token opposite to the position_token.
|
|
1727
|
+
* - `reduce_only`: Only allow reducing the existing position.///
|
|
1728
|
+
* - `protocol_fee_rate`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1729
|
+
* - `protocol_fee_rate_on_collateral`: Protocol fee rate from a market account represented as hundredths of a basis point (0.01% = 100).
|
|
1730
|
+
* - `fusion_pool`: Fusion pool.
|
|
1731
|
+
* - `tick_arrays`: Five tick arrays around the current pool price.
|
|
1732
|
+
*
|
|
1733
|
+
* # Returns
|
|
1734
|
+
* - `u64`: the maximum tradable amount
|
|
1735
|
+
*/
|
|
1736
|
+
export function getTradableAmount(collateral_token, available_balance, leverage, new_position_token, position_token, position_amount, position_debt, reduce_only, protocol_fee_rate, protocol_fee_rate_on_collateral, fusion_pool, tick_arrays) {
|
|
1737
|
+
try {
|
|
1738
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1739
|
+
wasm.getTradableAmount(retptr, addHeapObject(collateral_token), available_balance, leverage, addHeapObject(new_position_token), addHeapObject(position_token), position_amount, position_debt, reduce_only, protocol_fee_rate, protocol_fee_rate_on_collateral, addHeapObject(fusion_pool), addHeapObject(tick_arrays));
|
|
1740
|
+
var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
|
|
1741
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1742
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1743
|
+
if (r3) {
|
|
1744
|
+
throw takeObject(r2);
|
|
1745
|
+
}
|
|
1746
|
+
return BigInt.asUintN(64, r0);
|
|
1747
|
+
} finally {
|
|
1748
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
|
|
243
1752
|
export function __wbg_Error_e83987f665cf5504(arg0, arg1) {
|
|
244
1753
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
245
1754
|
return addHeapObject(ret);
|
|
246
1755
|
};
|
|
247
1756
|
|
|
1757
|
+
export function __wbg_Number_bb48ca12f395cd08(arg0) {
|
|
1758
|
+
const ret = Number(getObject(arg0));
|
|
1759
|
+
return ret;
|
|
1760
|
+
};
|
|
1761
|
+
|
|
248
1762
|
export function __wbg_String_eecc4a11987127d6(arg0, arg1) {
|
|
249
1763
|
const ret = String(getObject(arg1));
|
|
250
1764
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -253,6 +1767,13 @@ export function __wbg_String_eecc4a11987127d6(arg0, arg1) {
|
|
|
253
1767
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
254
1768
|
};
|
|
255
1769
|
|
|
1770
|
+
export function __wbg___wbindgen_bigint_get_as_i64_f3ebc5a755000afd(arg0, arg1) {
|
|
1771
|
+
const v = getObject(arg1);
|
|
1772
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
1773
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
1774
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
1775
|
+
};
|
|
1776
|
+
|
|
256
1777
|
export function __wbg___wbindgen_boolean_get_6d5a1ee65bab5f68(arg0) {
|
|
257
1778
|
const v = getObject(arg0);
|
|
258
1779
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
@@ -267,6 +1788,21 @@ export function __wbg___wbindgen_debug_string_df47ffb5e35e6763(arg0, arg1) {
|
|
|
267
1788
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
268
1789
|
};
|
|
269
1790
|
|
|
1791
|
+
export function __wbg___wbindgen_in_bb933bd9e1b3bc0f(arg0, arg1) {
|
|
1792
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
1793
|
+
return ret;
|
|
1794
|
+
};
|
|
1795
|
+
|
|
1796
|
+
export function __wbg___wbindgen_is_bigint_cb320707dcd35f0b(arg0) {
|
|
1797
|
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
|
1798
|
+
return ret;
|
|
1799
|
+
};
|
|
1800
|
+
|
|
1801
|
+
export function __wbg___wbindgen_is_function_ee8a6c5833c90377(arg0) {
|
|
1802
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
1803
|
+
return ret;
|
|
1804
|
+
};
|
|
1805
|
+
|
|
270
1806
|
export function __wbg___wbindgen_is_object_c818261d21f283a4(arg0) {
|
|
271
1807
|
const val = getObject(arg0);
|
|
272
1808
|
const ret = typeof(val) === 'object' && val !== null;
|
|
@@ -278,6 +1814,16 @@ export function __wbg___wbindgen_is_string_fbb76cb2940daafd(arg0) {
|
|
|
278
1814
|
return ret;
|
|
279
1815
|
};
|
|
280
1816
|
|
|
1817
|
+
export function __wbg___wbindgen_is_undefined_2d472862bd29a478(arg0) {
|
|
1818
|
+
const ret = getObject(arg0) === undefined;
|
|
1819
|
+
return ret;
|
|
1820
|
+
};
|
|
1821
|
+
|
|
1822
|
+
export function __wbg___wbindgen_jsval_eq_6b13ab83478b1c50(arg0, arg1) {
|
|
1823
|
+
const ret = getObject(arg0) === getObject(arg1);
|
|
1824
|
+
return ret;
|
|
1825
|
+
};
|
|
1826
|
+
|
|
281
1827
|
export function __wbg___wbindgen_jsval_loose_eq_b664b38a2f582147(arg0, arg1) {
|
|
282
1828
|
const ret = getObject(arg0) == getObject(arg1);
|
|
283
1829
|
return ret;
|
|
@@ -290,6 +1836,11 @@ export function __wbg___wbindgen_number_get_a20bf9b85341449d(arg0, arg1) {
|
|
|
290
1836
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
291
1837
|
};
|
|
292
1838
|
|
|
1839
|
+
export function __wbg___wbindgen_shr_5fb5dd3acf2615de(arg0, arg1) {
|
|
1840
|
+
const ret = getObject(arg0) >> getObject(arg1);
|
|
1841
|
+
return addHeapObject(ret);
|
|
1842
|
+
};
|
|
1843
|
+
|
|
293
1844
|
export function __wbg___wbindgen_string_get_e4f06c90489ad01b(arg0, arg1) {
|
|
294
1845
|
const obj = getObject(arg1);
|
|
295
1846
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
@@ -303,6 +1854,16 @@ export function __wbg___wbindgen_throw_b855445ff6a94295(arg0, arg1) {
|
|
|
303
1854
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
304
1855
|
};
|
|
305
1856
|
|
|
1857
|
+
export function __wbg_call_e762c39fa8ea36bf() { return handleError(function (arg0, arg1) {
|
|
1858
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
1859
|
+
return addHeapObject(ret);
|
|
1860
|
+
}, arguments) };
|
|
1861
|
+
|
|
1862
|
+
export function __wbg_done_2042aa2670fb1db1(arg0) {
|
|
1863
|
+
const ret = getObject(arg0).done;
|
|
1864
|
+
return ret;
|
|
1865
|
+
};
|
|
1866
|
+
|
|
306
1867
|
export function __wbg_entries_e171b586f8f6bdbf(arg0) {
|
|
307
1868
|
const ret = Object.entries(getObject(arg0));
|
|
308
1869
|
return addHeapObject(ret);
|
|
@@ -313,6 +1874,21 @@ export function __wbg_get_7bed016f185add81(arg0, arg1) {
|
|
|
313
1874
|
return addHeapObject(ret);
|
|
314
1875
|
};
|
|
315
1876
|
|
|
1877
|
+
export function __wbg_get_efcb449f58ec27c2() { return handleError(function (arg0, arg1) {
|
|
1878
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
1879
|
+
return addHeapObject(ret);
|
|
1880
|
+
}, arguments) };
|
|
1881
|
+
|
|
1882
|
+
export function __wbg_get_with_ref_key_1dc361bd10053bfe(arg0, arg1) {
|
|
1883
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
1884
|
+
return addHeapObject(ret);
|
|
1885
|
+
};
|
|
1886
|
+
|
|
1887
|
+
export function __wbg_get_with_ref_key_6550b2c093d2eb18(arg0, arg1) {
|
|
1888
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
1889
|
+
return addHeapObject(ret);
|
|
1890
|
+
};
|
|
1891
|
+
|
|
316
1892
|
export function __wbg_instanceof_ArrayBuffer_70beb1189ca63b38(arg0) {
|
|
317
1893
|
let result;
|
|
318
1894
|
try {
|
|
@@ -335,6 +1911,26 @@ export function __wbg_instanceof_Uint8Array_20c8e73002f7af98(arg0) {
|
|
|
335
1911
|
return ret;
|
|
336
1912
|
};
|
|
337
1913
|
|
|
1914
|
+
export function __wbg_isArray_643fafc484312e19(arg0) {
|
|
1915
|
+
const ret = Array.isArray(getObject(arg0));
|
|
1916
|
+
return ret;
|
|
1917
|
+
};
|
|
1918
|
+
|
|
1919
|
+
export function __wbg_isArray_96e0af9891d0945d(arg0) {
|
|
1920
|
+
const ret = Array.isArray(getObject(arg0));
|
|
1921
|
+
return ret;
|
|
1922
|
+
};
|
|
1923
|
+
|
|
1924
|
+
export function __wbg_isSafeInteger_d216eda7911dde36(arg0) {
|
|
1925
|
+
const ret = Number.isSafeInteger(getObject(arg0));
|
|
1926
|
+
return ret;
|
|
1927
|
+
};
|
|
1928
|
+
|
|
1929
|
+
export function __wbg_iterator_e5822695327a3c39() {
|
|
1930
|
+
const ret = Symbol.iterator;
|
|
1931
|
+
return addHeapObject(ret);
|
|
1932
|
+
};
|
|
1933
|
+
|
|
338
1934
|
export function __wbg_length_69bca3cb64fc8748(arg0) {
|
|
339
1935
|
const ret = getObject(arg0).length;
|
|
340
1936
|
return ret;
|
|
@@ -345,21 +1941,69 @@ export function __wbg_length_cdd215e10d9dd507(arg0) {
|
|
|
345
1941
|
return ret;
|
|
346
1942
|
};
|
|
347
1943
|
|
|
1944
|
+
export function __wbg_new_1acc0b6eea89d040() {
|
|
1945
|
+
const ret = new Object();
|
|
1946
|
+
return addHeapObject(ret);
|
|
1947
|
+
};
|
|
1948
|
+
|
|
348
1949
|
export function __wbg_new_5a79be3ab53b8aa5(arg0) {
|
|
349
1950
|
const ret = new Uint8Array(getObject(arg0));
|
|
350
1951
|
return addHeapObject(ret);
|
|
351
1952
|
};
|
|
352
1953
|
|
|
1954
|
+
export function __wbg_next_020810e0ae8ebcb0() { return handleError(function (arg0) {
|
|
1955
|
+
const ret = getObject(arg0).next();
|
|
1956
|
+
return addHeapObject(ret);
|
|
1957
|
+
}, arguments) };
|
|
1958
|
+
|
|
1959
|
+
export function __wbg_next_2c826fe5dfec6b6a(arg0) {
|
|
1960
|
+
const ret = getObject(arg0).next;
|
|
1961
|
+
return addHeapObject(ret);
|
|
1962
|
+
};
|
|
1963
|
+
|
|
353
1964
|
export function __wbg_prototypesetcall_2a6620b6922694b2(arg0, arg1, arg2) {
|
|
354
1965
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
355
1966
|
};
|
|
356
1967
|
|
|
1968
|
+
export function __wbg_set_3807d5f0bfc24aa7(arg0, arg1, arg2) {
|
|
1969
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
1970
|
+
};
|
|
1971
|
+
|
|
1972
|
+
export function __wbg_value_692627309814bb8c(arg0) {
|
|
1973
|
+
const ret = getObject(arg0).value;
|
|
1974
|
+
return addHeapObject(ret);
|
|
1975
|
+
};
|
|
1976
|
+
|
|
357
1977
|
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
358
1978
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
359
1979
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
360
1980
|
return addHeapObject(ret);
|
|
361
1981
|
};
|
|
362
1982
|
|
|
1983
|
+
export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
|
|
1984
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
1985
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
1986
|
+
return addHeapObject(ret);
|
|
1987
|
+
};
|
|
1988
|
+
|
|
1989
|
+
export function __wbindgen_cast_9ae0607507abb057(arg0) {
|
|
1990
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
1991
|
+
const ret = arg0;
|
|
1992
|
+
return addHeapObject(ret);
|
|
1993
|
+
};
|
|
1994
|
+
|
|
1995
|
+
export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
|
|
1996
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1997
|
+
const ret = arg0;
|
|
1998
|
+
return addHeapObject(ret);
|
|
1999
|
+
};
|
|
2000
|
+
|
|
2001
|
+
export function __wbindgen_cast_e7b45dd881f38ce3(arg0, arg1) {
|
|
2002
|
+
// Cast intrinsic for `U128 -> Externref`.
|
|
2003
|
+
const ret = (BigInt.asUintN(64, arg0) | (BigInt.asUintN(64, arg1) << BigInt(64)));
|
|
2004
|
+
return addHeapObject(ret);
|
|
2005
|
+
};
|
|
2006
|
+
|
|
363
2007
|
export function __wbindgen_object_clone_ref(arg0) {
|
|
364
2008
|
const ret = getObject(arg0);
|
|
365
2009
|
return addHeapObject(ret);
|