@pancakeswap/v3-sdk 1.0.0 → 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.
- package/LICENSE +674 -0
- package/dist/constants.d.ts +26 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/entities/index.d.ts +8 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/pool.d.ts +82 -0
- package/dist/entities/pool.d.ts.map +1 -0
- package/dist/entities/position.d.ts +131 -0
- package/dist/entities/position.d.ts.map +1 -0
- package/dist/entities/route.d.ts +27 -0
- package/dist/entities/route.d.ts.map +1 -0
- package/dist/entities/tick.d.ts +13 -0
- package/dist/entities/tick.d.ts.map +1 -0
- package/dist/entities/tickDataProvider.d.ts +32 -0
- package/dist/entities/tickDataProvider.d.ts.map +1 -0
- package/dist/entities/tickListDataProvider.d.ts +16 -0
- package/dist/entities/tickListDataProvider.d.ts.map +1 -0
- package/dist/entities/trade.d.ts +221 -0
- package/dist/entities/trade.d.ts.map +1 -0
- package/dist/index.d.ts +12 -1223
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +214 -227
- package/dist/index.mjs +214 -229
- package/dist/internalConstants.d.ts +11 -0
- package/dist/internalConstants.d.ts.map +1 -0
- package/dist/masterchefV3.d.ts +39 -0
- package/dist/masterchefV3.d.ts.map +1 -0
- package/dist/multicall.d.ts +10 -0
- package/dist/multicall.d.ts.map +1 -0
- package/dist/nonfungiblePositionManager.d.ts +149 -0
- package/dist/nonfungiblePositionManager.d.ts.map +1 -0
- package/dist/payments.d.ts +24 -0
- package/dist/payments.d.ts.map +1 -0
- package/dist/quoter.d.ts +38 -0
- package/dist/quoter.d.ts.map +1 -0
- package/dist/selfPermit.d.ts +26 -0
- package/dist/selfPermit.d.ts.map +1 -0
- package/dist/staker.d.ts +102 -0
- package/dist/staker.d.ts.map +1 -0
- package/dist/swapRouter.d.ts +52 -0
- package/dist/swapRouter.d.ts.map +1 -0
- package/dist/utils/calldata.d.ts +21 -0
- package/dist/utils/calldata.d.ts.map +1 -0
- package/dist/utils/computePoolAddress.d.ts +19 -0
- package/dist/utils/computePoolAddress.d.ts.map +1 -0
- package/dist/utils/encodeRouteToPath.d.ts +9 -0
- package/dist/utils/encodeRouteToPath.d.ts.map +1 -0
- package/dist/utils/encodeSqrtRatioX96.d.ts +9 -0
- package/dist/utils/encodeSqrtRatioX96.d.ts.map +1 -0
- package/dist/utils/feeCalculator.d.ts +65 -0
- package/dist/utils/feeCalculator.d.ts.map +1 -0
- package/dist/utils/fullMath.d.ts +8 -0
- package/dist/utils/fullMath.d.ts.map +1 -0
- package/dist/utils/index.d.ts +22 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/isSorted.d.ts +8 -0
- package/dist/utils/isSorted.d.ts.map +1 -0
- package/dist/utils/liquidityMath.d.ts +8 -0
- package/dist/utils/liquidityMath.d.ts.map +1 -0
- package/dist/utils/maxLiquidityForAmounts.d.ts +14 -0
- package/dist/utils/maxLiquidityForAmounts.d.ts.map +1 -0
- package/dist/utils/mostSignificantBit.d.ts +2 -0
- package/dist/utils/mostSignificantBit.d.ts.map +1 -0
- package/dist/utils/nearestUsableTick.d.ts +7 -0
- package/dist/utils/nearestUsableTick.d.ts.map +1 -0
- package/dist/utils/parseProtocolFees.d.ts +3 -0
- package/dist/utils/parseProtocolFees.d.ts.map +1 -0
- package/dist/utils/position.d.ts +8 -0
- package/dist/utils/position.d.ts.map +1 -0
- package/dist/utils/positionMath.d.ts +8 -0
- package/dist/utils/positionMath.d.ts.map +1 -0
- package/dist/utils/priceTickConversions.d.ts +16 -0
- package/dist/utils/priceTickConversions.d.ts.map +1 -0
- package/dist/utils/sqrtPriceMath.d.ts +13 -0
- package/dist/utils/sqrtPriceMath.d.ts.map +1 -0
- package/dist/utils/sqrtRatioX96ToPrice.d.ts +3 -0
- package/dist/utils/sqrtRatioX96ToPrice.d.ts.map +1 -0
- package/dist/utils/swapMath.d.ts +9 -0
- package/dist/utils/swapMath.d.ts.map +1 -0
- package/dist/utils/tickLibrary.d.ts +14 -0
- package/dist/utils/tickLibrary.d.ts.map +1 -0
- package/dist/utils/tickList.d.ts +25 -0
- package/dist/utils/tickList.d.ts.map +1 -0
- package/dist/utils/tickMath.d.ts +34 -0
- package/dist/utils/tickMath.d.ts.map +1 -0
- package/package.json +17 -14
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var sdk = require('@pancakeswap/sdk');
|
|
4
|
-
var JSBI4 = require('jsbi');
|
|
5
4
|
var invariant11 = require('tiny-invariant');
|
|
6
5
|
var swapSdkCore = require('@pancakeswap/swap-sdk-core');
|
|
7
6
|
var abi = require('@ethersproject/abi');
|
|
@@ -10,7 +9,6 @@ var solidity = require('@ethersproject/solidity');
|
|
|
10
9
|
|
|
11
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
11
|
|
|
13
|
-
var JSBI4__default = /*#__PURE__*/_interopDefault(JSBI4);
|
|
14
12
|
var invariant11__default = /*#__PURE__*/_interopDefault(invariant11);
|
|
15
13
|
|
|
16
14
|
// src/entities/pool.ts
|
|
@@ -37,15 +35,15 @@ var TICK_SPACINGS = {
|
|
|
37
35
|
[2500 /* MEDIUM */]: 50,
|
|
38
36
|
[1e4 /* HIGH */]: 200
|
|
39
37
|
};
|
|
40
|
-
var NEGATIVE_ONE =
|
|
41
|
-
var ZERO =
|
|
42
|
-
var ONE =
|
|
43
|
-
var Q96 =
|
|
44
|
-
var Q192 =
|
|
45
|
-
var MAX_FEE =
|
|
38
|
+
var NEGATIVE_ONE = BigInt(-1);
|
|
39
|
+
var ZERO = 0n;
|
|
40
|
+
var ONE = 1n;
|
|
41
|
+
var Q96 = 2n ** 96n;
|
|
42
|
+
var Q192 = Q96 ** 2n;
|
|
43
|
+
var MAX_FEE = 10n ** 6n;
|
|
46
44
|
var ONE_HUNDRED_PERCENT = new swapSdkCore.Percent("1");
|
|
47
45
|
var ZERO_PERCENT = new swapSdkCore.Percent("0");
|
|
48
|
-
var Q128 =
|
|
46
|
+
var Q128 = 2n ** 128n;
|
|
49
47
|
function computePoolAddress({
|
|
50
48
|
deployerAddress,
|
|
51
49
|
tokenA,
|
|
@@ -60,9 +58,11 @@ function computePoolAddress({
|
|
|
60
58
|
["bytes"],
|
|
61
59
|
[abi.defaultAbiCoder.encode(["address", "address", "uint24"], [token0.address, token1.address, fee])]
|
|
62
60
|
),
|
|
63
|
-
initCodeHashManualOverride
|
|
61
|
+
initCodeHashManualOverride ?? POOL_INIT_CODE_HASH
|
|
64
62
|
);
|
|
65
63
|
}
|
|
64
|
+
|
|
65
|
+
// src/utils/liquidityMath.ts
|
|
66
66
|
var LiquidityMath = class {
|
|
67
67
|
/**
|
|
68
68
|
* Cannot be constructed.
|
|
@@ -70,12 +70,14 @@ var LiquidityMath = class {
|
|
|
70
70
|
constructor() {
|
|
71
71
|
}
|
|
72
72
|
static addDelta(x, y) {
|
|
73
|
-
if (
|
|
74
|
-
return
|
|
73
|
+
if (y < ZERO) {
|
|
74
|
+
return x - y * NEGATIVE_ONE;
|
|
75
75
|
}
|
|
76
|
-
return
|
|
76
|
+
return x + y;
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
+
|
|
80
|
+
// src/utils/fullMath.ts
|
|
79
81
|
var FullMath = class {
|
|
80
82
|
/**
|
|
81
83
|
* Cannot be constructed.
|
|
@@ -83,21 +85,21 @@ var FullMath = class {
|
|
|
83
85
|
constructor() {
|
|
84
86
|
}
|
|
85
87
|
static mulDivRoundingUp(a, b, denominator) {
|
|
86
|
-
const product =
|
|
87
|
-
let result =
|
|
88
|
-
if (
|
|
89
|
-
result =
|
|
88
|
+
const product = a * b;
|
|
89
|
+
let result = product / denominator;
|
|
90
|
+
if (product % denominator !== ZERO)
|
|
91
|
+
result = result + ONE;
|
|
90
92
|
return result;
|
|
91
93
|
}
|
|
92
94
|
};
|
|
93
|
-
var MaxUint160 =
|
|
95
|
+
var MaxUint160 = 2n ** 160n - ONE;
|
|
94
96
|
function multiplyIn256(x, y) {
|
|
95
|
-
const product =
|
|
96
|
-
return
|
|
97
|
+
const product = x * y;
|
|
98
|
+
return product & sdk.MaxUint256;
|
|
97
99
|
}
|
|
98
100
|
function addIn256(x, y) {
|
|
99
|
-
const sum =
|
|
100
|
-
return
|
|
101
|
+
const sum = x + y;
|
|
102
|
+
return sum & sdk.MaxUint256;
|
|
101
103
|
}
|
|
102
104
|
var SqrtPriceMath = class {
|
|
103
105
|
/**
|
|
@@ -106,59 +108,59 @@ var SqrtPriceMath = class {
|
|
|
106
108
|
constructor() {
|
|
107
109
|
}
|
|
108
110
|
static getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, liquidity, roundUp) {
|
|
109
|
-
if (
|
|
111
|
+
if (sqrtRatioAX96 > sqrtRatioBX96) {
|
|
110
112
|
sqrtRatioAX96 = sqrtRatioBX96;
|
|
111
113
|
sqrtRatioBX96 = sqrtRatioAX96;
|
|
112
114
|
}
|
|
113
|
-
const numerator1 =
|
|
114
|
-
const numerator2 =
|
|
115
|
-
return roundUp ? FullMath.mulDivRoundingUp(FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96), ONE, sqrtRatioAX96) :
|
|
115
|
+
const numerator1 = liquidity << 96n;
|
|
116
|
+
const numerator2 = sqrtRatioBX96 - sqrtRatioAX96;
|
|
117
|
+
return roundUp ? FullMath.mulDivRoundingUp(FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96), ONE, sqrtRatioAX96) : numerator1 * numerator2 / sqrtRatioBX96 / sqrtRatioAX96;
|
|
116
118
|
}
|
|
117
119
|
static getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, liquidity, roundUp) {
|
|
118
|
-
if (
|
|
120
|
+
if (sqrtRatioAX96 > sqrtRatioBX96) {
|
|
119
121
|
sqrtRatioAX96 = sqrtRatioBX96;
|
|
120
122
|
sqrtRatioBX96 = sqrtRatioAX96;
|
|
121
123
|
}
|
|
122
|
-
return roundUp ? FullMath.mulDivRoundingUp(liquidity,
|
|
124
|
+
return roundUp ? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, Q96) : liquidity * (sqrtRatioBX96 - sqrtRatioAX96) / Q96;
|
|
123
125
|
}
|
|
124
126
|
static getNextSqrtPriceFromInput(sqrtPX96, liquidity, amountIn, zeroForOne) {
|
|
125
|
-
invariant11__default.default(
|
|
126
|
-
invariant11__default.default(
|
|
127
|
+
invariant11__default.default(sqrtPX96 > ZERO);
|
|
128
|
+
invariant11__default.default(liquidity > ZERO);
|
|
127
129
|
return zeroForOne ? this.getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true) : this.getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true);
|
|
128
130
|
}
|
|
129
131
|
static getNextSqrtPriceFromOutput(sqrtPX96, liquidity, amountOut, zeroForOne) {
|
|
130
|
-
invariant11__default.default(
|
|
131
|
-
invariant11__default.default(
|
|
132
|
+
invariant11__default.default(sqrtPX96 > ZERO);
|
|
133
|
+
invariant11__default.default(liquidity > ZERO);
|
|
132
134
|
return zeroForOne ? this.getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false) : this.getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);
|
|
133
135
|
}
|
|
134
136
|
static getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amount, add) {
|
|
135
|
-
if (
|
|
137
|
+
if (amount === ZERO)
|
|
136
138
|
return sqrtPX96;
|
|
137
|
-
const numerator1 =
|
|
139
|
+
const numerator1 = liquidity << 96n;
|
|
138
140
|
if (add) {
|
|
139
141
|
const product2 = multiplyIn256(amount, sqrtPX96);
|
|
140
|
-
if (
|
|
142
|
+
if (product2 / amount === sqrtPX96) {
|
|
141
143
|
const denominator2 = addIn256(numerator1, product2);
|
|
142
|
-
if (
|
|
144
|
+
if (denominator2 >= numerator1) {
|
|
143
145
|
return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator2);
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
|
-
return FullMath.mulDivRoundingUp(numerator1, ONE,
|
|
148
|
+
return FullMath.mulDivRoundingUp(numerator1, ONE, numerator1 / sqrtPX96 + amount);
|
|
147
149
|
}
|
|
148
150
|
const product = multiplyIn256(amount, sqrtPX96);
|
|
149
|
-
invariant11__default.default(
|
|
150
|
-
invariant11__default.default(
|
|
151
|
-
const denominator =
|
|
151
|
+
invariant11__default.default(product / amount === sqrtPX96);
|
|
152
|
+
invariant11__default.default(numerator1 > product);
|
|
153
|
+
const denominator = numerator1 - product;
|
|
152
154
|
return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator);
|
|
153
155
|
}
|
|
154
156
|
static getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amount, add) {
|
|
155
157
|
if (add) {
|
|
156
|
-
const quotient2 =
|
|
157
|
-
return
|
|
158
|
+
const quotient2 = amount <= MaxUint160 ? (amount << 96n) / liquidity : amount * Q96 / liquidity;
|
|
159
|
+
return sqrtPX96 + quotient2;
|
|
158
160
|
}
|
|
159
161
|
const quotient = FullMath.mulDivRoundingUp(amount, Q96, liquidity);
|
|
160
|
-
invariant11__default.default(
|
|
161
|
-
return
|
|
162
|
+
invariant11__default.default(sqrtPX96 > quotient);
|
|
163
|
+
return sqrtPX96 - quotient;
|
|
162
164
|
}
|
|
163
165
|
};
|
|
164
166
|
|
|
@@ -171,15 +173,12 @@ var SwapMath = class {
|
|
|
171
173
|
}
|
|
172
174
|
static computeSwapStep(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, amountRemaining, feePips) {
|
|
173
175
|
const returnValues = {};
|
|
174
|
-
const zeroForOne =
|
|
175
|
-
const exactIn =
|
|
176
|
+
const zeroForOne = sqrtRatioCurrentX96 >= sqrtRatioTargetX96;
|
|
177
|
+
const exactIn = amountRemaining >= ZERO;
|
|
176
178
|
if (exactIn) {
|
|
177
|
-
const amountRemainingLessFee =
|
|
178
|
-
JSBI4__default.default.multiply(amountRemaining, JSBI4__default.default.subtract(MAX_FEE, JSBI4__default.default.BigInt(feePips))),
|
|
179
|
-
MAX_FEE
|
|
180
|
-
);
|
|
179
|
+
const amountRemainingLessFee = amountRemaining * (MAX_FEE - BigInt(feePips)) / MAX_FEE;
|
|
181
180
|
returnValues.amountIn = zeroForOne ? SqrtPriceMath.getAmount0Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, true) : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, true);
|
|
182
|
-
if (
|
|
181
|
+
if (amountRemainingLessFee >= returnValues.amountIn) {
|
|
183
182
|
returnValues.sqrtRatioNextX96 = sqrtRatioTargetX96;
|
|
184
183
|
} else {
|
|
185
184
|
returnValues.sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput(
|
|
@@ -191,18 +190,18 @@ var SwapMath = class {
|
|
|
191
190
|
}
|
|
192
191
|
} else {
|
|
193
192
|
returnValues.amountOut = zeroForOne ? SqrtPriceMath.getAmount1Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, false) : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, false);
|
|
194
|
-
if (
|
|
193
|
+
if (amountRemaining * NEGATIVE_ONE >= returnValues.amountOut) {
|
|
195
194
|
returnValues.sqrtRatioNextX96 = sqrtRatioTargetX96;
|
|
196
195
|
} else {
|
|
197
196
|
returnValues.sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromOutput(
|
|
198
197
|
sqrtRatioCurrentX96,
|
|
199
198
|
liquidity,
|
|
200
|
-
|
|
199
|
+
amountRemaining * NEGATIVE_ONE,
|
|
201
200
|
zeroForOne
|
|
202
201
|
);
|
|
203
202
|
}
|
|
204
203
|
}
|
|
205
|
-
const max =
|
|
204
|
+
const max = sqrtRatioTargetX96 === returnValues.sqrtRatioNextX96;
|
|
206
205
|
if (zeroForOne) {
|
|
207
206
|
returnValues.amountIn = max && exactIn ? returnValues.amountIn : SqrtPriceMath.getAmount0Delta(returnValues.sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, true);
|
|
208
207
|
returnValues.amountOut = max && !exactIn ? returnValues.amountOut : SqrtPriceMath.getAmount1Delta(returnValues.sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, false);
|
|
@@ -210,33 +209,30 @@ var SwapMath = class {
|
|
|
210
209
|
returnValues.amountIn = max && exactIn ? returnValues.amountIn : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, returnValues.sqrtRatioNextX96, liquidity, true);
|
|
211
210
|
returnValues.amountOut = max && !exactIn ? returnValues.amountOut : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, returnValues.sqrtRatioNextX96, liquidity, false);
|
|
212
211
|
}
|
|
213
|
-
if (!exactIn &&
|
|
214
|
-
returnValues.amountOut =
|
|
212
|
+
if (!exactIn && returnValues.amountOut > amountRemaining * NEGATIVE_ONE) {
|
|
213
|
+
returnValues.amountOut = amountRemaining * NEGATIVE_ONE;
|
|
215
214
|
}
|
|
216
|
-
if (exactIn &&
|
|
217
|
-
returnValues.feeAmount =
|
|
215
|
+
if (exactIn && returnValues.sqrtRatioNextX96 !== sqrtRatioTargetX96) {
|
|
216
|
+
returnValues.feeAmount = amountRemaining - returnValues.amountIn;
|
|
218
217
|
} else {
|
|
219
218
|
returnValues.feeAmount = FullMath.mulDivRoundingUp(
|
|
220
219
|
returnValues.amountIn,
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
BigInt(feePips),
|
|
221
|
+
MAX_FEE - BigInt(feePips)
|
|
223
222
|
);
|
|
224
223
|
}
|
|
225
224
|
return [returnValues.sqrtRatioNextX96, returnValues.amountIn, returnValues.amountOut, returnValues.feeAmount];
|
|
226
225
|
}
|
|
227
226
|
};
|
|
228
|
-
var TWO =
|
|
229
|
-
var POWERS_OF_2 = [128, 64, 32, 16, 8, 4, 2, 1].map((pow) => [
|
|
230
|
-
pow,
|
|
231
|
-
JSBI4__default.default.exponentiate(TWO, JSBI4__default.default.BigInt(pow))
|
|
232
|
-
]);
|
|
227
|
+
var TWO = 2n;
|
|
228
|
+
var POWERS_OF_2 = [128, 64, 32, 16, 8, 4, 2, 1].map((pow) => [pow, TWO ** BigInt(pow)]);
|
|
233
229
|
function mostSignificantBit(x) {
|
|
234
|
-
invariant11__default.default(
|
|
235
|
-
invariant11__default.default(
|
|
230
|
+
invariant11__default.default(x > ZERO, "ZERO");
|
|
231
|
+
invariant11__default.default(x <= sdk.MaxUint256, "MAX");
|
|
236
232
|
let msb = 0;
|
|
237
233
|
for (const [power, min] of POWERS_OF_2) {
|
|
238
|
-
if (
|
|
239
|
-
x =
|
|
234
|
+
if (x >= min) {
|
|
235
|
+
x = x >> BigInt(power);
|
|
240
236
|
msb += power;
|
|
241
237
|
}
|
|
242
238
|
}
|
|
@@ -245,9 +241,9 @@ function mostSignificantBit(x) {
|
|
|
245
241
|
|
|
246
242
|
// src/utils/tickMath.ts
|
|
247
243
|
function mulShift(val, mulBy) {
|
|
248
|
-
return
|
|
244
|
+
return val * BigInt(mulBy) >> 128n;
|
|
249
245
|
}
|
|
250
|
-
var Q32 =
|
|
246
|
+
var Q32 = 2n ** 32n;
|
|
251
247
|
var _TickMath = class {
|
|
252
248
|
/**
|
|
253
249
|
* Cannot be constructed.
|
|
@@ -261,7 +257,7 @@ var _TickMath = class {
|
|
|
261
257
|
static getSqrtRatioAtTick(tick) {
|
|
262
258
|
invariant11__default.default(tick >= _TickMath.MIN_TICK && tick <= _TickMath.MAX_TICK && Number.isInteger(tick), "TICK");
|
|
263
259
|
const absTick = tick < 0 ? tick * -1 : tick;
|
|
264
|
-
let ratio = (absTick & 1) != 0 ?
|
|
260
|
+
let ratio = (absTick & 1) != 0 ? BigInt("0xfffcb933bd6fad37aa2d162d1a594001") : BigInt("0x100000000000000000000000000000000");
|
|
265
261
|
if ((absTick & 2) != 0)
|
|
266
262
|
ratio = mulShift(ratio, "0xfff97272373d413259a46990580e213a");
|
|
267
263
|
if ((absTick & 4) != 0)
|
|
@@ -301,8 +297,8 @@ var _TickMath = class {
|
|
|
301
297
|
if ((absTick & 524288) != 0)
|
|
302
298
|
ratio = mulShift(ratio, "0x48a170391f7dc42444e8fa2");
|
|
303
299
|
if (tick > 0)
|
|
304
|
-
ratio = sdk.
|
|
305
|
-
return
|
|
300
|
+
ratio = sdk.MaxUint256 / ratio;
|
|
301
|
+
return ratio % Q32 > ZERO ? ratio / Q32 + ONE : ratio / Q32;
|
|
306
302
|
}
|
|
307
303
|
/**
|
|
308
304
|
* Returns the tick corresponding to a given sqrt ratio, s.t. #getSqrtRatioAtTick(tick) <= sqrtRatioX96
|
|
@@ -310,39 +306,26 @@ var _TickMath = class {
|
|
|
310
306
|
* @param sqrtRatioX96 the sqrt ratio as a Q64.96 for which to compute the tick
|
|
311
307
|
*/
|
|
312
308
|
static getTickAtSqrtRatio(sqrtRatioX96) {
|
|
313
|
-
invariant11__default.default(
|
|
314
|
-
|
|
315
|
-
"SQRT_RATIO"
|
|
316
|
-
);
|
|
317
|
-
const sqrtRatioX128 = sdk.JSBI.leftShift(sqrtRatioX96, sdk.JSBI.BigInt(32));
|
|
309
|
+
invariant11__default.default(sqrtRatioX96 >= _TickMath.MIN_SQRT_RATIO && sqrtRatioX96 < _TickMath.MAX_SQRT_RATIO, "SQRT_RATIO");
|
|
310
|
+
const sqrtRatioX128 = sqrtRatioX96 << 32n;
|
|
318
311
|
const msb = mostSignificantBit(sqrtRatioX128);
|
|
319
312
|
let r;
|
|
320
|
-
if (
|
|
321
|
-
r =
|
|
313
|
+
if (BigInt(msb) >= 128n) {
|
|
314
|
+
r = sqrtRatioX128 >> BigInt(msb - 127);
|
|
322
315
|
} else {
|
|
323
|
-
r =
|
|
316
|
+
r = sqrtRatioX128 << BigInt(127 - msb);
|
|
324
317
|
}
|
|
325
|
-
let log_2 =
|
|
318
|
+
let log_2 = BigInt(msb) - 128n << 64n;
|
|
326
319
|
for (let i = 0; i < 14; i++) {
|
|
327
|
-
r =
|
|
328
|
-
const f =
|
|
329
|
-
log_2 =
|
|
330
|
-
r =
|
|
320
|
+
r = r * r >> 127n;
|
|
321
|
+
const f = r >> 128n;
|
|
322
|
+
log_2 = log_2 | f << BigInt(63 - i);
|
|
323
|
+
r = r >> f;
|
|
331
324
|
}
|
|
332
|
-
const log_sqrt10001 =
|
|
333
|
-
const tickLow =
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
sdk.JSBI.BigInt(128)
|
|
337
|
-
)
|
|
338
|
-
);
|
|
339
|
-
const tickHigh = sdk.JSBI.toNumber(
|
|
340
|
-
sdk.JSBI.signedRightShift(
|
|
341
|
-
sdk.JSBI.add(log_sqrt10001, sdk.JSBI.BigInt("291339464771989622907027621153398088495")),
|
|
342
|
-
sdk.JSBI.BigInt(128)
|
|
343
|
-
)
|
|
344
|
-
);
|
|
345
|
-
return tickLow === tickHigh ? tickLow : sdk.JSBI.lessThanOrEqual(_TickMath.getSqrtRatioAtTick(tickHigh), sqrtRatioX96) ? tickHigh : tickLow;
|
|
325
|
+
const log_sqrt10001 = log_2 * 255738958999603826347141n;
|
|
326
|
+
const tickLow = Number(log_sqrt10001 - 3402992956809132418596140100660247210n >> 128n);
|
|
327
|
+
const tickHigh = Number(log_sqrt10001 + 291339464771989622907027621153398088495n >> 128n);
|
|
328
|
+
return tickLow === tickHigh ? tickLow : _TickMath.getSqrtRatioAtTick(tickHigh) <= sqrtRatioX96 ? tickHigh : tickLow;
|
|
346
329
|
}
|
|
347
330
|
};
|
|
348
331
|
var TickMath = _TickMath;
|
|
@@ -358,11 +341,11 @@ TickMath.MAX_TICK = -_TickMath.MIN_TICK;
|
|
|
358
341
|
/**
|
|
359
342
|
* The sqrt ratio corresponding to the minimum tick that could be used on any pool.
|
|
360
343
|
*/
|
|
361
|
-
TickMath.MIN_SQRT_RATIO =
|
|
344
|
+
TickMath.MIN_SQRT_RATIO = 4295128739n;
|
|
362
345
|
/**
|
|
363
346
|
* The sqrt ratio corresponding to the maximum tick that could be used on any pool.
|
|
364
347
|
*/
|
|
365
|
-
TickMath.MAX_SQRT_RATIO =
|
|
348
|
+
TickMath.MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342n;
|
|
366
349
|
|
|
367
350
|
// src/entities/tickDataProvider.ts
|
|
368
351
|
var _NoTickDataProvider = class {
|
|
@@ -402,13 +385,7 @@ var TickList = class {
|
|
|
402
385
|
ticks.every(({ index }) => index % tickSpacing === 0),
|
|
403
386
|
"TICK_SPACING"
|
|
404
387
|
);
|
|
405
|
-
invariant11__default.default(
|
|
406
|
-
JSBI4__default.default.equal(
|
|
407
|
-
ticks.reduce((accumulator, { liquidityNet }) => JSBI4__default.default.add(accumulator, liquidityNet), ZERO),
|
|
408
|
-
ZERO
|
|
409
|
-
),
|
|
410
|
-
"ZERO_NET"
|
|
411
|
-
);
|
|
388
|
+
invariant11__default.default(ticks.reduce((accumulator, { liquidityNet }) => accumulator + liquidityNet, ZERO) === ZERO, "ZERO_NET");
|
|
412
389
|
invariant11__default.default(isSorted(ticks, tickComparator), "SORTED");
|
|
413
390
|
}
|
|
414
391
|
static isBelowSmallest(ticks, tick) {
|
|
@@ -493,8 +470,10 @@ var TickList = class {
|
|
|
493
470
|
return Math.abs(beforeIndex - afterIndex);
|
|
494
471
|
}
|
|
495
472
|
};
|
|
473
|
+
|
|
474
|
+
// src/utils/calldata.ts
|
|
496
475
|
function toHex(bigintIsh) {
|
|
497
|
-
const bigInt =
|
|
476
|
+
const bigInt = BigInt(bigintIsh);
|
|
498
477
|
let hex = bigInt.toString(16);
|
|
499
478
|
if (hex.length % 2 !== 0) {
|
|
500
479
|
hex = `0${hex}`;
|
|
@@ -524,48 +503,50 @@ function encodeRouteToPath(route, exactOutput) {
|
|
|
524
503
|
return exactOutput ? solidity.pack(types.reverse(), path.reverse()) : solidity.pack(types, path);
|
|
525
504
|
}
|
|
526
505
|
function encodeSqrtRatioX96(amount1, amount0) {
|
|
527
|
-
const numerator =
|
|
528
|
-
const denominator =
|
|
529
|
-
const ratioX192 =
|
|
506
|
+
const numerator = BigInt(amount1) << 192n;
|
|
507
|
+
const denominator = BigInt(amount0);
|
|
508
|
+
const ratioX192 = numerator / denominator;
|
|
530
509
|
return sdk.sqrt(ratioX192);
|
|
531
510
|
}
|
|
511
|
+
|
|
512
|
+
// src/utils/maxLiquidityForAmounts.ts
|
|
532
513
|
function maxLiquidityForAmount0Imprecise(sqrtRatioAX96, sqrtRatioBX96, amount0) {
|
|
533
|
-
if (
|
|
514
|
+
if (sqrtRatioAX96 > sqrtRatioBX96) {
|
|
534
515
|
sqrtRatioAX96 = sqrtRatioBX96;
|
|
535
516
|
sqrtRatioBX96 = sqrtRatioAX96;
|
|
536
517
|
}
|
|
537
|
-
const intermediate =
|
|
538
|
-
return
|
|
518
|
+
const intermediate = sqrtRatioAX96 * sqrtRatioBX96 / Q96;
|
|
519
|
+
return BigInt(amount0) * intermediate / (sqrtRatioBX96 - sqrtRatioAX96);
|
|
539
520
|
}
|
|
540
521
|
function maxLiquidityForAmount0Precise(sqrtRatioAX96, sqrtRatioBX96, amount0) {
|
|
541
|
-
if (
|
|
522
|
+
if (sqrtRatioAX96 > sqrtRatioBX96) {
|
|
542
523
|
sqrtRatioAX96 = sqrtRatioBX96;
|
|
543
524
|
sqrtRatioBX96 = sqrtRatioAX96;
|
|
544
525
|
}
|
|
545
|
-
const numerator =
|
|
546
|
-
const denominator =
|
|
547
|
-
return
|
|
526
|
+
const numerator = BigInt(amount0) * sqrtRatioAX96 * sqrtRatioBX96;
|
|
527
|
+
const denominator = Q96 * (sqrtRatioBX96 - sqrtRatioAX96);
|
|
528
|
+
return numerator / denominator;
|
|
548
529
|
}
|
|
549
530
|
function maxLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1) {
|
|
550
|
-
if (
|
|
531
|
+
if (sqrtRatioAX96 > sqrtRatioBX96) {
|
|
551
532
|
sqrtRatioAX96 = sqrtRatioBX96;
|
|
552
533
|
sqrtRatioBX96 = sqrtRatioAX96;
|
|
553
534
|
}
|
|
554
|
-
return
|
|
535
|
+
return BigInt(amount1) * Q96 / (sqrtRatioBX96 - sqrtRatioAX96);
|
|
555
536
|
}
|
|
556
537
|
function maxLiquidityForAmounts(sqrtRatioCurrentX96, sqrtRatioAX96, sqrtRatioBX96, amount0, amount1, useFullPrecision) {
|
|
557
|
-
if (
|
|
538
|
+
if (sqrtRatioAX96 > sqrtRatioBX96) {
|
|
558
539
|
sqrtRatioAX96 = sqrtRatioBX96;
|
|
559
540
|
sqrtRatioBX96 = sqrtRatioAX96;
|
|
560
541
|
}
|
|
561
542
|
const maxLiquidityForAmount0 = useFullPrecision ? maxLiquidityForAmount0Precise : maxLiquidityForAmount0Imprecise;
|
|
562
|
-
if (
|
|
543
|
+
if (sqrtRatioCurrentX96 <= sqrtRatioAX96) {
|
|
563
544
|
return maxLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0);
|
|
564
545
|
}
|
|
565
|
-
if (
|
|
546
|
+
if (sqrtRatioCurrentX96 < sqrtRatioBX96) {
|
|
566
547
|
const liquidity0 = maxLiquidityForAmount0(sqrtRatioCurrentX96, sqrtRatioBX96, amount0);
|
|
567
548
|
const liquidity1 = maxLiquidityForAmount1(sqrtRatioAX96, sqrtRatioCurrentX96, amount1);
|
|
568
|
-
return
|
|
549
|
+
return liquidity0 < liquidity1 ? liquidity0 : liquidity1;
|
|
569
550
|
}
|
|
570
551
|
return maxLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1);
|
|
571
552
|
}
|
|
@@ -580,6 +561,8 @@ function nearestUsableTick(tick, tickSpacing) {
|
|
|
580
561
|
return rounded - tickSpacing;
|
|
581
562
|
return rounded;
|
|
582
563
|
}
|
|
564
|
+
|
|
565
|
+
// src/utils/position.ts
|
|
583
566
|
var PositionLibrary = class {
|
|
584
567
|
/**
|
|
585
568
|
* Cannot be constructed.
|
|
@@ -588,20 +571,14 @@ var PositionLibrary = class {
|
|
|
588
571
|
}
|
|
589
572
|
// replicates the portions of Position#update required to compute unaccounted fees
|
|
590
573
|
static getTokensOwed(feeGrowthInside0LastX128, feeGrowthInside1LastX128, liquidity, feeGrowthInside0X128, feeGrowthInside1X128) {
|
|
591
|
-
const tokensOwed0 =
|
|
592
|
-
|
|
593
|
-
Q128
|
|
594
|
-
);
|
|
595
|
-
const tokensOwed1 = sdk.JSBI.divide(
|
|
596
|
-
sdk.JSBI.multiply(subIn256(feeGrowthInside1X128, feeGrowthInside1LastX128), liquidity),
|
|
597
|
-
Q128
|
|
598
|
-
);
|
|
574
|
+
const tokensOwed0 = subIn256(feeGrowthInside0X128, feeGrowthInside0LastX128) * liquidity / Q128;
|
|
575
|
+
const tokensOwed1 = subIn256(feeGrowthInside1X128, feeGrowthInside1LastX128) * liquidity / Q128;
|
|
599
576
|
return [tokensOwed0, tokensOwed1];
|
|
600
577
|
}
|
|
601
578
|
};
|
|
602
579
|
function tickToPrice(baseToken, quoteToken, tick) {
|
|
603
580
|
const sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);
|
|
604
|
-
const ratioX192 =
|
|
581
|
+
const ratioX192 = sqrtRatioX96 * sqrtRatioX96;
|
|
605
582
|
return baseToken.sortsBefore(quoteToken) ? new sdk.Price(baseToken, quoteToken, Q192, ratioX192) : new sdk.Price(baseToken, quoteToken, ratioX192, Q192);
|
|
606
583
|
}
|
|
607
584
|
function priceToClosestTick(price) {
|
|
@@ -618,11 +595,13 @@ function priceToClosestTick(price) {
|
|
|
618
595
|
}
|
|
619
596
|
return tick;
|
|
620
597
|
}
|
|
621
|
-
|
|
598
|
+
|
|
599
|
+
// src/utils/tickLibrary.ts
|
|
600
|
+
var Q256 = 2n ** 256n;
|
|
622
601
|
function subIn256(x, y) {
|
|
623
|
-
const difference =
|
|
624
|
-
if (
|
|
625
|
-
return
|
|
602
|
+
const difference = x - y;
|
|
603
|
+
if (difference < ZERO) {
|
|
604
|
+
return Q256 + difference;
|
|
626
605
|
}
|
|
627
606
|
return difference;
|
|
628
607
|
}
|
|
@@ -693,12 +672,13 @@ var PositionMath = {
|
|
|
693
672
|
};
|
|
694
673
|
function parseNumberToFraction(num, precision = 6) {
|
|
695
674
|
const scalar = 10 ** precision;
|
|
696
|
-
return new swapSdkCore.Fraction(
|
|
675
|
+
return new swapSdkCore.Fraction(BigInt(Math.floor(num * scalar)), BigInt(scalar));
|
|
697
676
|
}
|
|
698
677
|
|
|
699
678
|
// src/utils/feeCalculator.ts
|
|
700
679
|
var FeeCalculator = {
|
|
701
680
|
getEstimatedLPFee,
|
|
681
|
+
getEstimatedLPFeeByAmounts,
|
|
702
682
|
getLiquidityFromTick,
|
|
703
683
|
getLiquidityFromSqrtRatioX96,
|
|
704
684
|
getAverageLiquidity,
|
|
@@ -708,26 +688,40 @@ var FeeCalculator = {
|
|
|
708
688
|
getAmountsByLiquidityAndPrice,
|
|
709
689
|
getAmountsAtNewPrice
|
|
710
690
|
};
|
|
711
|
-
function getEstimatedLPFeeWithProtocolFee(
|
|
691
|
+
function getEstimatedLPFeeWithProtocolFee({ amount, currency, ...rest }) {
|
|
692
|
+
return getEstimatedLPFeeByAmountsWithProtocolFee({
|
|
693
|
+
...rest,
|
|
694
|
+
amountA: amount,
|
|
695
|
+
amountB: sdk.CurrencyAmount.fromRawAmount(currency, sdk.MaxUint256)
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
function getEstimatedLPFee({ amount, currency, ...rest }) {
|
|
699
|
+
return getEstimatedLPFeeByAmounts({
|
|
700
|
+
...rest,
|
|
701
|
+
amountA: amount,
|
|
702
|
+
amountB: sdk.CurrencyAmount.fromRawAmount(currency, sdk.MaxUint256)
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
function getEstimatedLPFeeByAmountsWithProtocolFee(options) {
|
|
712
706
|
try {
|
|
713
|
-
return
|
|
707
|
+
return tryGetEstimatedLPFeeByAmounts(options);
|
|
714
708
|
} catch (e) {
|
|
715
709
|
console.error(e);
|
|
716
710
|
return new sdk.Fraction(sdk.ZERO);
|
|
717
711
|
}
|
|
718
712
|
}
|
|
719
|
-
function
|
|
713
|
+
function getEstimatedLPFeeByAmounts({ protocolFee = ZERO_PERCENT, ...rest }) {
|
|
720
714
|
try {
|
|
721
|
-
const fee =
|
|
715
|
+
const fee = tryGetEstimatedLPFeeByAmounts(rest);
|
|
722
716
|
return ONE_HUNDRED_PERCENT.subtract(protocolFee).multiply(fee).asFraction;
|
|
723
717
|
} catch (e) {
|
|
724
718
|
console.error(e);
|
|
725
719
|
return new sdk.Fraction(sdk.ZERO);
|
|
726
720
|
}
|
|
727
721
|
}
|
|
728
|
-
function
|
|
729
|
-
|
|
730
|
-
|
|
722
|
+
function tryGetEstimatedLPFeeByAmounts({
|
|
723
|
+
amountA,
|
|
724
|
+
amountB,
|
|
731
725
|
volume24H,
|
|
732
726
|
sqrtRatioX96,
|
|
733
727
|
tickLower,
|
|
@@ -741,8 +735,14 @@ function tryGetEstimatedLPFee({
|
|
|
741
735
|
if (tickCurrent < tickLower || tickCurrent > tickUpper) {
|
|
742
736
|
return new sdk.Fraction(sdk.ZERO);
|
|
743
737
|
}
|
|
744
|
-
const liquidity = FeeCalculator.
|
|
745
|
-
|
|
738
|
+
const liquidity = FeeCalculator.getLiquidityByAmountsAndPrice({
|
|
739
|
+
amountA,
|
|
740
|
+
amountB,
|
|
741
|
+
tickUpper,
|
|
742
|
+
tickLower,
|
|
743
|
+
sqrtRatioX96
|
|
744
|
+
});
|
|
745
|
+
return insidePercentage.multiply(parseNumberToFraction(volume24H).multiply(BigInt(fee)).multiply(liquidity)).divide(MAX_FEE * (liquidity + mostActiveLiquidity)).asFraction;
|
|
746
746
|
}
|
|
747
747
|
function getDependentAmount(options) {
|
|
748
748
|
const { currency, amount, sqrtRatioX96, tickLower, tickUpper } = options;
|
|
@@ -809,42 +809,41 @@ function getAverageLiquidity(ticks, tickSpacing, tickLower, tickUpper) {
|
|
|
809
809
|
let currentTick = TickList.nextInitializedTick(ticks, tickLower, false);
|
|
810
810
|
let currentL = lowerOutOfBound ? sdk.ZERO : FeeCalculator.getLiquidityFromTick(ticks, currentTick.index);
|
|
811
811
|
let weightedL = sdk.ZERO;
|
|
812
|
-
const getWeightedLFromLastTickTo = (toTick) =>
|
|
812
|
+
const getWeightedLFromLastTickTo = (toTick) => currentL * BigInt(toTick - Math.max(lastTick.index, tickLower));
|
|
813
813
|
while (currentTick.index < tickUpper) {
|
|
814
|
-
weightedL
|
|
815
|
-
currentL
|
|
814
|
+
weightedL += getWeightedLFromLastTickTo(currentTick.index);
|
|
815
|
+
currentL += currentTick.liquidityNet;
|
|
816
816
|
lastTick = currentTick;
|
|
817
817
|
if (currentTick.index === ticks[ticks.length - 1].index) {
|
|
818
818
|
break;
|
|
819
819
|
}
|
|
820
820
|
currentTick = TickList.nextInitializedTick(ticks, currentTick.index, false);
|
|
821
821
|
}
|
|
822
|
-
weightedL
|
|
823
|
-
return
|
|
822
|
+
weightedL += getWeightedLFromLastTickTo(tickUpper);
|
|
823
|
+
return weightedL / BigInt(tickUpper - tickLower);
|
|
824
824
|
}
|
|
825
825
|
function getLiquidityFromSqrtRatioX96(ticks, sqrtRatioX96) {
|
|
826
826
|
const tick = TickMath.getTickAtSqrtRatio(sqrtRatioX96);
|
|
827
827
|
return FeeCalculator.getLiquidityFromTick(ticks, tick);
|
|
828
828
|
}
|
|
829
829
|
function getLiquidityFromTick(ticks, tick) {
|
|
830
|
-
var _a;
|
|
831
830
|
let liquidity = sdk.ZERO;
|
|
832
|
-
if (!
|
|
831
|
+
if (!ticks?.length)
|
|
833
832
|
return liquidity;
|
|
834
833
|
if (tick < ticks[0].index || tick > ticks[ticks.length - 1].index) {
|
|
835
834
|
return liquidity;
|
|
836
835
|
}
|
|
837
836
|
for (let i = 0; i < ticks.length - 1; ++i) {
|
|
838
|
-
liquidity
|
|
837
|
+
liquidity += ticks[i].liquidityNet;
|
|
839
838
|
const lowerTick = ticks[i].index;
|
|
840
|
-
const upperTick =
|
|
839
|
+
const upperTick = ticks[i + 1]?.index;
|
|
841
840
|
if (lowerTick <= tick && tick <= upperTick) {
|
|
842
841
|
break;
|
|
843
842
|
}
|
|
844
843
|
}
|
|
845
844
|
return liquidity;
|
|
846
845
|
}
|
|
847
|
-
var FEE_BASE =
|
|
846
|
+
var FEE_BASE = 10n ** 4n;
|
|
848
847
|
function parseProtocolFees(feeProtocol) {
|
|
849
848
|
const packed = Number(feeProtocol);
|
|
850
849
|
if (Number.isNaN(packed)) {
|
|
@@ -854,14 +853,18 @@ function parseProtocolFees(feeProtocol) {
|
|
|
854
853
|
const token1ProtocolFee = packed >> 16;
|
|
855
854
|
return [new sdk.Percent(token0ProtocolFee, FEE_BASE), new sdk.Percent(token1ProtocolFee, FEE_BASE)];
|
|
856
855
|
}
|
|
856
|
+
function sqrtRatioX96ToPrice(sqrtRatioX96, currencyA, currencyB) {
|
|
857
|
+
const ratioX192 = sqrtRatioX96 * sqrtRatioX96;
|
|
858
|
+
return currencyA.wrapped.sortsBefore(currencyB.wrapped) ? new swapSdkCore.Price(currencyA.wrapped, currencyB.wrapped, Q192, ratioX192) : new swapSdkCore.Price(currencyA.wrapped, currencyB.wrapped, ratioX192, Q192);
|
|
859
|
+
}
|
|
857
860
|
|
|
858
861
|
// src/entities/tick.ts
|
|
859
862
|
var Tick = class {
|
|
860
863
|
constructor({ index, liquidityGross, liquidityNet }) {
|
|
861
864
|
invariant11__default.default(index >= TickMath.MIN_TICK && index <= TickMath.MAX_TICK, "TICK");
|
|
862
865
|
this.index = index;
|
|
863
|
-
this.liquidityGross =
|
|
864
|
-
this.liquidityNet =
|
|
866
|
+
this.liquidityGross = BigInt(liquidityGross);
|
|
867
|
+
this.liquidityNet = BigInt(liquidityNet);
|
|
865
868
|
}
|
|
866
869
|
};
|
|
867
870
|
|
|
@@ -884,7 +887,7 @@ var NO_TICK_DATA_PROVIDER_DEFAULT = new NoTickDataProvider();
|
|
|
884
887
|
var Pool = class {
|
|
885
888
|
static getAddress(tokenA, tokenB, fee, initCodeHashManualOverride, deployerAddressOverride) {
|
|
886
889
|
return computePoolAddress({
|
|
887
|
-
deployerAddress: deployerAddressOverride
|
|
890
|
+
deployerAddress: deployerAddressOverride ?? DEPLOYER_ADDRESSES[tokenA.chainId],
|
|
888
891
|
fee,
|
|
889
892
|
tokenA,
|
|
890
893
|
tokenB,
|
|
@@ -905,8 +908,8 @@ var Pool = class {
|
|
|
905
908
|
invariant11__default.default(Number.isInteger(fee) && fee < 1e6, "FEE");
|
|
906
909
|
[this.token0, this.token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA];
|
|
907
910
|
this.fee = fee;
|
|
908
|
-
this.sqrtRatioX96 =
|
|
909
|
-
this.liquidity =
|
|
911
|
+
this.sqrtRatioX96 = BigInt(sqrtRatioX96);
|
|
912
|
+
this.liquidity = BigInt(liquidity);
|
|
910
913
|
this.tickCurrent = tickCurrent;
|
|
911
914
|
this.tickDataProvider = Array.isArray(ticks) ? new TickListDataProvider(ticks) : ticks;
|
|
912
915
|
}
|
|
@@ -922,25 +925,13 @@ var Pool = class {
|
|
|
922
925
|
* Returns the current mid price of the pool in terms of token0, i.e. the ratio of token1 over token0
|
|
923
926
|
*/
|
|
924
927
|
get token0Price() {
|
|
925
|
-
|
|
926
|
-
return (_a = this._token0Price) != null ? _a : this._token0Price = new sdk.Price(
|
|
927
|
-
this.token0,
|
|
928
|
-
this.token1,
|
|
929
|
-
Q192,
|
|
930
|
-
JSBI4__default.default.multiply(this.sqrtRatioX96, this.sqrtRatioX96)
|
|
931
|
-
);
|
|
928
|
+
return this._token0Price ?? (this._token0Price = new sdk.Price(this.token0, this.token1, Q192, this.sqrtRatioX96 * this.sqrtRatioX96));
|
|
932
929
|
}
|
|
933
930
|
/**
|
|
934
931
|
* Returns the current mid price of the pool in terms of token1, i.e. the ratio of token0 over token1
|
|
935
932
|
*/
|
|
936
933
|
get token1Price() {
|
|
937
|
-
|
|
938
|
-
return (_a = this._token1Price) != null ? _a : this._token1Price = new sdk.Price(
|
|
939
|
-
this.token1,
|
|
940
|
-
this.token0,
|
|
941
|
-
JSBI4__default.default.multiply(this.sqrtRatioX96, this.sqrtRatioX96),
|
|
942
|
-
Q192
|
|
943
|
-
);
|
|
934
|
+
return this._token1Price ?? (this._token1Price = new sdk.Price(this.token1, this.token0, this.sqrtRatioX96 * this.sqrtRatioX96, Q192));
|
|
944
935
|
}
|
|
945
936
|
/**
|
|
946
937
|
* Return the price of the given token in terms of the other token in the pool.
|
|
@@ -974,7 +965,7 @@ var Pool = class {
|
|
|
974
965
|
} = await this.swap(zeroForOne, inputAmount.quotient, sqrtPriceLimitX96);
|
|
975
966
|
const outputToken = zeroForOne ? this.token1 : this.token0;
|
|
976
967
|
return [
|
|
977
|
-
sdk.CurrencyAmount.fromRawAmount(outputToken,
|
|
968
|
+
sdk.CurrencyAmount.fromRawAmount(outputToken, outputAmount * NEGATIVE_ONE),
|
|
978
969
|
new Pool(this.token0, this.token1, this.fee, sqrtRatioX96, liquidity, tickCurrent, this.tickDataProvider)
|
|
979
970
|
];
|
|
980
971
|
}
|
|
@@ -993,8 +984,8 @@ var Pool = class {
|
|
|
993
984
|
sqrtRatioX96,
|
|
994
985
|
liquidity,
|
|
995
986
|
tickCurrent
|
|
996
|
-
} = await this.swap(zeroForOne,
|
|
997
|
-
invariant11__default.default(
|
|
987
|
+
} = await this.swap(zeroForOne, outputAmount.quotient * NEGATIVE_ONE, sqrtPriceLimitX96);
|
|
988
|
+
invariant11__default.default(amountSpecifiedRemaining === ZERO, "INSUFICIENT_LIQUIDITY");
|
|
998
989
|
const inputToken = zeroForOne ? this.token0 : this.token1;
|
|
999
990
|
return [
|
|
1000
991
|
sdk.CurrencyAmount.fromRawAmount(inputToken, inputAmount),
|
|
@@ -1013,15 +1004,15 @@ var Pool = class {
|
|
|
1013
1004
|
*/
|
|
1014
1005
|
async swap(zeroForOne, amountSpecified, sqrtPriceLimitX96) {
|
|
1015
1006
|
if (!sqrtPriceLimitX96)
|
|
1016
|
-
sqrtPriceLimitX96 = zeroForOne ?
|
|
1007
|
+
sqrtPriceLimitX96 = zeroForOne ? TickMath.MIN_SQRT_RATIO + ONE : TickMath.MAX_SQRT_RATIO - ONE;
|
|
1017
1008
|
if (zeroForOne) {
|
|
1018
|
-
invariant11__default.default(
|
|
1019
|
-
invariant11__default.default(
|
|
1009
|
+
invariant11__default.default(sqrtPriceLimitX96 > TickMath.MIN_SQRT_RATIO, "RATIO_MIN");
|
|
1010
|
+
invariant11__default.default(sqrtPriceLimitX96 < this.sqrtRatioX96, "RATIO_CURRENT");
|
|
1020
1011
|
} else {
|
|
1021
|
-
invariant11__default.default(
|
|
1022
|
-
invariant11__default.default(
|
|
1012
|
+
invariant11__default.default(sqrtPriceLimitX96 < TickMath.MAX_SQRT_RATIO, "RATIO_MAX");
|
|
1013
|
+
invariant11__default.default(sqrtPriceLimitX96 > this.sqrtRatioX96, "RATIO_CURRENT");
|
|
1023
1014
|
}
|
|
1024
|
-
const exactInput =
|
|
1015
|
+
const exactInput = amountSpecified >= ZERO;
|
|
1025
1016
|
const state = {
|
|
1026
1017
|
amountSpecifiedRemaining: amountSpecified,
|
|
1027
1018
|
amountCalculated: ZERO,
|
|
@@ -1029,7 +1020,7 @@ var Pool = class {
|
|
|
1029
1020
|
tick: this.tickCurrent,
|
|
1030
1021
|
liquidity: this.liquidity
|
|
1031
1022
|
};
|
|
1032
|
-
while (
|
|
1023
|
+
while (state.amountSpecifiedRemaining !== ZERO && state.sqrtPriceX96 != sqrtPriceLimitX96) {
|
|
1033
1024
|
const step = {};
|
|
1034
1025
|
step.sqrtPriceStartX96 = state.sqrtPriceX96;
|
|
1035
1026
|
[step.tickNext, step.initialized] = await this.tickDataProvider.nextInitializedTickWithinOneWord(
|
|
@@ -1045,30 +1036,27 @@ var Pool = class {
|
|
|
1045
1036
|
step.sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(step.tickNext);
|
|
1046
1037
|
[state.sqrtPriceX96, step.amountIn, step.amountOut, step.feeAmount] = SwapMath.computeSwapStep(
|
|
1047
1038
|
state.sqrtPriceX96,
|
|
1048
|
-
(zeroForOne ?
|
|
1039
|
+
(zeroForOne ? step.sqrtPriceNextX96 < sqrtPriceLimitX96 : step.sqrtPriceNextX96 > sqrtPriceLimitX96) ? sqrtPriceLimitX96 : step.sqrtPriceNextX96,
|
|
1049
1040
|
state.liquidity,
|
|
1050
1041
|
state.amountSpecifiedRemaining,
|
|
1051
1042
|
this.fee
|
|
1052
1043
|
);
|
|
1053
1044
|
if (exactInput) {
|
|
1054
|
-
state.amountSpecifiedRemaining =
|
|
1055
|
-
|
|
1056
|
-
JSBI4__default.default.add(step.amountIn, step.feeAmount)
|
|
1057
|
-
);
|
|
1058
|
-
state.amountCalculated = JSBI4__default.default.subtract(state.amountCalculated, step.amountOut);
|
|
1045
|
+
state.amountSpecifiedRemaining = state.amountSpecifiedRemaining - (step.amountIn + step.feeAmount);
|
|
1046
|
+
state.amountCalculated = state.amountCalculated - step.amountOut;
|
|
1059
1047
|
} else {
|
|
1060
|
-
state.amountSpecifiedRemaining =
|
|
1061
|
-
state.amountCalculated =
|
|
1048
|
+
state.amountSpecifiedRemaining = state.amountSpecifiedRemaining + step.amountOut;
|
|
1049
|
+
state.amountCalculated = state.amountCalculated + (step.amountIn + step.feeAmount);
|
|
1062
1050
|
}
|
|
1063
|
-
if (
|
|
1051
|
+
if (state.sqrtPriceX96 === step.sqrtPriceNextX96) {
|
|
1064
1052
|
if (step.initialized) {
|
|
1065
|
-
let liquidityNet =
|
|
1053
|
+
let liquidityNet = BigInt((await this.tickDataProvider.getTick(step.tickNext)).liquidityNet);
|
|
1066
1054
|
if (zeroForOne)
|
|
1067
|
-
liquidityNet =
|
|
1055
|
+
liquidityNet = liquidityNet * NEGATIVE_ONE;
|
|
1068
1056
|
state.liquidity = LiquidityMath.addDelta(state.liquidity, liquidityNet);
|
|
1069
1057
|
}
|
|
1070
1058
|
state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext;
|
|
1071
|
-
} else if (
|
|
1059
|
+
} else if (state.sqrtPriceX96 !== step.sqrtPriceStartX96) {
|
|
1072
1060
|
state.tick = TickMath.getTickAtSqrtRatio(state.sqrtPriceX96);
|
|
1073
1061
|
}
|
|
1074
1062
|
}
|
|
@@ -1103,7 +1091,7 @@ var Position = class {
|
|
|
1103
1091
|
this.pool = pool;
|
|
1104
1092
|
this.tickLower = tickLower;
|
|
1105
1093
|
this.tickUpper = tickUpper;
|
|
1106
|
-
this.liquidity =
|
|
1094
|
+
this.liquidity = BigInt(liquidity);
|
|
1107
1095
|
}
|
|
1108
1096
|
/**
|
|
1109
1097
|
* Returns the price of token0 at the lower tick
|
|
@@ -1162,12 +1150,12 @@ var Position = class {
|
|
|
1162
1150
|
const priceLower = this.pool.token0Price.asFraction.multiply(new sdk.Percent(1).subtract(slippageTolerance));
|
|
1163
1151
|
const priceUpper = this.pool.token0Price.asFraction.multiply(slippageTolerance.add(1));
|
|
1164
1152
|
let sqrtRatioX96Lower = encodeSqrtRatioX96(priceLower.numerator, priceLower.denominator);
|
|
1165
|
-
if (
|
|
1166
|
-
sqrtRatioX96Lower =
|
|
1153
|
+
if (sqrtRatioX96Lower <= TickMath.MIN_SQRT_RATIO) {
|
|
1154
|
+
sqrtRatioX96Lower = TickMath.MIN_SQRT_RATIO + 1n;
|
|
1167
1155
|
}
|
|
1168
1156
|
let sqrtRatioX96Upper = encodeSqrtRatioX96(priceUpper.numerator, priceUpper.denominator);
|
|
1169
|
-
if (
|
|
1170
|
-
sqrtRatioX96Upper =
|
|
1157
|
+
if (sqrtRatioX96Upper >= TickMath.MAX_SQRT_RATIO) {
|
|
1158
|
+
sqrtRatioX96Upper = TickMath.MAX_SQRT_RATIO - 1n;
|
|
1171
1159
|
}
|
|
1172
1160
|
return {
|
|
1173
1161
|
sqrtRatioX96Lower,
|
|
@@ -1401,7 +1389,7 @@ var Route = class {
|
|
|
1401
1389
|
this.pools = pools;
|
|
1402
1390
|
this.tokenPath = tokenPath;
|
|
1403
1391
|
this.input = input;
|
|
1404
|
-
this.output = output
|
|
1392
|
+
this.output = output ?? tokenPath[tokenPath.length - 1];
|
|
1405
1393
|
}
|
|
1406
1394
|
get chainId() {
|
|
1407
1395
|
return this.pools[0].chainId;
|
|
@@ -1492,13 +1480,12 @@ var Trade = class {
|
|
|
1492
1480
|
* The price expressed in terms of output amount/input amount.
|
|
1493
1481
|
*/
|
|
1494
1482
|
get executionPrice() {
|
|
1495
|
-
|
|
1496
|
-
return (_a = this._executionPrice) != null ? _a : this._executionPrice = new sdk.Price(
|
|
1483
|
+
return this._executionPrice ?? (this._executionPrice = new sdk.Price(
|
|
1497
1484
|
this.inputAmount.currency,
|
|
1498
1485
|
this.outputAmount.currency,
|
|
1499
1486
|
this.inputAmount.quotient,
|
|
1500
1487
|
this.outputAmount.quotient
|
|
1501
|
-
);
|
|
1488
|
+
));
|
|
1502
1489
|
}
|
|
1503
1490
|
/**
|
|
1504
1491
|
* Returns the percent difference between the route's mid price and the price impact
|
|
@@ -2757,7 +2744,7 @@ var Payments = _Payments;
|
|
|
2757
2744
|
Payments.INTERFACE = new abi.Interface(IPeripheryPaymentsWithFee_default);
|
|
2758
2745
|
|
|
2759
2746
|
// src/nonfungiblePositionManager.ts
|
|
2760
|
-
var MaxUint128 = toHex(
|
|
2747
|
+
var MaxUint128 = toHex(2n ** 128n - 1n);
|
|
2761
2748
|
function isMint(options) {
|
|
2762
2749
|
return Object.keys(options).some((k) => k === "recipient");
|
|
2763
2750
|
}
|
|
@@ -2783,7 +2770,7 @@ var _NonfungiblePositionManager = class {
|
|
|
2783
2770
|
};
|
|
2784
2771
|
}
|
|
2785
2772
|
static addCallParameters(position, options) {
|
|
2786
|
-
invariant11__default.default(
|
|
2773
|
+
invariant11__default.default(position.liquidity > ZERO, "ZERO_LIQUIDITY");
|
|
2787
2774
|
const calldatas = [];
|
|
2788
2775
|
const { amount0: amount0Desired, amount1: amount1Desired } = position.mintAmounts;
|
|
2789
2776
|
const minimumAmounts = position.mintAmountsWithSlippage(options.slippageTolerance);
|
|
@@ -2837,7 +2824,7 @@ var _NonfungiblePositionManager = class {
|
|
|
2837
2824
|
const { wrapped } = options.useNative;
|
|
2838
2825
|
invariant11__default.default(position.pool.token0.equals(wrapped) || position.pool.token1.equals(wrapped), "NO_WETH");
|
|
2839
2826
|
const wrappedValue = position.pool.token0.equals(wrapped) ? amount0Desired : amount1Desired;
|
|
2840
|
-
if (
|
|
2827
|
+
if (wrappedValue > ZERO) {
|
|
2841
2828
|
calldatas.push(Payments.encodeRefundETH());
|
|
2842
2829
|
}
|
|
2843
2830
|
value = toHex(wrappedValue);
|
|
@@ -2894,7 +2881,7 @@ var _NonfungiblePositionManager = class {
|
|
|
2894
2881
|
tickLower: position.tickLower,
|
|
2895
2882
|
tickUpper: position.tickUpper
|
|
2896
2883
|
});
|
|
2897
|
-
invariant11__default.default(
|
|
2884
|
+
invariant11__default.default(partialPosition.liquidity > ZERO, "ZERO_LIQUIDITY");
|
|
2898
2885
|
const { amount0: amount0Min, amount1: amount1Min } = partialPosition.burnAmountsWithSlippage(
|
|
2899
2886
|
options.slippageTolerance
|
|
2900
2887
|
);
|
|
@@ -3486,7 +3473,6 @@ var SwapQuoter = class {
|
|
|
3486
3473
|
* @returns The formatted calldata
|
|
3487
3474
|
*/
|
|
3488
3475
|
static quoteCallParameters(route, amount, tradeType, options = {}) {
|
|
3489
|
-
var _a;
|
|
3490
3476
|
const singleHop = route.pools.length === 1;
|
|
3491
3477
|
const quoteAmount = toHex(amount.quotient);
|
|
3492
3478
|
let calldata;
|
|
@@ -3496,7 +3482,7 @@ var SwapQuoter = class {
|
|
|
3496
3482
|
tokenIn: route.tokenPath[0].address,
|
|
3497
3483
|
tokenOut: route.tokenPath[1].address,
|
|
3498
3484
|
fee: route.pools[0].fee,
|
|
3499
|
-
sqrtPriceLimitX96: toHex(
|
|
3485
|
+
sqrtPriceLimitX96: toHex(options?.sqrtPriceLimitX96 ?? 0)
|
|
3500
3486
|
};
|
|
3501
3487
|
const v2QuoteParams = {
|
|
3502
3488
|
...baseQuoteParams,
|
|
@@ -3515,7 +3501,7 @@ var SwapQuoter = class {
|
|
|
3515
3501
|
options.useQuoterV2 ? [v2QuoteParams] : v1QuoteParams
|
|
3516
3502
|
);
|
|
3517
3503
|
} else {
|
|
3518
|
-
invariant11__default.default(
|
|
3504
|
+
invariant11__default.default(options?.sqrtPriceLimitX96 === void 0, "MULTIHOP_PRICE_LIMIT");
|
|
3519
3505
|
const path = encodeRouteToPath(route, tradeType === sdk.TradeType.EXACT_OUTPUT);
|
|
3520
3506
|
const tradeTypeFunctionName = tradeType === sdk.TradeType.EXACT_INPUT ? "quoteExactInput" : "quoteExactOutput";
|
|
3521
3507
|
calldata = swapInterface.encodeFunctionData(tradeTypeFunctionName, [path, quoteAmount]);
|
|
@@ -4248,7 +4234,6 @@ var _Staker = class {
|
|
|
4248
4234
|
* @returns The calldatas for 'unstakeToken' and 'claimReward'.
|
|
4249
4235
|
*/
|
|
4250
4236
|
static encodeClaim(incentiveKey, options) {
|
|
4251
|
-
var _a;
|
|
4252
4237
|
const calldatas = [];
|
|
4253
4238
|
calldatas.push(
|
|
4254
4239
|
_Staker.INTERFACE.encodeFunctionData("unstakeToken", [
|
|
@@ -4257,7 +4242,7 @@ var _Staker = class {
|
|
|
4257
4242
|
])
|
|
4258
4243
|
);
|
|
4259
4244
|
const recipient = sdk.validateAndParseAddress(options.recipient);
|
|
4260
|
-
const amount =
|
|
4245
|
+
const amount = options.amount ?? 0;
|
|
4261
4246
|
calldatas.push(
|
|
4262
4247
|
_Staker.INTERFACE.encodeFunctionData("claimReward", [incentiveKey.rewardToken.address, recipient, toHex(amount)])
|
|
4263
4248
|
);
|
|
@@ -4960,7 +4945,6 @@ var _SwapRouter = class {
|
|
|
4960
4945
|
* @param options options for the call parameters
|
|
4961
4946
|
*/
|
|
4962
4947
|
static swapCallParameters(trades, options) {
|
|
4963
|
-
var _a, _b;
|
|
4964
4948
|
if (!Array.isArray(trades)) {
|
|
4965
4949
|
trades = [trades];
|
|
4966
4950
|
}
|
|
@@ -5008,7 +4992,7 @@ var _SwapRouter = class {
|
|
|
5008
4992
|
deadline,
|
|
5009
4993
|
amountIn,
|
|
5010
4994
|
amountOutMinimum: amountOut,
|
|
5011
|
-
sqrtPriceLimitX96: toHex(
|
|
4995
|
+
sqrtPriceLimitX96: toHex(options.sqrtPriceLimitX96 ?? 0)
|
|
5012
4996
|
};
|
|
5013
4997
|
calldatas.push(_SwapRouter.INTERFACE.encodeFunctionData("exactInputSingle", [exactInputSingleParams]));
|
|
5014
4998
|
} else {
|
|
@@ -5020,7 +5004,7 @@ var _SwapRouter = class {
|
|
|
5020
5004
|
deadline,
|
|
5021
5005
|
amountOut,
|
|
5022
5006
|
amountInMaximum: amountIn,
|
|
5023
|
-
sqrtPriceLimitX96: toHex(
|
|
5007
|
+
sqrtPriceLimitX96: toHex(options.sqrtPriceLimitX96 ?? 0)
|
|
5024
5008
|
};
|
|
5025
5009
|
calldatas.push(_SwapRouter.INTERFACE.encodeFunctionData("exactOutputSingle", [exactOutputSingleParams]));
|
|
5026
5010
|
}
|
|
@@ -5768,7 +5752,7 @@ var _MasterChefV3 = class {
|
|
|
5768
5752
|
// Copy from NonfungiblePositionManager
|
|
5769
5753
|
// Only support increaseLiquidity
|
|
5770
5754
|
static addCallParameters(position, options) {
|
|
5771
|
-
invariant11__default.default(
|
|
5755
|
+
invariant11__default.default(position.liquidity > sdk.ZERO, "ZERO_LIQUIDITY");
|
|
5772
5756
|
const calldatas = [];
|
|
5773
5757
|
const { amount0: amount0Desired, amount1: amount1Desired } = position.mintAmounts;
|
|
5774
5758
|
const minimumAmounts = position.mintAmountsWithSlippage(options.slippageTolerance);
|
|
@@ -5848,7 +5832,7 @@ var _MasterChefV3 = class {
|
|
|
5848
5832
|
tickLower: position.tickLower,
|
|
5849
5833
|
tickUpper: position.tickUpper
|
|
5850
5834
|
});
|
|
5851
|
-
invariant11__default.default(
|
|
5835
|
+
invariant11__default.default(partialPosition.liquidity > sdk.ZERO, "ZERO_LIQUIDITY");
|
|
5852
5836
|
const { amount0: amount0Min, amount1: amount1Min } = partialPosition.burnAmountsWithSlippage(
|
|
5853
5837
|
options.slippageTolerance
|
|
5854
5838
|
);
|
|
@@ -5889,19 +5873,19 @@ var _MasterChefV3 = class {
|
|
|
5889
5873
|
...rest
|
|
5890
5874
|
})
|
|
5891
5875
|
);
|
|
5892
|
-
if (rest
|
|
5876
|
+
if (rest?.recipient) {
|
|
5893
5877
|
if (options.liquidityPercentage.equalTo(sdk.ONE)) {
|
|
5894
5878
|
calldatas.push(
|
|
5895
5879
|
_MasterChefV3.INTERFACE.encodeFunctionData("withdraw", [
|
|
5896
5880
|
tokenId.toString(),
|
|
5897
|
-
sdk.validateAndParseAddress(rest
|
|
5881
|
+
sdk.validateAndParseAddress(rest?.recipient)
|
|
5898
5882
|
])
|
|
5899
5883
|
);
|
|
5900
5884
|
} else {
|
|
5901
5885
|
calldatas.push(
|
|
5902
5886
|
_MasterChefV3.INTERFACE.encodeFunctionData("harvest", [
|
|
5903
5887
|
tokenId.toString(),
|
|
5904
|
-
sdk.validateAndParseAddress(rest
|
|
5888
|
+
sdk.validateAndParseAddress(rest?.recipient)
|
|
5905
5889
|
])
|
|
5906
5890
|
);
|
|
5907
5891
|
}
|
|
@@ -5997,6 +5981,8 @@ exports.getAmountsByLiquidityAndPrice = getAmountsByLiquidityAndPrice;
|
|
|
5997
5981
|
exports.getAverageLiquidity = getAverageLiquidity;
|
|
5998
5982
|
exports.getDependentAmount = getDependentAmount;
|
|
5999
5983
|
exports.getEstimatedLPFee = getEstimatedLPFee;
|
|
5984
|
+
exports.getEstimatedLPFeeByAmounts = getEstimatedLPFeeByAmounts;
|
|
5985
|
+
exports.getEstimatedLPFeeByAmountsWithProtocolFee = getEstimatedLPFeeByAmountsWithProtocolFee;
|
|
6000
5986
|
exports.getEstimatedLPFeeWithProtocolFee = getEstimatedLPFeeWithProtocolFee;
|
|
6001
5987
|
exports.getLiquidityByAmountsAndPrice = getLiquidityByAmountsAndPrice;
|
|
6002
5988
|
exports.getLiquidityBySingleAmount = getLiquidityBySingleAmount;
|
|
@@ -6009,6 +5995,7 @@ exports.mostSignificantBit = mostSignificantBit;
|
|
|
6009
5995
|
exports.nearestUsableTick = nearestUsableTick;
|
|
6010
5996
|
exports.parseProtocolFees = parseProtocolFees;
|
|
6011
5997
|
exports.priceToClosestTick = priceToClosestTick;
|
|
5998
|
+
exports.sqrtRatioX96ToPrice = sqrtRatioX96ToPrice;
|
|
6012
5999
|
exports.subIn256 = subIn256;
|
|
6013
6000
|
exports.tickToPrice = tickToPrice;
|
|
6014
6001
|
exports.toHex = toHex;
|