@orca-so/whirlpools-core 0.3.2 → 0.4.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/orca_whirlpools_core_js_bindings.d.ts +166 -166
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.js +322 -225
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.wasm.d.ts +32 -32
- package/dist/nodejs/orca_whirlpools_core_js_bindings.d.ts +166 -166
- package/dist/nodejs/orca_whirlpools_core_js_bindings.js +322 -225
- package/dist/nodejs/orca_whirlpools_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/orca_whirlpools_core_js_bindings_bg.wasm.d.ts +32 -32
- package/package.json +2 -2
|
@@ -1,36 +1,5 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
/**
|
|
4
|
-
* Get the first unoccupied position in a bundle
|
|
5
|
-
*
|
|
6
|
-
* # Arguments
|
|
7
|
-
* * `bundle` - The bundle to check
|
|
8
|
-
*
|
|
9
|
-
* # Returns
|
|
10
|
-
* * `u32` - The first unoccupied position (None if full)
|
|
11
|
-
*/
|
|
12
|
-
export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Check whether a position bundle is full
|
|
15
|
-
* A position bundle can contain 256 positions
|
|
16
|
-
*
|
|
17
|
-
* # Arguments
|
|
18
|
-
* * `bundle` - The bundle to check
|
|
19
|
-
*
|
|
20
|
-
* # Returns
|
|
21
|
-
* * `bool` - Whether the bundle is full
|
|
22
|
-
*/
|
|
23
|
-
export function isPositionBundleFull(bitmap: Uint8Array): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Check whether a position bundle is empty
|
|
26
|
-
*
|
|
27
|
-
* # Arguments
|
|
28
|
-
* * `bundle` - The bundle to check
|
|
29
|
-
*
|
|
30
|
-
* # Returns
|
|
31
|
-
* * `bool` - Whether the bundle is empty
|
|
32
|
-
*/
|
|
33
|
-
export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
|
|
34
3
|
/**
|
|
35
4
|
* Get the first tick index in the tick array that contains the specified tick index.
|
|
36
5
|
*
|
|
@@ -191,26 +160,57 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
|
|
|
191
160
|
*/
|
|
192
161
|
export function getTickIndexInArray(tick_index: number, tick_array_start_index: number, tick_spacing: number): number;
|
|
193
162
|
export function _POSITION_BUNDLE_SIZE(): number;
|
|
194
|
-
export function _TICK_ARRAY_NOT_EVENLY_SPACED(): number;
|
|
195
|
-
export function _TICK_INDEX_OUT_OF_BOUNDS(): number;
|
|
196
|
-
export function _INVALID_TICK_INDEX(): number;
|
|
197
|
-
export function _ARITHMETIC_OVERFLOW(): number;
|
|
198
|
-
export function _AMOUNT_EXCEEDS_MAX_U64(): number;
|
|
199
|
-
export function _SQRT_PRICE_OUT_OF_BOUNDS(): number;
|
|
200
|
-
export function _TICK_SEQUENCE_EMPTY(): number;
|
|
201
|
-
export function _SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(): number;
|
|
202
|
-
export function _INVALID_SQRT_PRICE_LIMIT_DIRECTION(): number;
|
|
203
|
-
export function _ZERO_TRADABLE_AMOUNT(): number;
|
|
204
|
-
export function _INVALID_TIMESTAMP(): number;
|
|
205
|
-
export function _INVALID_TRANSFER_FEE(): number;
|
|
206
|
-
export function _INVALID_SLIPPAGE_TOLERANCE(): number;
|
|
207
|
-
export function _TICK_INDEX_NOT_IN_ARRAY(): number;
|
|
208
163
|
export function _NUM_REWARDS(): number;
|
|
209
164
|
export function _FEE_RATE_DENOMINATOR(): number;
|
|
210
165
|
export function _TICK_ARRAY_SIZE(): number;
|
|
211
166
|
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
|
|
212
167
|
export function _MIN_TICK_INDEX(): number;
|
|
213
168
|
export function _MAX_TICK_INDEX(): number;
|
|
169
|
+
/**
|
|
170
|
+
* Get the first unoccupied position in a bundle
|
|
171
|
+
*
|
|
172
|
+
* # Arguments
|
|
173
|
+
* * `bundle` - The bundle to check
|
|
174
|
+
*
|
|
175
|
+
* # Returns
|
|
176
|
+
* * `u32` - The first unoccupied position (None if full)
|
|
177
|
+
*/
|
|
178
|
+
export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* Check whether a position bundle is full
|
|
181
|
+
* A position bundle can contain 256 positions
|
|
182
|
+
*
|
|
183
|
+
* # Arguments
|
|
184
|
+
* * `bundle` - The bundle to check
|
|
185
|
+
*
|
|
186
|
+
* # Returns
|
|
187
|
+
* * `bool` - Whether the bundle is full
|
|
188
|
+
*/
|
|
189
|
+
export function isPositionBundleFull(bitmap: Uint8Array): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Check whether a position bundle is empty
|
|
192
|
+
*
|
|
193
|
+
* # Arguments
|
|
194
|
+
* * `bundle` - The bundle to check
|
|
195
|
+
*
|
|
196
|
+
* # Returns
|
|
197
|
+
* * `bool` - Whether the bundle is empty
|
|
198
|
+
*/
|
|
199
|
+
export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
|
|
200
|
+
export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
|
|
201
|
+
export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
|
|
202
|
+
export function _INVALID_TICK_INDEX(): string;
|
|
203
|
+
export function _ARITHMETIC_OVERFLOW(): string;
|
|
204
|
+
export function _AMOUNT_EXCEEDS_MAX_U64(): string;
|
|
205
|
+
export function _SQRT_PRICE_OUT_OF_BOUNDS(): string;
|
|
206
|
+
export function _TICK_SEQUENCE_EMPTY(): string;
|
|
207
|
+
export function _SQRT_PRICE_LIMIT_OUT_OF_BOUNDS(): string;
|
|
208
|
+
export function _INVALID_SQRT_PRICE_LIMIT_DIRECTION(): string;
|
|
209
|
+
export function _ZERO_TRADABLE_AMOUNT(): string;
|
|
210
|
+
export function _INVALID_TIMESTAMP(): string;
|
|
211
|
+
export function _INVALID_TRANSFER_FEE(): string;
|
|
212
|
+
export function _INVALID_SLIPPAGE_TOLERANCE(): string;
|
|
213
|
+
export function _TICK_INDEX_NOT_IN_ARRAY(): string;
|
|
214
214
|
/**
|
|
215
215
|
* Check if a position is in range.
|
|
216
216
|
* When a position is in range it is earning fees and rewards
|
|
@@ -252,76 +252,6 @@ export function positionStatus(current_sqrt_price: bigint, tick_index_1: number,
|
|
|
252
252
|
* - A PositionRatio struct containing the ratio of token_a and token_b
|
|
253
253
|
*/
|
|
254
254
|
export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
|
|
255
|
-
/**
|
|
256
|
-
* Convert a price into a sqrt priceX64
|
|
257
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
258
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
259
|
-
*
|
|
260
|
-
* # Parameters
|
|
261
|
-
* * `price` - The price to convert
|
|
262
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
263
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
264
|
-
*
|
|
265
|
-
* # Returns
|
|
266
|
-
* * `u128` - The sqrt priceX64
|
|
267
|
-
*/
|
|
268
|
-
export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
|
|
269
|
-
/**
|
|
270
|
-
* Convert a sqrt priceX64 into a tick index
|
|
271
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
272
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
273
|
-
*
|
|
274
|
-
* # Parameters
|
|
275
|
-
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
276
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
277
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
278
|
-
*
|
|
279
|
-
* # Returns
|
|
280
|
-
* * `f64` - The decimal price
|
|
281
|
-
*/
|
|
282
|
-
export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
|
|
283
|
-
/**
|
|
284
|
-
* Invert a price
|
|
285
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
286
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
287
|
-
*
|
|
288
|
-
* # Parameters
|
|
289
|
-
* * `price` - The price to invert
|
|
290
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
291
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
292
|
-
*
|
|
293
|
-
* # Returns
|
|
294
|
-
* * `f64` - The inverted price
|
|
295
|
-
*/
|
|
296
|
-
export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
|
|
297
|
-
/**
|
|
298
|
-
* Convert a tick index into a price
|
|
299
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
300
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
301
|
-
*
|
|
302
|
-
* # Parameters
|
|
303
|
-
* * `tick_index` - The tick index to convert
|
|
304
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
305
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
306
|
-
*
|
|
307
|
-
* # Returns
|
|
308
|
-
* * `f64` - The decimal price
|
|
309
|
-
*/
|
|
310
|
-
export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
|
|
311
|
-
/**
|
|
312
|
-
* Convert a price into a tick index
|
|
313
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
314
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
315
|
-
*
|
|
316
|
-
* # Parameters
|
|
317
|
-
* * `price` - The price to convert
|
|
318
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
319
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
320
|
-
*
|
|
321
|
-
* # Returns
|
|
322
|
-
* * `i32` - The tick index
|
|
323
|
-
*/
|
|
324
|
-
export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
|
|
325
255
|
/**
|
|
326
256
|
* Calculate the amount A delta between two sqrt_prices
|
|
327
257
|
*
|
|
@@ -482,6 +412,76 @@ export function swapQuoteByInputToken(token_in: bigint, specified_token_a: boole
|
|
|
482
412
|
* The exact input or output amount for the swap transaction.
|
|
483
413
|
*/
|
|
484
414
|
export function swapQuoteByOutputToken(token_out: bigint, specified_token_a: boolean, slippage_tolerance_bps: number, whirlpool: WhirlpoolFacade, tick_arrays: TickArrayFacade[], transfer_fee_a?: TransferFee, transfer_fee_b?: TransferFee): ExactOutSwapQuote;
|
|
415
|
+
/**
|
|
416
|
+
* Convert a price into a sqrt priceX64
|
|
417
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
418
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
419
|
+
*
|
|
420
|
+
* # Parameters
|
|
421
|
+
* * `price` - The price to convert
|
|
422
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
423
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
424
|
+
*
|
|
425
|
+
* # Returns
|
|
426
|
+
* * `u128` - The sqrt priceX64
|
|
427
|
+
*/
|
|
428
|
+
export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
|
|
429
|
+
/**
|
|
430
|
+
* Convert a sqrt priceX64 into a tick index
|
|
431
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
432
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
433
|
+
*
|
|
434
|
+
* # Parameters
|
|
435
|
+
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
436
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
437
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
438
|
+
*
|
|
439
|
+
* # Returns
|
|
440
|
+
* * `f64` - The decimal price
|
|
441
|
+
*/
|
|
442
|
+
export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
|
|
443
|
+
/**
|
|
444
|
+
* Invert a price
|
|
445
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
446
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
447
|
+
*
|
|
448
|
+
* # Parameters
|
|
449
|
+
* * `price` - The price to invert
|
|
450
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
451
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
452
|
+
*
|
|
453
|
+
* # Returns
|
|
454
|
+
* * `f64` - The inverted price
|
|
455
|
+
*/
|
|
456
|
+
export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
|
|
457
|
+
/**
|
|
458
|
+
* Convert a tick index into a price
|
|
459
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
460
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
461
|
+
*
|
|
462
|
+
* # Parameters
|
|
463
|
+
* * `tick_index` - The tick index to convert
|
|
464
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
465
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
466
|
+
*
|
|
467
|
+
* # Returns
|
|
468
|
+
* * `f64` - The decimal price
|
|
469
|
+
*/
|
|
470
|
+
export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
|
|
471
|
+
/**
|
|
472
|
+
* Convert a price into a tick index
|
|
473
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
474
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
475
|
+
*
|
|
476
|
+
* # Parameters
|
|
477
|
+
* * `price` - The price to convert
|
|
478
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
479
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
480
|
+
*
|
|
481
|
+
* # Returns
|
|
482
|
+
* * `i32` - The tick index
|
|
483
|
+
*/
|
|
484
|
+
export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
|
|
485
485
|
/**
|
|
486
486
|
* Calculate fees owed for a position
|
|
487
487
|
*
|
|
@@ -610,6 +610,25 @@ export function increaseLiquidityQuoteB(token_amount_b: bigint, slippage_toleran
|
|
|
610
610
|
* - `CollectRewardsQuote`: The rewards owed for the 3 reward tokens.
|
|
611
611
|
*/
|
|
612
612
|
export function collectRewardsQuote(whirlpool: WhirlpoolFacade, position: PositionFacade, tick_lower: TickFacade, tick_upper: TickFacade, current_timestamp: bigint, transfer_fee_1?: TransferFee, transfer_fee_2?: TransferFee, transfer_fee_3?: TransferFee): CollectRewardsQuote;
|
|
613
|
+
export interface ExactOutSwapQuote {
|
|
614
|
+
tokenOut: bigint;
|
|
615
|
+
tokenEstIn: bigint;
|
|
616
|
+
tokenMaxIn: bigint;
|
|
617
|
+
tradeFee: bigint;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
export interface ExactInSwapQuote {
|
|
621
|
+
tokenIn: bigint;
|
|
622
|
+
tokenEstOut: bigint;
|
|
623
|
+
tokenMinOut: bigint;
|
|
624
|
+
tradeFee: bigint;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
export interface TransferFee {
|
|
628
|
+
feeBps: number;
|
|
629
|
+
maxFee: bigint;
|
|
630
|
+
}
|
|
631
|
+
|
|
613
632
|
export interface PositionRewardInfoFacade {
|
|
614
633
|
growthInsideCheckpoint: bigint;
|
|
615
634
|
amountOwed: bigint;
|
|
@@ -633,39 +652,31 @@ export interface PositionRatio {
|
|
|
633
652
|
ratioB: number;
|
|
634
653
|
}
|
|
635
654
|
|
|
636
|
-
export interface
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
tokenEstB: bigint;
|
|
640
|
-
tokenMaxA: bigint;
|
|
641
|
-
tokenMaxB: bigint;
|
|
655
|
+
export interface TickArrayFacade {
|
|
656
|
+
startTickIndex: number;
|
|
657
|
+
ticks: TickFacade[];
|
|
642
658
|
}
|
|
643
659
|
|
|
644
|
-
export interface
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
660
|
+
export interface TickFacade {
|
|
661
|
+
initialized: boolean;
|
|
662
|
+
liquidityNet: bigint;
|
|
663
|
+
liquidityGross: bigint;
|
|
664
|
+
feeGrowthOutsideA: bigint;
|
|
665
|
+
feeGrowthOutsideB: bigint;
|
|
666
|
+
rewardGrowthsOutside: bigint[];
|
|
650
667
|
}
|
|
651
668
|
|
|
652
|
-
export interface
|
|
653
|
-
|
|
654
|
-
|
|
669
|
+
export interface TickRange {
|
|
670
|
+
tickLowerIndex: number;
|
|
671
|
+
tickUpperIndex: number;
|
|
655
672
|
}
|
|
656
673
|
|
|
657
|
-
export interface
|
|
658
|
-
|
|
659
|
-
tokenEstIn: bigint;
|
|
660
|
-
tokenMaxIn: bigint;
|
|
661
|
-
tradeFee: bigint;
|
|
674
|
+
export interface CollectRewardQuote {
|
|
675
|
+
rewardsOwed: bigint;
|
|
662
676
|
}
|
|
663
677
|
|
|
664
|
-
export interface
|
|
665
|
-
|
|
666
|
-
tokenEstOut: bigint;
|
|
667
|
-
tokenMinOut: bigint;
|
|
668
|
-
tradeFee: bigint;
|
|
678
|
+
export interface CollectRewardsQuote {
|
|
679
|
+
rewards: CollectRewardQuote[];
|
|
669
680
|
}
|
|
670
681
|
|
|
671
682
|
export interface WhirlpoolRewardInfoFacade {
|
|
@@ -686,35 +697,24 @@ export interface WhirlpoolFacade {
|
|
|
686
697
|
rewardInfos: WhirlpoolRewardInfoFacade[];
|
|
687
698
|
}
|
|
688
699
|
|
|
689
|
-
export interface
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
startTickIndex: number;
|
|
696
|
-
ticks: TickFacade[];
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
export interface TickFacade {
|
|
700
|
-
initialized: boolean;
|
|
701
|
-
liquidityNet: bigint;
|
|
702
|
-
liquidityGross: bigint;
|
|
703
|
-
feeGrowthOutsideA: bigint;
|
|
704
|
-
feeGrowthOutsideB: bigint;
|
|
705
|
-
rewardGrowthsOutside: bigint[];
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
export interface TickRange {
|
|
709
|
-
tickLowerIndex: number;
|
|
710
|
-
tickUpperIndex: number;
|
|
700
|
+
export interface IncreaseLiquidityQuote {
|
|
701
|
+
liquidityDelta: bigint;
|
|
702
|
+
tokenEstA: bigint;
|
|
703
|
+
tokenEstB: bigint;
|
|
704
|
+
tokenMaxA: bigint;
|
|
705
|
+
tokenMaxB: bigint;
|
|
711
706
|
}
|
|
712
707
|
|
|
713
|
-
export interface
|
|
714
|
-
|
|
708
|
+
export interface DecreaseLiquidityQuote {
|
|
709
|
+
liquidityDelta: bigint;
|
|
710
|
+
tokenEstA: bigint;
|
|
711
|
+
tokenEstB: bigint;
|
|
712
|
+
tokenMinA: bigint;
|
|
713
|
+
tokenMinB: bigint;
|
|
715
714
|
}
|
|
716
715
|
|
|
717
|
-
export interface
|
|
718
|
-
|
|
716
|
+
export interface CollectFeesQuote {
|
|
717
|
+
feeOwedA: bigint;
|
|
718
|
+
feeOwedB: bigint;
|
|
719
719
|
}
|
|
720
720
|
|