@orca-so/whirlpools-core 0.1.18 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1,70 @@
1
- # Orca Whirlpools Typescript Core
1
+ # Orca Whirlpools Core SDK (WebAssembly)
2
+ This package provides developers with advanced functionalities for interacting with the Whirlpool Program on Solana. Originally written in Rust, it has been compiled to WebAssembly (Wasm). This compilation makes the SDK accessible in JavaScript/TypeScript environments, offering developers the same core features and calculations for their Typescript projects. The SDK exposes convenient methods for math calculations, quotes, and other utilities, enabling seamless integration within web-based projects.
3
+
4
+ ## Key Features
5
+ - **Math Library**: Contains a variety of functions for math operations related to bundles, positions, prices, ticks, and tokens, including calculations such as determining position status or price conversions.
6
+ - **Quote Library**: Provides utility functions for generating quotes, such as increasing liquidity, collecting fees or rewards, and swapping, to help developers make informed decisions regarding liquidity management.
7
+
8
+ ## Installation
9
+ You can install the package via npm:
10
+ ```bash
11
+ npm install @orca-so/whirlpools-core
12
+ ```
13
+
14
+ ## Usage
15
+ Here are some basic examples of how to use the package:
16
+
17
+ ### Math Example
18
+ The following example demonstrates how to use the `isPositionInRange` function to determine whether a position is currently in range.
19
+
20
+ ```tsx
21
+ import { isPositionInRange } from "@orca-so/whirlpools-core";
22
+
23
+ const currentSqrtPrice = 7448043534253661173n;
24
+ const tickIndex1 = -18304;
25
+ const tickIndex2 = -17956;
26
+
27
+ const inRange = isPositionInRange(currentSqrtPrice, tickIndex1, tickIndex2);
28
+ console.log("Position in range:", inRange);
29
+ ```
30
+
31
+ Expected output:
32
+ ```
33
+ Position in range? true
34
+ ```
35
+
36
+ ### Quote Example
37
+ The following example demonstrates how to use the `increaseLiquidityQuoteA` function to calculate a quote for increasing liquidity given a token A amount.
38
+
39
+ ```tsx
40
+ import { increaseLiquidityQuoteA } from "@orca-so/whirlpools-core";
41
+
42
+ const tokenAmountA = 1000000000n;
43
+ const slippageToleranceBps = 100;
44
+ const currentSqrtPrice = 7437568627975669726n;
45
+ const tickIndex1 = -18568;
46
+ const tickIndex2 = -17668;
47
+ const transferFeeA = { feeBps: 200, maxFee: 1000000000n };
48
+
49
+ const quote = increaseLiquidityQuoteA(
50
+ tokenAmountA,
51
+ slippageToleranceBps,
52
+ currentSqrtPrice,
53
+ tickIndex1,
54
+ tickIndex2,
55
+ transferFeeA,
56
+ );
57
+
58
+ console.log(quote);
59
+ ```
60
+
61
+ Expected output:
62
+ ```
63
+ {
64
+ liquidityDelta: 16011047470n,
65
+ tokenEstA: 1000000000n,
66
+ tokenEstB: 127889169n,
67
+ tokenMaxA: 1010000000n,
68
+ tokenMaxB: 129168061n
69
+ }
70
+ ```
@@ -0,0 +1,70 @@
1
+ # Orca Whirlpools Core SDK (WebAssembly)
2
+ This package provides developers with advanced functionalities for interacting with the Whirlpool Program on Solana. Originally written in Rust, it has been compiled to WebAssembly (Wasm). This compilation makes the SDK accessible in JavaScript/TypeScript environments, offering developers the same core features and calculations for their Typescript projects. The SDK exposes convenient methods for math calculations, quotes, and other utilities, enabling seamless integration within web-based projects.
3
+
4
+ ## Key Features
5
+ - **Math Library**: Contains a variety of functions for math operations related to bundles, positions, prices, ticks, and tokens, including calculations such as determining position status or price conversions.
6
+ - **Quote Library**: Provides utility functions for generating quotes, such as increasing liquidity, collecting fees or rewards, and swapping, to help developers make informed decisions regarding liquidity management.
7
+
8
+ ## Installation
9
+ You can install the package via npm:
10
+ ```bash
11
+ npm install @orca-so/whirlpools-core
12
+ ```
13
+
14
+ ## Usage
15
+ Here are some basic examples of how to use the package:
16
+
17
+ ### Math Example
18
+ The following example demonstrates how to use the `isPositionInRange` function to determine whether a position is currently in range.
19
+
20
+ ```tsx
21
+ import { isPositionInRange } from "@orca-so/whirlpools-core";
22
+
23
+ const currentSqrtPrice = 7448043534253661173n;
24
+ const tickIndex1 = -18304;
25
+ const tickIndex2 = -17956;
26
+
27
+ const inRange = isPositionInRange(currentSqrtPrice, tickIndex1, tickIndex2);
28
+ console.log("Position in range:", inRange);
29
+ ```
30
+
31
+ Expected output:
32
+ ```
33
+ Position in range? true
34
+ ```
35
+
36
+ ### Quote Example
37
+ The following example demonstrates how to use the `increaseLiquidityQuoteA` function to calculate a quote for increasing liquidity given a token A amount.
38
+
39
+ ```tsx
40
+ import { increaseLiquidityQuoteA } from "@orca-so/whirlpools-core";
41
+
42
+ const tokenAmountA = 1000000000n;
43
+ const slippageToleranceBps = 100;
44
+ const currentSqrtPrice = 7437568627975669726n;
45
+ const tickIndex1 = -18568;
46
+ const tickIndex2 = -17668;
47
+ const transferFeeA = { feeBps: 200, maxFee: 1000000000n };
48
+
49
+ const quote = increaseLiquidityQuoteA(
50
+ tokenAmountA,
51
+ slippageToleranceBps,
52
+ currentSqrtPrice,
53
+ tickIndex1,
54
+ tickIndex2,
55
+ transferFeeA,
56
+ );
57
+
58
+ console.log(quote);
59
+ ```
60
+
61
+ Expected output:
62
+ ```
63
+ {
64
+ liquidityDelta: 16011047470n,
65
+ tokenEstA: 1000000000n,
66
+ tokenEstB: 127889169n,
67
+ tokenMaxA: 1010000000n,
68
+ tokenMaxB: 129168061n
69
+ }
70
+ ```
@@ -1,5 +1,154 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function _POSITION_BUNDLE_SIZE(): number;
4
+ export function _NUM_REWARDS(): number;
5
+ export function _FEE_RATE_DENOMINATOR(): number;
6
+ export function _TICK_ARRAY_SIZE(): number;
7
+ export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
8
+ export function _MIN_TICK_INDEX(): number;
9
+ export function _MAX_TICK_INDEX(): number;
10
+ /**
11
+ * Get the first unoccupied position in a bundle
12
+ *
13
+ * # Arguments
14
+ * * `bundle` - The bundle to check
15
+ *
16
+ * # Returns
17
+ * * `u32` - The first unoccupied position (None if full)
18
+ */
19
+ export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
20
+ /**
21
+ * Check whether a position bundle is full
22
+ * A position bundle can contain 256 positions
23
+ *
24
+ * # Arguments
25
+ * * `bundle` - The bundle to check
26
+ *
27
+ * # Returns
28
+ * * `bool` - Whether the bundle is full
29
+ */
30
+ export function isPositionBundleFull(bitmap: Uint8Array): boolean;
31
+ /**
32
+ * Check whether a position bundle is empty
33
+ *
34
+ * # Arguments
35
+ * * `bundle` - The bundle to check
36
+ *
37
+ * # Returns
38
+ * * `bool` - Whether the bundle is empty
39
+ */
40
+ export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
41
+ /**
42
+ * Check if a position is in range.
43
+ * When a position is in range it is earning fees and rewards
44
+ *
45
+ * # Parameters
46
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
47
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
48
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
49
+ *
50
+ * # Returns
51
+ * - A boolean value indicating if the position is in range
52
+ */
53
+ export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
54
+ /**
55
+ * Calculate the status of a position
56
+ * The status can be one of three values:
57
+ * - InRange: The position is in range
58
+ * - BelowRange: The position is below the range
59
+ * - AboveRange: The position is above the range
60
+ *
61
+ * # Parameters
62
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
63
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
64
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
65
+ *
66
+ * # Returns
67
+ * - A PositionStatus enum value indicating the status of the position
68
+ */
69
+ export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
70
+ /**
71
+ * Calculate the token_a / token_b ratio of a (ficticious) position
72
+ *
73
+ * # Parameters
74
+ * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
75
+ * - `tick_index_1` - A i32 integer representing the first tick index of the position
76
+ * - `tick_index_2` - A i32 integer representing the second tick index of the position
77
+ *
78
+ * # Returns
79
+ * - A PositionRatio struct containing the ratio of token_a and token_b
80
+ */
81
+ export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
82
+ /**
83
+ * Convert a price into a sqrt priceX64
84
+ * IMPORTANT: floating point operations can reduce the precision of the result.
85
+ * Make sure to do these operations last and not to use the result for further calculations.
86
+ *
87
+ * # Parameters
88
+ * * `price` - The price to convert
89
+ * * `decimals_a` - The number of decimals of the base token
90
+ * * `decimals_b` - The number of decimals of the quote token
91
+ *
92
+ * # Returns
93
+ * * `u128` - The sqrt priceX64
94
+ */
95
+ export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
96
+ /**
97
+ * Convert a sqrt priceX64 into a tick index
98
+ * IMPORTANT: floating point operations can reduce the precision of the result.
99
+ * Make sure to do these operations last and not to use the result for further calculations.
100
+ *
101
+ * # Parameters
102
+ * * `sqrt_price` - The sqrt priceX64 to convert
103
+ * * `decimals_a` - The number of decimals of the base token
104
+ * * `decimals_b` - The number of decimals of the quote token
105
+ *
106
+ * # Returns
107
+ * * `f64` - The decimal price
108
+ */
109
+ export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
110
+ /**
111
+ * Invert a price
112
+ * IMPORTANT: floating point operations can reduce the precision of the result.
113
+ * Make sure to do these operations last and not to use the result for further calculations.
114
+ *
115
+ * # Parameters
116
+ * * `price` - The price to invert
117
+ * * `decimals_a` - The number of decimals of the base token
118
+ * * `decimals_b` - The number of decimals of the quote token
119
+ *
120
+ * # Returns
121
+ * * `f64` - The inverted price
122
+ */
123
+ export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
124
+ /**
125
+ * Convert a tick index into a price
126
+ * IMPORTANT: floating point operations can reduce the precision of the result.
127
+ * Make sure to do these operations last and not to use the result for further calculations.
128
+ *
129
+ * # Parameters
130
+ * * `tick_index` - The tick index to convert
131
+ * * `decimals_a` - The number of decimals of the base token
132
+ * * `decimals_b` - The number of decimals of the quote token
133
+ *
134
+ * # Returns
135
+ * * `f64` - The decimal price
136
+ */
137
+ export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
138
+ /**
139
+ * Convert a price into a tick index
140
+ * IMPORTANT: floating point operations can reduce the precision of the result.
141
+ * Make sure to do these operations last and not to use the result for further calculations.
142
+ *
143
+ * # Parameters
144
+ * * `price` - The price to convert
145
+ * * `decimals_a` - The number of decimals of the base token
146
+ * * `decimals_b` - The number of decimals of the quote token
147
+ *
148
+ * # Returns
149
+ * * `i32` - The tick index
150
+ */
151
+ export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
3
152
  /**
4
153
  * Get the first tick index in the tick array that contains the specified tick index.
5
154
  *
@@ -159,24 +308,6 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
159
308
  * - A i32 integer representing the tick index in the tick array
160
309
  */
