@kittycorn-labs/v4-sdk 1.1.30 → 2.0.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.
Files changed (197) hide show
  1. package/README.md +9 -0
  2. package/dist/{PositionManager.d.ts → cjs/src/PositionManager.d.ts} +169 -169
  3. package/dist/cjs/src/PositionManager.js +242 -0
  4. package/dist/cjs/src/PositionManager.js.map +1 -0
  5. package/dist/cjs/src/abis/IMulticall.json +23 -0
  6. package/dist/{actionConstants.d.ts → cjs/src/actionConstants.d.ts} +1 -1
  7. package/dist/cjs/src/actionConstants.js +6 -0
  8. package/dist/cjs/src/actionConstants.js.map +1 -0
  9. package/dist/{entities → cjs/src/entities}/index.d.ts +4 -4
  10. package/dist/cjs/src/entities/index.js +8 -0
  11. package/dist/cjs/src/entities/index.js.map +1 -0
  12. package/dist/{entities → cjs/src/entities}/pool.d.ts +103 -103
  13. package/dist/cjs/src/entities/pool.js +196 -0
  14. package/dist/cjs/src/entities/pool.js.map +1 -0
  15. package/dist/{entities → cjs/src/entities}/position.d.ts +144 -144
  16. package/dist/cjs/src/entities/position.js +273 -0
  17. package/dist/cjs/src/entities/position.js.map +1 -0
  18. package/dist/{entities → cjs/src/entities}/route.d.ts +28 -28
  19. package/dist/cjs/src/entities/route.js +89 -0
  20. package/dist/cjs/src/entities/route.js.map +1 -0
  21. package/dist/{entities → cjs/src/entities}/trade.d.ts +220 -220
  22. package/dist/cjs/src/entities/trade.js +441 -0
  23. package/dist/cjs/src/entities/trade.js.map +1 -0
  24. package/dist/{index.d.ts → cjs/src/index.d.ts} +4 -4
  25. package/dist/cjs/src/index.js +8 -0
  26. package/dist/cjs/src/index.js.map +1 -0
  27. package/dist/{internalConstants.d.ts → cjs/src/internalConstants.d.ts} +46 -46
  28. package/dist/cjs/src/internalConstants.js +69 -0
  29. package/dist/cjs/src/internalConstants.js.map +1 -0
  30. package/dist/{multicall.d.ts → cjs/src/multicall.d.ts} +10 -10
  31. package/dist/cjs/src/multicall.js +26 -0
  32. package/dist/cjs/src/multicall.js.map +1 -0
  33. package/dist/cjs/src/tokenize.d.ts +17 -0
  34. package/dist/cjs/src/tokenize.js +42 -0
  35. package/dist/cjs/src/tokenize.js.map +1 -0
  36. package/dist/{utils → cjs/src/utils}/calldata.d.ts +20 -20
  37. package/dist/cjs/src/utils/calldata.js +20 -0
  38. package/dist/cjs/src/utils/calldata.js.map +1 -0
  39. package/dist/{utils → cjs/src/utils}/currencyMap.d.ts +2 -2
  40. package/dist/cjs/src/utils/currencyMap.js +15 -0
  41. package/dist/cjs/src/utils/currencyMap.js.map +1 -0
  42. package/dist/{utils → cjs/src/utils}/encodeRouteToPath.d.ts +10 -10
  43. package/dist/cjs/src/utils/encodeRouteToPath.js +26 -0
  44. package/dist/cjs/src/utils/encodeRouteToPath.js.map +1 -0
  45. package/dist/{utils → cjs/src/utils}/hook.d.ts +45 -45
  46. package/dist/cjs/src/utils/hook.js +97 -0
  47. package/dist/cjs/src/utils/hook.js.map +1 -0
  48. package/dist/{utils → cjs/src/utils}/index.d.ts +11 -11
  49. package/dist/cjs/src/utils/index.js +15 -0
  50. package/dist/cjs/src/utils/index.js.map +1 -0
  51. package/dist/{utils → cjs/src/utils}/pathCurrency.d.ts +4 -4
  52. package/dist/cjs/src/utils/pathCurrency.js +27 -0
  53. package/dist/cjs/src/utils/pathCurrency.js.map +1 -0
  54. package/dist/{utils → cjs/src/utils}/positionManagerAbi.d.ts +102 -102
  55. package/dist/cjs/src/utils/positionManagerAbi.js +1318 -0
  56. package/dist/cjs/src/utils/positionManagerAbi.js.map +1 -0
  57. package/dist/{utils → cjs/src/utils}/priceTickConversions.d.ts +20 -20
  58. package/dist/cjs/src/utils/priceTickConversions.js +55 -0
  59. package/dist/cjs/src/utils/priceTickConversions.js.map +1 -0
  60. package/dist/{utils → cjs/src/utils}/sortsBefore.d.ts +2 -2
  61. package/dist/cjs/src/utils/sortsBefore.js +12 -0
  62. package/dist/cjs/src/utils/sortsBefore.js.map +1 -0
  63. package/dist/{utils → cjs/src/utils}/v4BaseActionsParser.d.ts +49 -45
  64. package/dist/cjs/src/utils/v4BaseActionsParser.js +193 -0
  65. package/dist/cjs/src/utils/v4BaseActionsParser.js.map +1 -0
  66. package/dist/{utils → cjs/src/utils}/v4Planner.d.ts +71 -55
  67. package/dist/cjs/src/utils/v4Planner.js +267 -0
  68. package/dist/cjs/src/utils/v4Planner.js.map +1 -0
  69. package/dist/{utils → cjs/src/utils}/v4PositionPlanner.d.ts +13 -12
  70. package/dist/cjs/src/utils/v4PositionPlanner.js +61 -0
  71. package/dist/cjs/src/utils/v4PositionPlanner.js.map +1 -0
  72. package/dist/esm/package.json +1 -0
  73. package/dist/esm/src/PositionManager.d.ts +169 -0
  74. package/dist/esm/src/PositionManager.js +237 -0
  75. package/dist/esm/src/PositionManager.js.map +1 -0
  76. package/dist/esm/src/abis/IMulticall.json +23 -0
  77. package/dist/esm/src/actionConstants.d.ts +1 -0
  78. package/dist/esm/src/actionConstants.js +3 -0
  79. package/dist/esm/src/actionConstants.js.map +1 -0
  80. package/dist/esm/src/entities/index.d.ts +4 -0
  81. package/dist/esm/src/entities/index.js +5 -0
  82. package/dist/esm/src/entities/index.js.map +1 -0
  83. package/dist/esm/src/entities/pool.d.ts +103 -0
  84. package/dist/esm/src/entities/pool.js +191 -0
  85. package/dist/esm/src/entities/pool.js.map +1 -0
  86. package/dist/esm/src/entities/position.d.ts +144 -0
  87. package/dist/esm/src/entities/position.js +268 -0
  88. package/dist/esm/src/entities/position.js.map +1 -0
  89. package/dist/esm/src/entities/route.d.ts +28 -0
  90. package/dist/esm/src/entities/route.js +84 -0
  91. package/dist/esm/src/entities/route.js.map +1 -0
  92. package/dist/esm/src/entities/trade.d.ts +220 -0
  93. package/dist/esm/src/entities/trade.js +435 -0
  94. package/dist/esm/src/entities/trade.js.map +1 -0
  95. package/dist/esm/src/index.d.ts +4 -0
  96. package/dist/esm/src/index.js +5 -0
  97. package/dist/esm/src/index.js.map +1 -0
  98. package/dist/esm/src/internalConstants.d.ts +46 -0
  99. package/dist/esm/src/internalConstants.js +65 -0
  100. package/dist/esm/src/internalConstants.js.map +1 -0
  101. package/dist/esm/src/multicall.d.ts +10 -0
  102. package/dist/esm/src/multicall.js +21 -0
  103. package/dist/esm/src/multicall.js.map +1 -0
  104. package/dist/esm/src/tokenize.d.ts +17 -0
  105. package/dist/esm/src/tokenize.js +37 -0
  106. package/dist/esm/src/tokenize.js.map +1 -0
  107. package/dist/esm/src/utils/calldata.d.ts +20 -0
  108. package/dist/esm/src/utils/calldata.js +15 -0
  109. package/dist/esm/src/utils/calldata.js.map +1 -0
  110. package/dist/esm/src/utils/currencyMap.d.ts +2 -0
  111. package/dist/esm/src/utils/currencyMap.js +11 -0
  112. package/dist/esm/src/utils/currencyMap.js.map +1 -0
  113. package/dist/esm/src/utils/encodeRouteToPath.d.ts +10 -0
  114. package/dist/esm/src/utils/encodeRouteToPath.js +22 -0
  115. package/dist/esm/src/utils/encodeRouteToPath.js.map +1 -0
  116. package/dist/esm/src/utils/hook.d.ts +45 -0
  117. package/dist/esm/src/utils/hook.js +92 -0
  118. package/dist/esm/src/utils/hook.js.map +1 -0
  119. package/dist/esm/src/utils/index.d.ts +11 -0
  120. package/dist/esm/src/utils/index.js +12 -0
  121. package/dist/esm/src/utils/index.js.map +1 -0
  122. package/dist/esm/src/utils/pathCurrency.d.ts +4 -0
  123. package/dist/esm/src/utils/pathCurrency.js +22 -0
  124. package/dist/esm/src/utils/pathCurrency.js.map +1 -0
  125. package/dist/esm/src/utils/positionManagerAbi.d.ts +102 -0
  126. package/dist/esm/src/utils/positionManagerAbi.js +1315 -0
  127. package/dist/esm/src/utils/positionManagerAbi.js.map +1 -0
  128. package/dist/esm/src/utils/priceTickConversions.d.ts +20 -0
  129. package/dist/esm/src/utils/priceTickConversions.js +49 -0
  130. package/dist/esm/src/utils/priceTickConversions.js.map +1 -0
  131. package/dist/esm/src/utils/sortsBefore.d.ts +2 -0
  132. package/dist/esm/src/utils/sortsBefore.js +8 -0
  133. package/dist/esm/src/utils/sortsBefore.js.map +1 -0
  134. package/dist/esm/src/utils/v4BaseActionsParser.d.ts +49 -0
  135. package/dist/esm/src/utils/v4BaseActionsParser.js +189 -0
  136. package/dist/esm/src/utils/v4BaseActionsParser.js.map +1 -0
  137. package/dist/esm/src/utils/v4Planner.d.ts +71 -0
  138. package/dist/esm/src/utils/v4Planner.js +261 -0
  139. package/dist/esm/src/utils/v4Planner.js.map +1 -0
  140. package/dist/esm/src/utils/v4PositionPlanner.d.ts +13 -0
  141. package/dist/esm/src/utils/v4PositionPlanner.js +57 -0
  142. package/dist/esm/src/utils/v4PositionPlanner.js.map +1 -0
  143. package/dist/types/src/PositionManager.d.ts +170 -0
  144. package/dist/types/src/PositionManager.d.ts.map +1 -0
  145. package/dist/types/src/actionConstants.d.ts +2 -0
  146. package/dist/types/src/actionConstants.d.ts.map +1 -0
  147. package/dist/types/src/entities/index.d.ts +5 -0
  148. package/dist/types/src/entities/index.d.ts.map +1 -0
  149. package/dist/types/src/entities/pool.d.ts +104 -0
  150. package/dist/types/src/entities/pool.d.ts.map +1 -0
  151. package/dist/types/src/entities/position.d.ts +145 -0
  152. package/dist/types/src/entities/position.d.ts.map +1 -0
  153. package/dist/types/src/entities/route.d.ts +29 -0
  154. package/dist/types/src/entities/route.d.ts.map +1 -0
  155. package/dist/types/src/entities/trade.d.ts +221 -0
  156. package/dist/types/src/entities/trade.d.ts.map +1 -0
  157. package/dist/types/src/index.d.ts +5 -0
  158. package/dist/types/src/index.d.ts.map +1 -0
  159. package/dist/types/src/internalConstants.d.ts +47 -0
  160. package/dist/types/src/internalConstants.d.ts.map +1 -0
  161. package/dist/types/src/multicall.d.ts +11 -0
  162. package/dist/types/src/multicall.d.ts.map +1 -0
  163. package/dist/types/src/tokenize.d.ts +18 -0
  164. package/dist/types/src/tokenize.d.ts.map +1 -0
  165. package/dist/types/src/utils/calldata.d.ts +21 -0
  166. package/dist/types/src/utils/calldata.d.ts.map +1 -0
  167. package/dist/types/src/utils/currencyMap.d.ts +3 -0
  168. package/dist/types/src/utils/currencyMap.d.ts.map +1 -0
  169. package/dist/types/src/utils/encodeRouteToPath.d.ts +11 -0
  170. package/dist/types/src/utils/encodeRouteToPath.d.ts.map +1 -0
  171. package/dist/types/src/utils/hook.d.ts +46 -0
  172. package/dist/types/src/utils/hook.d.ts.map +1 -0
  173. package/dist/types/src/utils/index.d.ts +12 -0
  174. package/dist/types/src/utils/index.d.ts.map +1 -0
  175. package/dist/types/src/utils/pathCurrency.d.ts +5 -0
  176. package/dist/types/src/utils/pathCurrency.d.ts.map +1 -0
  177. package/dist/types/src/utils/positionManagerAbi.d.ts +103 -0
  178. package/dist/types/src/utils/positionManagerAbi.d.ts.map +1 -0
  179. package/dist/types/src/utils/priceTickConversions.d.ts +21 -0
  180. package/dist/types/src/utils/priceTickConversions.d.ts.map +1 -0
  181. package/dist/types/src/utils/sortsBefore.d.ts +3 -0
  182. package/dist/types/src/utils/sortsBefore.d.ts.map +1 -0
  183. package/dist/types/src/utils/v4BaseActionsParser.d.ts +50 -0
  184. package/dist/types/src/utils/v4BaseActionsParser.d.ts.map +1 -0
  185. package/dist/types/src/utils/v4Planner.d.ts +72 -0
  186. package/dist/types/src/utils/v4Planner.d.ts.map +1 -0
  187. package/dist/types/src/utils/v4PositionPlanner.d.ts +14 -0
  188. package/dist/types/src/utils/v4PositionPlanner.d.ts.map +1 -0
  189. package/package.json +28 -46
  190. package/dist/index.js +0 -8
  191. package/dist/tokenizeAddresses.d.ts +0 -25
  192. package/dist/v4-sdk.cjs.development.js +0 -3633
  193. package/dist/v4-sdk.cjs.development.js.map +0 -1
  194. package/dist/v4-sdk.cjs.production.min.js +0 -2
  195. package/dist/v4-sdk.cjs.production.min.js.map +0 -1
  196. package/dist/v4-sdk.esm.js +0 -3597
  197. package/dist/v4-sdk.esm.js.map +0 -1
