@orca-so/whirlpools-core 1.0.3 → 1.0.4
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 +142 -142
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.js +180 -181
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.wasm +0 -0
- package/dist/browser/orca_whirlpools_core_js_bindings_bg.wasm.d.ts +3 -3
- package/dist/browser/package.json +1 -1
- package/dist/nodejs/orca_whirlpools_core_js_bindings.d.ts +142 -142
- package/dist/nodejs/orca_whirlpools_core_js_bindings.js +180 -181
- package/dist/nodejs/orca_whirlpools_core_js_bindings_bg.wasm +0 -0
- package/dist/nodejs/orca_whirlpools_core_js_bindings_bg.wasm.d.ts +3 -3
- package/dist/nodejs/package.json +1 -1
- package/package.json +6 -5
|
@@ -1,113 +1,5 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export function _NUM_REWARDS(): number;
|
|
4
|
-
export function _POSITION_BUNDLE_SIZE(): number;
|
|
5
|
-
export function _TICK_ARRAY_SIZE(): number;
|
|
6
|
-
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
|
|
7
|
-
export function _MIN_TICK_INDEX(): number;
|
|
8
|
-
export function _MAX_TICK_INDEX(): number;
|
|
9
|
-
/**
|
|
10
|
-
* Get the first unoccupied position in a bundle
|
|
11
|
-
*
|
|
12
|
-
* # Arguments
|
|
13
|
-
* * `bundle` - The bundle to check
|
|
14
|
-
*
|
|
15
|
-
* # Returns
|
|
16
|
-
* * `u32` - The first unoccupied position (None if full)
|
|
17
|
-
*/
|
|
18
|
-
export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Check whether a position bundle is full
|
|
21
|
-
* A position bundle can contain 256 positions
|
|
22
|
-
*
|
|
23
|
-
* # Arguments
|
|
24
|
-
* * `bundle` - The bundle to check
|
|
25
|
-
*
|
|
26
|
-
* # Returns
|
|
27
|
-
* * `bool` - Whether the bundle is full
|
|
28
|
-
*/
|
|
29
|
-
export function isPositionBundleFull(bitmap: Uint8Array): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Check whether a position bundle is empty
|
|
32
|
-
*
|
|
33
|
-
* # Arguments
|
|
34
|
-
* * `bundle` - The bundle to check
|
|
35
|
-
*
|
|
36
|
-
* # Returns
|
|
37
|
-
* * `bool` - Whether the bundle is empty
|
|
38
|
-
*/
|
|
39
|
-
export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Convert a price into a sqrt priceX64
|
|
42
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
43
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
44
|
-
*
|
|
45
|
-
* # Parameters
|
|
46
|
-
* * `price` - The price to convert
|
|
47
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
48
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
49
|
-
*
|
|
50
|
-
* # Returns
|
|
51
|
-
* * `u128` - The sqrt priceX64
|
|
52
|
-
*/
|
|
53
|
-
export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
|
|
54
|
-
/**
|
|
55
|
-
* Convert a sqrt priceX64 into a tick index
|
|
56
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
57
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
58
|
-
*
|
|
59
|
-
* # Parameters
|
|
60
|
-
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
61
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
62
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
63
|
-
*
|
|
64
|
-
* # Returns
|
|
65
|
-
* * `f64` - The decimal price
|
|
66
|
-
*/
|
|
67
|
-
export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
|
|
68
|
-
/**
|
|
69
|
-
* Invert a price
|
|
70
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
71
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
72
|
-
*
|
|
73
|
-
* # Parameters
|
|
74
|
-
* * `price` - The price to invert
|
|
75
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
76
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
77
|
-
*
|
|
78
|
-
* # Returns
|
|
79
|
-
* * `f64` - The inverted price
|
|
80
|
-
*/
|
|
81
|
-
export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
|
|
82
|
-
/**
|
|
83
|
-
* Convert a tick index into a price
|
|
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
|
-
* * `tick_index` - The tick index 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
|
-
* * `f64` - The decimal price
|
|
94
|
-
*/
|
|
95
|
-
export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
|
|
96
|
-
/**
|
|
97
|
-
* Convert a price 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
|
-
* * `price` - The price 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
|
-
* * `i32` - The tick index
|
|
108
|
-
*/
|
|
109
|
-
export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
|
|
110
|
-
export function _FEE_RATE_DENOMINATOR(): number;
|
|
111
3
|
/**
|
|
112
4
|
* Get the first tick index in the tick array that contains the specified tick index.
|
|
113
5
|
*
|
|
@@ -267,6 +159,114 @@ export function isFullRangeOnly(tick_spacing: number): boolean;
|
|
|
267
159
|
* - A u32 integer representing the tick index in the tick array
|
|
268
160
|
*/
|
|
269
161
|
export function getTickIndexInArray(tick_index: number, tick_array_start_index: number, tick_spacing: number): number;
|
|
162
|
+
export function _FEE_RATE_DENOMINATOR(): number;
|
|
163
|
+
export function _TICK_ARRAY_SIZE(): number;
|
|
164
|
+
export function _FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD(): number;
|
|
165
|
+
export function _MIN_TICK_INDEX(): number;
|
|
166
|
+
export function _MAX_TICK_INDEX(): number;
|
|
167
|
+
/**
|
|
168
|
+
* Get the first unoccupied position in a bundle
|
|
169
|
+
*
|
|
170
|
+
* # Arguments
|
|
171
|
+
* * `bundle` - The bundle to check
|
|
172
|
+
*
|
|
173
|
+
* # Returns
|
|
174
|
+
* * `u32` - The first unoccupied position (None if full)
|
|
175
|
+
*/
|
|
176
|
+
export function firstUnoccupiedPositionInBundle(bitmap: Uint8Array): number | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Check whether a position bundle is full
|
|
179
|
+
* A position bundle can contain 256 positions
|
|
180
|
+
*
|
|
181
|
+
* # Arguments
|
|
182
|
+
* * `bundle` - The bundle to check
|
|
183
|
+
*
|
|
184
|
+
* # Returns
|
|
185
|
+
* * `bool` - Whether the bundle is full
|
|
186
|
+
*/
|
|
187
|
+
export function isPositionBundleFull(bitmap: Uint8Array): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Check whether a position bundle is empty
|
|
190
|
+
*
|
|
191
|
+
* # Arguments
|
|
192
|
+
* * `bundle` - The bundle to check
|
|
193
|
+
*
|
|
194
|
+
* # Returns
|
|
195
|
+
* * `bool` - Whether the bundle is empty
|
|
196
|
+
*/
|
|
197
|
+
export function isPositionBundleEmpty(bitmap: Uint8Array): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Convert a price into a sqrt priceX64
|
|
200
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
201
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
202
|
+
*
|
|
203
|
+
* # Parameters
|
|
204
|
+
* * `price` - The price to convert
|
|
205
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
206
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
207
|
+
*
|
|
208
|
+
* # Returns
|
|
209
|
+
* * `u128` - The sqrt priceX64
|
|
210
|
+
*/
|
|
211
|
+
export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
|
|
212
|
+
/**
|
|
213
|
+
* Convert a sqrt priceX64 into a tick index
|
|
214
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
215
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
216
|
+
*
|
|
217
|
+
* # Parameters
|
|
218
|
+
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
219
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
220
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
221
|
+
*
|
|
222
|
+
* # Returns
|
|
223
|
+
* * `f64` - The decimal price
|
|
224
|
+
*/
|
|
225
|
+
export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
|
|
226
|
+
/**
|
|
227
|
+
* Invert a price
|
|
228
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
229
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
230
|
+
*
|
|
231
|
+
* # Parameters
|
|
232
|
+
* * `price` - The price to invert
|
|
233
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
234
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
235
|
+
*
|
|
236
|
+
* # Returns
|
|
237
|
+
* * `f64` - The inverted price
|
|
238
|
+
*/
|
|
239
|
+
export function invertPrice(price: number, decimals_a: number, decimals_b: number): number;
|
|
240
|
+
/**
|
|
241
|
+
* Convert a tick index into a price
|
|
242
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
243
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
244
|
+
*
|
|
245
|
+
* # Parameters
|
|
246
|
+
* * `tick_index` - The tick index to convert
|
|
247
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
248
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
249
|
+
*
|
|
250
|
+
* # Returns
|
|
251
|
+
* * `f64` - The decimal price
|
|
252
|
+
*/
|
|
253
|
+
export function tickIndexToPrice(tick_index: number, decimals_a: number, decimals_b: number): number;
|
|
254
|
+
/**
|
|
255
|
+
* Convert a price into a tick index
|
|
256
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
257
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
258
|
+
*
|
|
259
|
+
* # Parameters
|
|
260
|
+
* * `price` - The price to convert
|
|
261
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
262
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
263
|
+
*
|
|
264
|
+
* # Returns
|
|
265
|
+
* * `i32` - The tick index
|
|
266
|
+
*/
|
|
267
|
+
export function priceToTickIndex(price: number, decimals_a: number, decimals_b: number): number;
|
|
268
|
+
export function _NUM_REWARDS(): number;
|
|
269
|
+
export function _POSITION_BUNDLE_SIZE(): number;
|
|
270
270
|
export function _TICK_ARRAY_NOT_EVENLY_SPACED(): string;
|
|
271
271
|
export function _TICK_INDEX_OUT_OF_BOUNDS(): string;
|
|
272
272
|
export function _INVALID_TICK_INDEX(): string;
|
|
@@ -610,6 +610,40 @@ 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 | null, transfer_fee_2?: TransferFee | null, transfer_fee_3?: TransferFee | null): CollectRewardsQuote;
|
|
613
|
+
export interface TransferFee {
|
|
614
|
+
feeBps: number;
|
|
615
|
+
maxFee: bigint;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
export interface IncreaseLiquidityQuote {
|
|
619
|
+
liquidityDelta: bigint;
|
|
620
|
+
tokenEstA: bigint;
|
|
621
|
+
tokenEstB: bigint;
|
|
622
|
+
tokenMaxA: bigint;
|
|
623
|
+
tokenMaxB: bigint;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
export interface DecreaseLiquidityQuote {
|
|
627
|
+
liquidityDelta: bigint;
|
|
628
|
+
tokenEstA: bigint;
|
|
629
|
+
tokenEstB: bigint;
|
|
630
|
+
tokenMinA: bigint;
|
|
631
|
+
tokenMinB: bigint;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
export interface CollectFeesQuote {
|
|
635
|
+
feeOwedA: bigint;
|
|
636
|
+
feeOwedB: bigint;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export interface CollectRewardQuote {
|
|
640
|
+
rewardsOwed: bigint;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
export interface CollectRewardsQuote {
|
|
644
|
+
rewards: CollectRewardQuote[];
|
|
645
|
+
}
|
|
646
|
+
|
|
613
647
|
export interface TickArrayFacade {
|
|
614
648
|
startTickIndex: number;
|
|
615
649
|
ticks: TickFacade[];
|
|
@@ -661,40 +695,6 @@ export interface WhirlpoolFacade {
|
|
|
661
695
|
rewardInfos: WhirlpoolRewardInfoFacade[];
|
|
662
696
|
}
|
|
663
697
|
|
|
664
|
-
export interface TransferFee {
|
|
665
|
-
feeBps: number;
|
|
666
|
-
maxFee: bigint;
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
export interface IncreaseLiquidityQuote {
|
|
670
|
-
liquidityDelta: bigint;
|
|
671
|
-
tokenEstA: bigint;
|
|
672
|
-
tokenEstB: bigint;
|
|
673
|
-
tokenMaxA: bigint;
|
|
674
|
-
tokenMaxB: bigint;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
export interface DecreaseLiquidityQuote {
|
|
678
|
-
liquidityDelta: bigint;
|
|
679
|
-
tokenEstA: bigint;
|
|
680
|
-
tokenEstB: bigint;
|
|
681
|
-
tokenMinA: bigint;
|
|
682
|
-
tokenMinB: bigint;
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
export interface CollectFeesQuote {
|
|
686
|
-
feeOwedA: bigint;
|
|
687
|
-
feeOwedB: bigint;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
export interface CollectRewardQuote {
|
|
691
|
-
rewardsOwed: bigint;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
export interface CollectRewardsQuote {
|
|
695
|
-
rewards: CollectRewardQuote[];
|
|
696
|
-
}
|
|
697
|
-
|
|
698
698
|
export interface PositionRewardInfoFacade {
|
|
699
699
|
growthInsideCheckpoint: bigint;
|
|
700
700
|
amountOwed: bigint;
|
|
@@ -192,187 +192,6 @@ function getStringFromWasm0(ptr, len) {
|
|
|
192
192
|
ptr = ptr >>> 0;
|
|
193
193
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
194
194
|
}
|
|
195
|
-
|
|
196
|
-
module.exports._NUM_REWARDS = function() {
|
|
197
|
-
const ret = wasm._NUM_REWARDS();
|
|
198
|
-
return ret >>> 0;
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
module.exports._POSITION_BUNDLE_SIZE = function() {
|
|
202
|
-
const ret = wasm._POSITION_BUNDLE_SIZE();
|
|
203
|
-
return ret >>> 0;
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
module.exports._TICK_ARRAY_SIZE = function() {
|
|
207
|
-
const ret = wasm._TICK_ARRAY_SIZE();
|
|
208
|
-
return ret >>> 0;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
module.exports._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD = function() {
|
|
212
|
-
const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
|
|
213
|
-
return ret;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
module.exports._MIN_TICK_INDEX = function() {
|
|
217
|
-
const ret = wasm._MIN_TICK_INDEX();
|
|
218
|
-
return ret;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
module.exports._MAX_TICK_INDEX = function() {
|
|
222
|
-
const ret = wasm._MAX_TICK_INDEX();
|
|
223
|
-
return ret;
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
227
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
228
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
229
|
-
WASM_VECTOR_LEN = arg.length;
|
|
230
|
-
return ptr;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Get the first unoccupied position in a bundle
|
|
234
|
-
*
|
|
235
|
-
* # Arguments
|
|
236
|
-
* * `bundle` - The bundle to check
|
|
237
|
-
*
|
|
238
|
-
* # Returns
|
|
239
|
-
* * `u32` - The first unoccupied position (None if full)
|
|
240
|
-
*/
|
|
241
|
-
module.exports.firstUnoccupiedPositionInBundle = function(bitmap) {
|
|
242
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export_0);
|
|
243
|
-
const len0 = WASM_VECTOR_LEN;
|
|
244
|
-
const ret = wasm.firstUnoccupiedPositionInBundle(ptr0, len0);
|
|
245
|
-
return ret === 0x100000001 ? undefined : ret;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Check whether a position bundle is full
|
|
250
|
-
* A position bundle can contain 256 positions
|
|
251
|
-
*
|
|
252
|
-
* # Arguments
|
|
253
|
-
* * `bundle` - The bundle to check
|
|
254
|
-
*
|
|
255
|
-
* # Returns
|
|
256
|
-
* * `bool` - Whether the bundle is full
|
|
257
|
-
*/
|
|
258
|
-
module.exports.isPositionBundleFull = function(bitmap) {
|
|
259
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export_0);
|
|
260
|
-
const len0 = WASM_VECTOR_LEN;
|
|
261
|
-
const ret = wasm.isPositionBundleFull(ptr0, len0);
|
|
262
|
-
return ret !== 0;
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Check whether a position bundle is empty
|
|
267
|
-
*
|
|
268
|
-
* # Arguments
|
|
269
|
-
* * `bundle` - The bundle to check
|
|
270
|
-
*
|
|
271
|
-
* # Returns
|
|
272
|
-
* * `bool` - Whether the bundle is empty
|
|
273
|
-
*/
|
|
274
|
-
module.exports.isPositionBundleEmpty = function(bitmap) {
|
|
275
|
-
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export_0);
|
|
276
|
-
const len0 = WASM_VECTOR_LEN;
|
|
277
|
-
const ret = wasm.isPositionBundleEmpty(ptr0, len0);
|
|
278
|
-
return ret !== 0;
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Convert a price into a sqrt priceX64
|
|
283
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
284
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
285
|
-
*
|
|
286
|
-
* # Parameters
|
|
287
|
-
* * `price` - The price to convert
|
|
288
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
289
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
290
|
-
*
|
|
291
|
-
* # Returns
|
|
292
|
-
* * `u128` - The sqrt priceX64
|
|
293
|
-
*/
|
|
294
|
-
module.exports.priceToSqrtPrice = function(price, decimals_a, decimals_b) {
|
|
295
|
-
const ret = wasm.priceToSqrtPrice(price, decimals_a, decimals_b);
|
|
296
|
-
return takeObject(ret);
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Convert a sqrt priceX64 into a tick index
|
|
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
|
-
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
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 decimal price
|
|
311
|
-
*/
|
|
312
|
-
module.exports.sqrtPriceToPrice = function(sqrt_price, decimals_a, decimals_b) {
|
|
313
|
-
const ret = wasm.sqrtPriceToPrice(addHeapObject(sqrt_price), decimals_a, decimals_b);
|
|
314
|
-
return ret;
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Invert a price
|
|
319
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
320
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
321
|
-
*
|
|
322
|
-
* # Parameters
|
|
323
|
-
* * `price` - The price to invert
|
|
324
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
325
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
326
|
-
*
|
|
327
|
-
* # Returns
|
|
328
|
-
* * `f64` - The inverted price
|
|
329
|
-
*/
|
|
330
|
-
module.exports.invertPrice = function(price, decimals_a, decimals_b) {
|
|
331
|
-
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
332
|
-
return ret;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Convert a tick index into a price
|
|
337
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
338
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
339
|
-
*
|
|
340
|
-
* # Parameters
|
|
341
|
-
* * `tick_index` - The tick index to convert
|
|
342
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
343
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
344
|
-
*
|
|
345
|
-
* # Returns
|
|
346
|
-
* * `f64` - The decimal price
|
|
347
|
-
*/
|
|
348
|
-
module.exports.tickIndexToPrice = function(tick_index, decimals_a, decimals_b) {
|
|
349
|
-
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
350
|
-
return ret;
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Convert a price into a tick index
|
|
355
|
-
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
356
|
-
* Make sure to do these operations last and not to use the result for further calculations.
|
|
357
|
-
*
|
|
358
|
-
* # Parameters
|
|
359
|
-
* * `price` - The price to convert
|
|
360
|
-
* * `decimals_a` - The number of decimals of the base token
|
|
361
|
-
* * `decimals_b` - The number of decimals of the quote token
|
|
362
|
-
*
|
|
363
|
-
* # Returns
|
|
364
|
-
* * `i32` - The tick index
|
|
365
|
-
*/
|
|
366
|
-
module.exports.priceToTickIndex = function(price, decimals_a, decimals_b) {
|
|
367
|
-
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
368
|
-
return ret;
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
module.exports._FEE_RATE_DENOMINATOR = function() {
|
|
372
|
-
const ret = wasm._FEE_RATE_DENOMINATOR();
|
|
373
|
-
return ret >>> 0;
|
|
374
|
-
};
|
|
375
|
-
|
|
376
195
|
/**
|
|
377
196
|
* Get the first tick index in the tick array that contains the specified tick index.
|
|
378
197
|
*
|
|
@@ -599,6 +418,186 @@ module.exports.getTickIndexInArray = function(tick_index, tick_array_start_index
|
|
|
599
418
|
}
|
|
600
419
|
};
|
|
601
420
|
|
|
421
|
+
module.exports._FEE_RATE_DENOMINATOR = function() {
|
|
422
|
+
const ret = wasm._FEE_RATE_DENOMINATOR();
|
|
423
|
+
return ret >>> 0;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
module.exports._TICK_ARRAY_SIZE = function() {
|
|
427
|
+
const ret = wasm._TICK_ARRAY_SIZE();
|
|
428
|
+
return ret >>> 0;
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
module.exports._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD = function() {
|
|
432
|
+
const ret = wasm._FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD();
|
|
433
|
+
return ret;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
module.exports._MIN_TICK_INDEX = function() {
|
|
437
|
+
const ret = wasm._MIN_TICK_INDEX();
|
|
438
|
+
return ret;
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
module.exports._MAX_TICK_INDEX = function() {
|
|
442
|
+
const ret = wasm._MAX_TICK_INDEX();
|
|
443
|
+
return ret;
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
447
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
448
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
449
|
+
WASM_VECTOR_LEN = arg.length;
|
|
450
|
+
return ptr;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Get the first unoccupied position in a bundle
|
|
454
|
+
*
|
|
455
|
+
* # Arguments
|
|
456
|
+
* * `bundle` - The bundle to check
|
|
457
|
+
*
|
|
458
|
+
* # Returns
|
|
459
|
+
* * `u32` - The first unoccupied position (None if full)
|
|
460
|
+
*/
|
|
461
|
+
module.exports.firstUnoccupiedPositionInBundle = function(bitmap) {
|
|
462
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export_0);
|
|
463
|
+
const len0 = WASM_VECTOR_LEN;
|
|
464
|
+
const ret = wasm.firstUnoccupiedPositionInBundle(ptr0, len0);
|
|
465
|
+
return ret === 0x100000001 ? undefined : ret;
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Check whether a position bundle is full
|
|
470
|
+
* A position bundle can contain 256 positions
|
|
471
|
+
*
|
|
472
|
+
* # Arguments
|
|
473
|
+
* * `bundle` - The bundle to check
|
|
474
|
+
*
|
|
475
|
+
* # Returns
|
|
476
|
+
* * `bool` - Whether the bundle is full
|
|
477
|
+
*/
|
|
478
|
+
module.exports.isPositionBundleFull = function(bitmap) {
|
|
479
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export_0);
|
|
480
|
+
const len0 = WASM_VECTOR_LEN;
|
|
481
|
+
const ret = wasm.isPositionBundleFull(ptr0, len0);
|
|
482
|
+
return ret !== 0;
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Check whether a position bundle is empty
|
|
487
|
+
*
|
|
488
|
+
* # Arguments
|
|
489
|
+
* * `bundle` - The bundle to check
|
|
490
|
+
*
|
|
491
|
+
* # Returns
|
|
492
|
+
* * `bool` - Whether the bundle is empty
|
|
493
|
+
*/
|
|
494
|
+
module.exports.isPositionBundleEmpty = function(bitmap) {
|
|
495
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_export_0);
|
|
496
|
+
const len0 = WASM_VECTOR_LEN;
|
|
497
|
+
const ret = wasm.isPositionBundleEmpty(ptr0, len0);
|
|
498
|
+
return ret !== 0;
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Convert a price into a sqrt priceX64
|
|
503
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
504
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
505
|
+
*
|
|
506
|
+
* # Parameters
|
|
507
|
+
* * `price` - The price to convert
|
|
508
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
509
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
510
|
+
*
|
|
511
|
+
* # Returns
|
|
512
|
+
* * `u128` - The sqrt priceX64
|
|
513
|
+
*/
|
|
514
|
+
module.exports.priceToSqrtPrice = function(price, decimals_a, decimals_b) {
|
|
515
|
+
const ret = wasm.priceToSqrtPrice(price, decimals_a, decimals_b);
|
|
516
|
+
return takeObject(ret);
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Convert a sqrt priceX64 into a tick index
|
|
521
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
522
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
523
|
+
*
|
|
524
|
+
* # Parameters
|
|
525
|
+
* * `sqrt_price` - The sqrt priceX64 to convert
|
|
526
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
527
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
528
|
+
*
|
|
529
|
+
* # Returns
|
|
530
|
+
* * `f64` - The decimal price
|
|
531
|
+
*/
|
|
532
|
+
module.exports.sqrtPriceToPrice = function(sqrt_price, decimals_a, decimals_b) {
|
|
533
|
+
const ret = wasm.sqrtPriceToPrice(addHeapObject(sqrt_price), decimals_a, decimals_b);
|
|
534
|
+
return ret;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Invert a price
|
|
539
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
540
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
541
|
+
*
|
|
542
|
+
* # Parameters
|
|
543
|
+
* * `price` - The price to invert
|
|
544
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
545
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
546
|
+
*
|
|
547
|
+
* # Returns
|
|
548
|
+
* * `f64` - The inverted price
|
|
549
|
+
*/
|
|
550
|
+
module.exports.invertPrice = function(price, decimals_a, decimals_b) {
|
|
551
|
+
const ret = wasm.invertPrice(price, decimals_a, decimals_b);
|
|
552
|
+
return ret;
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Convert a tick index into a price
|
|
557
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
558
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
559
|
+
*
|
|
560
|
+
* # Parameters
|
|
561
|
+
* * `tick_index` - The tick index to convert
|
|
562
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
563
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
564
|
+
*
|
|
565
|
+
* # Returns
|
|
566
|
+
* * `f64` - The decimal price
|
|
567
|
+
*/
|
|
568
|
+
module.exports.tickIndexToPrice = function(tick_index, decimals_a, decimals_b) {
|
|
569
|
+
const ret = wasm.tickIndexToPrice(tick_index, decimals_a, decimals_b);
|
|
570
|
+
return ret;
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Convert a price into a tick index
|
|
575
|
+
* IMPORTANT: floating point operations can reduce the precision of the result.
|
|
576
|
+
* Make sure to do these operations last and not to use the result for further calculations.
|
|
577
|
+
*
|
|
578
|
+
* # Parameters
|
|
579
|
+
* * `price` - The price to convert
|
|
580
|
+
* * `decimals_a` - The number of decimals of the base token
|
|
581
|
+
* * `decimals_b` - The number of decimals of the quote token
|
|
582
|
+
*
|
|
583
|
+
* # Returns
|
|
584
|
+
* * `i32` - The tick index
|
|
585
|
+
*/
|
|
586
|
+
module.exports.priceToTickIndex = function(price, decimals_a, decimals_b) {
|
|
587
|
+
const ret = wasm.priceToTickIndex(price, decimals_a, decimals_b);
|
|
588
|
+
return ret;
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
module.exports._NUM_REWARDS = function() {
|
|
592
|
+
const ret = wasm._NUM_REWARDS();
|
|
593
|
+
return ret >>> 0;
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
module.exports._POSITION_BUNDLE_SIZE = function() {
|
|
597
|
+
const ret = wasm._POSITION_BUNDLE_SIZE();
|
|
598
|
+
return ret >>> 0;
|
|
599
|
+
};
|
|
600
|
+
|
|
602
601
|
module.exports._TICK_ARRAY_NOT_EVENLY_SPACED = function() {
|
|
603
602
|
try {
|
|
604
603
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
Binary file
|