161
310
  export function getTickIndexInArray(tick_index: number, tick_array_start_index: number, tick_spacing: number): number;
162
- /**
163
- * Calculate rewards owed for a position
164
- *
165
- * # Paramters
166
- * - `whirlpool`: The whirlpool state
167
- * - `position`: The position state
168
- * - `tick_lower`: The lower tick state
169
- * - `tick_upper`: The upper tick state
170
- * - `current_timestamp`: The current timestamp
171
- * - `transfer_fee_1`: The transfer fee for token 1
172
- * - `transfer_fee_2`: The transfer fee for token 2
173
- * - `transfer_fee_3`: The transfer fee for token 3
174
- *
175
- * # Returns
176
- * - `CollectRewardsQuote`: The rewards owed for the 3 reward tokens.
177
- */
178
- 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;
179
- export function _POSITION_BUNDLE_SIZE(): number;
180
311
  export function _TICK_ARRAY_NOT_EVENLY_SPACED(): number;
181
312
  export function _TICK_INDEX_OUT_OF_BOUNDS(): number;
182
313
  export function _INVALID_TICK_INDEX(): number;
@@ -190,154 +321,6 @@ export function _ZERO_TRADABLE_AMOUNT(): number;
190
321
  export function _INVALID_TIMESTAMP(): number;
