@huuduynvc/v3-sdk 3.24.1

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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/dist/constants.d.ts +23 -0
  4. package/dist/entities/index.d.ts +7 -0
  5. package/dist/entities/pool.d.ts +81 -0
  6. package/dist/entities/position.d.ts +131 -0
  7. package/dist/entities/route.d.ts +26 -0
  8. package/dist/entities/tick.d.ts +13 -0
  9. package/dist/entities/tickDataProvider.d.ts +31 -0
  10. package/dist/entities/tickListDataProvider.d.ts +15 -0
  11. package/dist/entities/trade.d.ts +220 -0
  12. package/dist/index.d.ts +10 -0
  13. package/dist/index.js +8 -0
  14. package/dist/internalConstants.d.ts +6 -0
  15. package/dist/multicall.d.ts +10 -0
  16. package/dist/nonfungiblePositionManager.d.ts +159 -0
  17. package/dist/payments.d.ts +24 -0
  18. package/dist/quoter.d.ts +37 -0
  19. package/dist/selfPermit.d.ts +25 -0
  20. package/dist/staker.d.ts +101 -0
  21. package/dist/swapRouter.d.ts +51 -0
  22. package/dist/utils/calldata.d.ts +20 -0
  23. package/dist/utils/computePoolAddress.d.ts +20 -0
  24. package/dist/utils/encodeRouteToPath.d.ts +8 -0
  25. package/dist/utils/encodeSqrtRatioX96.d.ts +9 -0
  26. package/dist/utils/fullMath.d.ts +8 -0
  27. package/dist/utils/index.d.ts +18 -0
  28. package/dist/utils/isSorted.d.ts +7 -0
  29. package/dist/utils/liquidityMath.d.ts +8 -0
  30. package/dist/utils/maxLiquidityForAmounts.d.ts +14 -0
  31. package/dist/utils/mostSignificantBit.d.ts +2 -0
  32. package/dist/utils/nearestUsableTick.d.ts +6 -0
  33. package/dist/utils/position.d.ts +8 -0
  34. package/dist/utils/priceTickConversions.d.ts +15 -0
  35. package/dist/utils/sqrtPriceMath.d.ts +13 -0
  36. package/dist/utils/swapMath.d.ts +9 -0
  37. package/dist/utils/tickLibrary.d.ts +14 -0
  38. package/dist/utils/tickList.d.ts +23 -0
  39. package/dist/utils/tickMath.d.ts +34 -0
  40. package/dist/utils/v3swap.d.ts +8 -0
  41. package/dist/v3-sdk.cjs.development.js +3265 -0
  42. package/dist/v3-sdk.cjs.development.js.map +1 -0
  43. package/dist/v3-sdk.cjs.production.min.js +2 -0
  44. package/dist/v3-sdk.cjs.production.min.js.map +1 -0
  45. package/dist/v3-sdk.esm.js +3224 -0
  46. package/dist/v3-sdk.esm.js.map +1 -0
  47. package/package.json +57 -0
