@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
|
@@ -1,133 +1,6 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
* Calculate the amount A delta between two sqrt_prices
|
|
5
|
-
*
|
|
6
|
-
* # Parameters
|
|
7
|
-
* - `sqrt_price_1`: The first square root price
|
|
8
|
-
* - `sqrt_price_2`: The second square root price
|
|
9
|
-
* - `liquidity`: The liquidity
|
|
10
|
-
* - `round_up`: Whether to round up or not
|
|
11
|
-
*
|
|
12
|
-
* # Returns
|
|
13
|
-
* - `u64`: The amount delta
|
|
14
|
-
*/
|
|
15
|
-
export function tryGetAmountDeltaA(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
|
|
16
|
-
/**
|
|
17
|
-
* Calculate the amount B delta between two sqrt_prices
|
|
18
|
-
*
|
|
19
|
-
* # Parameters
|
|
20
|
-
* - `sqrt_price_1`: The first square root price
|
|
21
|
-
* - `sqrt_price_2`: The second square root price
|
|
22
|
-
* - `liquidity`: The liquidity
|
|
23
|
-
* - `round_up`: Whether to round up or not
|
|
24
|
-
*
|
|
25
|
-
* # Returns
|
|
26
|
-
* - `u64`: The amount delta
|
|
27
|
-
*/
|
|
28
|
-
export function tryGetAmountDeltaB(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
|
|
29
|
-
/**
|
|
30
|
-
* Calculate the next square root price
|
|
31
|
-
*
|
|
32
|
-
* # Parameters
|
|
33
|
-
* - `current_sqrt_price`: The current square root price
|
|
34
|
-
* - `current_liquidity`: The current liquidity
|
|
35
|
-
* - `amount`: The amount
|
|
36
|
-
* - `specified_input`: Whether the input is specified
|
|
37
|
-
*
|
|
38
|
-
* # Returns
|
|
39
|
-
* - `u128`: The next square root price
|
|
40
|
-
*/
|
|
41
|
-
export function tryGetNextSqrtPriceFromA(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
|
|
42
|
-
/**
|
|
43
|
-
* Calculate the next square root price
|
|
44
|
-
*
|
|
45
|
-
* # Parameters
|
|
46
|
-
* - `current_sqrt_price`: The current square root price
|
|
47
|
-
* - `current_liquidity`: The current liquidity
|
|
48
|
-
* - `amount`: The amount
|
|
49
|
-
* - `specified_input`: Whether the input is specified
|
|
50
|
-
*
|
|
51
|
-
* # Returns
|
|
52
|
-
* - `u128`: The next square root price
|
|
53
|
-
*/
|
|
54
|
-
export function tryGetNextSqrtPriceFromB(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
|
|
55
|
-
/**
|
|
56
|
-
* Apply a transfer fee to an amount
|
|
57
|
-
* e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
|
|
58
|
-
* So the amount after fee will be 9900.
|
|
59
|
-
*
|
|
60
|
-
* # Parameters
|
|
61
|
-
* - `amount`: The amount to apply the fee to
|
|
62
|
-
* - `transfer_fee`: The transfer fee to apply
|
|
63
|
-
*
|
|
64
|
-
* # Returns
|
|
65
|
-
* - `u64`: The amount after the fee has been applied
|
|
66
|
-
*/
|
|
67
|
-
export function tryApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
|
|
68
|
-
/**
|
|
69
|
-
* Reverse the application of a transfer fee to an amount
|
|
70
|
-
* e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
|
|
71
|
-
* So the amount before fee will be 10000.
|
|
72
|
-
*
|
|
73
|
-
* # Parameters
|
|
74
|
-
* - `amount`: The amount to reverse the fee from
|
|
75
|
-
* - `transfer_fee`: The transfer fee to reverse
|
|
76
|
-
*
|
|
77
|
-
* # Returns
|
|
78
|
-
* - `u64`: The amount before the fee has been applied
|
|
79
|
-
*/
|
|
80
|
-
export function tryReverseApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
|
|
81
|
-
/**
|
|
82
|
-
* Get the maximum amount with a slippage tolerance
|
|
83
|
-
* e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
|
|
84
|
-
*
|
|
85
|
-
* # Parameters
|
|
86
|
-
* - `amount`: The amount to apply the fee to
|
|
87
|
-
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
88
|
-
*
|
|
89
|
-
* # Returns
|
|
90
|
-
* - `u64`: The maximum amount
|
|
91
|
-
*/
|
|
92
|
-
export function tryGetMaxAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
|
|
93
|
-
/**
|
|
94
|
-
* Get the minimum amount with a slippage tolerance
|
|
95
|
-
* e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
|
|
96
|
-
*
|
|
97
|
-
* # Parameters
|
|
98
|
-
* - `amount`: The amount to apply the fee to
|
|
99
|
-
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
100
|
-
*
|
|
101
|
-
* # Returns
|
|
102
|
-
* - `u64`: The minimum amount
|
|
103
|
-
*/
|
|
104
|
-
export function tryGetMinAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
|
|
105
|
-
/**
|
|
106
|
-
* Apply a swap fee to an amount
|
|
107
|
-
* e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
|
|
108
|
-
* So the amount after fee will be 9900.
|
|
109
|
-
*
|
|
110
|
-
* # Parameters
|
|
111
|
-
* - `amount`: The amount to apply the fee to
|
|
112
|
-
* - `fee_rate`: The fee rate to apply denominated in 1e6
|
|
113
|
-
*
|
|
114
|
-
* # Returns
|
|
115
|
-
* - `u64`: The amount after the fee has been applied
|
|
116
|
-
*/
|
|
117
|
-
export function tryApplySwapFee(amount: bigint, fee_rate: number): bigint;
|
|
118
|
-
/**
|
|
119
|
-
* Reverse the application of a swap fee to an amount
|
|
120
|
-
* e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
|
|
121
|
-
* So the amount before fee will be 10000.
|
|
122
|
-
*
|
|
123
|
-
* # Parameters
|
|
124
|
-
* - `amount`: The amount to reverse the fee from
|
|
125
|
-
* - `fee_rate`: The fee rate to reverse denominated in 1e6
|
|
126
|
-
*
|
|
127
|
-
* # Returns
|
|
128
|
-
* - `u64`: The amount before the fee has been applied
|
|
129
|
-
*/
|
|
130
|
-
export function tryReverseApplySwapFee(amount: bigint, fee_rate: number): bigint;
|
|
3
|
+
export function _POSITION_BUNDLE_SIZE(): number;
|
|
131
4
|
export function _FEE_RATE_MUL_VALUE(): number;
|
|
132
5
|
export function _MAX_PROTOCOL_FEE_RATE(): number;
|
|
133
6
|
export function _PROTOCOL_FEE_RATE_MUL_VALUE(): number;
|
|
@@ -394,7 +267,8 @@ export function tryGetLiquidityFromA(token_delta_a: bigint, sqrt_price_lower: bi
|
|
|
394
267
|
export function tryGetTokenAFromLiquidity(liquidity_delta: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint, round_up: boolean): bigint;
|
|
395
268
|
export function tryGetLiquidityFromB(token_delta_b: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint): bigint;
|
|
396
269
|
export function tryGetTokenBFromLiquidity(liquidity_delta: bigint, sqrt_price_lower: bigint, sqrt_price_upper: bigint, round_up: boolean): bigint;
|
|
397
|
-
export function
|
|
270
|
+
export function tryGetAmountsFromLiquidity(liquidity_delta: bigint, current_sqrt_price: bigint, tick_lower_index: number, tick_upper_index: number, round_up: boolean): TokenPair;
|
|
271
|
+
export function tryGetLiquidityFromAmounts(sqrt_price: bigint, sqrt_price_a_x64: bigint, sqrt_price_b_x64: bigint, amount_a: bigint, amount_b: bigint): bigint;
|
|
398
272
|
/**
|
|
399
273
|
* Calculate fees owed for a position
|
|
400
274
|
*
|
|
@@ -411,6 +285,134 @@ export function tryGetTokenEstimatesFromLiquidity(liquidity_delta: bigint, curre
|
|
|
411
285
|
*/
|
|
412
286
|
export function collectFeesQuote(fusion_pool: FusionPoolFacade, position: PositionFacade, tick_lower: TickFacade, tick_upper: TickFacade, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): CollectFeesQuote;
|
|
413
287
|
export function limitOrderFee(fusion_pool: FusionPoolFacade): number;
|
|
288
|
+
/**
|
|
289
|
+
* Calculate the amount A delta between two sqrt_prices
|
|
290
|
+
*
|
|
291
|
+
* # Parameters
|
|
292
|
+
* - `sqrt_price_1`: The first square root price
|
|
293
|
+
* - `sqrt_price_2`: The second square root price
|
|
294
|
+
* - `liquidity`: The liquidity
|
|
295
|
+
* - `round_up`: Whether to round up or not
|
|
296
|
+
*
|
|
297
|
+
* # Returns
|
|
298
|
+
* - `u64`: The amount delta
|
|
299
|
+
*/
|
|
300
|
+
export function tryGetAmountDeltaA(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
|
|
301
|
+
/**
|
|
302
|
+
* Calculate the amount B delta between two sqrt_prices
|
|
303
|
+
*
|
|
304
|
+
* # Parameters
|
|
305
|
+
* - `sqrt_price_1`: The first square root price
|
|
306
|
+
* - `sqrt_price_2`: The second square root price
|
|
307
|
+
* - `liquidity`: The liquidity
|
|
308
|
+
* - `round_up`: Whether to round up or not
|
|
309
|
+
*
|
|
310
|
+
* # Returns
|
|
311
|
+
* - `u64`: The amount delta
|
|
312
|
+
*/
|
|
313
|
+
export function tryGetAmountDeltaB(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
|
|
314
|
+
/**
|
|
315
|
+
* Calculate the next square root price
|
|
316
|
+
*
|
|
317
|
+
* # Parameters
|
|
318
|
+
* - `current_sqrt_price`: The current square root price
|
|
319
|
+
* - `current_liquidity`: The current liquidity
|
|
320
|
+
* - `amount`: The amount
|
|
321
|
+
* - `specified_input`: Whether the input is specified
|
|
322
|
+
*
|
|
323
|
+
* # Returns
|
|
324
|
+
* - `u128`: The next square root price
|
|
325
|
+
*/
|
|
326
|
+
export function tryGetNextSqrtPriceFromA(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
|
|
327
|
+
/**
|
|
328
|
+
* Calculate the next square root price
|
|
329
|
+
*
|
|
330
|
+
* # Parameters
|
|
331
|
+
* - `current_sqrt_price`: The current square root price
|
|
332
|
+
* - `current_liquidity`: The current liquidity
|
|
333
|
+
* - `amount`: The amount
|
|
334
|
+
* - `specified_input`: Whether the input is specified
|
|
335
|
+
*
|
|
336
|
+
* # Returns
|
|
337
|
+
* - `u128`: The next square root price
|
|
338
|
+
*/
|
|
339
|
+
export function tryGetNextSqrtPriceFromB(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
|
|
340
|
+
/**
|
|
341
|
+
* Apply a transfer fee to an amount
|
|
342
|
+
* e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
|
|
343
|
+
* So the amount after fee will be 9900.
|
|
344
|
+
*
|
|
345
|
+
* # Parameters
|
|
346
|
+
* - `amount`: The amount to apply the fee to
|
|
347
|
+
* - `transfer_fee`: The transfer fee to apply
|
|
348
|
+
*
|
|
349
|
+
* # Returns
|
|
350
|
+
* - `u64`: The amount after the fee has been applied
|
|
351
|
+
*/
|
|
352
|
+
export function tryApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
|
|
353
|
+
/**
|
|
354
|
+
* Reverse the application of a transfer fee to an amount
|
|
355
|
+
* e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
|
|
356
|
+
* So the amount before fee will be 10000.
|
|
357
|
+
*
|
|
358
|
+
* # Parameters
|
|
359
|
+
* - `amount`: The amount to reverse the fee from
|
|
360
|
+
* - `transfer_fee`: The transfer fee to reverse
|
|
361
|
+
*
|
|
362
|
+
* # Returns
|
|
363
|
+
* - `u64`: The amount before the fee has been applied
|
|
364
|
+
*/
|
|
365
|
+
export function tryReverseApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
|
|
366
|
+
/**
|
|
367
|
+
* Get the maximum amount with a slippage tolerance
|
|
368
|
+
* e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
|
|
369
|
+
*
|
|
370
|
+
* # Parameters
|
|
371
|
+
* - `amount`: The amount to apply the fee to
|
|
372
|
+
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
373
|
+
*
|
|
374
|
+
* # Returns
|
|
375
|
+
* - `u64`: The maximum amount
|
|
376
|
+
*/
|
|
377
|
+
export function tryGetMaxAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
|
|
378
|
+
/**
|
|
379
|
+
* Get the minimum amount with a slippage tolerance
|
|
380
|
+
* e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
|
|
381
|
+
*
|
|
382
|
+
* # Parameters
|
|
383
|
+
* - `amount`: The amount to apply the fee to
|
|
384
|
+
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
385
|
+
*
|
|
386
|
+
* # Returns
|
|
387
|
+
* - `u64`: The minimum amount
|
|
388
|
+
*/
|
|
389
|
+
export function tryGetMinAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
|
|
390
|
+
/**
|
|
391
|
+
* Apply a swap fee to an amount
|
|
392
|
+
* e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
|
|
393
|
+
* So the amount after fee will be 9900.
|
|
394
|
+
*
|
|
395
|
+
* # Parameters
|
|
396
|
+
* - `amount`: The amount to apply the fee to
|
|
397
|
+
* - `fee_rate`: The fee rate to apply denominated in 1e6
|
|
398
|
+
*
|
|
399
|
+
* # Returns
|
|
400
|
+
* - `u64`: The amount after the fee has been applied
|
|
401
|
+
*/
|
|
402
|
+
export function tryApplySwapFee(amount: bigint, fee_rate: number): bigint;
|
|
403
|
+
/**
|
|
404
|
+
* Reverse the application of a swap fee to an amount
|
|
405
|
+
* e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
|
|
406
|
+
* So the amount before fee will be 10000.
|
|
407
|
+
*
|
|
408
|
+
* # Parameters
|
|
409
|
+
* - `amount`: The amount to reverse the fee from
|
|
410
|
+
* - `fee_rate`: The fee rate to reverse denominated in 1e6
|
|
411
|
+
*
|
|
412
|
+
* # Returns
|
|
413
|
+
* - `u64`: The amount before the fee has been applied
|
|
414
|
+
*/
|
|
415
|
+
export function tryReverseApplySwapFee(amount: bigint, fee_rate: number): bigint;
|
|
414
416
|
/**
|
|
415
417
|
* Computes the limit order output amount by input amount.
|
|
416
418
|
* ### Parameters
|
|
@@ -439,24 +441,6 @@ export function limitOrderQuoteByOutputToken(amount_out: bigint, a_to_b_order: b
|
|
|
439
441
|
*/
|
|
440
442
|
export function limitOrderRewardByOutputToken(amount_out: bigint, fee_rate: number, protocol_fee_rate: number): bigint;
|
|
441
443
|
export function decreaseLimitOrderQuote(fusion_pool: FusionPoolFacade, limit_order: LimitOrderFacade, tick: TickFacade, amount: bigint, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): LimitOrderDecreaseQuote;
|
|
442
|
-
export function _POSITION_BUNDLE_SIZE(): number;
|
|
443
|
-
export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
|
|
444
|
-
export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
|
|
445
|
-
export function _INVALID_TICK_INDEX(): string;
|
|
446
|
-
export function _ARITHMETIC_OVERFLOW(): string;
|
|
447
|
-
export function _AMOUNT_EXCEEDS_MAX_U64(): string;
|
|
448
|
-
export function _AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT(): string;
|
|
449
|
-
export function _SQRT_PRICE_OUT_OF_BOUNDS(): string;
|
|
450
|
-
export function _TICK_SEQUENCE_EMPTY(): string;
|
|
451
|
-
export function _SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(): string;
|
|
452
|
-
export function _INVALID_SQRT_PRICE_LIMIT_DIRECTION(): string;
|
|
453
|
-
export function _ZERO_TRADABLE_AMOUNT(): string;
|
|
454
|
-
export function _INVALID_TIMESTAMP(): string;
|
|
455
|
-
export function _INVALID_TRANSFER_FEE(): string;
|
|
456
|
-
export function _INVALID_SLIPPAGE_TOLERANCE(): string;
|
|
457
|
-
export function _TICK_INDEX_NOT_IN_ARRAY(): string;
|
|
458
|
-
export function _INVALID_TICK_ARRAY_SEQUENCE(): string;
|
|
459
|
-
export function _LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC(): string;
|
|
460
444
|
/**
|
|
461
445
|
* Get the first unoccupied position in a bundle
|
|
462
446
|
*
|
|
@@ -599,23 +583,23 @@ export function tickIndexToPrice(tick_index: number, decimals_a: number, decimal
|
|
|
599
583
|
* * `i32` - The tick index
|
|
600
584
|
*/
|
|
601
585
|
export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
export function
|
|
586
|
+
export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
|
|
587
|
+
export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
|
|
588
|
+
export function _INVALID_TICK_INDEX(): string;
|
|
589
|
+
export function _ARITHMETIC_OVERFLOW(): string;
|
|
590
|
+
export function _AMOUNT_EXCEEDS_MAX_U64(): string;
|
|
591
|
+
export function _AMOUNT_EXCEEDS_LIMIT_ORDER_INPUT_AMOUNT(): string;
|
|
592
|
+
export function _SQRT_PRICE_OUT_OF_BOUNDS(): string;
|
|
593
|
+
export function _TICK_SEQUENCE_EMPTY(): string;
|
|
594
|
+
export function _SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(): string;
|
|
595
|
+
export function _INVALID_SQRT_PRICE_LIMIT_DIRECTION(): string;
|
|
596
|
+
export function _ZERO_TRADABLE_AMOUNT(): string;
|
|
597
|
+
export function _INVALID_TIMESTAMP(): string;
|
|
598
|
+
export function _INVALID_TRANSFER_FEE(): string;
|
|
599
|
+
export function _INVALID_SLIPPAGE_TOLERANCE(): string;
|
|
600
|
+
export function _TICK_INDEX_NOT_IN_ARRAY(): string;
|
|
601
|
+
export function _INVALID_TICK_ARRAY_SEQUENCE(): string;
|
|
602
|
+
export function _LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC(): string;
|
|
619
603
|
/**
|
|
620
604
|
* Computes the exact input or output amount for a swap transaction.
|
|
621
605
|
*
|
|
@@ -648,6 +632,26 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
|
|
|
648
632
|
* The exact input or output amount for the swap transaction.
|
|
649
633
|
*/
|
|
650
634
|
export function swapQuoteByOutputToken(token_out: bigint, specified_token_a: boolean, slippage_tolerance_bps: number, fusion_pool: FusionPoolFacade, tick_arrays: TickArrayFacade[], transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): ExactOutSwapQuote;
|
|
635
|
+
/**
|
|
636
|
+
* Computes the liquidation prices for an existing position.
|
|
637
|
+
*
|
|
638
|
+
* # Parameters
|
|
639
|
+
* - `tick_lower_index`: The lower tick index of the position.
|
|
640
|
+
* - `tick_upper_index`: The upper tick index of the position.
|
|
641
|
+
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
642
|
+
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
643
|
+
* - `liquidity`: Liquidity of the position.
|
|
644
|
+
* - `debt_a`: The amount of tokens A borrowed.
|
|
645
|
+
* - `debt_b`: The amount of tokens B borrowed.
|
|
646
|
+
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
647
|
+
*
|
|
648
|
+
* # Returns
|
|
649
|
+
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
650
|
+
*/
|
|
651
|
+
export function getLpPositionLiquidationPrices(tick_lower_index: number, tick_upper_index: number, liquidity: bigint, leftovers_a: bigint, leftovers_b: bigint, debt_a: bigint, debt_b: bigint, liquidation_threshold: number): LiquidationPrices;
|
|
652
|
+
export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
|
|
653
|
+
export function _HUNDRED_PERCENT(): number;
|
|
654
|
+
export function _COMPUTED_AMOUNT(): bigint;
|
|
651
655
|
/**
|
|
652
656
|
* Spot position increase quote
|
|
653
657
|
*
|
|
@@ -718,6 +722,7 @@ export function getSpotPositionLiquidationPrice(position_token: number, amount:
|
|
|
718
722
|
*/
|
|
719
723
|
export function getTradableAmount(collateral_token: number, available_balance: bigint, leverage: number, position_token: number, position_amount: bigint, protocol_fee_rate: number, protocol_fee_rate_on_collateral: number, fusion_pool: FusionPoolFacade, increase: boolean): bigint;
|
|
720
724
|
export function calculateTunaSpotPositionProtocolFee(collateral_token: number, borrowed_token: number, collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): TokenPair;
|
|
725
|
+
export function calculateTunaProtocolFee(collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): bigint;
|
|
721
726
|
export function _INVALID_ARGUMENTS(): string;
|
|
722
727
|
export function _JUPITER_QUOTE_REQUEST_ERROR(): string;
|
|
723
728
|
export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
|
|
@@ -758,6 +763,16 @@ export interface FusionPoolFacade {
|
|
|
758
763
|
olpFeeOwedB: bigint;
|
|
759
764
|
}
|
|
760
765
|
|
|
766
|
+
export interface CollectFeesQuote {
|
|
767
|
+
feeOwedA: bigint;
|
|
768
|
+
feeOwedB: bigint;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
export interface TokenPair {
|
|
772
|
+
a: bigint;
|
|
773
|
+
b: bigint;
|
|
774
|
+
}
|
|
775
|
+
|
|
761
776
|
export interface LimitOrderDecreaseQuote {
|
|
762
777
|
amountOutA: bigint;
|
|
763
778
|
amountOutB: bigint;
|
|
@@ -772,9 +787,9 @@ export interface LimitOrderFacade {
|
|
|
772
787
|
age: bigint;
|
|
773
788
|
}
|
|
774
789
|
|
|
775
|
-
export interface
|
|
776
|
-
|
|
777
|
-
|
|
790
|
+
export interface TransferFee {
|
|
791
|
+
feeBps: number;
|
|
792
|
+
maxFee: bigint;
|
|
778
793
|
}
|
|
779
794
|
|
|
780
795
|
export interface PositionFacade {
|
|
@@ -794,6 +809,22 @@ export interface PositionRatio {
|
|
|
794
809
|
ratioB: bigint;
|
|
795
810
|
}
|
|
796
811
|
|
|
812
|
+
export interface IncreaseLiquidityQuote {
|
|
813
|
+
liquidityDelta: bigint;
|
|
814
|
+
tokenEstA: bigint;
|
|
815
|
+
tokenEstB: bigint;
|
|
816
|
+
tokenMaxA: bigint;
|
|
817
|
+
tokenMaxB: bigint;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
export interface DecreaseLiquidityQuote {
|
|
821
|
+
liquidityDelta: bigint;
|
|
822
|
+
tokenEstA: bigint;
|
|
823
|
+
tokenEstB: bigint;
|
|
824
|
+
tokenMinA: bigint;
|
|
825
|
+
tokenMinB: bigint;
|
|
826
|
+
}
|
|
827
|
+
|
|
797
828
|
export interface TickArrayFacade {
|
|
798
829
|
startTickIndex: number;
|
|
799
830
|
ticks: TickFacade[];
|
|
@@ -818,44 +849,39 @@ export interface TickRange {
|
|
|
818
849
|
tickUpperIndex: number;
|
|
819
850
|
}
|
|
820
851
|
|
|
821
|
-
export interface
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
feeOwedB: bigint;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
export interface TransferFee {
|
|
843
|
-
feeBps: number;
|
|
844
|
-
maxFee: bigint;
|
|
852
|
+
export interface IncreaseLpPositionQuoteResult {
|
|
853
|
+
collateralA: bigint;
|
|
854
|
+
collateralB: bigint;
|
|
855
|
+
maxCollateralA: bigint;
|
|
856
|
+
maxCollateralB: bigint;
|
|
857
|
+
borrowA: bigint;
|
|
858
|
+
borrowB: bigint;
|
|
859
|
+
totalA: bigint;
|
|
860
|
+
totalB: bigint;
|
|
861
|
+
minTotalA: bigint;
|
|
862
|
+
minTotalB: bigint;
|
|
863
|
+
swapInput: bigint;
|
|
864
|
+
swapOutput: bigint;
|
|
865
|
+
swapAToB: boolean;
|
|
866
|
+
protocolFeeA: bigint;
|
|
867
|
+
protocolFeeB: bigint;
|
|
868
|
+
liquidationLowerPrice: number;
|
|
869
|
+
liquidationUpperPrice: number;
|
|
845
870
|
}
|
|
846
871
|
|
|
847
|
-
export interface
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
872
|
+
export interface IncreaseLpPositionQuoteArgs {
|
|
873
|
+
collateralA: bigint;
|
|
874
|
+
collateralB: bigint;
|
|
875
|
+
borrowA: bigint;
|
|
876
|
+
borrowB: bigint;
|
|
877
|
+
protocolFeeRate: number;
|
|
878
|
+
protocolFeeRateOnCollateral: number;
|
|
879
|
+
swapFeeRate: number;
|
|
880
|
+
sqrtPrice: bigint;
|
|
881
|
+
tickLowerIndex: number;
|
|
882
|
+
tickUpperIndex: number;
|
|
883
|
+
maxAmountSlippage: number;
|
|
884
|
+
liquidationThreshold: number;
|
|
859
885
|
}
|
|
860
886
|
|
|
861
887
|
export interface LiquidationPrices {
|
|
@@ -891,6 +917,20 @@ export interface DecreaseSpotPositionQuoteResult {
|
|
|
891
917
|
jupiterSwapIx: SwapInstruction | undefined;
|
|
892
918
|
}
|
|
893
919
|
|
|
920
|
+
export interface TunaSpotPositionFacade {
|
|
921
|
+
version: number;
|
|
922
|
+
marketMaker: number;
|
|
923
|
+
positionToken: number;
|
|
924
|
+
collateralToken: number;
|
|
925
|
+
flags: number;
|
|
926
|
+
amount: bigint;
|
|
927
|
+
loanShares: bigint;
|
|
928
|
+
loanFunds: bigint;
|
|
929
|
+
entrySqrtPrice: bigint;
|
|
930
|
+
lowerLimitOrderSqrtPrice: bigint;
|
|
931
|
+
upperLimitOrderSqrtPrice: bigint;
|
|
932
|
+
}
|
|
933
|
+
|
|
894
934
|
/**
|
|
895
935
|
* A hash; the 32-byte output of a hashing algorithm.
|
|
896
936
|
*
|