@crypticdot/defituna-core 3.3.6 → 3.4.2
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 +349 -291
- package/dist/browser/defituna_core_js_bindings_bg.js +547 -484
- package/dist/browser/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/defituna_core_js_bindings_bg.wasm.d.ts +44 -39
- package/dist/nodejs/defituna_core_js_bindings.d.ts +349 -291
- package/dist/nodejs/defituna_core_js_bindings.js +547 -484
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/defituna_core_js_bindings_bg.wasm.d.ts +44 -39
- package/package.json +2 -2
|
@@ -1,5 +1,140 @@
|
|
|
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;
|
|
131
|
+
export function _FEE_RATE_MUL_VALUE(): number;
|
|
132
|
+
export function _MAX_PROTOCOL_FEE_RATE(): number;
|
|
133
|
+
export function _PROTOCOL_FEE_RATE_MUL_VALUE(): number;
|
|
134
|
+
export function _TICK_ARRAY_SIZE(): number;
|
|
135
|
+
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
|
|
136
|
+
export function _MIN_TICK_INDEX(): number;
|
|
137
|
+
export function _MAX_TICK_INDEX(): number;
|
|
3
138
|
/**
|
|
4
139
|
* Get the first tick index in the tick array that contains the specified tick index.
|
|
5
140
|
*
|
|
@@ -159,162 +294,6 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
|
|
|
159
294
|
* - A u32 integer representing the tick index in the tick array
|
|
160
295
|
*/
|
|
161
296
|
export function getTickIndexInArray(tick_index: number, tick_array_start_index: number, tick_spacing: number): number;
|
|
162
|
-
/**
|
|
163
|
-
* Calculate the amount A delta between two sqrt_prices
|
|
164
|
-
*
|
|
165
|
-
* # Parameters
|
|
166
|
-
* - `sqrt_price_1`: The first square root price
|
|
167
|
-
* - `sqrt_price_2`: The second square root price
|
|
168
|
-
* - `liquidity`: The liquidity
|
|
169
|
-
* - `round_up`: Whether to round up or not
|
|
170
|
-
*
|
|
171
|
-
* # Returns
|
|
172
|
-
* - `u64`: The amount delta
|
|
173
|
-
*/
|
|
174
|
-
export function tryGetAmountDeltaA(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
|
|
175
|
-
/**
|
|
176
|
-
* Calculate the amount B delta between two sqrt_prices
|
|
177
|
-
*
|
|
178
|
-
* # Parameters
|
|
179
|
-
* - `sqrt_price_1`: The first square root price
|
|
180
|
-
* - `sqrt_price_2`: The second square root price
|
|
181
|
-
* - `liquidity`: The liquidity
|
|
182
|
-
* - `round_up`: Whether to round up or not
|
|
183
|
-
*
|
|
184
|
-
* # Returns
|
|
185
|
-
* - `u64`: The amount delta
|
|
186
|
-
*/
|
|
187
|
-
export function tryGetAmountDeltaB(sqrt_price_1: bigint, sqrt_price_2: bigint, liquidity: bigint, round_up: boolean): bigint;
|
|
188
|
-
/**
|
|
189
|
-
* Calculate the next square root price
|
|
190
|
-
*
|
|
191
|
-
* # Parameters
|
|
192
|
-
* - `current_sqrt_price`: The current square root price
|
|
193
|
-
* - `current_liquidity`: The current liquidity
|
|
194
|
-
* - `amount`: The amount
|
|
195
|
-
* - `specified_input`: Whether the input is specified
|
|
196
|
-
*
|
|
197
|
-
* # Returns
|
|
198
|
-
* - `u128`: The next square root price
|
|
199
|
-
*/
|
|
200
|
-
export function tryGetNextSqrtPriceFromA(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
|
|
201
|
-
/**
|
|
202
|
-
* Calculate the next square root price
|
|
203
|
-
*
|
|
204
|
-
* # Parameters
|
|
205
|
-
* - `current_sqrt_price`: The current square root price
|
|
206
|
-
* - `current_liquidity`: The current liquidity
|
|
207
|
-
* - `amount`: The amount
|
|
208
|
-
* - `specified_input`: Whether the input is specified
|
|
209
|
-
*
|
|
210
|
-
* # Returns
|
|
211
|
-
* - `u128`: The next square root price
|
|
212
|
-
*/
|
|
213
|
-
export function tryGetNextSqrtPriceFromB(current_sqrt_price: bigint, current_liquidity: bigint, amount: bigint, specified_input: boolean): bigint;
|
|
214
|
-
/**
|
|
215
|
-
* Apply a transfer fee to an amount
|
|
216
|
-
* e.g. You send 10000 amount with 100 fee rate. The fee amount will be 100.
|
|
217
|
-
* So the amount after fee will be 9900.
|
|
218
|
-
*
|
|
219
|
-
* # Parameters
|
|
220
|
-
* - `amount`: The amount to apply the fee to
|
|
221
|
-
* - `transfer_fee`: The transfer fee to apply
|
|
222
|
-
*
|
|
223
|
-
* # Returns
|
|
224
|
-
* - `u64`: The amount after the fee has been applied
|
|
225
|
-
*/
|
|
226
|
-
export function tryApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
|
|
227
|
-
/**
|
|
228
|
-
* Reverse the application of a transfer fee to an amount
|
|
229
|
-
* e.g. You received 9900 amount with 100 fee rate. The fee amount will be 100.
|
|
230
|
-
* So the amount before fee will be 10000.
|
|
231
|
-
*
|
|
232
|
-
* # Parameters
|
|
233
|
-
* - `amount`: The amount to reverse the fee from
|
|
234
|
-
* - `transfer_fee`: The transfer fee to reverse
|
|
235
|
-
*
|
|
236
|
-
* # Returns
|
|
237
|
-
* - `u64`: The amount before the fee has been applied
|
|
238
|
-
*/
|
|
239
|
-
export function tryReverseApplyTransferFee(amount: bigint, transfer_fee: TransferFee): bigint;
|
|
240
|
-
/**
|
|
241
|
-
* Get the maximum amount with a slippage tolerance
|
|
242
|
-
* e.g. Your estimated amount you send is 10000 with 100 slippage tolerance. The max you send will be 10100.
|
|
243
|
-
*
|
|
244
|
-
* # Parameters
|
|
245
|
-
* - `amount`: The amount to apply the fee to
|
|
246
|
-
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
247
|
-
*
|
|
248
|
-
* # Returns
|
|
249
|
-
* - `u64`: The maximum amount
|
|
250
|
-
*/
|
|
251
|
-
export function tryGetMaxAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
|
|
252
|
-
/**
|
|
253
|
-
* Get the minimum amount with a slippage tolerance
|
|
254
|
-
* e.g. Your estimated amount you receive is 10000 with 100 slippage tolerance. The min amount you receive will be 9900.
|
|
255
|
-
*
|
|
256
|
-
* # Parameters
|
|
257
|
-
* - `amount`: The amount to apply the fee to
|
|
258
|
-
* - `slippage_tolerance_bps`: The slippage tolerance in bps (should be in range 0..BPS_DENOMINATOR)
|
|
259
|
-
*
|
|
260
|
-
* # Returns
|
|
261
|
-
* - `u64`: The minimum amount
|
|
262
|
-
*/
|
|
263
|
-
export function tryGetMinAmountWithSlippageTolerance(amount: bigint, slippage_tolerance_bps: number): bigint;
|
|
264
|
-
/**
|
|
265
|
-
* Apply a swap fee to an amount
|
|
266
|
-
* e.g. You send 10000 amount with 10000 fee rate. The fee amount will be 100.
|
|
267
|
-
* So the amount after fee will be 9900.
|
|
268
|
-
*
|
|
269
|
-
* # Parameters
|
|
270
|
-
* - `amount`: The amount to apply the fee to
|
|
271
|
-
* - `fee_rate`: The fee rate to apply denominated in 1e6
|
|
272
|
-
*
|
|
273
|
-
* # Returns
|
|
274
|
-
* - `u64`: The amount after the fee has been applied
|
|
275
|
-
*/
|
|
276
|
-
export function tryApplySwapFee(amount: bigint, fee_rate: number): bigint;
|
|
277
|
-
/**
|
|
278
|
-
* Reverse the application of a swap fee to an amount
|
|
279
|
-
* e.g. You received 9900 amount with 10000 fee rate. The fee amount will be 100.
|
|
280
|
-
* So the amount before fee will be 10000.
|
|
281
|
-
*
|
|
282
|
-
* # Parameters
|
|
283
|
-
* - `amount`: The amount to reverse the fee from
|
|
284
|
-
* - `fee_rate`: The fee rate to reverse denominated in 1e6
|
|
285
|
-
*
|
|
286
|
-
* # Returns
|
|
287
|
-
* - `u64`: The amount before the fee has been applied
|
|
288
|
-
*/
|
|
289
|
-
export function tryReverseApplySwapFee(amount: bigint, fee_rate: number): bigint;
|
|
290
|
-
/**
|
|
291
|
-
* Computes the limit order output amount by input amount.
|
|
292
|
-
* ### Parameters
|
|
293
|
-
* - `amount_in` - The input token amount of a limit order.
|
|
294
|
-
* - `a_to_b_order` - The limit order direction.
|
|
295
|
-
* - `tick_index` - The tick index of an order.
|
|
296
|
-
* - `fusion_pool` - The fusion_pool state.
|
|
297
|
-
*/
|
|
298
|
-
export function limitOrderQuoteByInputToken(amount_in: bigint, a_to_b_order: boolean, tick_index: number, fusion_pool: FusionPoolFacade): bigint;
|
|
299
|
-
/**
|
|
300
|
-
* Computes the limit order input amount by output amount.
|
|
301
|
-
* ### Parameters
|
|
302
|
-
* - `amount_out` - The output token amount of a limit order.
|
|
303
|
-
* - `a_to_b_order` - The limit order direction.
|
|
304
|
-
* - `tick_index` - The tick index of an order.
|
|
305
|
-
* - `fusion_pool` - The fusion_pool state.
|
|
306
|
-
*/
|
|
307
|
-
export function limitOrderQuoteByOutputToken(amount_out: bigint, a_to_b_order: boolean, tick_index: number, fusion_pool: FusionPoolFacade): bigint;
|
|
308
|
-
/**
|
|
309
|
-
* Computes the limit order reward by input amount.
|
|
310
|
-
* ### Parameters
|
|
311
|
-
* - `amount_out` - The output token amount of a limit order (swap input).
|
|
312
|
-
* - `a_to_b_order` - The limit order direction.
|
|
313
|
-
* - `tick_index` - The tick index of an order.
|
|
314
|
-
* - `fusion_pool` - The fusion_pool state.
|
|
315
|
-
*/
|
|
316
|
-
export function limitOrderRewardByOutputToken(amount_out: bigint, fee_rate: number, protocol_fee_rate: number): bigint;
|
|
317
|
-
export function decreaseLimitOrderQuote(fusion_pool: FusionPoolFacade, limit_order: LimitOrderFacade, tick: TickFacade, amount: bigint, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): LimitOrderDecreaseQuote;
|
|
318
297
|
/**
|
|
319
298
|
* Calculate the quote for decreasing liquidity
|
|
320
299
|
*
|
|
@@ -424,88 +403,42 @@ export function tryGetTokenEstimatesFromLiquidity(liquidity_delta: bigint, curre
|
|
|
424
403
|
* - `position`: The position state
|
|
425
404
|
* - `tick_lower`: The lower tick state
|
|
426
405
|
* - `tick_upper`: The upper tick state
|
|
427
|
-
* - `transfer_fee_a`: The transfer fee for token A
|
|
428
|
-
* - `transfer_fee_b`: The transfer fee for token B
|
|
429
|
-
*
|
|
430
|
-
* # Returns
|
|
431
|
-
* - `CollectFeesQuote`: The fees owed for token A and token B
|
|
432
|
-
*/
|
|
433
|
-
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;
|
|
434
|
-
export function limitOrderFee(fusion_pool: FusionPoolFacade): number;
|
|
435
|
-
export function _TICK_ARRAY_SIZE(): number;
|
|
436
|
-
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
|
|
437
|
-
export function _MIN_TICK_INDEX(): number;
|
|
438
|
-
export function _MAX_TICK_INDEX(): number;
|
|
439
|
-
/**
|
|
440
|
-
* Convert a price into a sqrt priceX64
|
|
441
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
442
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
443
|
-
*
|
|
444
|
-
* # Parameters
|
|
445
|
-
* * `price` - The price to convert
|
|
446
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
447
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
448
|
-
*
|
|
449
|
-
* # Returns
|
|
450
|
-
* * `u128` - The sqrt priceX64
|
|
451
|
-
*/
|
|
452
|
-
export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
|
|
453
|
-
/**
|
|
454
|
-
* Convert a sqrt priceX64 into a tick index
|
|
455
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
456
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
457
|
-
*
|
|
458
|
-
* # Parameters
|
|
459
|
-
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
460
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
461
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
462
|
-
*
|
|
463
|
-
* # Returns
|
|
464
|
-
* * `f64` - The decimal price
|
|
465
|
-
*/
|
|
466
|
-
export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
|
|
467
|
-
/**
|
|
468
|
-
* Invert a price
|
|
469
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
470
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
471
|
-
*
|
|
472
|
-
* # Parameters
|
|
473
|
-
* * `price` - The price to invert
|
|
474
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
475
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
406
|
+
* - `transfer_fee_a`: The transfer fee for token A
|
|
407
|
+
* - `transfer_fee_b`: The transfer fee for token B
|
|
476
408
|
*
|
|
477
409
|
* # Returns
|
|
478
|
-
*
|
|
410
|
+
* - `CollectFeesQuote`: The fees owed for token A and token B
|
|
479
411
|
*/
|
|
480
|
-
export function
|
|
412
|
+
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
|
+
export function limitOrderFee(fusion_pool: FusionPoolFacade): number;
|
|
481
414
|
/**
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
489
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
490
|
-
*
|
|
491
|
-
* # Returns
|
|
492
|
-
* * `f64` - The decimal price
|
|
415
|
+
* Computes the limit order output amount by input amount.
|
|
416
|
+
* ### Parameters
|
|
417
|
+
* - `amount_in` - The input token amount of a limit order.
|
|
418
|
+
* - `a_to_b_order` - The limit order direction.
|
|
419
|
+
* - `tick_index` - The tick index of an order.
|
|
420
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
493
421
|
*/
|
|
494
|
-
export function
|
|
422
|
+
export function limitOrderQuoteByInputToken(amount_in: bigint, a_to_b_order: boolean, tick_index: number, fusion_pool: FusionPoolFacade): bigint;
|
|
495
423
|
/**
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
503
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
504
|
-
*
|
|
505
|
-
* # Returns
|
|
506
|
-
* * `i32` - The tick index
|
|
424
|
+
* Computes the limit order input amount by output amount.
|
|
425
|
+
* ### Parameters
|
|
426
|
+
* - `amount_out` - The output token amount of a limit order.
|
|
427
|
+
* - `a_to_b_order` - The limit order direction.
|
|
428
|
+
* - `tick_index` - The tick index of an order.
|
|
429
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
507
430
|
*/
|
|
508
|
-
export function
|
|
431
|
+
export function limitOrderQuoteByOutputToken(amount_out: bigint, a_to_b_order: boolean, tick_index: number, fusion_pool: FusionPoolFacade): bigint;
|
|
432
|
+
/**
|
|
433
|
+
* Computes the limit order reward by input amount.
|
|
434
|
+
* ### Parameters
|
|
435
|
+
* - `amount_out` - The output token amount of a limit order (swap input).
|
|
436
|
+
* - `a_to_b_order` - The limit order direction.
|
|
437
|
+
* - `tick_index` - The tick index of an order.
|
|
438
|
+
* - `fusion_pool` - The fusion_pool state.
|
|
439
|
+
*/
|
|
440
|
+
export function limitOrderRewardByOutputToken(amount_out: bigint, fee_rate: number, protocol_fee_rate: number): bigint;
|
|
441
|
+
export function decreaseLimitOrderQuote(fusion_pool: FusionPoolFacade, limit_order: LimitOrderFacade, tick: TickFacade, amount: bigint, transfer_fee_a?: TransferFee | null, transfer_fee_b?: TransferFee | null): LimitOrderDecreaseQuote;
|
|
509
442
|
export function _POSITION_BUNDLE_SIZE(): number;
|
|
510
443
|
export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
|
|
511
444
|
export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
|
|
@@ -524,9 +457,6 @@ export function _INVALID_SLIPPAGE_TOLERANCE(): string;
|
|
|
524
457
|
export function _TICK_INDEX_NOT_IN_ARRAY(): string;
|
|
525
458
|
export function _INVALID_TICK_ARRAY_SEQUENCE(): string;
|
|
526
459
|
export function _LIMIT_ORDER_AND_POOL_ARE_OUT_OF_SYNC(): string;
|
|
527
|
-
export function _FEE_RATE_MUL_VALUE(): number;
|
|
528
|
-
export function _MAX_PROTOCOL_FEE_RATE(): number;
|
|
529
|
-
export function _PROTOCOL_FEE_RATE_MUL_VALUE(): number;
|
|
530
460
|
/**
|
|
531
461
|
* Get the first unoccupied position in a bundle
|
|
532
462
|
*
|
|
@@ -599,6 +529,76 @@ export function positionStatus(current_sqrt_price: bigint, tick_index_1: number,
|
|
|
599
529
|
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
600
530
|
*/
|
|
601
531
|
export function positionRatioX64(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
|
|
532
|
+
/**
|
|
533
|
+
* Convert a price into a sqrt priceX64
|
|
534
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
535
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
536
|
+
*
|
|
537
|
+
* # Parameters
|
|
538
|
+
* * `price` - The price to convert
|
|
539
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
540
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
541
|
+
*
|
|
542
|
+
* # Returns
|
|
543
|
+
* * `u128` - The sqrt priceX64
|
|
544
|
+
*/
|
|
545
|
+
export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
|
|
546
|
+
/**
|
|
547
|
+
* Convert a sqrt priceX64 into a tick index
|
|
548
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
549
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
550
|
+
*
|
|
551
|
+
* # Parameters
|
|
552
|
+
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
553
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
554
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
555
|
+
*
|
|
556
|
+
* # Returns
|
|
557
|
+
* * `f64` - The decimal price
|
|
558
|
+
*/
|
|
559
|
+
export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
|
|
560
|
+
/**
|
|
561
|
+
* Invert a price
|
|
562
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
563
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
564
|
+
*
|
|
565
|
+
* # Parameters
|
|
566
|
+
* * `price` - The price to invert
|
|
567
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
568
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
569
|
+
*
|
|
570
|
+
* # Returns
|
|
571
|
+
* * `f64` - The inverted price
|
|
572
|
+
*/
|
|
573
|
+
export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
|
|
574
|
+
/**
|
|
575
|
+
* Convert a tick index into a price
|
|
576
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
577
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
578
|
+
*
|
|
579
|
+
* # Parameters
|
|
580
|
+
* * `tick_index` - The tick index to convert
|
|
581
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
582
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
583
|
+
*
|
|
584
|
+
* # Returns
|
|
585
|
+
* * `f64` - The decimal price
|
|
586
|
+
*/
|
|
587
|
+
export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
|
|
588
|
+
/**
|
|
589
|
+
* Convert a price into a tick index
|
|
590
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
591
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
592
|
+
*
|
|
593
|
+
* # Parameters
|
|
594
|
+
* * `price` - The price to convert
|
|
595
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
596
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
597
|
+
*
|
|
598
|
+
* # Returns
|
|
599
|
+
* * `i32` - The tick index
|
|
600
|
+
*/
|
|
601
|
+
export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
|
|
602
602
|
/**
|
|
603
603
|
* Computes the exact input or output amount for a swap transaction.
|
|
604
604
|
*
|
|
@@ -631,6 +631,26 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
|
|
|
631
631
|
* The exact input or output amount for the swap transaction.
|
|
632
632
|
*/
|
|
633
633
|
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;
|
|
634
|
+
/**
|
|
635
|
+
* Computes the liquidation prices for an existing position.
|
|
636
|
+
*
|
|
637
|
+
* # Parameters
|
|
638
|
+
* - `tick_lower_index`: The lower tick index of the position.
|
|
639
|
+
* - `tick_upper_index`: The upper tick index of the position.
|
|
640
|
+
* - `leftovers_a`: The amount of leftovers A in the position.
|
|
641
|
+
* - `leftovers_a`: The amount of leftovers B in the position.
|
|
642
|
+
* - `liquidity`: Liquidity of the position.
|
|
643
|
+
* - `debt_a`: The amount of tokens A borrowed.
|
|
644
|
+
* - `debt_b`: The amount of tokens B borrowed.
|
|
645
|
+
* - `liquidation_threshold`: The liquidation threshold of the market.
|
|
646
|
+
*
|
|
647
|
+
* # Returns
|
|
648
|
+
* - `LiquidationPrices`: An object containing lower/upper liquidation prices.
|
|
649
|
+
*/
|
|
650
|
+
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;
|
|
651
|
+
export function getIncreaseLpPositionQuote(args: IncreaseLpPositionQuoteArgs): IncreaseLpPositionQuoteResult;
|
|
652
|
+
export function _HUNDRED_PERCENT(): number;
|
|
653
|
+
export function _COMPUTED_AMOUNT(): bigint;
|
|
634
654
|
/**
|
|
635
655
|
* Spot position increase quote
|
|
636
656
|
*
|
|
@@ -681,7 +701,7 @@ export function getDecreaseSpotPositionQuote(decrease_amount: bigint, collateral
|
|
|
681
701
|
* # Returns
|
|
682
702
|
* - `f64`: Decimal liquidation price
|
|
683
703
|
*/
|
|
684
|
-
export function
|
|
704
|
+
export function getSpotPositionLiquidationPrice(position_token: number, amount: number, debt: number, liquidation_threshold: number): number;
|
|
685
705
|
/**
|
|
686
706
|
* Calculates the maximum tradable amount in the collateral token.
|
|
687
707
|
*
|
|
@@ -700,7 +720,8 @@ export function getLiquidationPrice(position_token: number, amount: number, debt
|
|
|
700
720
|
* - `u64`: the maximum tradable amount
|
|
701
721
|
*/
|
|
702
722
|
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;
|
|
703
|
-
export function
|
|
723
|
+
export function calculateTunaSpotPositionProtocolFee(collateral_token: number, borrowed_token: number, collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): TokenPair;
|
|
724
|
+
export function calculateTunaProtocolFee(collateral: bigint, borrow: bigint, protocol_fee_rate_on_collateral: number, protocol_fee_rate: number): bigint;
|
|
704
725
|
export function _INVALID_ARGUMENTS(): string;
|
|
705
726
|
export function _JUPITER_QUOTE_REQUEST_ERROR(): string;
|
|
706
727
|
export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
|
|
@@ -708,35 +729,6 @@ export function _JUPITER_SWAP_INSTRUCTIONS_REQUEST_ERROR(): string;
|
|
|
708
729
|
* Initialize Javascript logging and panic handler
|
|
709
730
|
*/
|
|
710
731
|
export function solana_program_init(): void;
|
|
711
|
-
export interface CollectFeesQuote {
|
|
712
|
-
feeOwedA: bigint;
|
|
713
|
-
feeOwedB: bigint;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
export interface TickArrayFacade {
|
|
717
|
-
startTickIndex: number;
|
|
718
|
-
ticks: TickFacade[];
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
export interface TickFacade {
|
|
722
|
-
initialized: boolean;
|
|
723
|
-
liquidityNet: bigint;
|
|
724
|
-
liquidityGross: bigint;
|
|
725
|
-
feeGrowthOutsideA: bigint;
|
|
726
|
-
feeGrowthOutsideB: bigint;
|
|
727
|
-
age: bigint;
|
|
728
|
-
openOrdersInput: bigint;
|
|
729
|
-
partFilledOrdersInput: bigint;
|
|
730
|
-
partFilledOrdersRemainingInput: bigint;
|
|
731
|
-
fulfilledAToBOrdersInput: bigint;
|
|
732
|
-
fulfilledBToAOrdersInput: bigint;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
export interface TickRange {
|
|
736
|
-
tickLowerIndex: number;
|
|
737
|
-
tickUpperIndex: number;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
732
|
export interface ExactOutSwapQuote {
|
|
741
733
|
tokenOut: bigint;
|
|
742
734
|
tokenEstIn: bigint;
|
|
@@ -770,32 +762,6 @@ export interface FusionPoolFacade {
|
|
|
770
762
|
olpFeeOwedB: bigint;
|
|
771
763
|
}
|
|
772
764
|
|
|
773
|
-
export interface IncreaseLiquidityQuote {
|
|
774
|
-
liquidityDelta: bigint;
|
|
775
|
-
tokenEstA: bigint;
|
|
776
|
-
tokenEstB: bigint;
|
|
777
|
-
tokenMaxA: bigint;
|
|
778
|
-
tokenMaxB: bigint;
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
export interface DecreaseLiquidityQuote {
|
|
782
|
-
liquidityDelta: bigint;
|
|
783
|
-
tokenEstA: bigint;
|
|
784
|
-
tokenEstB: bigint;
|
|
785
|
-
tokenMinA: bigint;
|
|
786
|
-
tokenMinB: bigint;
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
export interface TokenPair {
|
|
790
|
-
a: bigint;
|
|
791
|
-
b: bigint;
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
export interface TransferFee {
|
|
795
|
-
feeBps: number;
|
|
796
|
-
maxFee: bigint;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
765
|
export interface LimitOrderDecreaseQuote {
|
|
800
766
|
amountOutA: bigint;
|
|
801
767
|
amountOutB: bigint;
|
|
@@ -810,6 +776,11 @@ export interface LimitOrderFacade {
|
|
|
810
776
|
age: bigint;
|
|
811
777
|
}
|
|
812
778
|
|
|
779
|
+
export interface TokenPair {
|
|
780
|
+
a: bigint;
|
|
781
|
+
b: bigint;
|
|
782
|
+
}
|
|
783
|
+
|
|
813
784
|
export interface PositionFacade {
|
|
814
785
|
liquidity: bigint;
|
|
815
786
|
tickLowerIndex: number;
|
|
@@ -827,6 +798,93 @@ export interface PositionRatio {
|
|
|
827
798
|
ratioB: bigint;
|
|
828
799
|
}
|
|
829
800
|
|
|
801
|
+
export interface TickArrayFacade {
|
|
802
|
+
startTickIndex: number;
|
|
803
|
+
ticks: TickFacade[];
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
export interface TickFacade {
|
|
807
|
+
initialized: boolean;
|
|
808
|
+
liquidityNet: bigint;
|
|
809
|
+
liquidityGross: bigint;
|
|
810
|
+
feeGrowthOutsideA: bigint;
|
|
811
|
+
feeGrowthOutsideB: bigint;
|
|
812
|
+
age: bigint;
|
|
813
|
+
openOrdersInput: bigint;
|
|
814
|
+
partFilledOrdersInput: bigint;
|
|
815
|
+
partFilledOrdersRemainingInput: bigint;
|
|
816
|
+
fulfilledAToBOrdersInput: bigint;
|
|
817
|
+
fulfilledBToAOrdersInput: bigint;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
export interface TickRange {
|
|
821
|
+
tickLowerIndex: number;
|
|
822
|
+
tickUpperIndex: number;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
export interface IncreaseLiquidityQuote {
|
|
826
|
+
liquidityDelta: bigint;
|
|
827
|
+
tokenEstA: bigint;
|
|
828
|
+
tokenEstB: bigint;
|
|
829
|
+
tokenMaxA: bigint;
|
|
830
|
+
tokenMaxB: bigint;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
export interface DecreaseLiquidityQuote {
|
|
834
|
+
liquidityDelta: bigint;
|
|
835
|
+
tokenEstA: bigint;
|
|
836
|
+
tokenEstB: bigint;
|
|
837
|
+
tokenMinA: bigint;
|
|
838
|
+
tokenMinB: bigint;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
export interface CollectFeesQuote {
|
|
842
|
+
feeOwedA: bigint;
|
|
843
|
+
feeOwedB: bigint;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
export interface TransferFee {
|
|
847
|
+
feeBps: number;
|
|
848
|
+
maxFee: bigint;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
export interface IncreaseLpPositionQuoteResult {
|
|
852
|
+
collateralA: bigint;
|
|
853
|
+
collateralB: bigint;
|
|
854
|
+
maxCollateralA: bigint;
|
|
855
|
+
maxCollateralB: bigint;
|
|
856
|
+
borrowA: bigint;
|
|
857
|
+
borrowB: bigint;
|
|
858
|
+
totalA: bigint;
|
|
859
|
+
totalB: bigint;
|
|
860
|
+
minTotalA: bigint;
|
|
861
|
+
minTotalB: bigint;
|
|
862
|
+
swapInput: bigint;
|
|
863
|
+
swapOutput: bigint;
|
|
864
|
+
swapAToB: boolean;
|
|
865
|
+
protocolFeeA: bigint;
|
|
866
|
+
protocolFeeB: bigint;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
export interface IncreaseLpPositionQuoteArgs {
|
|
870
|
+
collateralA: bigint;
|
|
871
|
+
collateralB: bigint;
|
|
872
|
+
borrowA: bigint;
|
|
873
|
+
borrowB: bigint;
|
|
874
|
+
protocolFeeRate: number;
|
|
875
|
+
protocolFeeRateOnCollateral: number;
|
|
876
|
+
swapFeeRate: number;
|
|
877
|
+
sqrtPrice: bigint;
|
|
878
|
+
tickLowerIndex: number;
|
|
879
|
+
tickUpperIndex: number;
|
|
880
|
+
maxAmountSlippage: number;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
export interface LiquidationPrices {
|
|
884
|
+
lower: number;
|
|
885
|
+
upper: number;
|
|
886
|
+
}
|
|
887
|
+
|
|
830
888
|
export interface SwapInstruction {
|
|
831
889
|
data: number[];
|
|
832
890
|
accounts: AccountMeta[];
|