@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,104 @@
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
+ }
104
+ //# sourceMappingURL=pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../../src/entities/pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AACrF,OAAO,EAGL,IAAI,EACJ,mBAAmB,EACnB,gBAAgB,EAGjB,MAAM,wBAAwB,CAAA;AAM/B,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,eAAO,MAAM,gBAAgB,UAAW,CAAA;AAGxC,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;GAEG;AACH,qBAAa,IAAI;IACf,SAAgB,SAAS,EAAE,QAAQ,CAAA;IACnC,SAAgB,SAAS,EAAE,QAAQ,CAAA;IACnC,SAAgB,GAAG,EAAE,MAAM,CAAA;IAC3B,SAAgB,WAAW,EAAE,MAAM,CAAA;IACnC,SAAgB,YAAY,EAAE,IAAI,CAAA;IAClC,SAAgB,KAAK,EAAE,MAAM,CAAA;IAC7B,SAAgB,SAAS,EAAE,IAAI,CAAA;IAC/B,SAAgB,WAAW,EAAE,MAAM,CAAA;IACnC,SAAgB,gBAAgB,EAAE,gBAAgB,CAAA;IAClD,SAAgB,OAA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AAQ,CAAC,CAUrD;IACD,6CAA6C;IAC7C,IAAW,WAAW,IAAI,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAElD;IAED;;;;OAIG;IACI,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAK7D;;OAEG;IACH,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,0EAA0E;IAC7D,eAAe,CAC1B,WAAW,EAAE,cAAc,CAAC,QAAQ,CAAC,EACrC,iBAAiB,CAAC,EAAE,IAAI,GACvB,OAAO,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;IA4B5C;;;;;;OAMG;IACU,cAAc,CACzB,YAAY,EAAE,cAAc,CAAC,QAAQ,CAAC,EACtC,iBAAiB,CAAC,EAAE,IAAI,GACvB,OAAO,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;IA4B5C;;;;;;;;;OASG;YACW,IAAI;IAsBlB,OAAO,CAAC,eAAe;CAKxB"}
@@ -0,0 +1,145 @@
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 {};
145
+ //# sourceMappingURL=position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../../src/entities/position.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAc,MAAM,0BAA0B,CAAA;AAC1G,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAI7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AAEjE,UAAU,uBAAuB;IAC/B,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,EAAE,SAAS,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;;;GAKG;AACH,qBAAa,QAAQ;IACnB,SAAgB,IAAI,EAAE,IAAI,CAAA;IAC1B,SAAgB,SAAS,EAAE,MAAM,CAAA;IACjC,SAAgB,SAAS,EAAE,MAAM,CAAA;IACjC,SAAgB,SAAS,EAAE,IAAI,CAAA;IAG/B,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,YAAY,CAA0D;IAE9E;;;;;;OAMG;gBACgB,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,uBAAuB;IAWrF;;OAEG;IACH,IAAW,gBAAgB,IAAI,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAEvD;IAED;;OAEG;I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B,GACjB,EAAE;QACD,IAAI,EAAE,IAAI,CAAA;QACV,SAAS,EAAE,MAAM,CAAA;QACjB,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,SAAS,CAAA;QAClB,gBAAgB,EAAE,OAAO,CAAA;KAC1B;IAID;;;;;;;OAOG;WACW,WAAW,CAAC,EACxB,IAAI,EACJ,SAAS,EACT,SAAS,EACT,OAAO,GACR,EAAE;QACD,IAAI,EAAE,IAAI,CAAA;QACV,SAAS,EAAE,MAAM,CAAA;QACjB,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,SAAS,CAAA;KACnB;CAIF"}
@@ -0,0 +1,29 @@
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
+ }
29
+ //# sourceMappingURL=route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/entities/route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAG7B;;;;GAIG;AACH,qBAAa,KAAK,CAAC,MAAM,SAAS,QAAQ,EAAE,OAAO,SAAS,QAAQ;IAClE,SAAgB,KAAK,EAAE,IAAI,EAAE,CAAA;IAC7B,SAAgB,YAAY,EAAE,QAAQ,EAAE,CAAA;IACxC,SAAgB,KAAK,EAAE,MAAM,CAAA;IAC7B,SAAgB,MAAM,EAAE,OAAO,CAAA;IAC/B,SAAgB,SAAS,EAAE,QAAQ,CAAA;IACnC,SAAgB,UAAU,EAAE,QAAQ,CAAA;IAEpC,OAAO,CAAC,SAAS,CAAsC;IAEvD;;;;;OAKG;gBACgB,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAwChE,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED;;OAEG;IACH,IAAW,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CA2B5C;CACF"}
@@ -0,0 +1,221 @@
1
+ import { Currency, Percent, Price, CurrencyAmount, TradeType } from '@kittycorn-labs/sdk-core';
2
+ import { Pool } from './pool';
3
+ import { Route } from './route';
4
+ /**
5
+ * Trades comparator, an extension of the input output comparator that also considers other dimensions of the trade in ranking them
6
+ * @template TInput The input currency, either Ether or an ERC-20
7
+ * @template TOutput The output currency, either Ether or an ERC-20
8
+ * @template TTradeType The trade type, either exact input or exact output
9
+ * @param a The first trade to compare
10
+ * @param b The second trade to compare
11
+ * @returns A sorted ordering for two neighboring elements in a trade array
12
+ */
13
+ export declare function tradeComparator<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(a: Trade<TInput, TOutput, TTradeType>, b: Trade<TInput, TOutput, TTradeType>): number;
14
+ export interface BestTradeOptions {
15
+ maxNumResults?: number;
16
+ maxHops?: number;
17
+ }
18
+ /**
19
+ * Represents a trade executed against a set of routes where some percentage of the input is
20
+ * split across each route.
21
+ *
22
+ * Each route has its own set of pools. Pools can not be re-used across routes.
23
+ *
24
+ * Does not account for slippage, i.e., changes in price environment that can occur between
25
+ * the time the trade is submitted and when it is executed.
26
+ * @template TInput The input currency, either Ether or an ERC-20
27
+ * @template TOutput The output currency, either Ether or an ERC-20
28
+ * @template TTradeType The trade type, either exact input or exact output
29
+ */
30
+ export declare class Trade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {
31
+ /**
32
+ * @deprecated Deprecated in favor of 'swaps' property. If the trade consists of multiple routes
33
+ * this will return an error.
34
+ *
35
+ * When the trade consists of just a single route, this returns the route of the trade,
36
+ * i.e. which pools the trade goes through.
37
+ */
38
+ get route(): Route<TInput, TOutput>;
39
+ /**
40
+ * The swaps of the trade, i.e. which routes and how much is swapped in each that
41
+ * make up the trade.
42
+ */
43
+ readonly swaps: {
44
+ route: Route<TInput, TOutput>;
45
+ inputAmount: CurrencyAmount<TInput>;
46
+ outputAmount: CurrencyAmount<TOutput>;
47
+ }[];
48
+ /**
49
+ * The type of the trade, either exact in or exact out.
50
+ */
51
+ readonly tradeType: TTradeType;
52
+ /**
53
+ * The cached result of the input amount computation
54
+ * @private
55
+ */
56
+ private _inputAmount;
57
+ /**
58
+ * The input amount for the trade assuming no slippage.
59
+ */
60
+ get inputAmount(): CurrencyAmount<TInput>;
61
+ /**
62
+ * The cached result of the output amount computation
63
+ * @private
64
+ */
65
+ private _outputAmount;
66
+ /**
67
+ * The output amount for the trade assuming no slippage.
68
+ */
69
+ get outputAmount(): CurrencyAmount<TOutput>;
70
+ /**
71
+ * The cached result of the computed execution price
72
+ * @private
73
+ */
74
+ private _executionPrice;
75
+ /**
76
+ * The price expressed in terms of output amount/input amount.
77
+ */
78
+ get executionPrice(): Price<TInput, TOutput>;
79
+ /**
80
+ * The cached result of the price impact computation
81
+ * @private
82
+ */
83
+ private _priceImpact;
84
+ /**
85
+ * Returns the percent difference between the route's mid price and the price impact
86
+ */
87
+ get priceImpact(): Percent;
88
+ /**
89
+ * Constructs an exact in trade with the given amount in and route
90
+ * @template TInput The input currency, either Ether or an ERC-20
91
+ * @template TOutput The output currency, either Ether or an ERC-20
92
+ * @param route The route of the exact in trade
93
+ * @param amountIn The amount being passed in
94
+ * @returns The exact in trade
95
+ */
96
+ static exactIn<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountIn: CurrencyAmount<TInput>): Promise<Trade<TInput, TOutput, TradeType.EXACT_INPUT>>;
97
+ /**
98
+ * Constructs an exact out trade with the given amount out and route
99
+ * @template TInput The input currency, either Ether or an ERC-20
100
+ * @template TOutput The output currency, either Ether or an ERC-20
101
+ * @param route The route of the exact out trade
102
+ * @param amountOut The amount returned by the trade
103
+ * @returns The exact out trade
104
+ */
105
+ static exactOut<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountOut: CurrencyAmount<TOutput>): Promise<Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>>;
106
+ /**
107
+ * Constructs a trade by simulating swaps through the given route
108
+ * @template TInput The input currency, either Ether or an ERC-20.
109
+ * @template TOutput The output currency, either Ether or an ERC-20.
110
+ * @template TTradeType The type of the trade, either exact in or exact out.
111
+ * @param route route to swap through
112
+ * @param amount the amount specified, either input or output, depending on tradeType
113
+ * @param tradeType whether the trade is an exact input or exact output swap
114
+ * @returns The route
115
+ */
116
+ static fromRoute<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(route: Route<TInput, TOutput>, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>, tradeType: TTradeType): Promise<Trade<TInput, TOutput, TTradeType>>;
117
+ /**
118
+ * Constructs a trade from routes by simulating swaps
119
+ *
120
+ * @template TInput The input currency, either Ether or an ERC-20.
121
+ * @template TOutput The output currency, either Ether or an ERC-20.
122
+ * @template TTradeType The type of the trade, either exact in or exact out.
123
+ * @param routes the routes to swap through and how much of the amount should be routed through each
124
+ * @param tradeType whether the trade is an exact input or exact output swap
125
+ * @returns The trade
126
+ */
127
+ static fromRoutes<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(routes: {
128
+ amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
129
+ route: Route<TInput, TOutput>;
130
+ }[], tradeType: TTradeType): Promise<Trade<TInput, TOutput, TTradeType>>;
131
+ /**
132
+ * Creates a trade without computing the result of swapping through the route. Useful when you have simulated the trade
133
+ * elsewhere and do not have any tick data
134
+ * @template TInput The input currency, either Ether or an ERC-20
135
+ * @template TOutput The output currency, either Ether or an ERC-20
136
+ * @template TTradeType The type of the trade, either exact in or exact out
137
+ * @param constructorArguments The arguments passed to the trade constructor
138
+ * @returns The unchecked trade
139
+ */
140
+ static createUncheckedTrade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(constructorArguments: {
141
+ route: Route<TInput, TOutput>;
142
+ inputAmount: CurrencyAmount<TInput>;
143
+ outputAmount: CurrencyAmount<TOutput>;
144
+ tradeType: TTradeType;
145
+ }): Trade<TInput, TOutput, TTradeType>;
146
+ /**
147
+ * Creates a trade without computing the result of swapping through the routes. Useful when you have simulated the trade
148
+ * elsewhere and do not have any tick data
149
+ * @template TInput The input currency, either Ether or an ERC-20
150
+ * @template TOutput The output currency, either Ether or an ERC-20
151
+ * @template TTradeType The type of the trade, either exact in or exact out
152
+ * @param constructorArguments The arguments passed to the trade constructor
153
+ * @returns The unchecked trade
154
+ */
155
+ static createUncheckedTradeWithMultipleRoutes<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(constructorArguments: {
156
+ routes: {
157
+ route: Route<TInput, TOutput>;
158
+ inputAmount: CurrencyAmount<TInput>;
159
+ outputAmount: CurrencyAmount<TOutput>;
160
+ }[];
161
+ tradeType: TTradeType;
162
+ }): Trade<TInput, TOutput, TTradeType>;
163
+ /**
164
+ * Construct a trade by passing in the pre-computed property values
165
+ * @param routes The routes through which the trade occurs
166
+ * @param tradeType The type of trade, exact input or exact output
167
+ */
168
+ private constructor();
169
+ /**
170
+ * Get the minimum amount that must be received from this trade for the given slippage tolerance
171
+ * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
172
+ * @returns The amount out
173
+ */
174
+ minimumAmountOut(slippageTolerance: Percent, amountOut?: CurrencyAmount<TOutput>): CurrencyAmount<TOutput>;
175
+ /**
176
+ * Get the maximum amount in that can be spent via this trade for the given slippage tolerance
177
+ * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
178
+ * @returns The amount in
179
+ */
180
+ maximumAmountIn(slippageTolerance: Percent, amountIn?: CurrencyAmount<TInput>): CurrencyAmount<TInput>;
181
+ /**
182
+ * Return the execution price after accounting for slippage tolerance
183
+ * @param slippageTolerance the allowed tolerated slippage
184
+ * @returns The execution price
185
+ */
186
+ worstExecutionPrice(slippageTolerance: Percent): Price<TInput, TOutput>;
187
+ /**
188
+ * Given a list of pools, and a fixed amount in, returns the top `maxNumResults` trades that go from an input currency
189
+ * amount to an output currency, making at most `maxHops` hops.
190
+ * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
191
+ * the amount in among multiple routes.
192
+ * @param pools the pools to consider in finding the best trade
193
+ * @param nextAmountIn exact amount of input currency to spend
194
+ * @param currencyOut the desired currency out
195
+ * @param maxNumResults maximum number of results to return
196
+ * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool
197
+ * @param currentPools used in recursion; the current list of pools
198
+ * @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
199
+ * @param bestTrades used in recursion; the current list of best trades
200
+ * @returns The exact in trade
201
+ */
202
+ static bestTradeExactIn<TInput extends Currency, TOutput extends Currency>(pools: Pool[], currencyAmountIn: CurrencyAmount<TInput>, currencyOut: TOutput, { maxNumResults, maxHops }?: BestTradeOptions, currentPools?: Pool[], nextAmountIn?: CurrencyAmount<Currency>, bestTrades?: Trade<TInput, TOutput, TradeType.EXACT_INPUT>[]): Promise<Trade<TInput, TOutput, TradeType.EXACT_INPUT>[]>;
203
+ /**
204
+ * similar to the above method but instead targets a fixed output amount
205
+ * given a list of pools, and a fixed amount out, returns the top `maxNumResults` trades that go from an input currency
206
+ * to an output currency amount, making at most `maxHops` hops
207
+ * note this does not consider aggregation, as routes are linear. it's possible a better route exists by splitting
208
+ * the amount in among multiple routes.
209
+ * @param pools the pools to consider in finding the best trade
210
+ * @param currencyIn the currency to spend
211
+ * @param currencyAmountOut the desired currency amount out
212
+ * @param nextAmountOut the exact amount of currency out
213
+ * @param maxNumResults maximum number of results to return
214
+ * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool
215
+ * @param currentPools used in recursion; the current list of pools
216
+ * @param bestTrades used in recursion; the current list of best trades
217
+ * @returns The exact out trade
218
+ */
219
+ static bestTradeExactOut<TInput extends Currency, TOutput extends Currency>(pools: Pool[], currencyIn: TInput, currencyAmountOut: CurrencyAmount<TOutput>, { maxNumResults, maxHops }?: BestTradeOptions, currentPools?: Pool[], nextAmountOut?: CurrencyAmount<Currency>, bestTrades?: Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>[]): Promise<Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>[]>;
220
+ }
221
+ //# sourceMappingURL=trade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trade.d.ts","sourceRoot":"","sources":["../../../../src/entities/trade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAY,OAAO,EAAE,KAAK,EAAgB,cAAc,EAAE,SAAS,EAAS,MAAM,0BAA0B,CAAA;AAI7H,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,SAAS,QAAQ,EAAE,OAAO,SAAS,QAAQ,EAAE,UAAU,SAAS,SAAS,EAC7G,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,EACrC,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,UA0BtC;AAED,MAAM,WAAW,gBAAgB;IAE/B,aAAa,CA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GAAE,cAAc,CAAC,QAAQ,CAAoB,EACzD,UAAU,GAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,EAAO,GAC/D,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;IAsD3D;;;;;;;;;;;;;;;OAeG;WACiB,iBAAiB,CAAC,MAAM,SAAS,QAAQ,EAAE,OAAO,SAAS,QAAQ,EACrF,KAAK,EAAE,IAAI,EAAE,EACb,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,cAAc,CAAC,OAAO,CAAC,EAC1C,EAAE,aAAiB,EAAE,OAAW,EAAE,GAAE,gBAAqB,EAEzD,YAAY,GAAE,IAAI,EAAO,EACzB,aAAa,GAAE,cAAc,CAAC,QAAQ,CAAqB,EAC3D,UAAU,GAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,YAAY,CAAC,EAAO,GAChE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;CAsD7D"}
@@ -0,0 +1,5 @@
1
+ export * from './entities';
2
+ export * from './utils';
3
+ export * from './PositionManager';
4
+ export * from './tokenize';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AAEjC,cAAc,YAAY,CAAA"}
@@ -0,0 +1,47 @@
1
+ import JSBI from 'jsbi';
2
+ export declare const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
3
+ export declare const NEGATIVE_ONE: JSBI;
4
+ export declare const ZERO: JSBI;
5
+ export declare const ONE: JSBI;
6
+ export declare const ONE_ETHER: JSBI;
7
+ export declare const EMPTY_BYTES = "0x";
8
+ export declare const Q96: JSBI;
9
+ export declare const Q192: JSBI;
10
+ export declare const FEE_AMOUNT_LOW = 100;
11
+ export declare const FEE_AMOUNT_MEDIUM = 3000;
12
+ export declare const FEE_AMOUNT_HIGHEST = 10000;
13
+ export declare const TICK_SPACING_TEN = 10;
14
+ export declare const TICK_SPACING_SIXTY = 60;
15
+ export declare const MIN_SLIPPAGE_DECREASE = 0;
16
+ export declare const OPEN_DELTA: import("@ethersproject/bignumber").BigNumber;
17
+ export declare const SQRT_PRICE_1_1: JSBI;
18
+ export declare const EMPTY_HOOK = "0x0000000000000000000000000000000000000000";
19
+ export declare const NATIVE_NOT_SET = "NATIVE_NOT_SET";
20
+ export declare const ZERO_LIQUIDITY = "ZERO_LIQUIDITY";
21
+ export declare const NO_SQRT_PRICE = "NO_SQRT_PRICE";
22
+ export declare const CANNOT_BURN = "CANNOT_BURN";
23
+ /**
24
+ * Function fragments that exist on the PositionManager contract.
25
+ */
26
+ export declare enum PositionFunctions {
27
+ INITIALIZE_POOL = "initializePool",
28
+ MODIFY_LIQUIDITIES = "modifyLiquidities",
29
+ PERMIT_BATCH = "0x002a3e3a",
30
+ ERC721PERMIT_PERMIT = "0x0f5730f1"
31
+ }
32
+ /**
33
+ * The default factory enabled fee amounts, denominated in hundredths of bips.
34
+ */
35
+ export declare enum FeeAmount {
36
+ LOWEST = 100,
37
+ LOW = 500,
38
+ MEDIUM = 3000,
39
+ HIGH = 10000
40
+ }
41
+ /**
42
+ * The default factory tick spacings by fee amount.
43
+ */
44
+ export declare const TICK_SPACINGS: {
45
+ [amount in FeeAmount]: number;
46
+ };
47
+ //# sourceMappingURL=internalConstants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internalConstants.d.ts","sourceRoot":"","sources":["../../../src/internalConstants.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAKvB,eAAO,MAAM,YAAY,+CAAc,CAAA;AACvC,eAAO,MAAM,YAAY,MAAkB,CAAA;AAC3C,eAAO,MAAM,IAAI,MAAiB,CAAA;AAClC,eAAO,MAAM,GAAG,MAAiB,CAAA;AACjC,eAAO,MAAM,SAAS,MAAsD,CAAA;AAC5E,eAAO,MAAM,WAAW,OAAO,CAAA;AAG/B,eAAO,MAAM,GAAG,MAAqD,CAAA;AACrE,eAAO,MAAM,IAAI,MAAyC,CAAA;AAG1D,eAAO,MAAM,cAAc,MAAM,CAAA;AACjC,eAAO,MAAM,iBAAiB,OAAO,CAAA;AACrC,eAAO,MAAM,kBAAkB,QAAS,CAAA;AACxC,eAAO,MAAM,gBAAgB,KAAK,CAAA;AAClC,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAGpC,eAAO,MAAM,qBAAqB,IAAI,CAAA;AAGtC,eAAO,MAAM,UAAU,8CAAO,CAAA;AAG9B,eAAO,MAAM,cAAc,MAA2B,CAAA;AAGtD,eAAO,MAAM,UAAU,+CAA+C,CAAA;AAGtE,eAAO,MAAM,cAAc,mBAAmB,CAAA;AAC9C,eAAO,MAAM,cAAc,mBAAmB,CAAA;AAC9C,eAAO,MAAM,aAAa,kBAAkB,CAAA;AAC5C,eAAO,MAAM,WAAW,gBAAgB,CAAA;AAExC;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,eAAe,mBAAmB;IAClC,kBAAkB,sBAAsB;IAExC,YAAY,eAAe;IAE3B,mBAAmB,eAAe;CACnC;AAED;;GAEG;AACH,oBAAY,SAAS;IACnB,MAAM,MAAM;IACZ,GAAG,MAAM;IACT,MAAM,OAAO;IACb,IAAI,QAAQ;CACb;AAED;;GAEG;AAEH,eAAO,MAAM,aAAa,EAAE;KAAG,MAAM,IAAI,SAAS,GAAG,MAAM;CAK1D,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ export declare abstract class Multicall {
3
+ static INTERFACE: Interface;
4
+ /**
5
+ * Cannot be constructed.
6
+ */
7
+ private constructor();
8
+ static encodeMulticall(calldataList: string | string[]): string;
9
+ static decodeMulticall(encodedCalldata: string): string[];
10
+ }
11
+ //# sourceMappingURL=multicall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multicall.d.ts","sourceRoot":"","sources":["../../../src/multicall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,8BAAsB,SAAS;IAC7B,OAAc,SAAS,EAAE,SAAS,CAAgC;IAElE;;OAEG;IACH,OAAO;WAEO,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;WAUxD,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE;CAGjE"}
@@ -0,0 +1,18 @@
1
+ import { ChainId, Currency, Token } from '@kittycorn-labs/sdk-core';
2
+ import { Pool } from './entities/pool';
3
+ /** Current Kittycorn deployment. Legacy rebasing deployments are intentionally unsupported. */
4
+ export declare const KITTYCORN_BASE_SEPOLIA: {
5
+ chainId: ChainId;
6
+ bank: string;
7
+ router: string;
8
+ quoter: string;
9
+ tokens: {
10
+ underlying: Token;
11
+ tokenize: Token;
12
+ }[];
13
+ };
14
+ /** Conversion edges connect actual underlying/share currencies; they are not AMM liquidity. */
15
+ export declare function getTokenizePairs(chainId: number): [Currency, Currency, number, number, string][];
16
+ /** Recognize only registered conversion edges, never arbitrary pools containing a tToken. */
17
+ export declare function isTokenizeConversion(pool: Pool): boolean;
18
+ //# sourceMappingURL=tokenize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenize.d.ts","sourceRoot":"","sources":["../../../src/tokenize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAEtC,+FAA+F;AAC/F,eAAO,MAAM,sBAAsB;;;;;;;;;CAmBlC,CAAA;AAED,+FAA+F;AAC/F,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAIhG;AAED,6FAA6F;AAC7F,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAQxD"}
@@ -0,0 +1,21 @@
1
+ import { BigintIsh } from '@kittycorn-labs/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;
21
+ //# sourceMappingURL=calldata.d.ts.map