@@ -0,0 +1,159 @@
1
+ import { BigintIsh, Percent, CurrencyAmount, Currency, NativeCurrency } from '@uniswap/sdk-core';
2
+ import { Position } from './entities/position';
3
+ import { MethodParameters } from './utils/calldata';
4
+ import { Interface } from '@ethersproject/abi';
5
+ import { TypedDataDomain, TypedDataField } from '@ethersproject/abstract-signer';
6
+ import { PermitOptions } from './selfPermit';
7
+ import { Pool } from './entities';
8
+ export interface MintSpecificOptions {
9
+ /**
10
+ * The account that should receive the minted NFT.
11
+ */
12
+ recipient: string;
13
+ /**
14
+ * Creates pool if not initialized before mint.
15
+ */
16
+ createPool?: boolean;
17
+ }
18
+ export interface IncreaseSpecificOptions {
19
+ /**
20
+ * Indicates the ID of the position to increase liquidity for.
21
+ */
22
+ tokenId: BigintIsh;
23
+ }
24
+ /**
25
+ * Options for producing the calldata to add liquidity.
26
+ */
27
+ export interface CommonAddLiquidityOptions {
28
+ /**
29
+ * How much the pool price is allowed to move.
30
+ */
31
+ slippageTolerance: Percent;
32
+ /**
33
+ * When the transaction expires, in epoch seconds.
34
+ */
35
+ deadline: BigintIsh;
36
+ /**
37
+ * Whether to spend ether. If true, one of the pool tokens must be WETH, by default false
38
+ */
39
+ useNative?: NativeCurrency;
40
+ /**
41
+ * The optional permit parameters for spending token0
42
+ */
43
+ token0Permit?: PermitOptions;
44
+ /**
45
+ * The optional permit parameters for spending token1
46
+ */
47
+ token1Permit?: PermitOptions;
48
+ }
49
+ export declare type MintOptions = CommonAddLiquidityOptions & MintSpecificOptions;
50
+ export declare type IncreaseOptions = CommonAddLiquidityOptions & IncreaseSpecificOptions;
51
+ export declare type AddLiquidityOptions = MintOptions | IncreaseOptions;
52
+ export interface SafeTransferOptions {
53
+ /**
54
+ * The account sending the NFT.
55
+ */
56
+ sender: string;
57
+ /**
58
+ * The account that should receive the NFT.
59
+ */
60
+ recipient: string;
61
+ /**
62
+ * The id of the token being sent.
63
+ */
64
+ tokenId: BigintIsh;
65
+ /**
66
+ * The optional parameter that passes data to the `onERC721Received` call for the staker
67
+ */
68
+ data?: string;
69
+ }
70
+ export interface CollectOptions {
71
+ /**
72
+ * Indicates the ID of the position to collect for.
73
+ */
74
+ tokenId: BigintIsh;
75
+ /**
76
+ * Expected value of tokensOwed0, including as-of-yet-unaccounted-for fees/liquidity value to be burned
77
+ */
78
+ expectedCurrencyOwed0: CurrencyAmount<Currency>;
79
+ /**
80
+ * Expected value of tokensOwed1, including as-of-yet-unaccounted-for fees/liquidity value to be burned
81
+ */
82
+ expectedCurrencyOwed1: CurrencyAmount<Currency>;
83
+ /**
84
+ * The account that should receive the tokens.
85
+ */
86
+ recipient: string;
87
+ }
88
+ export interface NFTPermitValues {
89
+ spender: string;
90
+ tokenId: BigintIsh;
91
+ deadline: BigintIsh;
92
+ nonce: BigintIsh;
93
+ }
94
+ export interface NFTPermitData {
95
+ domain: TypedDataDomain;
96
+ types: Record<string, TypedDataField[]>;
97
+ values: NFTPermitValues;
98
+ }
99
+ export interface NFTPermitOptions {
100
+ v: 0 | 1 | 27 | 28;
101
+ r: string;
102
+ s: string;
103
+ deadline: BigintIsh;
104
+ spender: string;
105
+ }
106
+ /**
107
+ * Options for producing the calldata to exit a position.
108
+ */
109
+ export interface RemoveLiquidityOptions {
110
+ /**
111
+ * The ID of the token to exit
112
+ */
113
+ tokenId: BigintIsh;
114
+ /**
115
+ * The percentage of position liquidity to exit.
116
+ */
117
+ liquidityPercentage: Percent;
118
+ /**
119
+ * How much the pool price is allowed to move.
120
+ */
121
+ slippageTolerance: Percent;
122
+ /**
123
+ * When the transaction expires, in epoch seconds.
124
+ */
125
+ deadline: BigintIsh;
126
+ /**
127
+ * Whether the NFT should be burned if the entire position is being exited, by default false.
128
+ */
129
+ burnToken?: boolean;
130
+ /**
131
+ * 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
132
+ */
133
+ permit?: NFTPermitOptions;
134
+ /**
135
+ * Parameters to be passed on to collect
136
+ */
137
+ collectOptions: Omit<CollectOptions, 'tokenId'>;
138
+ }
139
+ export declare abstract class NonfungiblePositionManager {
140
+ static INTERFACE: Interface;
141
+ /**
142
+ * Cannot be constructed.
143
+ */
144
+ private constructor();
145
+ private static encodeCreate;
146
+ static createCallParameters(pool: Pool): MethodParameters;
147
+ static addCallParameters(position: Position, options: AddLiquidityOptions): MethodParameters;
148
+ private static encodeCollect;
149
+ static collectCallParameters(options: CollectOptions): MethodParameters;
150
+ /**
151
+ * Produces the calldata for completely or partially exiting a position
152
+ * @param position The position to exit
153
+ * @param options Additional information necessary for generating the calldata
154
+ * @returns The call parameters
155
+ */
156
+ static removeCallParameters(position: Position, options: RemoveLiquidityOptions): MethodParameters;
157
+ static safeTransferFromParameters(options: SafeTransferOptions): MethodParameters;
158
+ static getPermitData(permit: NFTPermitValues, positionManagerAddress: string, chainId: number): NFTPermitData;
159
+ }
@@ -0,0 +1,24 @@
1
+ import JSBI from 'jsbi';
2
+ import { Interface } from '@ethersproject/abi';
3
+ import { Percent, Token } from '@uniswap/sdk-core';
4
+ export interface FeeOptions {
5
+ /**
6
+ * The percent of the output that will be taken as a fee.
7
+ */
8
+ fee: Percent;
9
+ /**
10
+ * The recipient of the fee.
11
+ */
12
+ recipient: string;
13
+ }
14
+ export declare abstract class Payments {
15
+ static INTERFACE: Interface;
16
+ /**
17
+ * Cannot be constructed.
18
+ */
19
+ private constructor();
20
+ private static encodeFeeBips;
21
+ static encodeUnwrapWETH9(amountMinimum: JSBI, recipient: string, feeOptions?: FeeOptions): string;
22
+ static encodeSweepToken(token: Token, amountMinimum: JSBI, recipient: string, feeOptions?: FeeOptions): string;
23
+ static encodeRefundETH(): string;
24
+ }
@@ -0,0 +1,37 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { BigintIsh, Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core';
3
+ import { MethodParameters } from './utils';
4
+ import { Route } from './entities';
5
+ /**
6
+ * Optional arguments to send to the quoter.
7
+ */
8
+ export interface QuoteOptions {
9
+ /**
10
+ * The optional price limit for the trade.
11
+ */
12
+ sqrtPriceLimitX96?: BigintIsh;
13
+ /**
14
+ * The optional quoter interface to use
15
+ */
16
+ useQuoterV2?: boolean;
17
+ }
18
+ /**
19
+ * Represents the Uniswap V3 QuoterV1 contract with a method for returning the formatted
20
+ * calldata needed to call the quoter contract.
21
+ */
22
+ export declare abstract class SwapQuoter {
23
+ static V1INTERFACE: Interface;
24
+ static V2INTERFACE: Interface;
25
+ /**
26
+ * Produces the on-chain method name of the appropriate function within QuoterV2,
27
+ * and the relevant hex encoded parameters.
28
+ * @template TInput The input token, either Ether or an ERC-20
29
+ * @template TOutput The output token, either Ether or an ERC-20
30
+ * @param route The swap route, a list of pools through which a swap can occur
31
+ * @param amount The amount of the quote, either an amount in, or an amount out
32
+ * @param tradeType The trade type, either exact input or exact output
33
+ * @param options The optional params including price limit and Quoter contract switch
34
+ * @returns The formatted calldata
35
+ */
36
+ static quoteCallParameters<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amount: CurrencyAmount<TInput | TOutput>, tradeType: TradeType, options?: QuoteOptions): MethodParameters;
37
+ }
@@ -0,0 +1,25 @@
1
+ import { BigintIsh, Token } from '@uniswap/sdk-core';
2
+ import { Interface } from '@ethersproject/abi';
3
+ export interface StandardPermitArguments {
4
+ v: 0 | 1 | 27 | 28;
5
+ r: string;
6
+ s: string;
7
+ amount: BigintIsh;
8
+ deadline: BigintIsh;
9
+ }
10
+ export interface AllowedPermitArguments {
11
+ v: 0 | 1 | 27 | 28;
12
+ r: string;
13
+ s: string;
14
+ nonce: BigintIsh;
15
+ expiry: BigintIsh;
16
+ }
17
+ export declare type PermitOptions = StandardPermitArguments | AllowedPermitArguments;
18
+ export declare abstract class SelfPermit {
19
+ static INTERFACE: Interface;
20
+ /**
21
+ * Cannot be constructed.
22
+ */
23
+ private constructor();
24
+ static encodePermit(token: Token, options: PermitOptions): string;
25
+ }
@@ -0,0 +1,101 @@
1
+ import { BigintIsh, Token } from '@uniswap/sdk-core';
2
+ import { MethodParameters } from './utils/calldata';
3
+ import { Interface } from '@ethersproject/abi';
4
+ import { Pool } from './entities';
5
+ export declare type FullWithdrawOptions = ClaimOptions & WithdrawOptions;
6
+ /**
7
+ * Represents a unique staking program.
8
+ */
9
+ export interface IncentiveKey {
10
+ /**
11
+ * The token rewarded for participating in the staking program.
12
+ */
13
+ rewardToken: Token;
14
+ /**
15
+ * The pool that the staked positions must provide in.
16
+ */
17
+ pool: Pool;
18
+ /**
19
+ * The time when the incentive program begins.
20
+ */
21
+ startTime: BigintIsh;
22
+ /**
23
+ * The time that the incentive program ends.
24
+ */
25
+ endTime: BigintIsh;
26
+ /**
27
+ * The address which receives any remaining reward tokens at `endTime`.
28
+ */
29
+ refundee: string;
30
+ }
31
+ /**
32
+ * Options to specify when claiming rewards.
33
+ */
34
+ export interface ClaimOptions {
35
+ /**
36
+ * The id of the NFT
37
+ */
38
+ tokenId: BigintIsh;
39
+ /**
40
+ * Address to send rewards to.
41
+ */
42
+ recipient: string;
43
+ /**
44
+ * The amount of `rewardToken` to claim. 0 claims all.
45
+ */
46
+ amount?: BigintIsh;
47
+ }
48
+ /**
49
+ * Options to specify when withdrawing a position.
50
+ */
51
+ export interface WithdrawOptions {
52
+ /**
53
+ * Set when withdrawing. The position will be sent to `owner` on withdraw.
54
+ */
55
+ owner: string;
56
+ /**
57
+ * Set when withdrawing. `data` is passed to `safeTransferFrom` when transferring the position from contract back to owner.
58
+ */
59
+ data?: string;
60
+ }
61
+ export declare abstract class Staker {
62
+ static INTERFACE: Interface;
63
+ protected constructor();
64
+ private static INCENTIVE_KEY_ABI;
65
+ /**
66
+ * To claim rewards, must unstake and then claim.
67
+ * @param incentiveKey The unique identifier of a staking program.
68
+ * @param options Options for producing the calldata to claim. Can't claim unless you unstake.
69
+ * @returns The calldatas for 'unstakeToken' and 'claimReward'.
70
+ */
71
+ private static encodeClaim;
72
+ /**
73
+ *
74
+ * Note: A `tokenId` can be staked in many programs but to claim rewards and continue the program you must unstake, claim, and then restake.
75
+ * @param incentiveKeys An IncentiveKey or array of IncentiveKeys that `tokenId` is staked in.
76
+ * Input an array of IncentiveKeys to claim rewards for each program.
77
+ * @param options ClaimOptions to specify tokenId, recipient, and amount wanting to collect.
78
+ * Note that you can only specify one amount and one recipient across the various programs if you are collecting from multiple programs at once.
79
+ * @returns
80
+ */
81
+ static collectRewards(incentiveKeys: IncentiveKey | IncentiveKey[], options: ClaimOptions): MethodParameters;
82
+ /**
83
+ *
84
+ * @param incentiveKeys A list of incentiveKeys to unstake from. Should include all incentiveKeys (unique staking programs) that `options.tokenId` is staked in.
85
+ * @param withdrawOptions Options for producing claim calldata and withdraw calldata. Can't withdraw without unstaking all programs for `tokenId`.
86
+ * @returns Calldata for unstaking, claiming, and withdrawing.
87
+ */
88
+ static withdrawToken(incentiveKeys: IncentiveKey | IncentiveKey[], withdrawOptions: FullWithdrawOptions): MethodParameters;
89
+ /**
90
+ *
91
+ * @param incentiveKeys A single IncentiveKey or array of IncentiveKeys to be encoded and used in the data parameter in `safeTransferFrom`
92
+ * @returns An IncentiveKey as a string
93
+ */
94
+ static encodeDeposit(incentiveKeys: IncentiveKey | IncentiveKey[]): string;
95
+ /**
96
+ *
97
+ * @param incentiveKey An `IncentiveKey` which represents a unique staking program.
98
+ * @returns An encoded IncentiveKey to be read by ethers
99
+ */
100
+ private static _encodeIncentiveKey;
101
+ }
@@ -0,0 +1,51 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { BigintIsh, Currency, Percent, TradeType } from '@uniswap/sdk-core';
3
+ import { Trade } from './entities/trade';
4
+ import { PermitOptions } from './selfPermit';
5
+ import { MethodParameters } from './utils/calldata';
6
+ import { FeeOptions } from './payments';
7
+ /**
8
+ * Options for producing the arguments to send calls to the router.
9
+ */
10
+ export interface SwapOptions {
11
+ /**
12
+ * How much the execution price is allowed to move unfavorably from the trade execution price.
13
+ */
14
+ slippageTolerance: Percent;
15
+ /**
16
+ * The account that should receive the output.
17
+ */
18
+ recipient: string;
19
+ /**
20
+ * When the transaction expires, in epoch seconds.
21
+ */
22
+ deadline: BigintIsh;
23
+ /**
24
+ * The optional permit parameters for spending the input.
25
+ */
26
+ inputTokenPermit?: PermitOptions;
27
+ /**
28
+ * The optional price limit for the trade.
29
+ */
30
+ sqrtPriceLimitX96?: BigintIsh;
31
+ /**
32
+ * Optional information for taking a fee on output.
33
+ */
34
+ fee?: FeeOptions;
35
+ }
36
+ /**
37
+ * Represents the Uniswap V3 SwapRouter, and has static methods for helping execute trades.
38
+ */
39
+ export declare abstract class SwapRouter {
40
+ static INTERFACE: Interface;
41
+ /**
42
+ * Cannot be constructed.
43
+ */
44
+ private constructor();
45
+ /**
46
+ * Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
47
+ * @param trade to produce call parameters for
48
+ * @param options options for the call parameters
49
+ */
50
+ static swapCallParameters(trades: Trade<Currency, Currency, TradeType> | Trade<Currency, Currency, TradeType>[], options: SwapOptions): MethodParameters;
51
+ }
@@ -0,0 +1,20 @@
1
+ import { BigintIsh } from '@uniswap/sdk-core';
2
+ /**
3
+ * Generated method parameters for executing a call.
4
+ */
5
+ export interface MethodParameters {
6
+ /**
7
+ * The hex encoded calldata to perform the given operation
8
+ */
9
+ calldata: string;
10
+ /**
11
+ * The amount of ether (wei) to send in hex.
12
+ */
13
+ value: string;
14
+ }
15
+ /**
16
+ * Converts a big int to a hex string
17
+ * @param bigintIsh
18
+ * @returns The hex encoded calldata
19
+ */
20
+ export declare function toHex(bigintIsh: BigintIsh): string;
@@ -0,0 +1,20 @@
1
+ import { ChainId, Token } from '@uniswap/sdk-core';
2
+ import { FeeAmount } from '../constants';
3
+ /**
4
+ * Computes a pool address
5
+ * @param factoryAddress The Uniswap V3 factory address
6
+ * @param tokenA The first token of the pair, irrespective of sort order
7
+ * @param tokenB The second token of the pair, irrespective of sort order
8
+ * @param fee The fee tier of the pool
9
+ * @param initCodeHashManualOverride Override the init code hash used to compute the pool address if necessary
10
+ * @param chainId
11
+ * @returns The pool address
12
+ */
13
+ export declare function computePoolAddress({ factoryAddress, tokenA, tokenB, fee, initCodeHashManualOverride, chainId, }: {
14
+ factoryAddress: string;
15
+ tokenA: Token;
16
+ tokenB: Token;
17
+ fee: FeeAmount;
18
+ initCodeHashManualOverride?: string;
19
+ chainId?: ChainId;
20
+ }): string;
@@ -0,0 +1,8 @@
1
+ import { Currency } from '@uniswap/sdk-core';
2
+ import { Route } from '../entities/route';
3
+ /**
4
+ * Converts a route to a hex encoded path
5
+ * @param route the v3 path to convert to an encoded path
6
+ * @param exactOutput whether the route should be encoded in reverse, for making exact output swaps
7
+ */
8
+ export declare function encodeRouteToPath(route: Route<Currency, Currency>, exactOutput: boolean): string;
@@ -0,0 +1,9 @@
1
+ import JSBI from 'jsbi';
2
+ import { BigintIsh } from '@uniswap/sdk-core';
3
+ /**
4
+ * Returns the sqrt ratio as a Q64.96 corresponding to a given ratio of amount1 and amount0
5
+ * @param amount1 The numerator amount i.e., the amount of token1
6
+ * @param amount0 The denominator amount i.e., the amount of token0
7
+ * @returns The sqrt ratio
8
+ */
9
+ export declare function encodeSqrtRatioX96(amount1: BigintIsh, amount0: BigintIsh): JSBI;
@@ -0,0 +1,8 @@
1
+ import JSBI from 'jsbi';
2
+ export declare abstract class FullMath {
3
+ /**
4
+ * Cannot be constructed.
5
+ */
6
+ private constructor();
7
+ static mulDivRoundingUp(a: JSBI, b: JSBI, denominator: JSBI): JSBI;
8
+ }
@@ -0,0 +1,18 @@
1
+ export * from './calldata';
2
+ export * from './computePoolAddress';
3
+ export * from './encodeRouteToPath';
4
+ export * from './encodeSqrtRatioX96';
5
+ export * from './fullMath';
6
+ export * from './isSorted';
7
+ export * from './liquidityMath';
8
+ export * from './maxLiquidityForAmounts';
9
+ export * from './mostSignificantBit';
10
+ export * from './nearestUsableTick';
11
+ export * from './position';
12
+ export * from './priceTickConversions';
13
+ export * from './sqrtPriceMath';
14
+ export * from './v3swap';
15
+ export * from './swapMath';
16
+ export * from './tickLibrary';
17
+ export * from './tickList';
18
+ export * from './tickMath';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Determines if a tick list is sorted
3
+ * @param list The tick list
4
+ * @param comparator The comparator
5
+ * @returns true if sorted
6
+ */
7
+ export declare function isSorted<T>(list: Array<T>, comparator: (a: T, b: T) => number): boolean;
@@ -0,0 +1,8 @@
1
+ import JSBI from 'jsbi';
2
+ export declare abstract class LiquidityMath {
3
+ /**
4
+ * Cannot be constructed.
5
+ */
6
+ private constructor();
7
+ static addDelta(x: JSBI, y: JSBI): JSBI;
8
+ }
@@ -0,0 +1,14 @@
1
+ import { BigintIsh } from '@uniswap/sdk-core';
2
+ import JSBI from 'jsbi';
3
+ /**
4
+ * Computes the maximum amount of liquidity received for a given amount of token0, token1,
5
+ * and the prices at the tick boundaries.
6
+ * @param sqrtRatioCurrentX96 the current price
7
+ * @param sqrtRatioAX96 price at lower boundary
8
+ * @param sqrtRatioBX96 price at upper boundary
9
+ * @param amount0 token0 amount
10
+ * @param amount1 token1 amount
11
+ * @param useFullPrecision if false, liquidity will be maximized according to what the router can calculate,
12
+ * not what core can theoretically support
13
+ */
14
+ export declare function maxLiquidityForAmounts(sqrtRatioCurrentX96: JSBI, sqrtRatioAX96: JSBI, sqrtRatioBX96: JSBI, amount0: BigintIsh, amount1: BigintIsh, useFullPrecision: boolean): JSBI;
@@ -0,0 +1,2 @@
1
+ import JSBI from 'jsbi';
2
+ export declare function mostSignificantBit(x: JSBI): number;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the closest tick that is nearest a given tick and usable for the given tick spacing
3
+ * @param tick the target tick
4
+ * @param tickSpacing the spacing of the pool
5
+ */
6
+ export declare function nearestUsableTick(tick: number, tickSpacing: number): number;
@@ -0,0 +1,8 @@
1
+ import JSBI from 'jsbi';
2
+ export declare abstract class PositionLibrary {
3
+ /**
4
+ * Cannot be constructed.
5
+ */
6
+ private constructor();
7
+ static getTokensOwed(feeGrowthInside0LastX128: JSBI, feeGrowthInside1LastX128: JSBI, liquidity: JSBI, feeGrowthInside0X128: JSBI, feeGrowthInside1X128: JSBI): JSBI[];
8
+ }
@@ -0,0 +1,15 @@
1
+ import { Price, Token } from '@uniswap/sdk-core';
2
+ /**
3
+ * Returns a price object corresponding to the input tick and the base/quote token
4
+ * Inputs must be tokens because the address order is used to interpret the price represented by the tick
5
+ * @param baseToken the base token of the price
6
+ * @param quoteToken the quote token of the price
7
+ * @param tick the tick for which to return the price
8
+ */
9
+ export declare function tickToPrice(baseToken: Token, quoteToken: Token, tick: number): Price<Token, Token>;
10
+ /**
11
+ * Returns the first tick for which the given price is greater than or equal to the tick price
12
+ * @param price for which to return the closest tick that represents a price less than or equal to the input price,
13
+ * i.e. the price of the returned tick is less than or equal to the input price
14
+ */
15
+ export declare function priceToClosestTick(price: Price<Token, Token>): number;
@@ -0,0 +1,13 @@
1
+ import JSBI from 'jsbi';
2
+ export declare abstract class SqrtPriceMath {
3
+ /**
4
+ * Cannot be constructed.
5
+ */
6
+ private constructor();
7
+ static getAmount0Delta(sqrtRatioAX96: JSBI, sqrtRatioBX96: JSBI, liquidity: JSBI, roundUp: boolean): JSBI;
8
+ static getAmount1Delta(sqrtRatioAX96: JSBI, sqrtRatioBX96: JSBI, liquidity: JSBI, roundUp: boolean): JSBI;
9
+ static getNextSqrtPriceFromInput(sqrtPX96: JSBI, liquidity: JSBI, amountIn: JSBI, zeroForOne: boolean): JSBI;
10
+ static getNextSqrtPriceFromOutput(sqrtPX96: JSBI, liquidity: JSBI, amountOut: JSBI, zeroForOne: boolean): JSBI;
11
+ private static getNextSqrtPriceFromAmount0RoundingUp;
12
+ private static getNextSqrtPriceFromAmount1RoundingDown;
13
+ }
@@ -0,0 +1,9 @@
1
+ import JSBI from 'jsbi';
2
+ import { FeeAmount } from '../constants';
3
+ export declare abstract class SwapMath {
4
+ /**
5
+ * Cannot be constructed.
6
+ */
7
+ private constructor();
8
+ static computeSwapStep(sqrtRatioCurrentX96: JSBI, sqrtRatioTargetX96: JSBI, liquidity: JSBI, amountRemaining: JSBI, feePips: JSBI | FeeAmount): [JSBI, JSBI, JSBI, JSBI];
9
+ }
@@ -0,0 +1,14 @@
1
+ import JSBI from 'jsbi';
2
+ interface FeeGrowthOutside {
3
+ feeGrowthOutside0X128: JSBI;
4
+ feeGrowthOutside1X128: JSBI;
5
+ }
6
+ export declare function subIn256(x: JSBI, y: JSBI): JSBI;
7
+ export declare abstract class TickLibrary {
8
+ /**
9
+ * Cannot be constructed.
10
+ */
11
+ private constructor();
12
+ static getFeeGrowthInside(feeGrowthOutsideLower: FeeGrowthOutside, feeGrowthOutsideUpper: FeeGrowthOutside, tickLower: number, tickUpper: number, tickCurrent: number, feeGrowthGlobal0X128: JSBI, feeGrowthGlobal1X128: JSBI): JSBI[];
13
+ }
14
+ export {};
@@ -0,0 +1,23 @@
1
+ import { Tick } from '../entities/tick';
2
+ /**
3
+ * Utility methods for interacting with sorted lists of ticks
4
+ */
5
+ export declare abstract class TickList {
6
+ /**
7
+ * Cannot be constructed
8
+ */
9
+ private constructor();
10
+ static validateList(ticks: Tick[], tickSpacing: number): void;
11
+ static isBelowSmallest(ticks: readonly Tick[], tick: number): boolean;
12
+ static isAtOrAboveLargest(ticks: readonly Tick[], tick: number): boolean;
13
+ static getTick(ticks: readonly Tick[], index: number): Tick;
14
+ /**
15
+ * Finds the largest tick in the list of ticks that is less than or equal to tick
16
+ * @param ticks list of ticks
17
+ * @param tick tick to find the largest tick that is less than or equal to tick
18
+ * @private
19
+ */
20
+ private static binarySearch;
21
+ static nextInitializedTick(ticks: readonly Tick[], tick: number, lte: boolean): Tick;
22
+ static nextInitializedTickWithinOneWord(ticks: readonly Tick[], tick: number, lte: boolean, tickSpacing: number): [number, boolean];
23
+ }
@@ -0,0 +1,34 @@
1
+ import JSBI from 'jsbi';
2
+ export declare abstract class TickMath {
3
+ /**
4
+ * Cannot be constructed.
5
+ */
6
+ private constructor();
7
+ /**
8
+ * The minimum tick that can be used on any pool.
9
+ */
10
+ static MIN_TICK: number;
11
+ /**
12
+ * The maximum tick that can be used on any pool.
13
+ */
14
+ static MAX_TICK: number;
15
+ /**
16
+ * The sqrt ratio corresponding to the minimum tick that could be used on any pool.
17
+ */
18
+ static MIN_SQRT_RATIO: JSBI;
19
+ /**
20
+ * The sqrt ratio corresponding to the maximum tick that could be used on any pool.
21
+ */
22
+ static MAX_SQRT_RATIO: JSBI;
23
+ /**
24
+ * Returns the sqrt ratio as a Q64.96 for the given tick. The sqrt ratio is computed as sqrt(1.0001)^tick
25
+ * @param tick the tick for which to compute the sqrt ratio
26
+ */
27
+ static getSqrtRatioAtTick(tick: number): JSBI;
28
+ /**
29
+ * Returns the tick corresponding to a given sqrt ratio, s.t. #getSqrtRatioAtTick(tick) <= sqrtRatioX96
30
+ * and #getSqrtRatioAtTick(tick + 1) > sqrtRatioX96
31
+ * @param sqrtRatioX96 the sqrt ratio as a Q64.96 for which to compute the tick
32
+ */
33
+ static getTickAtSqrtRatio(sqrtRatioX96: JSBI): number;
34
+ }