@synthra-swap/sdk 0.1.4

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 (235) hide show
  1. package/README.md +12 -0
  2. package/chains.d.ts +1 -0
  3. package/chains.js +1 -0
  4. package/core.d.ts +1 -0
  5. package/core.js +1 -0
  6. package/dist/chain-registry.d.ts +22 -0
  7. package/dist/chain-registry.js +315 -0
  8. package/dist/chain-registry.js.map +1 -0
  9. package/dist/chains.d.ts +5 -0
  10. package/dist/chains.js +29 -0
  11. package/dist/chains.js.map +1 -0
  12. package/dist/core/addresses.d.ts +21 -0
  13. package/dist/core/addresses.js +76 -0
  14. package/dist/core/addresses.js.map +1 -0
  15. package/dist/core/chains.d.ts +51 -0
  16. package/dist/core/chains.js +82 -0
  17. package/dist/core/chains.js.map +1 -0
  18. package/dist/core/constants.d.ts +12 -0
  19. package/dist/core/constants.js +20 -0
  20. package/dist/core/constants.js.map +1 -0
  21. package/dist/core/entities/baseCurrency.d.ts +48 -0
  22. package/dist/core/entities/baseCurrency.js +29 -0
  23. package/dist/core/entities/baseCurrency.js.map +1 -0
  24. package/dist/core/entities/currency.d.ts +3 -0
  25. package/dist/core/entities/currency.js +3 -0
  26. package/dist/core/entities/currency.js.map +1 -0
  27. package/dist/core/entities/ether.d.ts +13 -0
  28. package/dist/core/entities/ether.js +32 -0
  29. package/dist/core/entities/ether.js.map +1 -0
  30. package/dist/core/entities/fractions/currencyAmount.d.ts +31 -0
  31. package/dist/core/entities/fractions/currencyAmount.js +74 -0
  32. package/dist/core/entities/fractions/currencyAmount.js.map +1 -0
  33. package/dist/core/entities/fractions/fraction.d.ts +24 -0
  34. package/dist/core/entities/fractions/fraction.js +106 -0
  35. package/dist/core/entities/fractions/fraction.js.map +1 -0
  36. package/dist/core/entities/fractions/index.d.ts +4 -0
  37. package/dist/core/entities/fractions/index.js +12 -0
  38. package/dist/core/entities/fractions/index.js.map +1 -0
  39. package/dist/core/entities/fractions/percent.d.ts +14 -0
  40. package/dist/core/entities/fractions/percent.js +45 -0
  41. package/dist/core/entities/fractions/percent.js.map +1 -0
  42. package/dist/core/entities/fractions/price.d.ts +38 -0
  43. package/dist/core/entities/fractions/price.js +75 -0
  44. package/dist/core/entities/fractions/price.js.map +1 -0
  45. package/dist/core/entities/index.d.ts +7 -0
  46. package/dist/core/entities/index.js +24 -0
  47. package/dist/core/entities/index.js.map +1 -0
  48. package/dist/core/entities/nativeCurrency.d.ts +8 -0
  49. package/dist/core/entities/nativeCurrency.js +16 -0
  50. package/dist/core/entities/nativeCurrency.js.map +1 -0
  51. package/dist/core/entities/nativeOnChain.d.ts +19 -0
  52. package/dist/core/entities/nativeOnChain.js +141 -0
  53. package/dist/core/entities/nativeOnChain.js.map +1 -0
  54. package/dist/core/entities/token.d.ts +48 -0
  55. package/dist/core/entities/token.js +71 -0
  56. package/dist/core/entities/token.js.map +1 -0
  57. package/dist/core/entities/weth9.d.ts +7 -0
  58. package/dist/core/entities/weth9.js +28 -0
  59. package/dist/core/entities/weth9.js.map +1 -0
  60. package/dist/core/index.d.ts +5 -0
  61. package/dist/core/index.js +22 -0
  62. package/dist/core/index.js.map +1 -0
  63. package/dist/core/utils/computePriceImpact.d.ts +8 -0
  64. package/dist/core/utils/computePriceImpact.js +18 -0
  65. package/dist/core/utils/computePriceImpact.js.map +1 -0
  66. package/dist/core/utils/index.d.ts +4 -0
  67. package/dist/core/utils/index.js +12 -0
  68. package/dist/core/utils/index.js.map +1 -0
  69. package/dist/core/utils/sortedInsert.d.ts +1 -0
  70. package/dist/core/utils/sortedInsert.js +40 -0
  71. package/dist/core/utils/sortedInsert.js.map +1 -0
  72. package/dist/core/utils/sqrt.d.ts +7 -0
  73. package/dist/core/utils/sqrt.js +34 -0
  74. package/dist/core/utils/sqrt.js.map +1 -0
  75. package/dist/core/utils/validateAndParseAddress.d.ts +10 -0
  76. package/dist/core/utils/validateAndParseAddress.js +31 -0
  77. package/dist/core/utils/validateAndParseAddress.js.map +1 -0
  78. package/dist/index.d.ts +4 -0
  79. package/dist/index.js +34 -0
  80. package/dist/index.js.map +1 -0
  81. package/dist/universal-router/entities/Command.d.ts +12 -0
  82. package/dist/universal-router/entities/Command.js +9 -0
  83. package/dist/universal-router/entities/Command.js.map +1 -0
  84. package/dist/universal-router/entities/index.d.ts +3 -0
  85. package/dist/universal-router/entities/index.js +20 -0
  86. package/dist/universal-router/entities/index.js.map +1 -0
  87. package/dist/universal-router/entities/protocols/index.d.ts +2 -0
  88. package/dist/universal-router/entities/protocols/index.js +19 -0
  89. package/dist/universal-router/entities/protocols/index.js.map +1 -0
  90. package/dist/universal-router/entities/protocols/uniswap.d.ts +32 -0
  91. package/dist/universal-router/entities/protocols/uniswap.js +143 -0
  92. package/dist/universal-router/entities/protocols/uniswap.js.map +1 -0
  93. package/dist/universal-router/entities/protocols/unwrapWETH.d.ts +12 -0
  94. package/dist/universal-router/entities/protocols/unwrapWETH.js +35 -0
  95. package/dist/universal-router/entities/protocols/unwrapWETH.js.map +1 -0
  96. package/dist/universal-router/entities/trade.d.ts +41 -0
  97. package/dist/universal-router/entities/trade.js +114 -0
  98. package/dist/universal-router/entities/trade.js.map +1 -0
  99. package/dist/universal-router/index.d.ts +5 -0
  100. package/dist/universal-router/index.js +31 -0
  101. package/dist/universal-router/index.js.map +1 -0
  102. package/dist/universal-router/swapRouter.d.ts +29 -0
  103. package/dist/universal-router/swapRouter.js +102 -0
  104. package/dist/universal-router/swapRouter.js.map +1 -0
  105. package/dist/universal-router/utils/constants.d.ts +8 -0
  106. package/dist/universal-router/utils/constants.js +21 -0
  107. package/dist/universal-router/utils/constants.js.map +1 -0
  108. package/dist/universal-router/utils/getNativeCurrencyValue.d.ts +2 -0
  109. package/dist/universal-router/utils/getNativeCurrencyValue.js +19 -0
  110. package/dist/universal-router/utils/getNativeCurrencyValue.js.map +1 -0
  111. package/dist/universal-router/utils/inputTokens.d.ts +16 -0
  112. package/dist/universal-router/utils/inputTokens.js +44 -0
  113. package/dist/universal-router/utils/inputTokens.js.map +1 -0
  114. package/dist/universal-router/utils/numbers.d.ts +6 -0
  115. package/dist/universal-router/utils/numbers.js +24 -0
  116. package/dist/universal-router/utils/numbers.js.map +1 -0
  117. package/dist/universal-router/utils/routerCommands.d.ts +29 -0
  118. package/dist/universal-router/utils/routerCommands.js +64 -0
  119. package/dist/universal-router/utils/routerCommands.js.map +1 -0
  120. package/dist/universal-router/utils/routerTradeAdapter.d.ts +40 -0
  121. package/dist/universal-router/utils/routerTradeAdapter.js +82 -0
  122. package/dist/universal-router/utils/routerTradeAdapter.js.map +1 -0
  123. package/dist/v3/abis.d.ts +6 -0
  124. package/dist/v3/abis.js +39 -0
  125. package/dist/v3/abis.js.map +1 -0
  126. package/dist/v3/constants.d.ts +18 -0
  127. package/dist/v3/constants.js +26 -0
  128. package/dist/v3/constants.js.map +1 -0
  129. package/dist/v3/entities/index.d.ts +7 -0
  130. package/dist/v3/entities/index.js +24 -0
  131. package/dist/v3/entities/index.js.map +1 -0
  132. package/dist/v3/entities/pool.d.ts +81 -0
  133. package/dist/v3/entities/pool.js +215 -0
  134. package/dist/v3/entities/pool.js.map +1 -0
  135. package/dist/v3/entities/position.d.ts +131 -0
  136. package/dist/v3/entities/position.js +250 -0
  137. package/dist/v3/entities/position.js.map +1 -0
  138. package/dist/v3/entities/route.d.ts +26 -0
  139. package/dist/v3/entities/route.js +77 -0
  140. package/dist/v3/entities/route.js.map +1 -0
  141. package/dist/v3/entities/tick.d.ts +13 -0
  142. package/dist/v3/entities/tick.js +19 -0
  143. package/dist/v3/entities/tick.js.map +1 -0
  144. package/dist/v3/entities/tickDataProvider.d.ts +31 -0
  145. package/dist/v3/entities/tickDataProvider.js +18 -0
  146. package/dist/v3/entities/tickDataProvider.js.map +1 -0
  147. package/dist/v3/entities/tickListDataProvider.d.ts +15 -0
  148. package/dist/v3/entities/tickListDataProvider.js +23 -0
  149. package/dist/v3/entities/tickListDataProvider.js.map +1 -0
  150. package/dist/v3/entities/trade.d.ts +220 -0
  151. package/dist/v3/entities/trade.js +442 -0
  152. package/dist/v3/entities/trade.js.map +1 -0
  153. package/dist/v3/index.d.ts +9 -0
  154. package/dist/v3/index.js +26 -0
  155. package/dist/v3/index.js.map +1 -0
  156. package/dist/v3/internalConstants.d.ts +6 -0
  157. package/dist/v3/internalConstants.js +15 -0
  158. package/dist/v3/internalConstants.js.map +1 -0
  159. package/dist/v3/multicall.d.ts +9 -0
  160. package/dist/v3/multicall.js +20 -0
  161. package/dist/v3/multicall.js.map +1 -0
  162. package/dist/v3/nonfungiblePositionManager.d.ts +146 -0
  163. package/dist/v3/nonfungiblePositionManager.js +231 -0
  164. package/dist/v3/nonfungiblePositionManager.js.map +1 -0
  165. package/dist/v3/payments.d.ts +24 -0
  166. package/dist/v3/payments.js +55 -0
  167. package/dist/v3/payments.js.map +1 -0
  168. package/dist/v3/quoter.d.ts +37 -0
  169. package/dist/v3/quoter.js +76 -0
  170. package/dist/v3/quoter.js.map +1 -0
  171. package/dist/v3/selfPermit.d.ts +25 -0
  172. package/dist/v3/selfPermit.js +37 -0
  173. package/dist/v3/selfPermit.js.map +1 -0
  174. package/dist/v3/swapRouter.d.ts +51 -0
  175. package/dist/v3/swapRouter.js +147 -0
  176. package/dist/v3/swapRouter.js.map +1 -0
  177. package/dist/v3/utils/calldata.d.ts +20 -0
  178. package/dist/v3/utils/calldata.js +22 -0
  179. package/dist/v3/utils/calldata.js.map +1 -0
  180. package/dist/v3/utils/computePoolAddress.d.ts +18 -0
  181. package/dist/v3/utils/computePoolAddress.js +22 -0
  182. package/dist/v3/utils/computePoolAddress.js.map +1 -0
  183. package/dist/v3/utils/encodeRouteToPath.d.ts +8 -0
  184. package/dist/v3/utils/encodeRouteToPath.js +32 -0
  185. package/dist/v3/utils/encodeRouteToPath.js.map +1 -0
  186. package/dist/v3/utils/encodeSqrtRatioX96.d.ts +9 -0
  187. package/dist/v3/utils/encodeSqrtRatioX96.js +22 -0
  188. package/dist/v3/utils/encodeSqrtRatioX96.js.map +1 -0
  189. package/dist/v3/utils/fullMath.d.ts +8 -0
  190. package/dist/v3/utils/fullMath.js +23 -0
  191. package/dist/v3/utils/fullMath.js.map +1 -0
  192. package/dist/v3/utils/index.d.ts +17 -0
  193. package/dist/v3/utils/index.js +34 -0
  194. package/dist/v3/utils/index.js.map +1 -0
  195. package/dist/v3/utils/isSorted.d.ts +7 -0
  196. package/dist/v3/utils/isSorted.js +19 -0
  197. package/dist/v3/utils/isSorted.js.map +1 -0
  198. package/dist/v3/utils/liquidityMath.d.ts +8 -0
  199. package/dist/v3/utils/liquidityMath.js +24 -0
  200. package/dist/v3/utils/liquidityMath.js.map +1 -0
  201. package/dist/v3/utils/maxLiquidityForAmounts.d.ts +14 -0
  202. package/dist/v3/utils/maxLiquidityForAmounts.js +89 -0
  203. package/dist/v3/utils/maxLiquidityForAmounts.js.map +1 -0
  204. package/dist/v3/utils/mostSignificantBit.d.ts +2 -0
  205. package/dist/v3/utils/mostSignificantBit.js +29 -0
  206. package/dist/v3/utils/mostSignificantBit.js.map +1 -0
  207. package/dist/v3/utils/nearestUsableTick.d.ts +6 -0
  208. package/dist/v3/utils/nearestUsableTick.js +27 -0
  209. package/dist/v3/utils/nearestUsableTick.js.map +1 -0
  210. package/dist/v3/utils/position.d.ts +8 -0
  211. package/dist/v3/utils/position.js +23 -0
  212. package/dist/v3/utils/position.js.map +1 -0
  213. package/dist/v3/utils/priceTickConversions.d.ts +15 -0
  214. package/dist/v3/utils/priceTickConversions.js +52 -0
  215. package/dist/v3/utils/priceTickConversions.js.map +1 -0
  216. package/dist/v3/utils/sqrtPriceMath.d.ts +13 -0
  217. package/dist/v3/utils/sqrtPriceMath.js +97 -0
  218. package/dist/v3/utils/sqrtPriceMath.js.map +1 -0
  219. package/dist/v3/utils/swapMath.d.ts +9 -0
  220. package/dist/v3/utils/swapMath.js +79 -0
  221. package/dist/v3/utils/swapMath.js.map +1 -0
  222. package/dist/v3/utils/tickLibrary.d.ts +14 -0
  223. package/dist/v3/utils/tickLibrary.js +53 -0
  224. package/dist/v3/utils/tickLibrary.js.map +1 -0
  225. package/dist/v3/utils/tickList.d.ts +23 -0
  226. package/dist/v3/utils/tickList.js +110 -0
  227. package/dist/v3/utils/tickList.js.map +1 -0
  228. package/dist/v3/utils/tickMath.d.ts +34 -0
  229. package/dist/v3/utils/tickMath.js +127 -0
  230. package/dist/v3/utils/tickMath.js.map +1 -0
  231. package/package.json +80 -0
  232. package/universal-router.d.ts +1 -0
  233. package/universal-router.js +1 -0
  234. package/v3.d.ts +1 -0
  235. package/v3.js +1 -0