@@ -1,144 +1,144 @@
1
- import { BigintIsh, Percent, Price, CurrencyAmount, Currency } from '@kittycorn-labs/sdk-core';
2
- import JSBI from 'jsbi';
3
- import { Pool } from './pool';
4
- import { AllowanceTransferPermitBatch } from '../PositionManager';
5
- interface PositionConstructorArgs {
6
- pool: Pool;
7
- liquidity: BigintIsh;
8
- tickLower: number;
9
- tickUpper: number;
10
- }
11
- /**
12
- * Represents a position on a Uniswap V4 Pool
13
- * @dev Similar to the V3 implementation
14
- * - using Currency instead of Token
15
- * - keep in mind that Pool and liquidity must be fetched from the pool manager
16
- */
17
- export declare class Position {
18
- readonly pool: Pool;
19
- readonly tickLower: number;
20
- readonly tickUpper: number;
21
- readonly liquidity: JSBI;
22
- private _token0Amount;
23
- private _token1Amount;
24
- private _mintAmounts;
25
- /**
26
- * Constructs a position for a given pool with the given liquidity
27
- * @param pool For which pool the liquidity is assigned
28
- * @param liquidity The amount of liquidity that is in the position
29
- * @param tickLower The lower tick of the position
30
- * @param tickUpper The upper tick of the position
31
- */
32
- constructor({ pool, liquidity, tickLower, tickUpper }: PositionConstructorArgs);
33
- /**
34
- * Returns the price of token0 at the lower tick
35
- */
36
- get token0PriceLower(): Price<Currency, Currency>;
37
- /**
38
- * Returns the price of token0 at the upper tick
39
- */
40
- get token0PriceUpper(): Price<Currency, Currency>;
41
- /**
42
- * Returns the amount of token0 that this position's liquidity could be burned for at the current pool price
43
- */
44
- get amount0(): CurrencyAmount<Currency>;
45
- /**
46
- * Returns the amount of token1 that this position's liquidity could be burned for at the current pool price
47
- */
48
- get amount1(): CurrencyAmount<Currency>;
49
- /**
50
- * Returns the lower and upper sqrt ratios if the price 'slips' up to slippage tolerance percentage
51
- * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
52
- * @returns The sqrt ratios after slippage
53
- */
54
- private ratiosAfterSlippage;
55
- /**
56
- * Returns the maximum amount of token0 and token1 that must be sent in order to safely mint the amount of liquidity held by the position
57
- * with the given slippage tolerance
58
- * @param slippageTolerance Tolerance of unfavorable slippage from the current price
59
- * @returns The amounts, with slippage
60
- * @dev In v4, minting and increasing is protected by maximum amounts of token0 and token1.
61
- */
62
- mintAmountsWithSlippage(slippageTolerance: Percent): Readonly<{
63
- amount0: JSBI;
64
- amount1: JSBI;
65
- }>;
66
- /**
67
- * Returns the minimum amounts that should be requested in order to safely burn the amount of liquidity held by the
68
- * position with the given slippage tolerance
69
- * @param slippageTolerance tolerance of unfavorable slippage from the current price
70
- * @returns The amounts, with slippage
71
- */
72
- burnAmountsWithSlippage(slippageTolerance: Percent): Readonly<{
73
- amount0: JSBI;
74
- amount1: JSBI;
75
- }>;
76
- /**
77
- * Returns the minimum amounts that must be sent in order to mint the amount of liquidity held by the position at
78
- * the current price for the pool
79
- */
80
- get mintAmounts(): Readonly<{
81
- amount0: JSBI;
82
- amount1: JSBI;
83
- }>;
84
- /**
85
- * Returns the AllowanceTransferPermitBatch for adding liquidity to a position
86
- * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
87
- * @param spender The spender of the permit (should usually be the PositionManager)
88
- * @param nonce A valid permit2 nonce
89
- * @param deadline The deadline for the permit
90
- */
91
- permitBatchData(slippageTolerance: Percent, spender: string, nonce: BigintIsh, deadline: BigintIsh): AllowanceTransferPermitBatch;
92
- /**
93
- * Computes the maximum amount of liquidity received for a given amount of token0, token1,
94
- * and the prices at the tick boundaries.
95
- * @param pool The pool for which the position should be created
96
- * @param tickLower The lower tick of the position
97
- * @param tickUpper The upper tick of the position
98
- * @param amount0 token0 amountzw
99
- * @param amount1 token1 amount
100
- * @param useFullPrecision If false, liquidity will be maximized according to what the router can calculate,
101
- * not what core can theoretically support
102
- * @returns The amount of liquidity for the position
103
- */
104
- static fromAmounts({ pool, tickLower, tickUpper, amount0, amount1, useFullPrecision, }: {
105
- pool: Pool;
106
- tickLower: number;
107
- tickUpper: number;
108
- amount0: BigintIsh;
109
- amount1: BigintIsh;
110
- useFullPrecision: boolean;
111
- }): Position;
112
- /**
113
- * Computes a position with the maximum amount of liquidity received for a given amount of token0, assuming an unlimited amount of token1
114
- * @param pool The pool for which the position is created
115
- * @param tickLower The lower tick
116
- * @param tickUpper The upper tick
117
- * @param amount0 The desired amount of token0
118
- * @param useFullPrecision If true, liquidity will be maximized according to what the router can calculate,
119
- * not what core can theoretically support
120
- * @returns The position
121
- */
122
- static fromAmount0({ pool, tickLower, tickUpper, amount0, useFullPrecision, }: {
123
- pool: Pool;
124
- tickLower: number;
125
- tickUpper: number;
126
- amount0: BigintIsh;
127
- useFullPrecision: boolean;
128
- }): Position;
129
- /**
130
- * Computes a position with the maximum amount of liquidity received for a given amount of token1, assuming an unlimited amount of token0
131
- * @param pool The pool for which the position is created
132
- * @param tickLower The lower tick
133
- * @param tickUpper The upper tick
134
- * @param amount1 The desired amount of token1
135
- * @returns The position
136
- */
137
- static fromAmount1({ pool, tickLower, tickUpper, amount1, }: {
138
- pool: Pool;
139
- tickLower: number;
140
- tickUpper: number;
141
- amount1: BigintIsh;
142
- }): Position;
143
- }
144
- export {};
1
+ import { BigintIsh, Percent, Price, CurrencyAmount, Currency } from '@kittycorn-labs/sdk-core';
2
+ import JSBI from 'jsbi';
3
+ import { Pool } from './pool';
4
+ import { AllowanceTransferPermitBatch } from '../PositionManager';
5
+ interface PositionConstructorArgs {
6
+ pool: Pool;
7
+ liquidity: BigintIsh;
8
+ tickLower: number;
9
+ tickUpper: number;
10
+ }
11
+ /**
12
+ * Represents a position on a Uniswap V4 Pool
13
+ * @dev Similar to the V3 implementation
14
+ * - using Currency instead of Token
15
+ * - keep in mind that Pool and liquidity must be fetched from the pool manager
16
+ */
17
+ export declare class Position {
18
+ readonly pool: Pool;
19
+ readonly tickLower: number;
20
+ readonly tickUpper: number;
21
+ readonly liquidity: JSBI;
22
+ private _token0Amount;
23
+ private _token1Amount;
24
+ private _mintAmounts;
25
+ /**
26
+ * Constructs a position for a given pool with the given liquidity
27
+ * @param pool For which pool the liquidity is assigned
28
+ * @param liquidity The amount of liquidity that is in the position
29
+ * @param tickLower The lower tick of the position
30
+ * @param tickUpper The upper tick of the position
31
+ */
32
+ constructor({ pool, liquidity, tickLower, tickUpper }: PositionConstructorArgs);
33
+ /**
34
+ * Returns the price of token0 at the lower tick
35
+ */
36
+ get token0PriceLower(): Price<Currency, Currency>;
37
+ /**
38
+ * Returns the price of token0 at the upper tick
39
+ */
40
+ get token0PriceUpper(): Price<Currency, Currency>;
41
+ /**
42
+ * Returns the amount of token0 that this position's liquidity could be burned for at the current pool price
43
+ */
44
+ get amount0(): CurrencyAmount<Currency>;
45
+ /**
46
+ * Returns the amount of token1 that this position's liquidity could be burned for at the current pool price
47
+ */
48
+ get amount1(): CurrencyAmount<Currency>;
49
+ /**
50
+ * Returns the lower and upper sqrt ratios if the price 'slips' up to slippage tolerance percentage
51
+ * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
52
+ * @returns The sqrt ratios after slippage
53
+ */
54
+ private ratiosAfterSlippage;
55
+ /**
56
+ * Returns the maximum amount of token0 and token1 that must be sent in order to safely mint the amount of liquidity held by the position
57
+ * with the given slippage tolerance
58
+ * @param slippageTolerance Tolerance of unfavorable slippage from the current price
59
+ * @returns The amounts, with slippage
60
+ * @dev In v4, minting and increasing is protected by maximum amounts of token0 and token1.
61
+ */
62
+ mintAmountsWithSlippage(slippageTolerance: Percent): Readonly<{
63
+ amount0: JSBI;
64
+ amount1: JSBI;
65
+ }>;
66
+ /**
67
+ * Returns the minimum amounts that should be requested in order to safely burn the amount of liquidity held by the
68
+ * position with the given slippage tolerance
69
+ * @param slippageTolerance tolerance of unfavorable slippage from the current price
70
+ * @returns The amounts, with slippage
71
+ */
72
+ burnAmountsWithSlippage(slippageTolerance: Percent): Readonly<{
73
+ amount0: JSBI;
74
+ amount1: JSBI;
75
+ }>;
76
+ /**
77
+ * Returns the minimum amounts that must be sent in order to mint the amount of liquidity held by the position at
78
+ * the current price for the pool
79
+ */
80
+ get mintAmounts(): Readonly<{
81
+ amount0: JSBI;
82
+ amount1: JSBI;
83
+ }>;
84
+ /**
85
+ * Returns the AllowanceTransferPermitBatch for adding liquidity to a position
86
+ * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
87
+ * @param spender The spender of the permit (should usually be the PositionManager)
88
+ * @param nonce A valid permit2 nonce
89
+ * @param deadline The deadline for the permit
90
+ */
91
+ permitBatchData(slippageTolerance: Percent, spender: string, nonce: BigintIsh, deadline: BigintIsh): AllowanceTransferPermitBatch;
92
+ /**
93
+ * Computes the maximum amount of liquidity received for a given amount of token0, token1,
94
+ * and the prices at the tick boundaries.
95
+ * @param pool The pool for which the position should be created
96
+ * @param tickLower The lower tick of the position
97
+ * @param tickUpper The upper tick of the position
98
+ * @param amount0 token0 amountzw
99
+ * @param amount1 token1 amount
100
+ * @param useFullPrecision If false, liquidity will be maximized according to what the router can calculate,
101
+ * not what core can theoretically support
102
+ * @returns The amount of liquidity for the position
103
+ */
104
+ static fromAmounts({ pool, tickLower, tickUpper, amount0, amount1, useFullPrecision, }: {
105
+ pool: Pool;
106
+ tickLower: number;
107
+ tickUpper: number;
108
+ amount0: BigintIsh;
109
+ amount1: BigintIsh;
110
+ useFullPrecision: boolean;
111
+ }): Position;
112
+ /**
113
+ * Computes a position with the maximum amount of liquidity received for a given amount of token0, assuming an unlimited amount of token1
114
+ * @param pool The pool for which the position is created
115
+ * @param tickLower The lower tick
116
+ * @param tickUpper The upper tick
117
+ * @param amount0 The desired amount of token0
118
+ * @param useFullPrecision If true, liquidity will be maximized according to what the router can calculate,
119
+ * not what core can theoretically support
120
+ * @returns The position
121
+ */
122
+ static fromAmount0({ pool, tickLower, tickUpper, amount0, useFullPrecision, }: {
123
+ pool: Pool;
124
+ tickLower: number;
125
+ tickUpper: number;
126
+ amount0: BigintIsh;
127
+ useFullPrecision: boolean;
128
+ }): Position;
129
+ /**
130
+ * Computes a position with the maximum amount of liquidity received for a given amount of token1, assuming an unlimited amount of token0
131
+ * @param pool The pool for which the position is created
132
+ * @param tickLower The lower tick
133
+ * @param tickUpper The upper tick
134
+ * @param amount1 The desired amount of token1
135
+ * @returns The position
136
+ */
137
+ static fromAmount1({ pool, tickLower, tickUpper, amount1, }: {
138
+ pool: Pool;
139
+ tickLower: number;
140
+ tickUpper: number;
141
+ amount1: BigintIsh;
142
+ }): Position;
143
+ }
144
+ export {};
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Position = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const sdk_core_1 = require("@kittycorn-labs/sdk-core");
6
+ const jsbi_1 = tslib_1.__importDefault(require("jsbi"));
7
+ const tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
8
+ const pool_1 = require("./pool");
9
+ const v3_sdk_1 = require("@kittycorn-labs/v3-sdk");
10
+ const internalConstants_1 = require("../internalConstants");
11
+ const priceTickConversions_1 = require("../utils/priceTickConversions");
12
+ /**
13
+ * Represents a position on a Uniswap V4 Pool
14
+ * @dev Similar to the V3 implementation
15
+ * - using Currency instead of Token
16
+ * - keep in mind that Pool and liquidity must be fetched from the pool manager
17
+ */
18
+ class Position {
19
+ /**
20
+ * Constructs a position for a given pool with the given liquidity
21
+ * @param pool For which pool the liquidity is assigned
22
+ * @param liquidity The amount of liquidity that is in the position
23
+ * @param tickLower The lower tick of the position
24
+ * @param tickUpper The upper tick of the position
25
+ */
26
+ constructor({ pool, liquidity, tickLower, tickUpper }) {
27
+ // cached resuts for the getters
28
+ this._token0Amount = null;
29
+ this._token1Amount = null;
30
+ this._mintAmounts = null;
31
+ (0, tiny_invariant_1.default)(tickLower < tickUpper, 'TICK_ORDER');
32
+ (0, tiny_invariant_1.default)(tickLower >= v3_sdk_1.TickMath.MIN_TICK && tickLower % pool.tickSpacing === 0, 'TICK_LOWER');
33
+ (0, tiny_invariant_1.default)(tickUpper <= v3_sdk_1.TickMath.MAX_TICK && tickUpper % pool.tickSpacing === 0, 'TICK_UPPER');
34
+ this.pool = pool;
35
+ this.tickLower = tickLower;
36
+ this.tickUpper = tickUpper;
37
+ this.liquidity = jsbi_1.default.BigInt(liquidity);
38
+ }
39
+ /**
40
+ * Returns the price of token0 at the lower tick
41
+ */
42
+ get token0PriceLower() {
43
+ return (0, priceTickConversions_1.tickToPrice)(this.pool.currency0, this.pool.currency1, this.tickLower);
44
+ }
45
+ /**
46
+ * Returns the price of token0 at the upper tick
47
+ */
48
+ get token0PriceUpper() {
49
+ return (0, priceTickConversions_1.tickToPrice)(this.pool.currency0, this.pool.currency1, this.tickUpper);
50
+ }
51
+ /**
52
+ * Returns the amount of token0 that this position's liquidity could be burned for at the current pool price
53
+ */
54
+ get amount0() {
55
+ if (!this._token0Amount) {
56
+ if (this.pool.tickCurrent < this.tickLower) {
57
+ this._token0Amount = sdk_core_1.CurrencyAmount.fromRawAmount(this.pool.currency0, v3_sdk_1.SqrtPriceMath.getAmount0Delta(v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickLower), v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, false));
58
+ }
59
+ else if (this.pool.tickCurrent < this.tickUpper) {
60
+ this._token0Amount = sdk_core_1.CurrencyAmount.fromRawAmount(this.pool.currency0, v3_sdk_1.SqrtPriceMath.getAmount0Delta(this.pool.sqrtRatioX96, v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, false));
61
+ }
62
+ else {
63
+ this._token0Amount = sdk_core_1.CurrencyAmount.fromRawAmount(this.pool.currency0, internalConstants_1.ZERO);
64
+ }
65
+ }
66
+ return this._token0Amount;
67
+ }
68
+ /**
69
+ * Returns the amount of token1 that this position's liquidity could be burned for at the current pool price
70
+ */
71
+ get amount1() {
72
+ if (!this._token1Amount) {
73
+ if (this.pool.tickCurrent < this.tickLower) {
74
+ this._token1Amount = sdk_core_1.CurrencyAmount.fromRawAmount(this.pool.currency1, internalConstants_1.ZERO);
75
+ }
76
+ else if (this.pool.tickCurrent < this.tickUpper) {
77
+ this._token1Amount = sdk_core_1.CurrencyAmount.fromRawAmount(this.pool.currency1, v3_sdk_1.SqrtPriceMath.getAmount1Delta(v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickLower), this.pool.sqrtRatioX96, this.liquidity, false));
78
+ }
79
+ else {
80
+ this._token1Amount = sdk_core_1.CurrencyAmount.fromRawAmount(this.pool.currency1, v3_sdk_1.SqrtPriceMath.getAmount1Delta(v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickLower), v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, false));
81
+ }
82
+ }
83
+ return this._token1Amount;
84
+ }
85
+ /**
86
+ * Returns the lower and upper sqrt ratios if the price 'slips' up to slippage tolerance percentage
87
+ * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
88
+ * @returns The sqrt ratios after slippage
89
+ */
90
+ ratiosAfterSlippage(slippageTolerance) {
91
+ const priceLower = this.pool.token0Price.asFraction.multiply(new sdk_core_1.Percent(1).subtract(slippageTolerance));
92
+ const priceUpper = this.pool.token0Price.asFraction.multiply(slippageTolerance.add(1));
93
+ let sqrtRatioX96Lower = (0, v3_sdk_1.encodeSqrtRatioX96)(priceLower.numerator, priceLower.denominator);
94
+ if (jsbi_1.default.lessThanOrEqual(sqrtRatioX96Lower, v3_sdk_1.TickMath.MIN_SQRT_RATIO)) {
95
+ sqrtRatioX96Lower = jsbi_1.default.add(v3_sdk_1.TickMath.MIN_SQRT_RATIO, jsbi_1.default.BigInt(1));
96
+ }
97
+ let sqrtRatioX96Upper = (0, v3_sdk_1.encodeSqrtRatioX96)(priceUpper.numerator, priceUpper.denominator);
98
+ if (jsbi_1.default.greaterThanOrEqual(sqrtRatioX96Upper, v3_sdk_1.TickMath.MAX_SQRT_RATIO)) {
99
+ sqrtRatioX96Upper = jsbi_1.default.subtract(v3_sdk_1.TickMath.MAX_SQRT_RATIO, jsbi_1.default.BigInt(1));
100
+ }
101
+ return {
102
+ sqrtRatioX96Lower,
103
+ sqrtRatioX96Upper,
104
+ };
105
+ }
106
+ /**
107
+ * Returns the maximum amount of token0 and token1 that must be sent in order to safely mint the amount of liquidity held by the position
108
+ * with the given slippage tolerance
109
+ * @param slippageTolerance Tolerance of unfavorable slippage from the current price
110
+ * @returns The amounts, with slippage
111
+ * @dev In v4, minting and increasing is protected by maximum amounts of token0 and token1.
112
+ */
113
+ mintAmountsWithSlippage(slippageTolerance) {
114
+ // get lower/upper prices
115
+ // these represent the lowest and highest prices that the pool is allowed to "slip" to
116
+ const { sqrtRatioX96Upper, sqrtRatioX96Lower } = this.ratiosAfterSlippage(slippageTolerance);
117
+ // construct counterfactual pools from the lower bounded price and the upper bounded price
118
+ const poolLower = new pool_1.Pool(this.pool.token0, this.pool.token1, this.pool.fee, this.pool.tickSpacing, this.pool.hooks, sqrtRatioX96Lower, 0 /* liquidity doesn't matter */, v3_sdk_1.TickMath.getTickAtSqrtRatio(sqrtRatioX96Lower));
119
+ const poolUpper = new pool_1.Pool(this.pool.token0, this.pool.token1, this.pool.fee, this.pool.tickSpacing, this.pool.hooks, sqrtRatioX96Upper, 0 /* liquidity doesn't matter */, v3_sdk_1.TickMath.getTickAtSqrtRatio(sqrtRatioX96Upper));
120
+ // Note: Slippage derivation in v4 is different from v3.
121
+ // When creating a position (minting) or adding to a position (increasing) slippage is bounded by the MAXIMUM amount in in token0 and token1.
122
+ // The largest amount of token1 will happen when the price slips up, so we use the poolUpper to get amount1.
123
+ // The largest amount of token0 will happen when the price slips down, so we use the poolLower to get amount0.
124
+ // Ie...We want the larger amounts, which occurs at the upper price for amount1...
125
+ const { amount1 } = new Position({
126
+ pool: poolUpper,
127
+ liquidity: this.liquidity,
128
+ tickLower: this.tickLower,
129
+ tickUpper: this.tickUpper,
130
+ }).mintAmounts;
131
+ // ...and the lower for amount0
132
+ const { amount0 } = new Position({
133
+ pool: poolLower,
134
+ liquidity: this.liquidity,
135
+ tickLower: this.tickLower,
136
+ tickUpper: this.tickUpper,
137
+ }).mintAmounts;
138
+ return { amount0, amount1 };
139
+ }
140
+ /**
141
+ * Returns the minimum amounts that should be requested in order to safely burn the amount of liquidity held by the
142
+ * position with the given slippage tolerance
143
+ * @param slippageTolerance tolerance of unfavorable slippage from the current price
144
+ * @returns The amounts, with slippage
145
+ */
146
+ burnAmountsWithSlippage(slippageTolerance) {
147
+ // get lower/upper prices
148
+ const { sqrtRatioX96Upper, sqrtRatioX96Lower } = this.ratiosAfterSlippage(slippageTolerance);
149
+ // construct counterfactual pools
150
+ const poolLower = new pool_1.Pool(this.pool.currency0, this.pool.currency1, this.pool.fee, this.pool.tickSpacing, this.pool.hooks, sqrtRatioX96Lower, 0 /* liquidity doesn't matter */, v3_sdk_1.TickMath.getTickAtSqrtRatio(sqrtRatioX96Lower));
151
+ const poolUpper = new pool_1.Pool(this.pool.currency0, this.pool.currency1, this.pool.fee, this.pool.tickSpacing, this.pool.hooks, sqrtRatioX96Upper, 0 /* liquidity doesn't matter */, v3_sdk_1.TickMath.getTickAtSqrtRatio(sqrtRatioX96Upper));
152
+ // we want the smaller amounts...
153
+ // ...which occurs at the upper price for amount0...
154
+ const amount0 = new Position({
155
+ pool: poolUpper,
156
+ liquidity: this.liquidity,
157
+ tickLower: this.tickLower,
158
+ tickUpper: this.tickUpper,
159
+ }).amount0;
160
+ // ...and the lower for amount1
161
+ const amount1 = new Position({
162
+ pool: poolLower,
163
+ liquidity: this.liquidity,
164
+ tickLower: this.tickLower,
165
+ tickUpper: this.tickUpper,
166
+ }).amount1;
167
+ return { amount0: amount0.quotient, amount1: amount1.quotient };
168
+ }
169
+ /**
170
+ * Returns the minimum amounts that must be sent in order to mint the amount of liquidity held by the position at
171
+ * the current price for the pool
172
+ */
173
+ get mintAmounts() {
174
+ if (this._mintAmounts === null) {
175
+ if (this.pool.tickCurrent < this.tickLower) {
176
+ return {
177
+ amount0: v3_sdk_1.SqrtPriceMath.getAmount0Delta(v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickLower), v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, true),
178
+ amount1: internalConstants_1.ZERO,
179
+ };
180
+ }
181
+ else if (this.pool.tickCurrent < this.tickUpper) {
182
+ return {
183
+ amount0: v3_sdk_1.SqrtPriceMath.getAmount0Delta(this.pool.sqrtRatioX96, v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, true),
184
+ amount1: v3_sdk_1.SqrtPriceMath.getAmount1Delta(v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickLower), this.pool.sqrtRatioX96, this.liquidity, true),
185
+ };
186
+ }
187
+ else {
188
+ return {
189
+ amount0: internalConstants_1.ZERO,
190
+ amount1: v3_sdk_1.SqrtPriceMath.getAmount1Delta(v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickLower), v3_sdk_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, true),
191
+ };
192
+ }
193
+ }
194
+ return this._mintAmounts;
195
+ }
196
+ /**
197
+ * Returns the AllowanceTransferPermitBatch for adding liquidity to a position
198
+ * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
199
+ * @param spender The spender of the permit (should usually be the PositionManager)
200
+ * @param nonce A valid permit2 nonce
201
+ * @param deadline The deadline for the permit
202
+ */
203
+ permitBatchData(slippageTolerance, spender, nonce, deadline) {
204
+ const { amount0, amount1 } = this.mintAmountsWithSlippage(slippageTolerance);
205
+ return {
206
+ details: [
207
+ {
208
+ token: this.pool.currency0.wrapped.address,
209
+ amount: amount0,
210
+ expiration: deadline,
211
+ nonce: nonce,
212
+ },
213
+ {
214
+ token: this.pool.currency1.wrapped.address,
215
+ amount: amount1,
216
+ expiration: deadline,
217
+ nonce: nonce,
218
+ },
219
+ ],
220
+ spender,
221
+ sigDeadline: deadline,
222
+ };
223
+ }
224
+ /**
225
+ * Computes the maximum amount of liquidity received for a given amount of token0, token1,
226
+ * and the prices at the tick boundaries.
227
+ * @param pool The pool for which the position should be created
228
+ * @param tickLower The lower tick of the position
229
+ * @param tickUpper The upper tick of the position
230
+ * @param amount0 token0 amountzw
231
+ * @param amount1 token1 amount
232
+ * @param useFullPrecision If false, liquidity will be maximized according to what the router can calculate,
233
+ * not what core can theoretically support
234
+ * @returns The amount of liquidity for the position
235
+ */
236
+ static fromAmounts({ pool, tickLower, tickUpper, amount0, amount1, useFullPrecision, }) {
237
+ const sqrtRatioAX96 = v3_sdk_1.TickMath.getSqrtRatioAtTick(tickLower);
238
+ const sqrtRatioBX96 = v3_sdk_1.TickMath.getSqrtRatioAtTick(tickUpper);
239
+ return new Position({
240
+ pool,
241
+ tickLower,
242
+ tickUpper,
243
+ liquidity: (0, v3_sdk_1.maxLiquidityForAmounts)(pool.sqrtRatioX96, sqrtRatioAX96, sqrtRatioBX96, amount0, amount1, useFullPrecision),
244
+ });
245
+ }
246
+ /**
247
+ * Computes a position with the maximum amount of liquidity received for a given amount of token0, assuming an unlimited amount of token1
248
+ * @param pool The pool for which the position is created
249
+ * @param tickLower The lower tick
250
+ * @param tickUpper The upper tick
251
+ * @param amount0 The desired amount of token0
252
+ * @param useFullPrecision If true, liquidity will be maximized according to what the router can calculate,
253
+ * not what core can theoretically support
254
+ * @returns The position
255
+ */
256
+ static fromAmount0({ pool, tickLower, tickUpper, amount0, useFullPrecision, }) {
257
+ return Position.fromAmounts({ pool, tickLower, tickUpper, amount0, amount1: sdk_core_1.MaxUint256, useFullPrecision });
258
+ }
259
+ /**
260
+ * Computes a position with the maximum amount of liquidity received for a given amount of token1, assuming an unlimited amount of token0
261
+ * @param pool The pool for which the position is created
262
+ * @param tickLower The lower tick
263
+ * @param tickUpper The upper tick
264
+ * @param amount1 The desired amount of token1
265
+ * @returns The position
266
+ */
267
+ static fromAmount1({ pool, tickLower, tickUpper, amount1, }) {
268
+ // this function always uses full precision,
269
+ return Position.fromAmounts({ pool, tickLower, tickUpper, amount0: sdk_core_1.MaxUint256, amount1, useFullPrecision: true });
270
+ }
271
+ }
272
+ exports.Position = Position;
273
+ //# sourceMappingURL=position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.js","sourceRoot":"","sources":["../../../../src/entities/position.ts"],"names":[],"mapp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ool';
3
- /**
4
- * Represents a list of pools through which a swap can occur
5
- * @template TInput The input currency
6
- * @template TOutput The output currency
7
- */
8
- export declare class Route<TInput extends Currency, TOutput extends Currency> {
9
- readonly pools: Pool[];
10
- readonly currencyPath: Currency[];
11
- readonly input: TInput;
12
- readonly output: TOutput;
13
- readonly pathInput: Currency;
14
- readonly pathOutput: Currency;
15
- private _midPrice;
16
- /**
17
- * Creates an instance of route.
18
- * @param pools An array of `Pool` objects, ordered by the route the swap will take
19
- * @param input The input currency
20
- * @param output The output currency
21
- */
22
- constructor(pools: Pool[], input: TInput, output: TOutput);
23
- get chainId(): number;
24
- /**
25
- * Returns the mid price of the route
26
- */
27
- get midPrice(): Price<TInput, TOutput>;
28
- }
1
+ import { Currency, Price } from '@kittycorn-labs/sdk-core';
2
+ import { Pool } from './pool';
3
+ /**
4
+ * Represents a list of pools through which a swap can occur
5
+ * @template TInput The input currency
6
+ * @template TOutput The output currency
7
+ */
8
+ export declare class Route<TInput extends Currency, TOutput extends Currency> {
9
+ readonly pools: Pool[];
10
+ readonly currencyPath: Currency[];
11
+ readonly input: TInput;
12
+ readonly output: TOutput;
13
+ readonly pathInput: Currency;
14
+ readonly pathOutput: Currency;
15
+ private _midPrice;
16
+ /**
17
+ * Creates an instance of route.
18
+ * @param pools An array of `Pool` objects, ordered by the route the swap will take
19
+ * @param input The input currency
20
+ * @param output The output currency
21
+ */
22
+ constructor(pools: Pool[], input: TInput, output: TOutput);
23
+ get chainId(): number;
24
+ /**
25
+ * Returns the mid price of the route
26
+ */
27
+ get midPrice(): Price<TInput, TOutput>;
28
+ }