@orca-so/whirlpools-core 0.3.3 → 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 +149 -149
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.js +307 -210
- 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 +149 -149
- package/dist/nodejs/orca_whirlpools_core_js_bindings.js +307 -210
- 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
|
*
|
|
@@ -624,27 +624,32 @@ export interface ExactInSwapQuote {
|
|
|
624
624
|
tradeFee: bigint;
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
-
export interface
|
|
628
|
-
|
|
629
|
-
|
|
627
|
+
export interface TransferFee {
|
|
628
|
+
feeBps: number;
|
|
629
|
+
maxFee: bigint;
|
|
630
630
|
}
|
|
631
631
|
|
|
632
|
-
export interface
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
632
|
+
export interface PositionRewardInfoFacade {
|
|
633
|
+
growthInsideCheckpoint: bigint;
|
|
634
|
+
amountOwed: bigint;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
export interface PositionFacade {
|
|
636
638
|
liquidity: bigint;
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
639
|
+
tickLowerIndex: number;
|
|
640
|
+
tickUpperIndex: number;
|
|
641
|
+
feeGrowthCheckpointA: bigint;
|
|
642
|
+
feeOwedA: bigint;
|
|
643
|
+
feeGrowthCheckpointB: bigint;
|
|
644
|
+
feeOwedB: bigint;
|
|
645
|
+
rewardInfos: PositionRewardInfoFacade[];
|
|
643
646
|
}
|
|
644
647
|
|
|
645
|
-
export
|
|
646
|
-
|
|
647
|
-
|
|
648
|
+
export type PositionStatus = "priceInRange" | "priceBelowRange" | "priceAboveRange" | "invalid";
|
|
649
|
+
|
|
650
|
+
export interface PositionRatio {
|
|
651
|
+
ratioA: number;
|
|
652
|
+
ratioB: number;
|
|
648
653
|
}
|
|
649
654
|
|
|
650
655
|
export interface TickArrayFacade {
|
|
@@ -674,27 +679,22 @@ export interface CollectRewardsQuote {
|
|
|
674
679
|
rewards: CollectRewardQuote[];
|
|
675
680
|
}
|
|
676
681
|
|
|
677
|
-
export interface
|
|
678
|
-
|
|
679
|
-
|
|
682
|
+
export interface WhirlpoolRewardInfoFacade {
|
|
683
|
+
emissionsPerSecondX64: bigint;
|
|
684
|
+
growthGlobalX64: bigint;
|
|
680
685
|
}
|
|
681
686
|
|
|
682
|
-
export interface
|
|
687
|
+
export interface WhirlpoolFacade {
|
|
688
|
+
tickSpacing: number;
|
|
689
|
+
feeRate: number;
|
|
690
|
+
protocolFeeRate: number;
|
|
683
691
|
liquidity: bigint;
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
rewardInfos: PositionRewardInfoFacade[];
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
export type PositionStatus = "priceInRange" | "priceBelowRange" | "priceAboveRange" | "invalid";
|
|
694
|
-
|
|
695
|
-
export interface PositionRatio {
|
|
696
|
-
ratioA: number;
|
|
697
|
-
ratioB: number;
|
|
692
|
+
sqrtPrice: bigint;
|
|
693
|
+
tickCurrentIndex: number;
|
|
694
|
+
feeGrowthGlobalA: bigint;
|
|
695
|
+
feeGrowthGlobalB: bigint;
|
|
696
|
+
rewardLastUpdatedTimestamp: bigint;
|
|
697
|
+
rewardInfos: WhirlpoolRewardInfoFacade[];
|
|
698
698
|
}
|
|
699
699
|
|
|
700
700
|
export interface IncreaseLiquidityQuote {
|