@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
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./pool"), exports);
5
+ tslib_1.__exportStar(require("./route"), exports);
6
+ tslib_1.__exportStar(require("./trade"), exports);
7
+ tslib_1.__exportStar(require("./position"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/entities/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB;AACtB,kDAAuB;AACvB,kDAAuB;AACvB,qDAA0B"}
@@ -1,103 +1,103 @@
1
- import { BigintIsh, Currency, CurrencyAmount, Price } from '@kittycorn-labs/sdk-core';
2
- import { Tick, TickConstructorArgs, TickDataProvider } from '@kittycorn-labs/v3-sdk';
3
- import JSBI from 'jsbi';
4
- export declare const DYNAMIC_FEE_FLAG = 8388608;
5
- export declare type PoolKey = {
6
- currency0: string;
7
- currency1: string;
8
- fee: number;
9
- tickSpacing: number;
10
- hooks: string;
11
- };
12
- /**
13
- * Represents a V4 pool
14
- */
15
- export declare class Pool {
16
- readonly currency0: Currency;
17
- readonly currency1: Currency;
18
- readonly fee: number;
19
- readonly tickSpacing: number;
20
- readonly sqrtRatioX96: JSBI;
21
- readonly hooks: string;
22
- readonly liquidity: JSBI;
23
- readonly tickCurrent: number;
24
- readonly tickDataProvider: TickDataProvider;
25
- readonly poolKey: PoolKey;
26
- readonly poolId: string;
27
- private _currency0Price?;
28
- private _currency1Price?;
29
- static getPoolKey(currencyA: Currency, currencyB: Currency, fee: number, tickSpacing: number, hooks: string): PoolKey;
30
- static getPoolId(currencyA: Currency, currencyB: Currency, fee: number, tickSpacing: number, hooks: string): string;
31
- /**
32
- * Construct a pool
33
- * @param currencyA One of the currencys in the pool
34
- * @param currencyB The other currency in the pool
35
- * @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool
36
- * @param tickSpacing The tickSpacing of the pool
37
- * @param hooks The address of the hook contract
38
- * @param sqrtRatioX96 The sqrt of the current ratio of amounts of currency1 to currency0
39
- * @param liquidity The current value of in range liquidity
40
- * @param tickCurrent The current tick of the pool
41
- */
42
- constructor(currencyA: Currency, currencyB: Currency, fee: number, tickSpacing: number, hooks: string, sqrtRatioX96: BigintIsh, liquidity: BigintIsh, tickCurrent: number, ticks?: TickDataProvider | (Tick | TickConstructorArgs)[]);
43
- /** backwards compatibility with v2/3 sdks */
44
- get token0(): Currency;
45
- get token1(): Currency;
46
- /**
47
- * Returns true if the currency is either currency0 or currency1
48
- * @param currency The currency to check
49
- * @returns True if currency is either currency0 or currency1
50
- */
51
- involvesCurrency(currency: Currency): boolean;
52
- /** backwards compatibility with v2/3 sdks */
53
- involvesToken(currency: Currency): boolean;
54
- /**
55
- * v4-only involvesToken convenience method, used for mixed route ETH <-> WETH connection only
56
- * @param currency
57
- */
58
- v4InvolvesToken(currency: Currency): boolean;
59
- /**
60
- * Returns the current mid price of the pool in terms of currency0, i.e. the ratio of currency1 over currency0
61
- */
62
- get currency0Price(): Price<Currency, Currency>;
63
- /** backwards compatibility with v2/3 sdks */
64
- get token0Price(): Price<Currency, Currency>;
65
- /**
66
- * Returns the current mid price of the pool in terms of currency1, i.e. the ratio of currency0 over currency1
67
- */
68
- get currency1Price(): Price<Currency, Currency>;
69
- /** backwards compatibility with v2/3 sdks */
70
- get token1Price(): Price<Currency, Currency>;
71
- /**
72
- * Return the price of the given currency in terms of the other currency in the pool.
73
- * @param currency The currency to return price of
74
- * @returns The price of the given currency, in terms of the other.
75
- */
76
- priceOf(currency: Currency): Price<Currency, Currency>;
77
- /**
78
- * Returns the chain ID of the currencies in the pool.
79
- */
80
- get chainId(): number;
81
- /** Works only for vanilla hookless v3 pools, otherwise throws an error */
82
- getOutputAmount(inputAmount: CurrencyAmount<Currency>, sqrtPriceLimitX96?: JSBI): Promise<[CurrencyAmount<Currency>, Pool]>;
83
- /**
84
- * Given a desired output amount of a currency, return the computed input amount and a pool with state updated after the trade
85
- * Works only for vanilla hookless v3 pools, otherwise throws an error
86
- * @param outputAmount the output amount for which to quote the input amount
87
- * @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
88
- * @returns The input amount and the pool with updated state
89
- */
90
- getInputAmount(outputAmount: CurrencyAmount<Currency>, sqrtPriceLimitX96?: JSBI): Promise<[CurrencyAmount<Currency>, Pool]>;
91
- /**
92
- * Executes a swap
93
- * @param zeroForOne Whether the amount in is token0 or token1
94
- * @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
95
- * @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
96
- * @returns amountCalculated
97
- * @returns sqrtRatioX96
98
- * @returns liquidity
99
- * @returns tickCurrent
100
- */
101
- private swap;
102
- private hookImpactsSwap;
103
- }
1
+ import { BigintIsh, Currency, CurrencyAmount, Price } from '@kittycorn-labs/sdk-core';
2
+ import { Tick, TickConstructorArgs, TickDataProvider } from '@kittycorn-labs/v3-sdk';
3
+ import JSBI from 'jsbi';
4
+ export declare const DYNAMIC_FEE_FLAG = 8388608;
5
+ export type PoolKey = {
6
+ currency0: string;
7
+ currency1: string;
8
+ fee: number;
9
+ tickSpacing: number;
10
+ hooks: string;
11
+ };
12
+ /**
13
+ * Represents a V4 pool
14
+ */
15
+ export declare class Pool {
16
+ readonly currency0: Currency;
17
+ readonly currency1: Currency;
18
+ readonly fee: number;
19
+ readonly tickSpacing: number;
20
+ readonly sqrtRatioX96: JSBI;
21
+ readonly hooks: string;
22
+ readonly liquidity: JSBI;
23
+ readonly tickCurrent: number;
24
+ readonly tickDataProvider: TickDataProvider;
25
+ readonly poolKey: PoolKey;
26
+ readonly poolId: string;
27
+ private _currency0Price?;
28
+ private _currency1Price?;
29
+ static getPoolKey(currencyA: Currency, currencyB: Currency, fee: number, tickSpacing: number, hooks: string): PoolKey;
30
+ static getPoolId(currencyA: Currency, currencyB: Currency, fee: number, tickSpacing: number, hooks: string): string;
31
+ /**
32
+ * Construct a pool
33
+ * @param currencyA One of the currencys in the pool
34
+ * @param currencyB The other currency in the pool
35
+ * @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool
36
+ * @param tickSpacing The tickSpacing of the pool
37
+ * @param hooks The address of the hook contract
38
+ * @param sqrtRatioX96 The sqrt of the current ratio of amounts of currency1 to currency0
39
+ * @param liquidity The current value of in range liquidity
40
+ * @param tickCurrent The current tick of the pool
41
+ */
42
+ constructor(currencyA: Currency, currencyB: Currency, fee: number, tickSpacing: number, hooks: string, sqrtRatioX96: BigintIsh, liquidity: BigintIsh, tickCurrent: number, ticks?: TickDataProvider | (Tick | TickConstructorArgs)[]);
43
+ /** backwards compatibility with v2/3 sdks */
44
+ get token0(): Currency;
45
+ get token1(): Currency;
46
+ /**
47
+ * Returns true if the currency is either currency0 or currency1
48
+ * @param currency The currency to check
49
+ * @returns True if currency is either currency0 or currency1
50
+ */
51
+ involvesCurrency(currency: Currency): boolean;
52
+ /** backwards compatibility with v2/3 sdks */
53
+ involvesToken(currency: Currency): boolean;
54
+ /**
55
+ * v4-only involvesToken convenience method, used for mixed route ETH <-> WETH connection only
56
+ * @param currency
57
+ */
58
+ v4InvolvesToken(currency: Currency): boolean;
59
+ /**
60
+ * Returns the current mid price of the pool in terms of currency0, i.e. the ratio of currency1 over currency0
61
+ */
62
+ get currency0Price(): Price<Currency, Currency>;
63
+ /** backwards compatibility with v2/3 sdks */
64
+ get token0Price(): Price<Currency, Currency>;
65
+ /**
66
+ * Returns the current mid price of the pool in terms of currency1, i.e. the ratio of currency0 over currency1
67
+ */
68
+ get currency1Price(): Price<Currency, Currency>;
69
+ /** backwards compatibility with v2/3 sdks */
70
+ get token1Price(): Price<Currency, Currency>;
71
+ /**
72
+ * Return the price of the given currency in terms of the other currency in the pool.
73
+ * @param currency The currency to return price of
74
+ * @returns The price of the given currency, in terms of the other.
75
+ */
76
+ priceOf(currency: Currency): Price<Currency, Currency>;
77
+ /**
78
+ * Returns the chain ID of the currencies in the pool.
79
+ */
80
+ get chainId(): number;
81
+ /** Works only for vanilla hookless v3 pools, otherwise throws an error */
82
+ getOutputAmount(inputAmount: CurrencyAmount<Currency>, sqrtPriceLimitX96?: JSBI): Promise<[CurrencyAmount<Currency>, Pool]>;
83
+ /**
84
+ * Given a desired output amount of a currency, return the computed input amount and a pool with state updated after the trade
85
+ * Works only for vanilla hookless v3 pools, otherwise throws an error
86
+ * @param outputAmount the output amount for which to quote the input amount
87
+ * @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
88
+ * @returns The input amount and the pool with updated state
89
+ */
90
+ getInputAmount(outputAmount: CurrencyAmount<Currency>, sqrtPriceLimitX96?: JSBI): Promise<[CurrencyAmount<Currency>, Pool]>;
91
+ /**
92
+ * Executes a swap
93
+ * @param zeroForOne Whether the amount in is token0 or token1
94
+ * @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
95
+ * @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
96
+ * @returns amountCalculated
97
+ * @returns sqrtRatioX96
98
+ * @returns liquidity
99
+ * @returns tickCurrent
100
+ */
101
+ private swap;
102
+ private hookImpactsSwap;
103
+ }
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Pool = exports.DYNAMIC_FEE_FLAG = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
6
+ const solidity_1 = require("@ethersproject/solidity");
7
+ const sdk_core_1 = require("@kittycorn-labs/sdk-core");
8
+ const v3_sdk_1 = require("@kittycorn-labs/v3-sdk");
9
+ const abi_1 = require("@ethersproject/abi");
10
+ const address_1 = require("@ethersproject/address");
11
+ const sortsBefore_1 = require("../utils/sortsBefore");
12
+ const hook_1 = require("../utils/hook");
13
+ const internalConstants_1 = require("../internalConstants");
14
+ const jsbi_1 = tslib_1.__importDefault(require("jsbi"));
15
+ exports.DYNAMIC_FEE_FLAG = 0x800000;
16
+ const NO_TICK_DATA_PROVIDER_DEFAULT = new v3_sdk_1.NoTickDataProvider();
17
+ /**
18
+ * Represents a V4 pool
19
+ */
20
+ class Pool {
21
+ static getPoolKey(currencyA, currencyB, fee, tickSpacing, hooks) {
22
+ (0, tiny_invariant_1.default)((0, address_1.isAddress)(hooks), 'Invalid hook address');
23
+ const [currency0, currency1] = (0, sortsBefore_1.sortsBefore)(currencyA, currencyB) ? [currencyA, currencyB] : [currencyB, currencyA];
24
+ const currency0Addr = currency0.isNative ? internalConstants_1.ADDRESS_ZERO : currency0.wrapped.address;
25
+ const currency1Addr = currency1.isNative ? internalConstants_1.ADDRESS_ZERO : currency1.wrapped.address;
26
+ return {
27
+ currency0: currency0Addr,
28
+ currency1: currency1Addr,
29
+ fee,
30
+ tickSpacing,
31
+ hooks,
32
+ };
33
+ }
34
+ static getPoolId(currencyA, currencyB, fee, tickSpacing, hooks) {
35
+ const [currency0, currency1] = (0, sortsBefore_1.sortsBefore)(currencyA, currencyB) ? [currencyA, currencyB] : [currencyB, currencyA];
36
+ const currency0Addr = currency0.isNative ? internalConstants_1.ADDRESS_ZERO : currency0.wrapped.address;
37
+ const currency1Addr = currency1.isNative ? internalConstants_1.ADDRESS_ZERO : currency1.wrapped.address;
38
+ return (0, solidity_1.keccak256)(['bytes'], [
39
+ abi_1.defaultAbiCoder.encode(['address', 'address', 'uint24', 'int24', 'address'], [currency0Addr, currency1Addr, fee, tickSpacing, hooks]),
40
+ ]);
41
+ }
42
+ /**
43
+ * Construct a pool
44
+ * @param currencyA One of the currencys in the pool
45
+ * @param currencyB The other currency in the pool
46
+ * @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool
47
+ * @param tickSpacing The tickSpacing of the pool
48
+ * @param hooks The address of the hook contract
49
+ * @param sqrtRatioX96 The sqrt of the current ratio of amounts of currency1 to currency0
50
+ * @param liquidity The current value of in range liquidity
51
+ * @param tickCurrent The current tick of the pool
52
+ */
53
+ constructor(currencyA, currencyB, fee, tickSpacing, hooks, sqrtRatioX96, liquidity, tickCurrent, ticks = NO_TICK_DATA_PROVIDER_DEFAULT) {
54
+ (0, tiny_invariant_1.default)((0, address_1.isAddress)(hooks), 'Invalid hook address');
55
+ (0, tiny_invariant_1.default)(Number.isInteger(fee) && (fee === exports.DYNAMIC_FEE_FLAG || fee < 1000000), 'FEE');
56
+ if (fee === exports.DYNAMIC_FEE_FLAG) {
57
+ (0, tiny_invariant_1.default)(Number(hooks) > 0, 'Dynamic fee pool requires a hook');
58
+ }
59
+ const tickCurrentSqrtRatioX96 = v3_sdk_1.TickMath.getSqrtRatioAtTick(tickCurrent);
60
+ const nextTickSqrtRatioX96 = v3_sdk_1.TickMath.getSqrtRatioAtTick(tickCurrent + 1);
61
+ (0, tiny_invariant_1.default)(jsbi_1.default.greaterThanOrEqual(jsbi_1.default.BigInt(sqrtRatioX96), tickCurrentSqrtRatioX96) &&
62
+ jsbi_1.default.lessThanOrEqual(jsbi_1.default.BigInt(sqrtRatioX96), nextTickSqrtRatioX96), 'PRICE_BOUNDS');
63
+ [this.currency0, this.currency1] = (0, sortsBefore_1.sortsBefore)(currencyA, currencyB)
64
+ ? [currencyA, currencyB]
65
+ : [currencyB, currencyA];
66
+ this.fee = fee;
67
+ this.sqrtRatioX96 = jsbi_1.default.BigInt(sqrtRatioX96);
68
+ this.tickSpacing = tickSpacing;
69
+ this.hooks = hooks;
70
+ this.liquidity = jsbi_1.default.BigInt(liquidity);
71
+ this.tickCurrent = tickCurrent;
72
+ this.tickDataProvider = Array.isArray(ticks) ? new v3_sdk_1.TickListDataProvider(ticks, tickSpacing) : ticks;
73
+ this.poolKey = Pool.getPoolKey(this.currency0, this.currency1, this.fee, this.tickSpacing, this.hooks);
74
+ this.poolId = Pool.getPoolId(this.currency0, this.currency1, this.fee, this.tickSpacing, this.hooks);
75
+ }
76
+ /** backwards compatibility with v2/3 sdks */
77
+ get token0() {
78
+ return this.currency0;
79
+ }
80
+ get token1() {
81
+ return this.currency1;
82
+ }
83
+ /**
84
+ * Returns true if the currency is either currency0 or currency1
85
+ * @param currency The currency to check
86
+ * @returns True if currency is either currency0 or currency1
87
+ */
88
+ involvesCurrency(currency) {
89
+ return currency.equals(this.currency0) || currency.equals(this.currency1);
90
+ }
91
+ /** backwards compatibility with v2/3 sdks */
92
+ involvesToken(currency) {
93
+ return this.involvesCurrency(currency);
94
+ }
95
+ /**
96
+ * v4-only involvesToken convenience method, used for mixed route ETH <-> WETH connection only
97
+ * @param currency
98
+ */
99
+ v4InvolvesToken(currency) {
100
+ return (this.involvesCurrency(currency) ||
101
+ currency.wrapped.equals(this.currency0) ||
102
+ currency.wrapped.equals(this.currency1) ||
103
+ currency.wrapped.equals(this.currency0.wrapped) ||
104
+ currency.wrapped.equals(this.currency1.wrapped));
105
+ }
106
+ /**
107
+ * Returns the current mid price of the pool in terms of currency0, i.e. the ratio of currency1 over currency0
108
+ */
109
+ get currency0Price() {
110
+ var _a;
111
+ return ((_a = this._currency0Price) !== null && _a !== void 0 ? _a : (this._currency0Price = new sdk_core_1.Price(this.currency0, this.currency1, internalConstants_1.Q192, jsbi_1.default.multiply(this.sqrtRatioX96, this.sqrtRatioX96))));
112
+ }
113
+ /** backwards compatibility with v2/3 sdks */
114
+ get token0Price() {
115
+ return this.currency0Price;
116
+ }
117
+ /**
118
+ * Returns the current mid price of the pool in terms of currency1, i.e. the ratio of currency0 over currency1
119
+ */
120
+ get currency1Price() {
121
+ var _a;
122
+ return ((_a = this._currency1Price) !== null && _a !== void 0 ? _a : (this._currency1Price = new sdk_core_1.Price(this.currency1, this.currency0, jsbi_1.default.multiply(this.sqrtRatioX96, this.sqrtRatioX96), internalConstants_1.Q192)));
123
+ }
124
+ /** backwards compatibility with v2/3 sdks */
125
+ get token1Price() {
126
+ return this.currency1Price;
127
+ }
128
+ /**
129
+ * Return the price of the given currency in terms of the other currency in the pool.
130
+ * @param currency The currency to return price of
131
+ * @returns The price of the given currency, in terms of the other.
132
+ */
133
+ priceOf(currency) {
134
+ (0, tiny_invariant_1.default)(this.involvesCurrency(currency), 'CURRENCY');
135
+ return currency.equals(this.currency0) ? this.currency0Price : this.currency1Price;
136
+ }
137
+ /**
138
+ * Returns the chain ID of the currencies in the pool.
139
+ */
140
+ get chainId() {
141
+ return this.currency0.chainId;
142
+ }
143
+ /** Works only for vanilla hookless v3 pools, otherwise throws an error */
144
+ async getOutputAmount(inputAmount, sqrtPriceLimitX96) {
145
+ (0, tiny_invariant_1.default)(this.involvesCurrency(inputAmount.currency), 'CURRENCY');
146
+ const zeroForOne = inputAmount.currency.equals(this.currency0);
147
+ const { amountCalculated: outputAmount, sqrtRatioX96, liquidity, tickCurrent, } = await this.swap(zeroForOne, inputAmount.quotient, sqrtPriceLimitX96);
148
+ const outputCurrency = zeroForOne ? this.currency1 : this.currency0;
149
+ return [
150
+ sdk_core_1.CurrencyAmount.fromRawAmount(outputCurrency, jsbi_1.default.multiply(outputAmount, internalConstants_1.NEGATIVE_ONE)),
151
+ new Pool(this.currency0, this.currency1, this.fee, this.tickSpacing, this.hooks, sqrtRatioX96, liquidity, tickCurrent, this.tickDataProvider),
152
+ ];
153
+ }
154
+ /**
155
+ * Given a desired output amount of a currency, return the computed input amount and a pool with state updated after the trade
156
+ * Works only for vanilla hookless v3 pools, otherwise throws an error
157
+ * @param outputAmount the output amount for which to quote the input amount
158
+ * @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
159
+ * @returns The input amount and the pool with updated state
160
+ */
161
+ async getInputAmount(outputAmount, sqrtPriceLimitX96) {
162
+ (0, tiny_invariant_1.default)(this.involvesCurrency(outputAmount.currency), 'CURRENCY');
163
+ const zeroForOne = outputAmount.currency.equals(this.currency1);
164
+ const { amountCalculated: inputAmount, sqrtRatioX96, liquidity, tickCurrent, } = await this.swap(zeroForOne, jsbi_1.default.multiply(outputAmount.quotient, internalConstants_1.NEGATIVE_ONE), sqrtPriceLimitX96);
165
+ const inputCurrency = zeroForOne ? this.currency0 : this.currency1;
166
+ return [
167
+ sdk_core_1.CurrencyAmount.fromRawAmount(inputCurrency, inputAmount),
168
+ new Pool(this.currency0, this.currency1, this.fee, this.tickSpacing, this.hooks, sqrtRatioX96, liquidity, tickCurrent, this.tickDataProvider),
169
+ ];
170
+ }
171
+ /**
172
+ * Executes a swap
173
+ * @param zeroForOne Whether the amount in is token0 or token1
174
+ * @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
175
+ * @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
176
+ * @returns amountCalculated
177
+ * @returns sqrtRatioX96
178
+ * @returns liquidity
179
+ * @returns tickCurrent
180
+ */
181
+ async swap(zeroForOne, amountSpecified, sqrtPriceLimitX96) {
182
+ if (!this.hookImpactsSwap()) {
183
+ return (0, v3_sdk_1.v3Swap)(jsbi_1.default.BigInt(this.fee), this.sqrtRatioX96, this.tickCurrent, this.liquidity, this.tickSpacing, this.tickDataProvider, zeroForOne, amountSpecified, sqrtPriceLimitX96);
184
+ }
185
+ else {
186
+ throw new Error('Unsupported hook');
187
+ }
188
+ }
189
+ hookImpactsSwap() {
190
+ // could use this function to clear certain hooks that may have swap Permissions, but we know they don't interfere
191
+ // in the swap outcome
192
+ return hook_1.Hook.hasSwapPermissions(this.hooks);
193
+ }
194
+ }
195
+ exports.Pool = Pool;
196
+ //# sourceMappingURL=pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool.js","sourceRoot":"","sources":["../../../../src/entities/pool.ts"],"names":[],"mappings":";;;;AAAA,4EAAsC;AACtC,sDAAmD;AACnD,uDAAqF;AACrF,mDAQ+B;AAC/B,4CA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