@sun-protocol/sun-sdk-sunswap-v3 0.1.0-beta.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.
@@ -0,0 +1,1236 @@
1
+ import { BigintIsh, Token, Price, CurrencyAmount, Percent, Currency, TradeType, Network, TronAddress, ContractCallAction, NativeCurrency, ContractParameter } from '@sun-protocol/sun-sdk-core';
2
+ import JSBI from 'jsbi';
3
+ import { Interface } from '@ethersproject/abi';
4
+ import { BytesLike } from '@ethersproject/bytes';
5
+
6
+ declare const IS_TVM = true;
7
+ declare const FACTORY_ADDRESS = "0xc2708485c99cd8cf058de1a9a7e3c2d8261a995c";
8
+ declare const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
9
+ declare const POOL_INIT_CODE_HASH = "0xba928a717d71946d75999ef1adef801a79cd34a20efecea8b2876b85f5f49580";
10
+ /**
11
+ * SunSwap V3 factory-enabled fee amounts, denominated in hundredths of bips.
12
+ *
13
+ * Migrated from `@sunio/sun-sdk@1.0.9`.
14
+ */
15
+ declare enum FeeAmount {
16
+ LOWEST = 100,
17
+ LOW = 500,
18
+ MEDIUM = 3000,
19
+ HIGH = 10000
20
+ }
21
+ /**
22
+ * Default tick spacing for each supported fee amount.
23
+ */
24
+ declare const TICK_SPACINGS: Record<FeeAmount, number>;
25
+
26
+ interface TickConstructorArgs {
27
+ index: number;
28
+ liquidityGross: BigintIsh;
29
+ liquidityNet: BigintIsh;
30
+ }
31
+ declare class Tick {
32
+ readonly index: number;
33
+ readonly liquidityGross: JSBI;
34
+ readonly liquidityNet: JSBI;
35
+ constructor({ index, liquidityGross, liquidityNet }: TickConstructorArgs);
36
+ }
37
+
38
+ /**
39
+ * Provides information about ticks
40
+ */
41
+ interface TickDataProvider {
42
+ /**
43
+ * Return information corresponding to a specific tick
44
+ * @param tick the tick to load
45
+ */
46
+ getTick(tick: number): Promise<{
47
+ liquidityNet: BigintIsh;
48
+ }>;
49
+ /**
50
+ * Return the next tick that is initialized within a single word
51
+ * @param tick The current tick
52
+ * @param lte Whether the next tick should be lte the current tick
53
+ * @param tickSpacing The tick spacing of the pool
54
+ */
55
+ nextInitializedTickWithinOneWord(tick: number, lte: boolean, tickSpacing: number): Promise<[number, boolean]>;
56
+ }
57
+ /**
58
+ * This tick data provider does not know how to fetch any tick data. It throws whenever it is required. Useful if you
59
+ * do not need to load tick data for your use case.
60
+ */
61
+ declare class NoTickDataProvider implements TickDataProvider {
62
+ private static ERROR_MESSAGE;
63
+ getTick(_tick: number): Promise<{
64
+ liquidityNet: BigintIsh;
65
+ }>;
66
+ nextInitializedTickWithinOneWord(_tick: number, _lte: boolean, _tickSpacing: number): Promise<[number, boolean]>;
67
+ }
68
+
69
+ interface PoolConstructorArgs {
70
+ readonly tokenA: Token;
71
+ readonly tokenB: Token;
72
+ readonly fee: FeeAmount;
73
+ readonly sqrtRatioX96: BigintIsh;
74
+ readonly liquidity: BigintIsh;
75
+ readonly tickCurrent: number;
76
+ readonly ticks?: TickDataProvider | (Tick | TickConstructorArgs)[];
77
+ readonly isV4?: boolean;
78
+ readonly tickSpacing?: number;
79
+ }
80
+ /**
81
+ * Represents a V3 pool
82
+ */
83
+ declare class Pool {
84
+ readonly token0: Token;
85
+ readonly token1: Token;
86
+ readonly fee: FeeAmount;
87
+ readonly sqrtRatioX96: JSBI;
88
+ readonly liquidity: JSBI;
89
+ readonly tickCurrent: number;
90
+ readonly tickDataProvider: TickDataProvider;
91
+ readonly _tickSpacing: number | undefined;
92
+ readonly isV4: undefined | boolean;
93
+ private _token0Price?;
94
+ private _token1Price?;
95
+ static getAddress(tokenA: Token, tokenB: Token, fee: FeeAmount, initCodeHashManualOverride?: string, factoryAddressOverride?: string): string;
96
+ /**
97
+ * Construct a pool
98
+ * @param tokenA One of the tokens in the pool
99
+ * @param tokenB The other token in the pool
100
+ * @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool
101
+ * @param sqrtRatioX96 The sqrt of the current ratio of amounts of token1 to token0
102
+ * @param liquidity The current value of in range liquidity
103
+ * @param tickCurrent The current tick of the pool
104
+ * @param ticks The current state of the pool ticks or a data provider that can return tick data
105
+ * @param isV4 v3 or v4
106
+ * @param tickSpacing number
107
+ */
108
+ constructor(args: PoolConstructorArgs);
109
+ constructor(tokenA: Token, tokenB: Token, fee: FeeAmount, sqrtRatioX96: BigintIsh, liquidity: BigintIsh, tickCurrent: number, ticks?: TickDataProvider | (Tick | TickConstructorArgs)[], isV4?: boolean, tickSpacing?: number);
110
+ /**
111
+ * Returns true if the token is either token0 or token1
112
+ * @param token The token to check
113
+ * @returns True if token is either token0 or token
114
+ */
115
+ involvesToken(token: Token): boolean;
116
+ /**
117
+ * Returns the current mid price of the pool in terms of token0, i.e. the ratio of token1 over token0
118
+ */
119
+ get token0Price(): Price<Token, Token>;
120
+ /**
121
+ * Returns the current mid price of the pool in terms of token1, i.e. the ratio of token0 over token1
122
+ */
123
+ get token1Price(): Price<Token, Token>;
124
+ /**
125
+ * Return the price of the given token in terms of the other token in the pool.
126
+ * @param token The token to return price of
127
+ * @returns The price of the given token, in terms of the other.
128
+ */
129
+ priceOf(token: Token): Price<Token, Token>;
130
+ /**
131
+ * Returns the chain ID of the tokens in the pool.
132
+ */
133
+ get chainId(): number;
134
+ /**
135
+ * Given an input amount of a token, return the computed output amount, and a pool with state updated after the trade
136
+ * @param inputAmount The input amount for which to quote the output amount
137
+ * @param sqrtPriceLimitX96 The Q64.96 sqrt price limit
138
+ * @returns The output amount and the pool with updated state
139
+ */
140
+ getOutputAmount(inputAmount: CurrencyAmount<Token>, sqrtPriceLimitX96?: JSBI): Promise<[CurrencyAmount<Token>, Pool]>;
141
+ /**
142
+ * Given a desired output amount of a token, return the computed input amount and a pool with state updated after the trade
143
+ * @param outputAmount the output amount for which to quote the input amount
144
+ * @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap
145
+ * @returns The input amount and the pool with updated state
146
+ */
147
+ getInputAmount(outputAmount: CurrencyAmount<Token>, sqrtPriceLimitX96?: JSBI): Promise<[CurrencyAmount<Token>, Pool]>;
148
+ /**
149
+ * Executes a swap
150
+ * @param zeroForOne Whether the amount in is token0 or token1
151
+ * @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
152
+ * @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap
153
+ * @returns amountCalculated
154
+ * @returns sqrtRatioX96
155
+ * @returns liquidity
156
+ * @returns tickCurrent
157
+ */
158
+ private swap;
159
+ get tickSpacing(): number;
160
+ }
161
+
162
+ interface PositionConstructorArgs {
163
+ pool: Pool;
164
+ tickLower: number;
165
+ tickUpper: number;
166
+ liquidity: BigintIsh;
167
+ }
168
+ /**
169
+ * Represents a position on a Uniswap V3 Pool
170
+ */
171
+ declare class Position {
172
+ readonly pool: Pool;
173
+ readonly tickLower: number;
174
+ readonly tickUpper: number;
175
+ readonly liquidity: JSBI;
176
+ private _token0Amount;
177
+ private _token1Amount;
178
+ private _mintAmounts;
179
+ /**
180
+ * Constructs a position for a given pool with the given liquidity
181
+ * @param pool For which pool the liquidity is assigned
182
+ * @param liquidity The amount of liquidity that is in the position
183
+ * @param tickLower The lower tick of the position
184
+ * @param tickUpper The upper tick of the position
185
+ */
186
+ constructor({ pool, liquidity, tickLower, tickUpper }: PositionConstructorArgs);
187
+ /**
188
+ * Returns the price of token0 at the lower tick
189
+ */
190
+ get token0PriceLower(): Price<Token, Token>;
191
+ /**
192
+ * Returns the price of token0 at the upper tick
193
+ */
194
+ get token0PriceUpper(): Price<Token, Token>;
195
+ /**
196
+ * Returns the amount of token0 that this position's liquidity could be burned for at the current pool price
197
+ */
198
+ get amount0(): CurrencyAmount<Token>;
199
+ /**
200
+ * Returns the amount of token1 that this position's liquidity could be burned for at the current pool price
201
+ */
202
+ get amount1(): CurrencyAmount<Token>;
203
+ /**
204
+ * Returns the lower and upper sqrt ratios if the price 'slips' up to slippage tolerance percentage
205
+ * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
206
+ * @returns The sqrt ratios after slippage
207
+ */
208
+ private ratiosAfterSlippage;
209
+ /**
210
+ * Returns the minimum amounts that must be sent in order to safely mint the amount of liquidity held by the position
211
+ * with the given slippage tolerance
212
+ * @param slippageTolerance Tolerance of unfavorable slippage from the current price
213
+ * @returns The amounts, with slippage
214
+ */
215
+ mintAmountsWithSlippage(slippageTolerance: Percent): Readonly<{
216
+ amount0: JSBI;
217
+ amount1: JSBI;
218
+ }>;
219
+ /**
220
+ * Returns the minimum amounts that should be requested in order to safely burn the amount of liquidity held by the
221
+ * position with the given slippage tolerance
222
+ * @param slippageTolerance tolerance of unfavorable slippage from the current price
223
+ * @returns The amounts, with slippage
224
+ */
225
+ burnAmountsWithSlippage(slippageTolerance: Percent): Readonly<{
226
+ amount0: JSBI;
227
+ amount1: JSBI;
228
+ }>;
229
+ /**
230
+ * Returns the minimum amounts that must be sent in order to mint the amount of liquidity held by the position at
231
+ * the current price for the pool
232
+ */
233
+ get mintAmounts(): Readonly<{
234
+ amount0: JSBI;
235
+ amount1: JSBI;
236
+ }>;
237
+ /**
238
+ * Computes the maximum amount of liquidity received for a given amount of token0, token1,
239
+ * and the prices at the tick boundaries.
240
+ * @param pool The pool for which the position should be created
241
+ * @param tickLower The lower tick of the position
242
+ * @param tickUpper The upper tick of the position
243
+ * @param amount0 token0 amount
244
+ * @param amount1 token1 amount
245
+ * @param useFullPrecision If false, liquidity will be maximized according to what the router can calculate,
246
+ * not what core can theoretically support
247
+ * @returns The amount of liquidity for the position
248
+ */
249
+ static fromAmounts({ pool, tickLower, tickUpper, amount0, amount1, useFullPrecision }: {
250
+ pool: Pool;
251
+ tickLower: number;
252
+ tickUpper: number;
253
+ amount0: BigintIsh;
254
+ amount1: BigintIsh;
255
+ useFullPrecision: boolean;
256
+ }): Position;
257
+ /**
258
+ * Computes a position with the maximum amount of liquidity received for a given amount of token0, assuming an unlimited amount of token1
259
+ * @param pool The pool for which the position is created
260
+ * @param tickLower The lower tick
261
+ * @param tickUpper The upper tick
262
+ * @param amount0 The desired amount of token0
263
+ * @param useFullPrecision If true, liquidity will be maximized according to what the router can calculate,
264
+ * not what core can theoretically support
265
+ * @returns The position
266
+ */
267
+ static fromAmount0({ pool, tickLower, tickUpper, amount0, useFullPrecision }: {
268
+ pool: Pool;
269
+ tickLower: number;
270
+ tickUpper: number;
271
+ amount0: BigintIsh;
272
+ useFullPrecision: boolean;
273
+ }): Position;
274
+ /**
275
+ * Computes a position with the maximum amount of liquidity received for a given amount of token1, assuming an unlimited amount of token0
276
+ * @param pool The pool for which the position is created
277
+ * @param tickLower The lower tick
278
+ * @param tickUpper The upper tick
279
+ * @param amount1 The desired amount of token1
280
+ * @returns The position
281
+ */
282
+ static fromAmount1({ pool, tickLower, tickUpper, amount1 }: {
283
+ pool: Pool;
284
+ tickLower: number;
285
+ tickUpper: number;
286
+ amount1: BigintIsh;
287
+ }): Position;
288
+ }
289
+
290
+ /**
291
+ * Represents a list of pools through which a swap can occur
292
+ * @template TInput The input token
293
+ * @template TOutput The output token
294
+ */
295
+ declare class Route<TInput extends Currency, TOutput extends Currency> {
296
+ readonly pools: Pool[];
297
+ readonly tokenPath: Token[];
298
+ readonly input: TInput;
299
+ readonly output: TOutput;
300
+ private _midPrice;
301
+ /**
302
+ * Creates an instance of route.
303
+ * @param pools An array of `Pool` objects, ordered by the route the swap will take
304
+ * @param input The input token
305
+ * @param output The output token
306
+ */
307
+ constructor(pools: Pool[], input: TInput, output: TOutput);
308
+ get chainId(): number;
309
+ /**
310
+ * Returns the mid price of the route
311
+ */
312
+ get midPrice(): Price<TInput, TOutput>;
313
+ }
314
+
315
+ /**
316
+ * A data provider for ticks that is backed by an in-memory array of ticks.
317
+ */
318
+ declare class TickListDataProvider implements TickDataProvider {
319
+ private ticks;
320
+ constructor(ticks: (Tick | TickConstructorArgs)[], tickSpacing: number);
321
+ getTick(tick: number): Promise<{
322
+ liquidityNet: BigintIsh;
323
+ liquidityGross: BigintIsh;
324
+ }>;
325
+ nextInitializedTickWithinOneWord(tick: number, lte: boolean, tickSpacing: number): Promise<[number, boolean]>;
326
+ }
327
+
328
+ /**
329
+ * Trades comparator, an extension of the input output comparator that also considers other dimensions of the trade in ranking them
330
+ * @template TInput The input token, either Ether or an ERC-20
331
+ * @template TOutput The output token, either Ether or an ERC-20
332
+ * @template TTradeType The trade type, either exact input or exact output
333
+ * @param a The first trade to compare
334
+ * @param b The second trade to compare
335
+ * @returns A sorted ordering for two neighboring elements in a trade array
336
+ */
337
+ declare function tradeComparator<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(a: Trade<TInput, TOutput, TTradeType>, b: Trade<TInput, TOutput, TTradeType>): number;
338
+ interface BestTradeOptions {
339
+ maxNumResults?: number;
340
+ maxHops?: number;
341
+ }
342
+ /**
343
+ * Represents a trade executed against a set of routes where some percentage of the input is
344
+ * split across each route.
345
+ *
346
+ * Each route has its own set of pools. Pools can not be re-used across routes.
347
+ *
348
+ * Does not account for slippage, i.e., changes in price environment that can occur between
349
+ * the time the trade is submitted and when it is executed.
350
+ * @template TInput The input token, either Ether or an ERC-20
351
+ * @template TOutput The output token, either Ether or an ERC-20
352
+ * @template TTradeType The trade type, either exact input or exact output
353
+ */
354
+ declare class Trade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {
355
+ /**
356
+ * @deprecated Deprecated in favor of 'swaps' property. If the trade consists of multiple routes
357
+ * this will return an error.
358
+ *
359
+ * When the trade consists of just a single route, this returns the route of the trade,
360
+ * i.e. which pools the trade goes through.
361
+ */
362
+ get route(): Route<TInput, TOutput>;
363
+ /**
364
+ * The swaps of the trade, i.e. which routes and how much is swapped in each that
365
+ * make up the trade.
366
+ */
367
+ readonly swaps: {
368
+ route: Route<TInput, TOutput>;
369
+ inputAmount: CurrencyAmount<TInput>;
370
+ outputAmount: CurrencyAmount<TOutput>;
371
+ }[];
372
+ /**
373
+ * The type of the trade, either exact in or exact out.
374
+ */
375
+ readonly tradeType: TTradeType;
376
+ /**
377
+ * The cached result of the input amount computation
378
+ * @private
379
+ */
380
+ private _inputAmount;
381
+ /**
382
+ * The input amount for the trade assuming no slippage.
383
+ */
384
+ get inputAmount(): CurrencyAmount<TInput>;
385
+ /**
386
+ * The cached result of the output amount computation
387
+ * @private
388
+ */
389
+ private _outputAmount;
390
+ /**
391
+ * The output amount for the trade assuming no slippage.
392
+ */
393
+ get outputAmount(): CurrencyAmount<TOutput>;
394
+ /**
395
+ * The cached result of the computed execution price
396
+ * @private
397
+ */
398
+ private _executionPrice;
399
+ /**
400
+ * The price expressed in terms of output amount/input amount.
401
+ */
402
+ get executionPrice(): Price<TInput, TOutput>;
403
+ /**
404
+ * The cached result of the price impact computation
405
+ * @private
406
+ */
407
+ private _priceImpact;
408
+ /**
409
+ * Returns the percent difference between the route's mid price and the price impact
410
+ */
411
+ get priceImpact(): Percent;
412
+ /**
413
+ * Constructs an exact in trade with the given amount in and route
414
+ * @template TInput The input token, either Ether or an ERC-20
415
+ * @template TOutput The output token, either Ether or an ERC-20
416
+ * @param route The route of the exact in trade
417
+ * @param amountIn The amount being passed in
418
+ * @returns The exact in trade
419
+ */
420
+ static exactIn<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountIn: CurrencyAmount<TInput>): Promise<Trade<TInput, TOutput, TradeType.EXACT_INPUT>>;
421
+ /**
422
+ * Constructs an exact out trade with the given amount out and route
423
+ * @template TInput The input token, either Ether or an ERC-20
424
+ * @template TOutput The output token, either Ether or an ERC-20
425
+ * @param route The route of the exact out trade
426
+ * @param amountOut The amount returned by the trade
427
+ * @returns The exact out trade
428
+ */
429
+ static exactOut<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountOut: CurrencyAmount<TOutput>): Promise<Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>>;
430
+ /**
431
+ * Constructs a trade by simulating swaps through the given route
432
+ * @template TInput The input token, either Ether or an ERC-20.
433
+ * @template TOutput The output token, either Ether or an ERC-20.
434
+ * @template TTradeType The type of the trade, either exact in or exact out.
435
+ * @param route route to swap through
436
+ * @param amount the amount specified, either input or output, depending on tradeType
437
+ * @param tradeType whether the trade is an exact input or exact output swap
438
+ * @returns The route
439
+ */
440
+ static fromRoute<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(route: Route<TInput, TOutput>, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>, tradeType: TTradeType): Promise<Trade<TInput, TOutput, TTradeType>>;
441
+ /**
442
+ * Constructs a trade from routes by simulating swaps
443
+ *
444
+ * @template TInput The input token, either Ether or an ERC-20.
445
+ * @template TOutput The output token, either Ether or an ERC-20.
446
+ * @template TTradeType The type of the trade, either exact in or exact out.
447
+ * @param routes the routes to swap through and how much of the amount should be routed through each
448
+ * @param tradeType whether the trade is an exact input or exact output swap
449
+ * @returns The trade
450
+ */
451
+ static fromRoutes<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(routes: {
452
+ amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
453
+ route: Route<TInput, TOutput>;
454
+ }[], tradeType: TTradeType): Promise<Trade<TInput, TOutput, TTradeType>>;
455
+ /**
456
+ * Creates a trade without computing the result of swapping through the route. Useful when you have simulated the trade
457
+ * elsewhere and do not have any tick data
458
+ * @template TInput The input token, either Ether or an ERC-20
459
+ * @template TOutput The output token, either Ether or an ERC-20
460
+ * @template TTradeType The type of the trade, either exact in or exact out
461
+ * @param constructorArguments The arguments passed to the trade constructor
462
+ * @returns The unchecked trade
463
+ */
464
+ static createUncheckedTrade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(constructorArguments: {
465
+ route: Route<TInput, TOutput>;
466
+ inputAmount: CurrencyAmount<TInput>;
467
+ outputAmount: CurrencyAmount<TOutput>;
468
+ tradeType: TTradeType;
469
+ }): Trade<TInput, TOutput, TTradeType>;
470
+ /**
471
+ * Creates a trade without computing the result of swapping through the routes. Useful when you have simulated the trade
472
+ * elsewhere and do not have any tick data
473
+ * @template TInput The input token, either Ether or an ERC-20
474
+ * @template TOutput The output token, either Ether or an ERC-20
475
+ * @template TTradeType The type of the trade, either exact in or exact out
476
+ * @param constructorArguments The arguments passed to the trade constructor
477
+ * @returns The unchecked trade
478
+ */
479
+ static createUncheckedTradeWithMultipleRoutes<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(constructorArguments: {
480
+ routes: {
481
+ route: Route<TInput, TOutput>;
482
+ inputAmount: CurrencyAmount<TInput>;
483
+ outputAmount: CurrencyAmount<TOutput>;
484
+ }[];
485
+ tradeType: TTradeType;
486
+ }): Trade<TInput, TOutput, TTradeType>;
487
+ /**
488
+ * Construct a trade by passing in the pre-computed property values
489
+ * @param routes The routes through which the trade occurs
490
+ * @param tradeType The type of trade, exact input or exact output
491
+ */
492
+ private constructor();
493
+ /**
494
+ * Get the minimum amount that must be received from this trade for the given slippage tolerance
495
+ * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
496
+ * @returns The amount out
497
+ */
498
+ minimumAmountOut(slippageTolerance: Percent, amountOut?: CurrencyAmount<TOutput>): CurrencyAmount<TOutput>;
499
+ /**
500
+ * Get the maximum amount in that can be spent via this trade for the given slippage tolerance
501
+ * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
502
+ * @returns The amount in
503
+ */
504
+ maximumAmountIn(slippageTolerance: Percent, amountIn?: CurrencyAmount<TInput>): CurrencyAmount<TInput>;
505
+ /**
506
+ * Return the execution price after accounting for slippage tolerance
507
+ * @param slippageTolerance the allowed tolerated slippage
508
+ * @returns The execution price
509
+ */
510
+ worstExecutionPrice(slippageTolerance: Percent): Price<TInput, TOutput>;
511
+ /**
512
+ * Given a list of pools, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
513
+ * amount to an output token, making at most `maxHops` hops.
514
+ * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
515
+ * the amount in among multiple routes.
516
+ * @param pools the pools to consider in finding the best trade
517
+ * @param nextAmountIn exact amount of input currency to spend
518
+ * @param currencyOut the desired currency out
519
+ * @param maxNumResults maximum number of results to return
520
+ * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool
521
+ * @param currentPools used in recursion; the current list of pools
522
+ * @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
523
+ * @param bestTrades used in recursion; the current list of best trades
524
+ * @returns The exact in trade
525
+ */
526
+ static bestTradeExactIn<TInput extends Currency, TOutput extends Currency>(pools: Pool[], currencyAmountIn: CurrencyAmount<TInput>, currencyOut: TOutput, { maxNumResults, maxHops }?: BestTradeOptions, currentPools?: Pool[], nextAmountIn?: CurrencyAmount<Currency>, bestTrades?: Trade<TInput, TOutput, TradeType.EXACT_INPUT>[]): Promise<Trade<TInput, TOutput, TradeType.EXACT_INPUT>[]>;
527
+ /**
528
+ * similar to the above method but instead targets a fixed output amount
529
+ * given a list of pools, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token
530
+ * to an output token amount, making at most `maxHops` hops
531
+ * note this does not consider aggregation, as routes are linear. it's possible a better route exists by splitting
532
+ * the amount in among multiple routes.
533
+ * @param pools the pools to consider in finding the best trade
534
+ * @param currencyIn the currency to spend
535
+ * @param currencyAmountOut the desired currency amount out
536
+ * @param nextAmountOut the exact amount of currency out
537
+ * @param maxNumResults maximum number of results to return
538
+ * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool
539
+ * @param currentPools used in recursion; the current list of pools
540
+ * @param bestTrades used in recursion; the current list of best trades
541
+ * @returns The exact out trade
542
+ */
543
+ static bestTradeExactOut<TInput extends Currency, TOutput extends Currency>(pools: Pool[], currencyIn: TInput, currencyAmountOut: CurrencyAmount<TOutput>, { maxNumResults, maxHops }?: BestTradeOptions, currentPools?: Pool[], nextAmountOut?: CurrencyAmount<Currency>, bestTrades?: Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>[]): Promise<Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>[]>;
544
+ }
545
+
546
+ declare const V3_POSITION_MANAGER_SELECTORS: {
547
+ readonly createAndInitializePoolIfNecessary: "createAndInitializePoolIfNecessary(address,address,uint24,uint160)";
548
+ readonly mint: "mint((address,address,uint24,int24,int24,uint256,uint256,uint256,uint256,address,uint256))";
549
+ readonly increaseLiquidity: "increaseLiquidity((uint256,uint256,uint256,uint256,uint256,uint256))";
550
+ readonly decreaseLiquidity: "decreaseLiquidity((uint256,uint128,uint256,uint256,uint256))";
551
+ readonly collect: "collect((uint256,address,uint128,uint128))";
552
+ };
553
+ declare const MaxUint128: JSBI;
554
+ interface V3ActionOptions {
555
+ readonly network: Network;
556
+ readonly positionManager?: TronAddress;
557
+ readonly feeLimit?: number;
558
+ readonly id?: string;
559
+ }
560
+ interface BuildV3CreatePoolActionParams extends V3ActionOptions {
561
+ readonly pool: Pool;
562
+ }
563
+ interface BuildV3MintPositionActionParams extends V3ActionOptions {
564
+ readonly position: Position;
565
+ readonly recipient: TronAddress;
566
+ readonly amount0Min: BigintIsh;
567
+ readonly amount1Min: BigintIsh;
568
+ readonly deadline: BigintIsh;
569
+ }
570
+ interface BuildV3IncreaseLiquidityActionParams extends V3ActionOptions {
571
+ readonly tokenId: BigintIsh;
572
+ readonly position: Position;
573
+ readonly amount0Min: BigintIsh;
574
+ readonly amount1Min: BigintIsh;
575
+ readonly deadline: BigintIsh;
576
+ }
577
+ interface BuildV3DecreaseLiquidityActionParams extends V3ActionOptions {
578
+ readonly tokenId: BigintIsh;
579
+ readonly liquidity: BigintIsh;
580
+ readonly amount0Min: BigintIsh;
581
+ readonly amount1Min: BigintIsh;
582
+ readonly deadline: BigintIsh;
583
+ }
584
+ interface BuildV3CollectActionParams extends V3ActionOptions {
585
+ readonly tokenId: BigintIsh;
586
+ readonly recipient: TronAddress;
587
+ readonly amount0Max?: BigintIsh;
588
+ readonly amount1Max?: BigintIsh;
589
+ }
590
+ declare function buildV3CreatePoolAction(params: BuildV3CreatePoolActionParams): ContractCallAction;
591
+ declare function buildV3MintPositionAction(params: BuildV3MintPositionActionParams): ContractCallAction;
592
+ declare function buildV3IncreaseLiquidityAction(params: BuildV3IncreaseLiquidityActionParams): ContractCallAction;
593
+ declare function buildV3DecreaseLiquidityAction(params: BuildV3DecreaseLiquidityActionParams): ContractCallAction;
594
+ declare function buildV3CollectAction(params: BuildV3CollectActionParams): ContractCallAction;
595
+
596
+ declare const V3_POOL_SLOT0_ABI: {
597
+ readonly type: "function";
598
+ readonly name: "slot0";
599
+ readonly stateMutability: "view";
600
+ readonly inputs: readonly [];
601
+ readonly outputs: readonly [{
602
+ readonly name: "sqrtPriceX96";
603
+ readonly type: "uint160";
604
+ }, {
605
+ readonly name: "tick";
606
+ readonly type: "int24";
607
+ }, {
608
+ readonly name: "observationIndex";
609
+ readonly type: "uint16";
610
+ }, {
611
+ readonly name: "observationCardinality";
612
+ readonly type: "uint16";
613
+ }, {
614
+ readonly name: "observationCardinalityNext";
615
+ readonly type: "uint16";
616
+ }, {
617
+ readonly name: "feeProtocol";
618
+ readonly type: "uint8";
619
+ }, {
620
+ readonly name: "unlocked";
621
+ readonly type: "bool";
622
+ }];
623
+ };
624
+ declare const V3_POOL_LIQUIDITY_ABI: {
625
+ readonly type: "function";
626
+ readonly name: "liquidity";
627
+ readonly stateMutability: "view";
628
+ readonly inputs: readonly [];
629
+ readonly outputs: readonly [{
630
+ readonly type: "uint128";
631
+ }];
632
+ };
633
+ declare const V3_POOL_FEE_ABI: {
634
+ readonly type: "function";
635
+ readonly name: "fee";
636
+ readonly stateMutability: "view";
637
+ readonly inputs: readonly [];
638
+ readonly outputs: readonly [{
639
+ readonly type: "uint24";
640
+ }];
641
+ };
642
+ declare const V3_POOL_TICK_SPACING_ABI: {
643
+ readonly type: "function";
644
+ readonly name: "tickSpacing";
645
+ readonly stateMutability: "view";
646
+ readonly inputs: readonly [];
647
+ readonly outputs: readonly [{
648
+ readonly type: "int24";
649
+ }];
650
+ };
651
+ declare const V3_POSITION_MANAGER_POSITIONS_ABI: {
652
+ readonly type: "function";
653
+ readonly name: "positions";
654
+ readonly stateMutability: "view";
655
+ readonly inputs: readonly [{
656
+ readonly name: "tokenId";
657
+ readonly type: "uint256";
658
+ }];
659
+ readonly outputs: readonly [{
660
+ readonly name: "nonce";
661
+ readonly type: "uint96";
662
+ }, {
663
+ readonly name: "operator";
664
+ readonly type: "address";
665
+ }, {
666
+ readonly name: "token0";
667
+ readonly type: "address";
668
+ }, {
669
+ readonly name: "token1";
670
+ readonly type: "address";
671
+ }, {
672
+ readonly name: "fee";
673
+ readonly type: "uint24";
674
+ }, {
675
+ readonly name: "tickLower";
676
+ readonly type: "int24";
677
+ }, {
678
+ readonly name: "tickUpper";
679
+ readonly type: "int24";
680
+ }, {
681
+ readonly name: "liquidity";
682
+ readonly type: "uint128";
683
+ }, {
684
+ readonly name: "feeGrowthInside0LastX128";
685
+ readonly type: "uint256";
686
+ }, {
687
+ readonly name: "feeGrowthInside1LastX128";
688
+ readonly type: "uint256";
689
+ }, {
690
+ readonly name: "tokensOwed0";
691
+ readonly type: "uint128";
692
+ }, {
693
+ readonly name: "tokensOwed1";
694
+ readonly type: "uint128";
695
+ }];
696
+ };
697
+ declare const V3_POSITION_MANAGER_OWNER_OF_ABI: {
698
+ readonly type: "function";
699
+ readonly name: "ownerOf";
700
+ readonly stateMutability: "view";
701
+ readonly inputs: readonly [{
702
+ readonly name: "tokenId";
703
+ readonly type: "uint256";
704
+ }];
705
+ readonly outputs: readonly [{
706
+ readonly type: "address";
707
+ }];
708
+ };
709
+ declare const V3_POSITION_MANAGER_GET_APPROVED_ABI: {
710
+ readonly type: "function";
711
+ readonly name: "getApproved";
712
+ readonly stateMutability: "view";
713
+ readonly inputs: readonly [{
714
+ readonly name: "tokenId";
715
+ readonly type: "uint256";
716
+ }];
717
+ readonly outputs: readonly [{
718
+ readonly type: "address";
719
+ }];
720
+ };
721
+ declare const V3_POSITION_MANAGER_IS_APPROVED_FOR_ALL_ABI: {
722
+ readonly type: "function";
723
+ readonly name: "isApprovedForAll";
724
+ readonly stateMutability: "view";
725
+ readonly inputs: readonly [{
726
+ readonly name: "owner";
727
+ readonly type: "address";
728
+ }, {
729
+ readonly name: "operator";
730
+ readonly type: "address";
731
+ }];
732
+ readonly outputs: readonly [{
733
+ readonly type: "bool";
734
+ }];
735
+ };
736
+
737
+ declare abstract class Multicall {
738
+ static INTERFACE: Interface;
739
+ /**
740
+ * Cannot be constructed.
741
+ */
742
+ private constructor();
743
+ static encodeMulticall(calldatas: string | string[]): string;
744
+ }
745
+
746
+ /**
747
+ * Generated method parameters for executing a call.
748
+ */
749
+ interface MethodParameters {
750
+ /**
751
+ * The hex encoded calldata to perform the given operation
752
+ */
753
+ calldata: string;
754
+ /**
755
+ * The amount of ether (wei) to send in hex.
756
+ */
757
+ value: string;
758
+ /**
759
+ * function_selector
760
+ */
761
+ function_selector: string;
762
+ /**
763
+ * parameter
764
+ */
765
+ parameter: Array<object>;
766
+ }
767
+ /**
768
+ * Converts a big int to a hex string
769
+ * @param bigintIsh
770
+ * @returns The hex encoded calldata
771
+ */
772
+ declare function toHex(bigintIsh: BigintIsh): string;
773
+
774
+ interface StandardPermitArguments {
775
+ v: 0 | 1 | 27 | 28;
776
+ r: string;
777
+ s: string;
778
+ amount: BigintIsh;
779
+ deadline: BigintIsh;
780
+ }
781
+ interface AllowedPermitArguments {
782
+ v: 0 | 1 | 27 | 28;
783
+ r: string;
784
+ s: string;
785
+ nonce: BigintIsh;
786
+ expiry: BigintIsh;
787
+ }
788
+ type PermitOptions = StandardPermitArguments | AllowedPermitArguments;
789
+ declare abstract class SelfPermit {
790
+ static INTERFACE: Interface;
791
+ /**
792
+ * Cannot be constructed.
793
+ */
794
+ private constructor();
795
+ static encodePermit(token: Token, options: PermitOptions): string;
796
+ }
797
+
798
+ interface MintSpecificOptions {
799
+ /**
800
+ * The account that should receive the minted NFT.
801
+ */
802
+ recipient: string;
803
+ /**
804
+ * Creates pool if not initialized before mint.
805
+ */
806
+ createPool?: boolean;
807
+ }
808
+ interface IncreaseSpecificOptions {
809
+ /**
810
+ * Indicates the ID of the position to increase liquidity for.
811
+ */
812
+ tokenId: BigintIsh;
813
+ }
814
+ /**
815
+ * Options for producing the calldata to add liquidity.
816
+ */
817
+ interface CommonAddLiquidityOptions {
818
+ /**
819
+ * How much the pool price is allowed to move.
820
+ */
821
+ slippageTolerance: Percent;
822
+ /**
823
+ * When the transaction expires, in epoch seconds.
824
+ */
825
+ deadline: BigintIsh;
826
+ /**
827
+ * Whether to spend ether. If true, one of the pool tokens must be WETH, by default false
828
+ */
829
+ useNative?: NativeCurrency;
830
+ /**
831
+ * The optional permit parameters for spending token0
832
+ */
833
+ token0Permit?: PermitOptions;
834
+ /**
835
+ * The optional permit parameters for spending token1
836
+ */
837
+ token1Permit?: PermitOptions;
838
+ }
839
+ type MintOptions = CommonAddLiquidityOptions & MintSpecificOptions;
840
+ type IncreaseOptions = CommonAddLiquidityOptions & IncreaseSpecificOptions;
841
+ type AddLiquidityOptions = MintOptions | IncreaseOptions;
842
+ interface SafeTransferOptions {
843
+ /**
844
+ * The account sending the NFT.
845
+ */
846
+ sender: string;
847
+ /**
848
+ * The account that should receive the NFT.
849
+ */
850
+ recipient: string;
851
+ /**
852
+ * The id of the token being sent.
853
+ */
854
+ tokenId: BigintIsh;
855
+ /**
856
+ * The optional parameter that passes data to the `onERC721Received` call for the staker
857
+ */
858
+ data?: string;
859
+ }
860
+ interface CollectOptions {
861
+ /**
862
+ * Indicates the ID of the position to collect for.
863
+ */
864
+ tokenId: BigintIsh;
865
+ /**
866
+ * Expected value of tokensOwed0, including as-of-yet-unaccounted-for fees/liquidity value to be burned
867
+ */
868
+ expectedCurrencyOwed0: CurrencyAmount<Currency>;
869
+ /**
870
+ * Expected value of tokensOwed1, including as-of-yet-unaccounted-for fees/liquidity value to be burned
871
+ */
872
+ expectedCurrencyOwed1: CurrencyAmount<Currency>;
873
+ /**
874
+ * The account that should receive the tokens.
875
+ */
876
+ recipient: string;
877
+ }
878
+ interface NFTPermitOptions {
879
+ v: 0 | 1 | 27 | 28;
880
+ r: string;
881
+ s: string;
882
+ deadline: BigintIsh;
883
+ spender: string;
884
+ }
885
+ /**
886
+ * Options for producing the calldata to exit a position.
887
+ */
888
+ interface RemoveLiquidityOptions {
889
+ /**
890
+ * The ID of the token to exit
891
+ */
892
+ tokenId: BigintIsh;
893
+ /**
894
+ * The percentage of position liquidity to exit.
895
+ */
896
+ liquidityPercentage: Percent;
897
+ /**
898
+ * How much the pool price is allowed to move.
899
+ */
900
+ slippageTolerance: Percent;
901
+ /**
902
+ * When the transaction expires, in epoch seconds.
903
+ */
904
+ deadline: BigintIsh;
905
+ /**
906
+ * Whether the NFT should be burned if the entire position is being exited, by default false.
907
+ */
908
+ burnToken?: boolean;
909
+ /**
910
+ * The optional permit of the token ID being exited, in case the exit transaction is being sent by an account that does not own the NFT
911
+ */
912
+ permit?: NFTPermitOptions;
913
+ /**
914
+ * Parameters to be passed on to collect
915
+ */
916
+ collectOptions: Omit<CollectOptions, 'tokenId'>;
917
+ }
918
+ declare abstract class NonfungiblePositionManager {
919
+ static INTERFACE: Interface;
920
+ /**
921
+ * Cannot be constructed.
922
+ */
923
+ private constructor();
924
+ private static encodeCreate;
925
+ static createCallParameters(pool: Pool): MethodParameters;
926
+ static addCallParameters(position: Position, options: AddLiquidityOptions): MethodParameters;
927
+ private static encodeCollect;
928
+ static collectCallParameters(options: CollectOptions): MethodParameters;
929
+ /**
930
+ * Produces the calldata for completely or partially exiting a position
931
+ * @param position The position to exit
932
+ * @param options Additional information necessary for generating the calldata
933
+ * @returns The call parameters
934
+ */
935
+ static removeCallParameters(position: Position, options: RemoveLiquidityOptions): MethodParameters;
936
+ static safeTransferFromParameters(options: SafeTransferOptions): MethodParameters;
937
+ }
938
+
939
+ interface FeeOptions {
940
+ /**
941
+ * The percent of the output that will be taken as a fee.
942
+ */
943
+ fee: Percent;
944
+ /**
945
+ * The recipient of the fee.
946
+ */
947
+ recipient: string;
948
+ }
949
+ declare abstract class Payments {
950
+ static INTERFACE: Interface;
951
+ /**
952
+ * Cannot be constructed.
953
+ */
954
+ private constructor();
955
+ private static encodeFeeBips;
956
+ static encodeUnwrapWETH9(amountMinimum: JSBI, recipient: string, feeOptions?: FeeOptions): string;
957
+ static encodeSweepToken(token: Token, amountMinimum: JSBI, recipient: string, feeOptions?: FeeOptions): string;
958
+ static encodeRefundETH(): string;
959
+ }
960
+
961
+ declare const V3_INIT_CODE_HASH: Record<Network, `0x${string}`>;
962
+ interface ComputeV3PoolAddressParams {
963
+ readonly network: Network;
964
+ readonly tokenA: Token | TronAddress | string;
965
+ readonly tokenB: Token | TronAddress | string;
966
+ readonly fee: number;
967
+ readonly factory?: TronAddress | string;
968
+ readonly initCodeHash?: string;
969
+ readonly wrappedNative?: TronAddress | string;
970
+ }
971
+ declare function computeV3PoolAddress(params: ComputeV3PoolAddressParams): TronAddress;
972
+
973
+ interface V3ContractReadSpec {
974
+ readonly target: TronAddress;
975
+ readonly functionSelector: string;
976
+ readonly parameters?: readonly ContractParameter[];
977
+ readonly abiFunction?: unknown;
978
+ readonly metadata?: Record<string, unknown>;
979
+ }
980
+ declare const V3_POOL_READ_SELECTORS: {
981
+ readonly slot0: "slot0()";
982
+ readonly liquidity: "liquidity()";
983
+ readonly fee: "fee()";
984
+ readonly tickSpacing: "tickSpacing()";
985
+ };
986
+ declare const V3_POSITION_MANAGER_READ_SELECTORS: {
987
+ readonly positions: "positions(uint256)";
988
+ readonly ownerOf: "ownerOf(uint256)";
989
+ readonly getApproved: "getApproved(uint256)";
990
+ readonly isApprovedForAll: "isApprovedForAll(address,address)";
991
+ };
992
+ interface V3ReadOptions {
993
+ readonly network: Network;
994
+ readonly positionManager?: TronAddress;
995
+ }
996
+ interface BuildV3PoolReadParams {
997
+ readonly pool: TronAddress;
998
+ }
999
+ interface BuildV3PositionReadParams extends V3ReadOptions {
1000
+ readonly tokenId: BigintIsh;
1001
+ }
1002
+ interface BuildV3PositionApprovalReadParams extends V3ReadOptions {
1003
+ readonly owner: TronAddress;
1004
+ readonly operator: TronAddress;
1005
+ }
1006
+ declare function buildV3PoolSlot0Read(params: BuildV3PoolReadParams): V3ContractReadSpec;
1007
+ declare function buildV3PoolLiquidityRead(params: BuildV3PoolReadParams): V3ContractReadSpec;
1008
+ declare function buildV3PoolFeeRead(params: BuildV3PoolReadParams): V3ContractReadSpec;
1009
+ declare function buildV3PoolTickSpacingRead(params: BuildV3PoolReadParams): V3ContractReadSpec;
1010
+ declare function buildV3PoolStateReads(params: BuildV3PoolReadParams): readonly V3ContractReadSpec[];
1011
+ declare function buildV3PositionRead(params: BuildV3PositionReadParams): V3ContractReadSpec;
1012
+ declare function buildV3PositionOwnerRead(params: BuildV3PositionReadParams): V3ContractReadSpec;
1013
+ declare function buildV3PositionApprovedRead(params: BuildV3PositionReadParams): V3ContractReadSpec;
1014
+ declare function buildV3PositionApprovalForAllRead(params: BuildV3PositionApprovalReadParams): V3ContractReadSpec;
1015
+ declare function buildV3PositionReads(params: BuildV3PositionReadParams): readonly V3ContractReadSpec[];
1016
+
1017
+ interface V3PoolKey {
1018
+ readonly network: Network;
1019
+ readonly token0: Token;
1020
+ readonly token1: Token;
1021
+ readonly fee: FeeAmount;
1022
+ }
1023
+ interface V3PoolState {
1024
+ readonly poolKey: V3PoolKey;
1025
+ readonly sqrtRatioX96: JSBI;
1026
+ readonly liquidity: JSBI;
1027
+ readonly tickCurrent: number;
1028
+ readonly tickSpacing: number;
1029
+ }
1030
+ interface V3TickRange {
1031
+ readonly tickLower: number;
1032
+ readonly tickUpper: number;
1033
+ }
1034
+ interface V3Position {
1035
+ readonly tokenId: BigintIsh;
1036
+ readonly poolKey: V3PoolKey;
1037
+ readonly liquidity: JSBI;
1038
+ readonly tickLower: number;
1039
+ readonly tickUpper: number;
1040
+ readonly tokensOwed0?: JSBI;
1041
+ readonly tokensOwed1?: JSBI;
1042
+ readonly feeGrowthInside0LastX128?: JSBI;
1043
+ readonly feeGrowthInside1LastX128?: JSBI;
1044
+ }
1045
+
1046
+ /**
1047
+ * Computes a pool address
1048
+ * @param factoryAddress The Uniswap V3 factory address
1049
+ * @param tokenA The first token of the pair, irrespective of sort order
1050
+ * @param tokenB The second token of the pair, irrespective of sort order
1051
+ * @param fee The fee tier of the pool
1052
+ * @param initCodeHashManualOverride Override the init code hash used to compute the pool address if necessary
1053
+ * @returns The pool address
1054
+ */
1055
+ declare function computePoolAddress({ factoryAddress, tokenA, tokenB, fee, initCodeHashManualOverride }: {
1056
+ factoryAddress: string;
1057
+ tokenA: Token;
1058
+ tokenB: Token;
1059
+ fee: FeeAmount;
1060
+ initCodeHashManualOverride?: string;
1061
+ }): string;
1062
+
1063
+ declare function getTronCreate2Address(from: string, salt: BytesLike, initCodeHash: BytesLike): string;
1064
+
1065
+ /**
1066
+ * Returns the sqrt ratio as a Q64.96 corresponding to amount1 / amount0.
1067
+ *
1068
+ * Migrated from `@sunio/sun-sdk@1.0.9`.
1069
+ */
1070
+ declare function encodeSqrtRatioX96(amount1: BigintIsh, amount0: BigintIsh): JSBI;
1071
+
1072
+ /**
1073
+ * Converts a route to a hex encoded path
1074
+ * @param route the v3 path to convert to an encoded path
1075
+ * @param exactOutput whether the route should be encoded in reverse, for making exact output swaps
1076
+ */
1077
+ declare function encodeRouteToPath(route: Route<Currency, Currency>, exactOutput: boolean): string;
1078
+
1079
+ /**
1080
+ * Fixed-point multiplication/division helpers.
1081
+ *
1082
+ * Migrated from `@sunio/sun-sdk@1.0.9`.
1083
+ */
1084
+ declare abstract class FullMath {
1085
+ private constructor();
1086
+ static mulDivRoundingUp(a: JSBI, b: JSBI, denominator: JSBI): JSBI;
1087
+ }
1088
+
1089
+ /**
1090
+ * Determines if a tick list is sorted
1091
+ * @param list The tick list
1092
+ * @param comparator The comparator
1093
+ * @returns true if sorted
1094
+ */
1095
+ declare function isSorted<T>(list: Array<T>, comparator: (a: T, b: T) => number): boolean;
1096
+
1097
+ declare abstract class LiquidityMath {
1098
+ /**
1099
+ * Cannot be constructed.
1100
+ */
1101
+ private constructor();
1102
+ static addDelta(x: JSBI, y: JSBI): JSBI;
1103
+ }
1104
+
1105
+ /**
1106
+ * Computes the maximum liquidity received for token0/token1 amounts.
1107
+ *
1108
+ * Migrated from `@sunio/sun-sdk@1.0.9`.
1109
+ */
1110
+ declare function maxLiquidityForAmounts(sqrtRatioCurrentX96: JSBI, sqrtRatioAX96: JSBI, sqrtRatioBX96: JSBI, amount0: BigintIsh, amount1: BigintIsh, useFullPrecision: boolean): JSBI;
1111
+
1112
+ /**
1113
+ * Returns the index of the most significant bit of the input.
1114
+ *
1115
+ * Migrated from `@sunio/sun-sdk@1.0.9`.
1116
+ */
1117
+ declare function mostSignificantBit(x: JSBI): number;
1118
+
1119
+ /**
1120
+ * Returns the closest usable tick for the given tick spacing.
1121
+ *
1122
+ * Migrated from `@sunio/sun-sdk@1.0.9`.
1123
+ */
1124
+ declare function nearestUsableTick(tick: number, tickSpacing: number): number;
1125
+
1126
+ declare abstract class PositionLibrary {
1127
+ /**
1128
+ * Cannot be constructed.
1129
+ */
1130
+ private constructor();
1131
+ static getTokensOwed(feeGrowthInside0LastX128: JSBI, feeGrowthInside1LastX128: JSBI, liquidity: JSBI, feeGrowthInside0X128: JSBI, feeGrowthInside1X128: JSBI): JSBI[];
1132
+ }
1133
+
1134
+ /**
1135
+ * Returns a price object corresponding to the input tick and the base/quote token
1136
+ * Inputs must be tokens because the address order is used to interpret the price represented by the tick
1137
+ * @param baseToken the base token of the price
1138
+ * @param quoteToken the quote token of the price
1139
+ * @param tick the tick for which to return the price
1140
+ */
1141
+ declare function tickToPrice(baseToken: Token, quoteToken: Token, tick: number): Price<Token, Token>;
1142
+ /**
1143
+ * Returns the first tick for which the given price is greater than or equal to the tick price
1144
+ * @param price for which to return the closest tick that represents a price less than or equal to the input price,
1145
+ * i.e. the price of the returned tick is less than or equal to the input price
1146
+ */
1147
+ declare function priceToClosestTick(price: Price<Token, Token>): number;
1148
+
1149
+ /**
1150
+ * Sqrt price delta and next-price math for V3 pools.
1151
+ *
1152
+ * Migrated from `@sunio/sun-sdk@1.0.9`.
1153
+ */
1154
+ declare abstract class SqrtPriceMath {
1155
+ private constructor();
1156
+ static getAmount0Delta(sqrtRatioAX96: JSBI, sqrtRatioBX96: JSBI, liquidity: JSBI, roundUp: boolean): JSBI;
1157
+ static getAmount1Delta(sqrtRatioAX96: JSBI, sqrtRatioBX96: JSBI, liquidity: JSBI, roundUp: boolean): JSBI;
1158
+ static getNextSqrtPriceFromInput(sqrtPX96: JSBI, liquidity: JSBI, amountIn: JSBI, zeroForOne: boolean): JSBI;
1159
+ static getNextSqrtPriceFromOutput(sqrtPX96: JSBI, liquidity: JSBI, amountOut: JSBI, zeroForOne: boolean): JSBI;
1160
+ private static getNextSqrtPriceFromAmount0RoundingUp;
1161
+ private static getNextSqrtPriceFromAmount1RoundingDown;
1162
+ }
1163
+
1164
+ declare abstract class SwapMath {
1165
+ /**
1166
+ * Cannot be constructed.
1167
+ */
1168
+ private constructor();
1169
+ static computeSwapStep(sqrtRatioCurrentX96: JSBI, sqrtRatioTargetX96: JSBI, liquidity: JSBI, amountRemaining: JSBI, feePips: FeeAmount): [JSBI, JSBI, JSBI, JSBI];
1170
+ }
1171
+
1172
+ interface FeeGrowthOutside {
1173
+ feeGrowthOutside0X128: JSBI;
1174
+ feeGrowthOutside1X128: JSBI;
1175
+ }
1176
+ declare function subIn256(x: JSBI, y: JSBI): JSBI;
1177
+ declare abstract class TickLibrary {
1178
+ /**
1179
+ * Cannot be constructed.
1180
+ */
1181
+ private constructor();
1182
+ static getFeeGrowthInside(feeGrowthOutsideLower: FeeGrowthOutside, feeGrowthOutsideUpper: FeeGrowthOutside, tickLower: number, tickUpper: number, tickCurrent: number, feeGrowthGlobal0X128: JSBI, feeGrowthGlobal1X128: JSBI): JSBI[];
1183
+ }
1184
+
1185
+ /**
1186
+ * Utility methods for interacting with sorted lists of ticks
1187
+ */
1188
+ declare abstract class TickList {
1189
+ /**
1190
+ * Cannot be constructed
1191
+ */
1192
+ private constructor();
1193
+ static validateList(ticks: Tick[], tickSpacing: number): void;
1194
+ static isBelowSmallest(ticks: readonly Tick[], tick: number): boolean;
1195
+ static isAtOrAboveLargest(ticks: readonly Tick[], tick: number): boolean;
1196
+ static getTick(ticks: readonly Tick[], index: number): Tick;
1197
+ /**
1198
+ * Finds the largest tick in the list of ticks that is less than or equal to tick
1199
+ * @param ticks list of ticks
1200
+ * @param tick tick to find the largest tick that is less than or equal to tick
1201
+ * @private
1202
+ */
1203
+ private static binarySearch;
1204
+ static nextInitializedTick(ticks: readonly Tick[], tick: number, lte: boolean): Tick;
1205
+ static nextInitializedTickWithinOneWord(ticks: readonly Tick[], tick: number, lte: boolean, tickSpacing: number): [number, boolean];
1206
+ }
1207
+
1208
+ /**
1209
+ * Math library for converting between ticks and sqrt ratios.
1210
+ *
1211
+ * Migrated from `@sunio/sun-sdk@1.0.9`.
1212
+ */
1213
+ declare abstract class TickMath {
1214
+ private constructor();
1215
+ static MIN_TICK: number;
1216
+ static MAX_TICK: number;
1217
+ static MIN_SQRT_RATIO: JSBI;
1218
+ static MAX_SQRT_RATIO: JSBI;
1219
+ static getSqrtRatioAtTick(tick: number): JSBI;
1220
+ static getTickAtSqrtRatio(sqrtRatioX96: JSBI): number;
1221
+ }
1222
+
1223
+ declare function isSupportedFeeAmount(fee: number): fee is FeeAmount;
1224
+ declare function getTickSpacing(fee: FeeAmount): number;
1225
+ declare function validateTickSpacing(tickSpacing: number): number;
1226
+ declare function validateTickRange(tickLower: number, tickUpper: number, tickSpacing: number): {
1227
+ tickLower: number;
1228
+ tickUpper: number;
1229
+ };
1230
+ declare function validateTickRangeForFee(tickLower: number, tickUpper: number, fee: FeeAmount): {
1231
+ tickLower: number;
1232
+ tickUpper: number;
1233
+ tickSpacing: number;
1234
+ };
1235
+
1236
+ export { ADDRESS_ZERO, type AddLiquidityOptions, type AllowedPermitArguments, type BestTradeOptions, type BuildV3CollectActionParams, type BuildV3CreatePoolActionParams, type BuildV3DecreaseLiquidityActionParams, type BuildV3IncreaseLiquidityActionParams, type BuildV3MintPositionActionParams, type BuildV3PoolReadParams, type BuildV3PositionApprovalReadParams, type BuildV3PositionReadParams, type CollectOptions, type CommonAddLiquidityOptions, type ComputeV3PoolAddressParams, FACTORY_ADDRESS, FeeAmount, type FeeOptions, FullMath, IS_TVM, type IncreaseOptions, type IncreaseSpecificOptions, LiquidityMath, MaxUint128, type MethodParameters, type MintOptions, type MintSpecificOptions, Multicall, type NFTPermitOptions, NoTickDataProvider, NonfungiblePositionManager, POOL_INIT_CODE_HASH, Payments, type PermitOptions, Pool, type PoolConstructorArgs, Position, PositionLibrary, type RemoveLiquidityOptions, Route, type SafeTransferOptions, SelfPermit, SqrtPriceMath, type StandardPermitArguments, SwapMath, TICK_SPACINGS, Tick, type TickConstructorArgs, type TickDataProvider, TickLibrary, TickList, TickListDataProvider, TickMath, Trade, type V3ActionOptions, type V3ContractReadSpec, type V3PoolKey, type V3PoolState, type V3Position, type V3ReadOptions, type V3TickRange, V3_INIT_CODE_HASH, V3_POOL_FEE_ABI, V3_POOL_LIQUIDITY_ABI, V3_POOL_READ_SELECTORS, V3_POOL_SLOT0_ABI, V3_POOL_TICK_SPACING_ABI, V3_POSITION_MANAGER_GET_APPROVED_ABI, V3_POSITION_MANAGER_IS_APPROVED_FOR_ALL_ABI, V3_POSITION_MANAGER_OWNER_OF_ABI, V3_POSITION_MANAGER_POSITIONS_ABI, V3_POSITION_MANAGER_READ_SELECTORS, V3_POSITION_MANAGER_SELECTORS, buildV3CollectAction, buildV3CreatePoolAction, buildV3DecreaseLiquidityAction, buildV3IncreaseLiquidityAction, buildV3MintPositionAction, buildV3PoolFeeRead, buildV3PoolLiquidityRead, buildV3PoolSlot0Read, buildV3PoolStateReads, buildV3PoolTickSpacingRead, buildV3PositionApprovalForAllRead, buildV3PositionApprovedRead, buildV3PositionOwnerRead, buildV3PositionRead, buildV3PositionReads, computePoolAddress, computeV3PoolAddress, encodeRouteToPath, encodeSqrtRatioX96, getTickSpacing, getTronCreate2Address, isSorted, isSupportedFeeAmount, maxLiquidityForAmounts, mostSignificantBit, nearestUsableTick, priceToClosestTick, subIn256, tickToPrice, toHex, tradeComparator, validateTickRange, validateTickRangeForFee, validateTickSpacing };