191
322
  export function _INVALID_TRANSFER_FEE(): number;
192
323
  export function _INVALID_SLIPPAGE_TOLERANCE(): number;
193
- export function _NUM_REWARDS(): number;
194
- export function _FEE_RATE_DENOMINATOR(): number;
195
- export function _TICK_ARRAY_SIZE(): number;
196
- export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
197
- export function _MIN_TICK_INDEX(): number;
198
- export function _MAX_TICK_INDEX(): number;
199
- /**
200
- * Get the first unoccupied position in a bundle
201
- *
202
- * # Arguments
203
- * * `bundle` - The bundle to check
204
- *
205
- * # Returns
206
- * * `u32` - The first unoccupied position (None if full)
207
- */
208
- export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
209
- /**
210
- * Check whether a position bundle is full
211
- * A position bundle can contain 256 positions
212
- *
213
- * # Arguments
214
- * * `bundle` - The bundle to check
215
- *
216
- * # Returns
217
- * * `bool` - Whether the bundle is full
218
- */
219
- export function isPositionBundleFull(bitmap: Uint8Array): boolean;
220
- /**
221
- * Check whether a position bundle is empty
222
- *
223
- * # Arguments
224
- * * `bundle` - The bundle to check
225
- *
226
- * # Returns
227
- * * `bool` - Whether the bundle is empty
228
- */
229
- export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
230
- /**
231
- * Check if a position is in range.
232
- * When a position is in range it is earning fees and rewards
233
- *
234
- * # Parameters
235
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
236
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
237
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
238
- *
239
- * # Returns
240
- * - A boolean value indicating if the position is in range
241
- */
242
- export function isPositionInRange(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): boolean;
243
- /**
244
- * Calculate the status of a position
245
- * The status can be one of three values:
246
- * - InRange: The position is in range
247
- * - BelowRange: The position is below the range
248
- * - AboveRange: The position is above the range
249
- *
250
- * # Parameters
251
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
252
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
253
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
254
- *
255
- * # Returns
256
- * - A PositionStatus enum value indicating the status of the position
257
- */
258
- export function positionStatus(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionStatus;
259
- /**
260
- * Calculate the token_a / token_b ratio of a (ficticious) position
261
- *
262
- * # Parameters
263
- * - `sqrt_price` - A u128 integer representing the sqrt price of the pool
264
- * - `tick_index_1` - A i32 integer representing the first tick index of the position
265
- * - `tick_index_2` - A i32 integer representing the second tick index of the position
266
- *
267
- * # Returns
268
- * - A PositionRatio struct containing the ratio of token_a and token_b
269
- */
270
- export function positionRatio(current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number): PositionRatio;
271
- /**
272
- * Convert a price into a sqrt priceX64
273
- * IMPORTANT: floating point operations can reduce the precision of the result.
274
- * Make sure to do these operations last and not to use the result for further calculations.
275
- *
276
- * # Parameters
277
- * * `price` - The price to convert
278
- * * `decimals_a` - The number of decimals of the base token
279
- * * `decimals_b` - The number of decimals of the quote token
280
- *
281
- * # Returns
282
- * * `u128` - The sqrt priceX64
283
- */
284
- export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
285
- /**
286
- * Convert a sqrt priceX64 into a tick index
287
- * IMPORTANT: floating point operations can reduce the precision of the result.
288
- * Make sure to do these operations last and not to use the result for further calculations.
289
- *
290
- * # Parameters
291
- * * `sqrt_price` - The sqrt priceX64 to convert
292
- * * `decimals_a` - The number of decimals of the base token
293
- * * `decimals_b` - The number of decimals of the quote token
294
- *
295
- * # Returns
296
- * * `f64` - The decimal price
297
- */
298
- export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
299
- /**
300
- * Invert a price
301
- * IMPORTANT: floating point operations can reduce the precision of the result.
302
- * Make sure to do these operations last and not to use the result for further calculations.
303
- *
304
- * # Parameters
305
- * * `price` - The price to invert
306
- * * `decimals_a` - The number of decimals of the base token
307
- * * `decimals_b` - The number of decimals of the quote token
308
- *
309
- * # Returns
310
- * * `f64` - The inverted price
311
- */
312
- export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
313
- /**
314
- * Convert a tick index into a price
315
- * IMPORTANT: floating point operations can reduce the precision of the result.
316
- * Make sure to do these operations last and not to use the result for further calculations.
317
- *
318
- * # Parameters
319
- * * `tick_index` - The tick index to convert
320
- * * `decimals_a` - The number of decimals of the base token
321
- * * `decimals_b` - The number of decimals of the quote token
322
- *
323
- * # Returns
324
- * * `f64` - The decimal price
325
- */
326
- export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
327
- /**
328
- * Convert a price into a tick index
329
- * IMPORTANT: floating point operations can reduce the precision of the result.
330
- * Make sure to do these operations last and not to use the result for further calculations.
331
- *
332
- * # Parameters
333
- * * `price` - The price to convert
334
- * * `decimals_a` - The number of decimals of the base token
335
- * * `decimals_b` - The number of decimals of the quote token
336
- *
337
- * # Returns
338
- * * `i32` - The tick index
339
- */
340
- export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
341
324
  /**
342
325
  * Calculate the amount A delta between two sqrt_prices
343
326
  *
@@ -609,6 +592,23 @@ export function increaseLiquidityQuoteA(token_amount_a: bigint, slippage_toleran
609
592
  * - An IncreaseLiquidityQuote struct containing the estimated token amounts
610
593
  */
611
594
  export function increaseLiquidityQuoteB(token_amount_b: bigint, slippage_tolerance_bps: number, current_sqrt_price: bigint, tick_index_1: number, tick_index_2: number, transfer_fee_a?: TransferFee, transfer_fee_b?: TransferFee): IncreaseLiquidityQuote;
595
+ /**
596
+ * Calculate rewards owed for a position
597
+ *
598
+ * # Paramters
599
+ * - `whirlpool`: The whirlpool state
600
+ * - `position`: The position state
601
+ * - `tick_lower`: The lower tick state
602
+ * - `tick_upper`: The upper tick state
603
+ * - `current_timestamp`: The current timestamp
604
+ * - `transfer_fee_1`: The transfer fee for token 1
605
+ * - `transfer_fee_2`: The transfer fee for token 2
606
+ * - `transfer_fee_3`: The transfer fee for token 3
607
+ *
608
+ * # Returns
609
+ * - `CollectRewardsQuote`: The rewards owed for the 3 reward tokens.
610
+ */
611
+ 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;
612
612
  export interface PositionRewardInfoFacade {
613
613
  growthInsideCheckpoint: bigint;
614
614
  amountOwed: bigint;
@@ -653,11 +653,6 @@ export interface CollectFeesQuote {
653
653
  feeOwedB: bigint;
654
654
  }
655
655
 
656
- export interface TransferFee {
657
- feeBps: number;
658
- maxFee: bigint;
659
- }
660
-
661
656
  export interface ExactOutSwapQuote {
662
657
  tokenOut: bigint;
663
658
  tokenEstIn: bigint;
@@ -672,6 +667,29 @@ export interface ExactInSwapQuote {
672
667
  tradeFee: bigint;
673
668
  }
674
669
 
670
+ export interface WhirlpoolRewardInfoFacade {
671
+ emissionsPerSecondX64: bigint;
672
+ growthGlobalX64: bigint;
673
+ }
674
+
675
+ export interface WhirlpoolFacade {
676
+ tickSpacing: number;
677
+ feeRate: number;
678
+ protocolFeeRate: number;
679
+ liquidity: bigint;
680
+ sqrtPrice: bigint;
681
+ tickCurrentIndex: number;
682
+ feeGrowthGlobalA: bigint;
683
+ feeGrowthGlobalB: bigint;
684
+ rewardLastUpdatedTimestamp: bigint;
685
+ rewardInfos: WhirlpoolRewardInfoFacade[];
686
+ }
687
+
688
+ export interface TransferFee {
689
+ feeBps: number;
690
+ maxFee: bigint;
691
+ }
692
+
675
693
  export interface TickArrayFacade {
676
694
  startTickIndex: number;
677
695
  ticks: TickFacade[];
@@ -699,117 +717,3 @@ export interface CollectRewardsQuote {
699
717
  rewards: CollectRewardQuote[];
700
718
  }
701
719
 
702
- export interface WhirlpoolRewardInfoFacade {
703
- emissionsPerSecondX64: bigint;
704
- growthGlobalX64: bigint;
705
- }
706
-
707
- export interface WhirlpoolFacade {
708
- tickSpacing: number;
709
- feeRate: number;
710
- protocolFeeRate: number;
711
- liquidity: bigint;
712
- sqrtPrice: bigint;
713
- tickCurrentIndex: number;
714
- feeGrowthGlobalA: bigint;
715
- feeGrowthGlobalB: bigint;
716
- rewardLastUpdatedTimestamp: bigint;
717
- rewardInfos: WhirlpoolRewardInfoFacade[];
718
- }
719
-
720
-
721
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
722
-
723
- export interface InitOutput {
724
- readonly memory: WebAssembly.Memory;
725
- readonly getTickArrayStartTickIndex: (a: number, b: number) => number;
726
- readonly tickIndexToSqrtPrice: (a: number) => number;
727
- readonly sqrtPriceToTickIndex: (a: number) => number;
728
- readonly getInitializableTickIndex: (a: number, b: number, c: number) => number;
729
- readonly getPrevInitializableTickIndex: (a: number, b: number) => number;
730
- readonly getNextInitializableTickIndex: (a: number, b: number) => number;
731
- readonly isTickIndexInBounds: (a: number) => number;
732
- readonly isTickInitializable: (a: number, b: number) => number;
733
- readonly invertTickIndex: (a: number) => number;
734
- readonly invertSqrtPrice: (a: number) => number;
735
- readonly getFullRangeTickIndexes: (a: number) => number;
736
- readonly orderTickIndexes: (a: number, b: number) => number;
737
- readonly isFullRangeOnly: (a: number) => number;
738
- readonly getTickIndexInArray: (a: number, b: number, c: number) => number;
739
- readonly collectRewardsQuote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
740
- readonly decreaseLiquidityQuote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
741
- readonly decreaseLiquidityQuoteA: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
742
- readonly decreaseLiquidityQuoteB: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
743
- readonly increaseLiquidityQuote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
744
- readonly increaseLiquidityQuoteA: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
745
- readonly increaseLiquidityQuoteB: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
746
- readonly tryGetAmountDeltaA: (a: number, b: number, c: number, d: number, e: number) => void;
747
- readonly tryGetAmountDeltaB: (a: number, b: number, c: number, d: number, e: number) => void;
748
- readonly tryGetNextSqrtPriceFromA: (a: number, b: number, c: number, d: number, e: number) => void;
749
- readonly tryGetNextSqrtPriceFromB: (a: number, b: number, c: number, d: number, e: number) => void;
750
- readonly tryApplyTransferFee: (a: number, b: number, c: number) => void;
751
- readonly tryReverseApplyTransferFee: (a: number, b: number, c: number) => void;
752
- readonly tryGetMaxAmountWithSlippageTolerance: (a: number, b: number, c: number) => void;
753
- readonly tryGetMinAmountWithSlippageTolerance: (a: number, b: number, c: number) => void;
754
- readonly tryApplySwapFee: (a: number, b: number, c: number) => void;
755
- readonly tryReverseApplySwapFee: (a: number, b: number, c: number) => void;
756
- readonly swapQuoteByInputToken: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
757
- readonly swapQuoteByOutputToken: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
758
- readonly _POSITION_BUNDLE_SIZE: () => number;
759
- readonly _TICK_ARRAY_NOT_EVENLY_SPACED: () => number;
760
- readonly _TICK_INDEX_OUT_OF_BOUNDS: () => number;
761
- readonly _INVALID_TICK_INDEX: () => number;
762
- readonly _ARITHMETIC_OVERFLOW: () => number;
763
- readonly _AMOUNT_EXCEEDS_MAX_U64: () => number;
764
- readonly _SQRT_PRICE_OUT_OF_BOUNDS: () => number;
765
- readonly _TICK_SEQUENCE_EMPTY: () => number;
766
- readonly _SQRT_PRICE_LIMIT_OUT_OF_BOUNDS: () => number;
767
- readonly _INVALID_SQRT_PRICE_LIMIT_DIRECTION: () => number;
768
- readonly _ZERO_TRADABLE_AMOUNT: () => number;
769
- readonly _INVALID_TIMESTAMP: () => number;
770
- readonly _INVALID_TRANSFER_FEE: () => number;
771
- readonly _INVALID_SLIPPAGE_TOLERANCE: () => number;
772
- readonly _NUM_REWARDS: () => number;
773
- readonly _FEE_RATE_DENOMINATOR: () => number;
774
- readonly _TICK_ARRAY_SIZE: () => number;
775
- readonly _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD: () => number;
776
- readonly _MIN_TICK_INDEX: () => number;
777
- readonly _MAX_TICK_INDEX: () => number;
778
- readonly firstUnoccupiedPositionInBundle: (a: number, b: number, c: number) => void;
779
- readonly isPositionBundleFull: (a: number, b: number) => number;
780
- readonly isPositionBundleEmpty: (a: number, b: number) => number;
781
- readonly isPositionInRange: (a: number, b: number, c: number) => number;
782
- readonly positionStatus: (a: number, b: number, c: number) => number;
783
- readonly positionRatio: (a: number, b: number, c: number) => number;
784
- readonly priceToSqrtPrice: (a: number, b: number, c: number) => number;
785
- readonly sqrtPriceToPrice: (a: number, b: number, c: number) => number;
786
- readonly invertPrice: (a: number, b: number, c: number) => number;
787
- readonly tickIndexToPrice: (a: number, b: number, c: number) => number;
788
- readonly priceToTickIndex: (a: number, b: number, c: number) => number;
789
- readonly collectFeesQuote: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
790
- readonly __wbindgen_malloc: (a: number, b: number) => number;
791
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
792
- readonly __wbindgen_exn_store: (a: number) => void;
793
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
794
- }
795
-
796
- export type SyncInitInput = BufferSource | WebAssembly.Module;
797
- /**
798
- * Instantiates the given `module`, which can either be bytes or
799
- * a precompiled `WebAssembly.Module`.
800
- *
801
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
802
- *
803
- * @returns {InitOutput}
804
- */
805
- export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
806
-
807
- /**
808
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
809
- * for everything else, calls `WebAssembly.instantiate` directly.
810
- *
811
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
812
- *
813
- * @returns {Promise<InitOutput>}
814
- */
815
- export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,5 @@
1
+ import * as wasm from "./orca_whirlpools_core_js_bindings_bg.wasm";
2
+ export * from "./orca_whirlpools_core_js_bindings_bg.js";
3
+ import { __wbg_set_wasm } from "./orca_whirlpools_core_js_bindings_bg.js";
4
+ __wbg_set_wasm(wasm);
5
+ wasm.__wbindgen_start();