@@ -0,0 +1,131 @@
1
+ import { BigintIsh, Percent, Price, CurrencyAmount, Token } from '../../core';
2
+ import JSBI from 'jsbi';
3
+ import { Pool } from './pool';
4
+ interface PositionConstructorArgs {
5
+ pool: Pool;
6
+ tickLower: number;
7
+ tickUpper: number;
8
+ liquidity: BigintIsh;
9
+ }
10
+ /**
11
+ * Represents a position on a Synthra V3 pool.
12
+ */
13
+ export declare class Position {
14
+ readonly pool: Pool;
15
+ readonly tickLower: number;
16
+ readonly tickUpper: number;
17
+ readonly liquidity: JSBI;
18
+ private _token0Amount;
19
+ private _token1Amount;
20
+ private _mintAmounts;
21
+ /**
22
+ * Constructs a position for a given pool with the given liquidity
23
+ * @param pool For which pool the liquidity is assigned
24
+ * @param liquidity The amount of liquidity that is in the position
25
+ * @param tickLower The lower tick of the position
26
+ * @param tickUpper The upper tick of the position
27
+ */
28
+ constructor({ pool, liquidity, tickLower, tickUpper }: PositionConstructorArgs);
29
+ /**
30
+ * Returns the price of token0 at the lower tick
31
+ */
32
+ get token0PriceLower(): Price<Token, Token>;
33
+ /**
34
+ * Returns the price of token0 at the upper tick
35
+ */
36
+ get token0PriceUpper(): Price<Token, Token>;
37
+ /**
38
+ * Returns the amount of token0 that this position's liquidity could be burned for at the current pool price
39
+ */
40
+ get amount0(): CurrencyAmount<Token>;
41
+ /**
42
+ * Returns the amount of token1 that this position's liquidity could be burned for at the current pool price
43
+ */
44
+ get amount1(): CurrencyAmount<Token>;
45
+ /**
46
+ * Returns the lower and upper sqrt ratios if the price 'slips' up to slippage tolerance percentage
47
+ * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
48
+ * @returns The sqrt ratios after slippage
49
+ */
50
+ private ratiosAfterSlippage;
51
+ /**
52
+ * Returns the minimum amounts that must be sent in order to safely mint the amount of liquidity held by the position
53
+ * with the given slippage tolerance
54
+ * @param slippageTolerance Tolerance of unfavorable slippage from the current price
55
+ * @returns The amounts, with slippage
56
+ */
57
+ mintAmountsWithSlippage(slippageTolerance: Percent): Readonly<{
58
+ amount0: JSBI;
59
+ amount1: JSBI;
60
+ }>;
61
+ /**
62
+ * Returns the minimum amounts that should be requested in order to safely burn the amount of liquidity held by the
63
+ * position with the given slippage tolerance
64
+ * @param slippageTolerance tolerance of unfavorable slippage from the current price
65
+ * @returns The amounts, with slippage
66
+ */
67
+ burnAmountsWithSlippage(slippageTolerance: Percent): Readonly<{
68
+ amount0: JSBI;
69
+ amount1: JSBI;
70
+ }>;
71
+ /**
72
+ * Returns the minimum amounts that must be sent in order to mint the amount of liquidity held by the position at
73
+ * the current price for the pool
74
+ */
75
+ get mintAmounts(): Readonly<{
76
+ amount0: JSBI;
77
+ amount1: JSBI;
78
+ }>;
79
+ /**
80
+ * Computes the maximum amount of liquidity received for a given amount of token0, token1,
81
+ * and the prices at the tick boundaries.
82
+ * @param pool The pool for which the position should be created
83
+ * @param tickLower The lower tick of the position
84
+ * @param tickUpper The upper tick of the position
85
+ * @param amount0 token0 amount
86
+ * @param amount1 token1 amount
87
+ * @param useFullPrecision If false, liquidity will be maximized according to what the router can calculate,
88
+ * not what core can theoretically support
89
+ * @returns The amount of liquidity for the position
90
+ */
91
+ static fromAmounts({ pool, tickLower, tickUpper, amount0, amount1, useFullPrecision }: {
92
+ pool: Pool;
93
+ tickLower: number;
94
+ tickUpper: number;
95
+ amount0: BigintIsh;
96
+ amount1: BigintIsh;
97
+ useFullPrecision: boolean;
98
+ }): Position;
99
+ /**
100
+ * Computes a position with the maximum amount of liquidity received for a given amount of token0, assuming an unlimited amount of token1
101
+ * @param pool The pool for which the position is created
102
+ * @param tickLower The lower tick
103
+ * @param tickUpper The upper tick
104
+ * @param amount0 The desired amount of token0
105
+ * @param useFullPrecision If true, liquidity will be maximized according to what the router can calculate,
106
+ * not what core can theoretically support
107
+ * @returns The position
108
+ */
109
+ static fromAmount0({ pool, tickLower, tickUpper, amount0, useFullPrecision }: {
110
+ pool: Pool;
111
+ tickLower: number;
112
+ tickUpper: number;
113
+ amount0: BigintIsh;
114
+ useFullPrecision: boolean;
115
+ }): Position;
116
+ /**
117
+ * Computes a position with the maximum amount of liquidity received for a given amount of token1, assuming an unlimited amount of token0
118
+ * @param pool The pool for which the position is created
119
+ * @param tickLower The lower tick
120
+ * @param tickUpper The upper tick
121
+ * @param amount1 The desired amount of token1
122
+ * @returns The position
123
+ */
124
+ static fromAmount1({ pool, tickLower, tickUpper, amount1 }: {
125
+ pool: Pool;
126
+ tickLower: number;
127
+ tickUpper: number;
128
+ amount1: BigintIsh;
129
+ }): Position;
130
+ }
131
+ export {};
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Position = void 0;
7
+ const core_1 = require("../../core");
8
+ const jsbi_1 = __importDefault(require("jsbi"));
9
+ const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
10
+ const internalConstants_1 = require("../internalConstants");
11
+ const maxLiquidityForAmounts_1 = require("../utils/maxLiquidityForAmounts");
12
+ const priceTickConversions_1 = require("../utils/priceTickConversions");
13
+ const sqrtPriceMath_1 = require("../utils/sqrtPriceMath");
14
+ const tickMath_1 = require("../utils/tickMath");
15
+ const encodeSqrtRatioX96_1 = require("../utils/encodeSqrtRatioX96");
16
+ const pool_1 = require("./pool");
17
+ /**
18
+ * Represents a position on a Synthra V3 pool.
19
+ */
20
+ class Position {
21
+ /**
22
+ * Constructs a position for a given pool with the given liquidity
23
+ * @param pool For which pool the liquidity is assigned
24
+ * @param liquidity The amount of liquidity that is in the position
25
+ * @param tickLower The lower tick of the position
26
+ * @param tickUpper The upper tick of the position
27
+ */
28
+ constructor({ pool, liquidity, tickLower, tickUpper }) {
29
+ // cached resuts for the getters
30
+ this._token0Amount = null;
31
+ this._token1Amount = null;
32
+ this._mintAmounts = null;
33
+ (0, tiny_invariant_1.default)(tickLower < tickUpper, 'TICK_ORDER');
34
+ (0, tiny_invariant_1.default)(tickLower >= tickMath_1.TickMath.MIN_TICK && tickLower % pool.tickSpacing === 0, 'TICK_LOWER');
35
+ (0, tiny_invariant_1.default)(tickUpper <= tickMath_1.TickMath.MAX_TICK && tickUpper % pool.tickSpacing === 0, 'TICK_UPPER');
36
+ this.pool = pool;
37
+ this.tickLower = tickLower;
38
+ this.tickUpper = tickUpper;
39
+ this.liquidity = jsbi_1.default.BigInt(liquidity);
40
+ }
41
+ /**
42
+ * Returns the price of token0 at the lower tick
43
+ */
44
+ get token0PriceLower() {
45
+ return (0, priceTickConversions_1.tickToPrice)(this.pool.token0, this.pool.token1, this.tickLower);
46
+ }
47
+ /**
48
+ * Returns the price of token0 at the upper tick
49
+ */
50
+ get token0PriceUpper() {
51
+ return (0, priceTickConversions_1.tickToPrice)(this.pool.token0, this.pool.token1, this.tickUpper);
52
+ }
53
+ /**
54
+ * Returns the amount of token0 that this position's liquidity could be burned for at the current pool price
55
+ */
56
+ get amount0() {
57
+ if (this._token0Amount === null) {
58
+ if (this.pool.tickCurrent < this.tickLower) {
59
+ this._token0Amount = core_1.CurrencyAmount.fromRawAmount(this.pool.token0, sqrtPriceMath_1.SqrtPriceMath.getAmount0Delta(tickMath_1.TickMath.getSqrtRatioAtTick(this.tickLower), tickMath_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, false));
60
+ }
61
+ else if (this.pool.tickCurrent < this.tickUpper) {
62
+ this._token0Amount = core_1.CurrencyAmount.fromRawAmount(this.pool.token0, sqrtPriceMath_1.SqrtPriceMath.getAmount0Delta(this.pool.sqrtRatioX96, tickMath_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, false));
63
+ }
64
+ else {
65
+ this._token0Amount = core_1.CurrencyAmount.fromRawAmount(this.pool.token0, internalConstants_1.ZERO);
66
+ }
67
+ }
68
+ return this._token0Amount;
69
+ }
70
+ /**
71
+ * Returns the amount of token1 that this position's liquidity could be burned for at the current pool price
72
+ */
73
+ get amount1() {
74
+ if (this._token1Amount === null) {
75
+ if (this.pool.tickCurrent < this.tickLower) {
76
+ this._token1Amount = core_1.CurrencyAmount.fromRawAmount(this.pool.token1, internalConstants_1.ZERO);
77
+ }
78
+ else if (this.pool.tickCurrent < this.tickUpper) {
79
+ this._token1Amount = core_1.CurrencyAmount.fromRawAmount(this.pool.token1, sqrtPriceMath_1.SqrtPriceMath.getAmount1Delta(tickMath_1.TickMath.getSqrtRatioAtTick(this.tickLower), this.pool.sqrtRatioX96, this.liquidity, false));
80
+ }
81
+ else {
82
+ this._token1Amount = core_1.CurrencyAmount.fromRawAmount(this.pool.token1, sqrtPriceMath_1.SqrtPriceMath.getAmount1Delta(tickMath_1.TickMath.getSqrtRatioAtTick(this.tickLower), tickMath_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, false));
83
+ }
84
+ }
85
+ return this._token1Amount;
86
+ }
87
+ /**
88
+ * Returns the lower and upper sqrt ratios if the price 'slips' up to slippage tolerance percentage
89
+ * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
90
+ * @returns The sqrt ratios after slippage
91
+ */
92
+ ratiosAfterSlippage(slippageTolerance) {
93
+ const priceLower = this.pool.token0Price.asFraction.multiply(new core_1.Percent(1).subtract(slippageTolerance));
94
+ const priceUpper = this.pool.token0Price.asFraction.multiply(slippageTolerance.add(1));
95
+ let sqrtRatioX96Lower = (0, encodeSqrtRatioX96_1.encodeSqrtRatioX96)(priceLower.numerator, priceLower.denominator);
96
+ if (jsbi_1.default.lessThanOrEqual(sqrtRatioX96Lower, tickMath_1.TickMath.MIN_SQRT_RATIO)) {
97
+ sqrtRatioX96Lower = jsbi_1.default.add(tickMath_1.TickMath.MIN_SQRT_RATIO, jsbi_1.default.BigInt(1));
98
+ }
99
+ let sqrtRatioX96Upper = (0, encodeSqrtRatioX96_1.encodeSqrtRatioX96)(priceUpper.numerator, priceUpper.denominator);
100
+ if (jsbi_1.default.greaterThanOrEqual(sqrtRatioX96Upper, tickMath_1.TickMath.MAX_SQRT_RATIO)) {
101
+ sqrtRatioX96Upper = jsbi_1.default.subtract(tickMath_1.TickMath.MAX_SQRT_RATIO, jsbi_1.default.BigInt(1));
102
+ }
103
+ return {
104
+ sqrtRatioX96Lower,
105
+ sqrtRatioX96Upper
106
+ };
107
+ }
108
+ /**
109
+ * Returns the minimum amounts that must be sent in order to safely mint the amount of liquidity held by the position
110
+ * with the given slippage tolerance
111
+ * @param slippageTolerance Tolerance of unfavorable slippage from the current price
112
+ * @returns The amounts, with slippage
113
+ */
114
+ mintAmountsWithSlippage(slippageTolerance) {
115
+ // get lower/upper prices
116
+ const { sqrtRatioX96Upper, sqrtRatioX96Lower } = this.ratiosAfterSlippage(slippageTolerance);
117
+ // construct counterfactual pools
118
+ const poolLower = new pool_1.Pool(this.pool.token0, this.pool.token1, this.pool.fee, sqrtRatioX96Lower, 0 /* liquidity doesn't matter */, tickMath_1.TickMath.getTickAtSqrtRatio(sqrtRatioX96Lower));
119
+ const poolUpper = new pool_1.Pool(this.pool.token0, this.pool.token1, this.pool.fee, sqrtRatioX96Upper, 0 /* liquidity doesn't matter */, tickMath_1.TickMath.getTickAtSqrtRatio(sqrtRatioX96Upper));
120
+ // because the router is imprecise, we need to calculate the position that will be created (assuming no slippage)
121
+ const positionThatWillBeCreated = Position.fromAmounts({
122
+ pool: this.pool,
123
+ tickLower: this.tickLower,
124
+ tickUpper: this.tickUpper,
125
+ ...this.mintAmounts,
126
+ useFullPrecision: false
127
+ });
128
+ // we want the smaller amounts...
129
+ // ...which occurs at the upper price for amount0...
130
+ const { amount0 } = new Position({
131
+ pool: poolUpper,
132
+ liquidity: positionThatWillBeCreated.liquidity,
133
+ tickLower: this.tickLower,
134
+ tickUpper: this.tickUpper
135
+ }).mintAmounts;
136
+ // ...and the lower for amount1
137
+ const { amount1 } = new Position({
138
+ pool: poolLower,
139
+ liquidity: positionThatWillBeCreated.liquidity,
140
+ tickLower: this.tickLower,
141
+ tickUpper: this.tickUpper
142
+ }).mintAmounts;
143
+ return { amount0, amount1 };
144
+ }
145
+ /**
146
+ * Returns the minimum amounts that should be requested in order to safely burn the amount of liquidity held by the
147
+ * position with the given slippage tolerance
148
+ * @param slippageTolerance tolerance of unfavorable slippage from the current price
149
+ * @returns The amounts, with slippage
150
+ */
151
+ burnAmountsWithSlippage(slippageTolerance) {
152
+ // get lower/upper prices
153
+ const { sqrtRatioX96Upper, sqrtRatioX96Lower } = this.ratiosAfterSlippage(slippageTolerance);
154
+ // construct counterfactual pools
155
+ const poolLower = new pool_1.Pool(this.pool.token0, this.pool.token1, this.pool.fee, sqrtRatioX96Lower, 0 /* liquidity doesn't matter */, tickMath_1.TickMath.getTickAtSqrtRatio(sqrtRatioX96Lower));
156
+ const poolUpper = new pool_1.Pool(this.pool.token0, this.pool.token1, this.pool.fee, sqrtRatioX96Upper, 0 /* liquidity doesn't matter */, tickMath_1.TickMath.getTickAtSqrtRatio(sqrtRatioX96Upper));
157
+ // we want the smaller amounts...
158
+ // ...which occurs at the upper price for amount0...
159
+ const amount0 = new Position({
160
+ pool: poolUpper,
161
+ liquidity: this.liquidity,
162
+ tickLower: this.tickLower,
163
+ tickUpper: this.tickUpper
164
+ }).amount0;
165
+ // ...and the lower for amount1
166
+ const amount1 = new Position({
167
+ pool: poolLower,
168
+ liquidity: this.liquidity,
169
+ tickLower: this.tickLower,
170
+ tickUpper: this.tickUpper
171
+ }).amount1;
172
+ return { amount0: amount0.quotient, amount1: amount1.quotient };
173
+ }
174
+ /**
175
+ * Returns the minimum amounts that must be sent in order to mint the amount of liquidity held by the position at
176
+ * the current price for the pool
177
+ */
178
+ get mintAmounts() {
179
+ if (this._mintAmounts === null) {
180
+ if (this.pool.tickCurrent < this.tickLower) {
181
+ return {
182
+ amount0: sqrtPriceMath_1.SqrtPriceMath.getAmount0Delta(tickMath_1.TickMath.getSqrtRatioAtTick(this.tickLower), tickMath_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, true),
183
+ amount1: internalConstants_1.ZERO
184
+ };
185
+ }
186
+ else if (this.pool.tickCurrent < this.tickUpper) {
187
+ return {
188
+ amount0: sqrtPriceMath_1.SqrtPriceMath.getAmount0Delta(this.pool.sqrtRatioX96, tickMath_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, true),
189
+ amount1: sqrtPriceMath_1.SqrtPriceMath.getAmount1Delta(tickMath_1.TickMath.getSqrtRatioAtTick(this.tickLower), this.pool.sqrtRatioX96, this.liquidity, true)
190
+ };
191
+ }
192
+ else {
193
+ return {
194
+ amount0: internalConstants_1.ZERO,
195
+ amount1: sqrtPriceMath_1.SqrtPriceMath.getAmount1Delta(tickMath_1.TickMath.getSqrtRatioAtTick(this.tickLower), tickMath_1.TickMath.getSqrtRatioAtTick(this.tickUpper), this.liquidity, true)
196
+ };
197
+ }
198
+ }
199
+ return this._mintAmounts;
200
+ }
201
+ /**
202
+ * Computes the maximum amount of liquidity received for a given amount of token0, token1,
203
+ * and the prices at the tick boundaries.
204
+ * @param pool The pool for which the position should be created
205
+ * @param tickLower The lower tick of the position
206
+ * @param tickUpper The upper tick of the position
207
+ * @param amount0 token0 amount
208
+ * @param amount1 token1 amount
209
+ * @param useFullPrecision If false, liquidity will be maximized according to what the router can calculate,
210
+ * not what core can theoretically support
211
+ * @returns The amount of liquidity for the position
212
+ */
213
+ static fromAmounts({ pool, tickLower, tickUpper, amount0, amount1, useFullPrecision }) {
214
+ const sqrtRatioAX96 = tickMath_1.TickMath.getSqrtRatioAtTick(tickLower);
215
+ const sqrtRatioBX96 = tickMath_1.TickMath.getSqrtRatioAtTick(tickUpper);
216
+ return new Position({
217
+ pool,
218
+ tickLower,
219
+ tickUpper,
220
+ liquidity: (0, maxLiquidityForAmounts_1.maxLiquidityForAmounts)(pool.sqrtRatioX96, sqrtRatioAX96, sqrtRatioBX96, amount0, amount1, useFullPrecision)
221
+ });
222
+ }
223
+ /**
224
+ * Computes a position with the maximum amount of liquidity received for a given amount of token0, assuming an unlimited amount of token1
225
+ * @param pool The pool for which the position is created
226
+ * @param tickLower The lower tick
227
+ * @param tickUpper The upper tick
228
+ * @param amount0 The desired amount of token0
229
+ * @param useFullPrecision If true, liquidity will be maximized according to what the router can calculate,
230
+ * not what core can theoretically support
231
+ * @returns The position
232
+ */
233
+ static fromAmount0({ pool, tickLower, tickUpper, amount0, useFullPrecision }) {
234
+ return Position.fromAmounts({ pool, tickLower, tickUpper, amount0, amount1: core_1.MaxUint256, useFullPrecision });
235
+ }
236
+ /**
237
+ * Computes a position with the maximum amount of liquidity received for a given amount of token1, assuming an unlimited amount of token0
238
+ * @param pool The pool for which the position is created
239
+ * @param tickLower The lower tick
240
+ * @param tickUpper The upper tick
241
+ * @param amount1 The desired amount of token1
242
+ * @returns The position
243
+ */
244
+ static fromAmount1({ pool, tickLower, tickUpper, amount1 }) {
245
+ // this function always uses full precision,
246
+ return Position.fromAmounts({ pool, tickLower, tickUpper, amount0: core_1.MaxUint256, amount1, useFullPrecision: true });
247
+ }
248
+ }
249
+ exports.Position = Position;
250
+ //# sourceMappingURL=position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.js","sourceRoot":"","sources":["../../../src/v3/entities/position.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAyF;AACzF,gDAAuB;AACvB,oEAAsC;AACtC,4DAA2C;AAC3C,4EAAwE;AACxE,wEAA2D;AAC3D,0DAAsD;AACtD,gDAA4C;AAC5C,oEAAgE;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AAE,OAAO,EAAE,OAAO,EAAE,iBAAU,EAAE,gBAAgB,EAAE,CAAC,CAAA;IAC7G,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,WAAW,CAAC,EACxB,IAAI,EACJ,SAAS,EACT,SAAS,EACT,OAAO,EAMR;QACC,4CAA4C;QAC5C,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAA;IACnH,CAAC;CACF;AAlXD,4BAkXC"}
@@ -0,0 +1,26 @@
1
+ import { Currency, Price, Token } from '../../core';
2
+ import { Pool } from './pool';
3
+ /**
4
+ * Represents a list of pools through which a swap can occur
5
+ * @template TInput The input token
6
+ * @template TOutput The output token
7
+ */
8
+ export declare class Route<TInput extends Currency, TOutput extends Currency> {
9
+ readonly pools: Pool[];
10
+ readonly tokenPath: Token[];
11
+ readonly input: TInput;
12
+ readonly output: TOutput;
13
+ private _midPrice;
14
+ /**
15
+ * Creates an instance of route.
16
+ * @param pools An array of `Pool` objects, ordered by the route the swap will take
17
+ * @param input The input token
18
+ * @param output The output token
19
+ */
20
+ constructor(pools: Pool[], input: TInput, output: TOutput);
21
+ get chainId(): number;
22
+ /**
23
+ * Returns the mid price of the route
24
+ */
25
+ get midPrice(): Price<TInput, TOutput>;
26
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Route = void 0;
7
+ const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
8
+ const core_1 = require("../../core");
9
+ /**
10
+ * Represents a list of pools through which a swap can occur
11
+ * @template TInput The input token
12
+ * @template TOutput The output token
13
+ */
14
+ class Route {
15
+ /**
16
+ * Creates an instance of route.
17
+ * @param pools An array of `Pool` objects, ordered by the route the swap will take
18
+ * @param input The input token
19
+ * @param output The output token
20
+ */
21
+ constructor(pools, input, output) {
22
+ this._midPrice = null;
23
+ (0, tiny_invariant_1.default)(pools.length > 0, 'POOLS');
24
+ const chainId = pools[0].chainId;
25
+ const allOnSameChain = pools.every(pool => pool.chainId === chainId);
26
+ (0, tiny_invariant_1.default)(allOnSameChain, 'CHAIN_IDS');
27
+ const wrappedInput = input.wrapped;
28
+ (0, tiny_invariant_1.default)(pools[0].involvesToken(wrappedInput), 'INPUT');
29
+ (0, tiny_invariant_1.default)(pools[pools.length - 1].involvesToken(output.wrapped), 'OUTPUT');
30
+ /**
31
+ * Normalizes token0-token1 order and selects the next token/fee step to add to the path
32
+ * */
33
+ const tokenPath = [wrappedInput];
34
+ for (const [i, pool] of pools.entries()) {
35
+ const currentInputToken = tokenPath[i];
36
+ (0, tiny_invariant_1.default)(currentInputToken.equals(pool.token0) || currentInputToken.equals(pool.token1), 'PATH');
37
+ const nextToken = currentInputToken.equals(pool.token0) ? pool.token1 : pool.token0;
38
+ tokenPath.push(nextToken);
39
+ }
40
+ this.pools = pools;
41
+ this.tokenPath = tokenPath;
42
+ this.input = input;
43
+ this.output = (output !== null && output !== void 0 ? output : tokenPath[tokenPath.length - 1]);
44
+ }
45
+ get chainId() {
46
+ return this.pools[0].chainId;
47
+ }
48
+ /**
49
+ * Returns the mid price of the route
50
+ */
51
+ get midPrice() {
52
+ if (this._midPrice !== null)
53
+ return this._midPrice;
54
+ const price = this.pools.slice(1).reduce(({ nextInput, price }, pool) => {
55
+ return nextInput.equals(pool.token0)
56
+ ? {
57
+ nextInput: pool.token1,
58
+ price: price.multiply(pool.token0Price)
59
+ }
60
+ : {
61
+ nextInput: pool.token0,
62
+ price: price.multiply(pool.token1Price)
63
+ };
64
+ }, this.pools[0].token0.equals(this.input.wrapped)
65
+ ? {
66
+ nextInput: this.pools[0].token1,
67
+ price: this.pools[0].token0Price
68
+ }
69
+ : {
70
+ nextInput: this.pools[0].token0,
71
+ price: this.pools[0].token1Price
72
+ }).price;
73
+ return (this._midPrice = new core_1.Price(this.input, this.output, price.denominator, price.numerator));
74
+ }
75
+ }
76
+ exports.Route = Route;
77
+ //# sourceMappingURL=route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../src/v3/entities/route.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAsC;AAEtC,qCAAmD;AAGnD;;;;GAIG;AACH,MAAa,KAAK;IAQhB;;;;;OAKG;IACH,YAAmB,KAAa,EAAE,KAAa,EAAE,MAAe;QARxD,cAAS,GAAkC,IAAI,CAAA;QASrD,IAAA,wBAAS,EAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,OAAO,CAAC,CAAA;QAEpC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;QAChC,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,CAAA;QACpE,IAAA,wBAAS,EAAC,cAAc,EAAE,WAAW,CAAC,CAAA;QAEtC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAA;QAClC,IAAA,wBAAS,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAA;QAExD,IAAA,wBAAS,EAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAA;QAE1E;;aAEK;QACL,MAAM,SAAS,GAAY,CAAC,YAAY,CAAC,CAAA;QACzC,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE;YACvC,MAAM,iBAAiB,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;YACtC,IAAA,wBAAS,E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AE,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC;iBACxC,CAAA;QACP,CAAC,EACD,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YAC7C,CAAC,CAAC;gBACE,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;gBAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW;aACjC;YACH,CAAC,CAAC;gBACE,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;gBAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW;aACjC,CACN,CAAC,KAAK,CAAA;QAEP,OAAO,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,YAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA;IAClG,CAAC;CACF;AA9ED,sBA8EC"}
@@ -0,0 +1,13 @@
1
+ import JSBI from 'jsbi';
2
+ import { BigintIsh } from '../../core';
3
+ export interface TickConstructorArgs {
4
+ index: number;
5
+ liquidityGross: BigintIsh;
6
+ liquidityNet: BigintIsh;
7
+ }
8
+ export declare class Tick {
9
+ readonly index: number;
10
+ readonly liquidityGross: JSBI;
11
+ readonly liquidityNet: JSBI;
12
+ constructor({ index, liquidityGross, liquidityNet }: TickConstructorArgs);
13
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Tick = void 0;
7
+ const jsbi_1 = __importDefault(require("jsbi"));
8
+ const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
9
+ const utils_1 = require("../utils");
10
+ class Tick {
11
+ constructor({ index, liquidityGross, liquidityNet }) {
12
+ (0, tiny_invariant_1.default)(index >= utils_1.TickMath.MIN_TICK && index <= utils_1.TickMath.MAX_TICK, 'TICK');
13
+ this.index = index;
14
+ this.liquidityGross = jsbi_1.default.BigInt(liquidityGross);
15
+ this.liquidityNet = jsbi_1.default.BigInt(liquidityNet);
16
+ }
17
+ }
18
+ exports.Tick = Tick;
19
+ //# sourceMappingURL=tick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tick.js","sourceRoot":"","sources":["../../../src/v3/entities/tick.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,oEAAsC;AAEtC,oCAAmC;AAQnC,MAAa,IAAI;IAKf,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,YAAY,EAAuB;QACtE,IAAA,wBAAS,EAAC,KAAK,IAAI,gBAAQ,CAAC,QAAQ,IAAI,KAAK,IAAI,gBAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAC3E,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,cAAc,GAAG,cAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;QACjD,IAAI,CAAC,YAAY,GAAG,cAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAC/C,CAAC;CACF;AAXD,oBAWC"}
@@ -0,0 +1,31 @@
1
+ import { BigintIsh } from '../../core';
2
+ /**
3
+ * Provides information about ticks
4
+ */
5
+ export interface TickDataProvider {
6
+ /**
7
+ * Return information corresponding to a specific tick
8
+ * @param tick the tick to load
9
+ */
10
+ getTick(tick: number): Promise<{
11
+ liquidityNet: BigintIsh;
12
+ }>;
13
+ /**
14
+ * Return the next tick that is initialized within a single word
15
+ * @param tick The current tick
16
+ * @param lte Whether the next tick should be lte the current tick
17
+ * @param tickSpacing The tick spacing of the pool
18
+ */
19
+ nextInitializedTickWithinOneWord(tick: number, lte: boolean, tickSpacing: number): Promise<[number, boolean]>;
20
+ }
21
+ /**
22
+ * This tick data provider does not know how to fetch any tick data. It throws whenever it is required. Useful if you
23
+ * do not need to load tick data for your use case.
24
+ */
25
+ export declare class NoTickDataProvider implements TickDataProvider {
26
+ private static ERROR_MESSAGE;
27
+ getTick(_tick: number): Promise<{
28
+ liquidityNet: BigintIsh;
29
+ }>;
30
+ nextInitializedTickWithinOneWord(_tick: number, _lte: boolean, _tickSpacing: number): Promise<[number, boolean]>;
31
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoTickDataProvider = void 0;
4
+ /**
5
+ * This tick data provider does not know how to fetch any tick data. It throws whenever it is required. Useful if you
6
+ * do not need to load tick data for your use case.
7
+ */
8
+ class NoTickDataProvider {
9
+ async getTick(_tick) {
10
+ throw new Error(NoTickDataProvider.ERROR_MESSAGE);
11
+ }
12
+ async nextInitializedTickWithinOneWord(_tick, _lte, _tickSpacing) {
13
+ throw new Error(NoTickDataProvider.ERROR_MESSAGE);
14
+ }
15
+ }
16
+ exports.NoTickDataProvider = NoTickDataProvider;
17
+ NoTickDataProvider.ERROR_MESSAGE = 'No tick data provider was given';
18
+ //# sourceMappingURL=tickDataProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tickDataProvider.js","sourceRoot":"","sources":["../../../src/v3/entities/tickDataProvider.ts"],"names":[],"mappings":";;;AAqBA;;;GAGG;AACH,MAAa,kBAAkB;IAE7B,KAAK,CAAC,OAAO,CAAC,KAAa;QACzB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAA;IACnD,CAAC;IAED,KAAK,CAAC,gCAAgC,CACpC,KAAa,EACb,IAAa,EACb,YAAoB;QAEpB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAA;IACnD,CAAC;;AAZH,gDAaC;AAZgB,gCAAa,GAAG,iCAAiC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { BigintIsh } from '../../core';
2
+ import { Tick, TickConstructorArgs } from './tick';
3
+ import { TickDataProvider } from './tickDataProvider';
4
+ /**
5
+ * A data provider for ticks that is backed by an in-memory array of ticks.
6
+ */
7
+ export declare class TickListDataProvider implements TickDataProvider {
8
+ private ticks;
9
+ constructor(ticks: (Tick | TickConstructorArgs)[], tickSpacing: number);
10
+ getTick(tick: number): Promise<{
11
+ liquidityNet: BigintIsh;
12
+ liquidityGross: BigintIsh;
13
+ }>;
14
+ nextInitializedTickWithinOneWord(tick: number, lte: boolean, tickSpacing: number): Promise<[number, boolean]>;
15
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TickListDataProvider = void 0;
4
+ const tickList_1 = require("../utils/tickList");
5
+ const tick_1 = require("./tick");
6
+ /**
7
+ * A data provider for ticks that is backed by an in-memory array of ticks.
8
+ */
9
+ class TickListDataProvider {
10
+ constructor(ticks, tickSpacing) {
11
+ const ticksMapped = ticks.map(t => (t instanceof tick_1.Tick ? t : new tick_1.Tick(t)));
12
+ tickList_1.TickList.validateList(ticksMapped, tickSpacing);
13
+ this.ticks = ticksMapped;
14
+ }
15
+ async getTick(tick) {
16
+ return tickList_1.TickList.getTick(this.ticks, tick);
17
+ }
18
+ async nextInitializedTickWithinOneWord(tick, lte, tickSpacing) {
19
+ return tickList_1.TickList.nextInitializedTickWithinOneWord(this.ticks, tick, lte, tickSpacing);
20
+ }
21
+ }
22
+ exports.TickListDataProvider = TickListDataProvider;
23
+ //# sourceMappingURL=tickListDataProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tickListDataProvider.js","sourceRoot":"","sources":["../../../src/v3/entities/tickListDataProvider.ts"],"names":[],"mappings":";;;AACA,gDAA4C;AAC5C,iCAAkD;AAGlD;;GAEG;AACH,MAAa,oBAAoB;IAG/B,YAAY,KAAqC,EAAE,WAAmB;QACpE,MAAM,WAAW,GAAW,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,WAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,WAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACjF,mBAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,WAAW,CAAC,CAAA;QAC/C,IAAI,CAAC,KAAK,GAAG,WAAW,CAAA;IAC1B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAY;QACxB,OAAO,mBAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,gCAAgC,CAAC,IAAY,EAAE,GAAY,EAAE,WAAmB;QACpF,OAAO,mBAAQ,CAAC,gCAAgC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,CAAC,CAAA;IACtF,CAAC;CACF;AAhBD,oDAgBC"}