@kamino-finance/kliquidity-sdk 8.3.1 → 8.3.2
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/dist/Kamino.d.ts +12 -12
- package/dist/Kamino.d.ts.map +1 -1
- package/dist/Kamino.js +101 -120
- package/dist/Kamino.js.map +1 -1
- package/dist/constants/numericalValues.d.ts +3 -0
- package/dist/constants/numericalValues.d.ts.map +1 -1
- package/dist/constants/numericalValues.js +4 -1
- package/dist/constants/numericalValues.js.map +1 -1
- package/dist/rebalance_methods/autodriftRebalance.d.ts.map +1 -1
- package/dist/rebalance_methods/autodriftRebalance.js +10 -10
- package/dist/rebalance_methods/autodriftRebalance.js.map +1 -1
- package/dist/rebalance_methods/driftRebalance.d.ts.map +1 -1
- package/dist/rebalance_methods/driftRebalance.js +10 -10
- package/dist/rebalance_methods/driftRebalance.js.map +1 -1
- package/dist/rebalance_methods/expanderRebalance.d.ts.map +1 -1
- package/dist/rebalance_methods/expanderRebalance.js +3 -4
- package/dist/rebalance_methods/expanderRebalance.js.map +1 -1
- package/dist/rebalance_methods/pricePercentageRebalance.d.ts.map +1 -1
- package/dist/rebalance_methods/pricePercentageRebalance.js +5 -6
- package/dist/rebalance_methods/pricePercentageRebalance.js.map +1 -1
- package/dist/rebalance_methods/pricePercentageWithResetRebalance.d.ts.map +1 -1
- package/dist/rebalance_methods/pricePercentageWithResetRebalance.js +5 -6
- package/dist/rebalance_methods/pricePercentageWithResetRebalance.js.map +1 -1
- package/dist/rebalance_methods/takeProfitRebalance.d.ts.map +1 -1
- package/dist/rebalance_methods/takeProfitRebalance.js +5 -5
- package/dist/rebalance_methods/takeProfitRebalance.js.map +1 -1
- package/dist/services/OrcaService.d.ts +7 -11
- package/dist/services/OrcaService.d.ts.map +1 -1
- package/dist/services/OrcaService.js +132 -100
- package/dist/services/OrcaService.js.map +1 -1
- package/dist/services/OrcaWhirlpoolsResponse.d.ts +63 -92
- package/dist/services/OrcaWhirlpoolsResponse.d.ts.map +1 -1
- package/dist/utils/farms.d.ts +1 -0
- package/dist/utils/farms.d.ts.map +1 -0
- package/dist/utils/farms.js +2 -0
- package/dist/utils/farms.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/orca.d.ts +37 -1
- package/dist/utils/orca.d.ts.map +1 -1
- package/dist/utils/orca.js +242 -0
- package/dist/utils/orca.js.map +1 -1
- package/dist/utils/tokenUtils.d.ts +5 -5
- package/dist/utils/tokenUtils.d.ts.map +1 -1
- package/dist/utils/tokenUtils.js +11 -7
- package/dist/utils/tokenUtils.js.map +1 -1
- package/dist/utils/types.d.ts +5 -0
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/utils/types.js.map +1 -1
- package/dist/utils/utils.d.ts +0 -1
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +3 -4
- package/dist/utils/utils.js.map +1 -1
- package/dist/utils/whirlpools.d.ts +12 -1
- package/dist/utils/whirlpools.d.ts.map +1 -1
- package/dist/utils/whirlpools.js +30 -29
- package/dist/utils/whirlpools.js.map +1 -1
- package/package.json +4 -3
- package/src/Kamino.ts +252 -205
- package/src/constants/numericalValues.ts +5 -0
- package/src/rebalance_methods/autodriftRebalance.ts +30 -22
- package/src/rebalance_methods/driftRebalance.ts +30 -22
- package/src/rebalance_methods/expanderRebalance.ts +7 -4
- package/src/rebalance_methods/pricePercentageRebalance.ts +13 -6
- package/src/rebalance_methods/pricePercentageWithResetRebalance.ts +13 -6
- package/src/rebalance_methods/takeProfitRebalance.ts +13 -5
- package/src/services/OrcaService.ts +162 -125
- package/src/services/OrcaWhirlpoolsResponse.ts +69 -101
- package/src/utils/farms.ts +0 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/orca.ts +377 -1
- package/src/utils/tokenUtils.ts +5 -5
- package/src/utils/types.ts +7 -0
- package/src/utils/utils.ts +2 -4
- package/src/utils/whirlpools.ts +50 -31
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Decimal from 'decimal.js';
|
|
2
2
|
import { PositionRange, RebalanceFieldInfo, RebalanceFieldsDict } from '../utils/types';
|
|
3
3
|
import { Dex, readPriceOption } from '../utils';
|
|
4
|
-
import { priceToTickIndex,
|
|
4
|
+
import { priceToTickIndex, sqrtPriceToPrice as orcaSqrtPriceToPrice, tickIndexToPrice } from '@orca-so/whirlpools-core';
|
|
5
5
|
import { RebalanceRaw } from '../@codegen/kliquidity/types';
|
|
6
6
|
import { RebalanceTypeLabelName } from './consts';
|
|
7
7
|
import { upsertManyRebalanceFieldInfos } from './utils';
|
|
@@ -138,20 +138,24 @@ export function getPositionRangeFromAutodriftParams(
|
|
|
138
138
|
const upperTickIndex = startMidTick.add(ticksAboveMid);
|
|
139
139
|
|
|
140
140
|
if (dex == 'ORCA') {
|
|
141
|
-
const lowerPrice = tickIndexToPrice(lowerTickIndex.toNumber(), tokenADecimals, tokenBDecimals);
|
|
142
|
-
const upperPrice = tickIndexToPrice(upperTickIndex.toNumber(), tokenADecimals, tokenBDecimals);
|
|
141
|
+
const lowerPrice = new Decimal(tickIndexToPrice(lowerTickIndex.toNumber(), tokenADecimals, tokenBDecimals));
|
|
142
|
+
const upperPrice = new Decimal(tickIndexToPrice(upperTickIndex.toNumber(), tokenADecimals, tokenBDecimals));
|
|
143
143
|
return { lowerPrice, upperPrice };
|
|
144
144
|
} else if (dex == 'RAYDIUM') {
|
|
145
|
-
const lowerPrice =
|
|
146
|
-
SqrtPriceMath.
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
const lowerPrice = new Decimal(
|
|
146
|
+
SqrtPriceMath.sqrtPriceX64ToPrice(
|
|
147
|
+
SqrtPriceMath.getSqrtPriceX64FromTick(lowerTickIndex.toNumber()),
|
|
148
|
+
tokenADecimals,
|
|
149
|
+
tokenBDecimals
|
|
150
|
+
)
|
|
149
151
|
);
|
|
150
152
|
|
|
151
|
-
const upperPrice =
|
|
152
|
-
SqrtPriceMath.
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
const upperPrice = new Decimal(
|
|
154
|
+
SqrtPriceMath.sqrtPriceX64ToPrice(
|
|
155
|
+
SqrtPriceMath.getSqrtPriceX64FromTick(upperTickIndex.toNumber()),
|
|
156
|
+
tokenADecimals,
|
|
157
|
+
tokenBDecimals
|
|
158
|
+
)
|
|
155
159
|
);
|
|
156
160
|
|
|
157
161
|
return { lowerPrice, upperPrice };
|
|
@@ -184,7 +188,7 @@ export function getDefaultAutodriftRebalanceFieldInfos(
|
|
|
184
188
|
tokenBDecimals: number,
|
|
185
189
|
tickSpacing: number
|
|
186
190
|
): RebalanceFieldInfo[] {
|
|
187
|
-
const currentTickIndex = priceToTickIndex(price, tokenADecimals, tokenBDecimals);
|
|
191
|
+
const currentTickIndex = priceToTickIndex(price.toNumber(), tokenADecimals, tokenBDecimals);
|
|
188
192
|
const startMidTick = new Decimal(currentTickIndex);
|
|
189
193
|
|
|
190
194
|
return getAutodriftRebalanceFieldInfos(
|
|
@@ -262,19 +266,23 @@ export function readAutodriftRebalanceStateFromStrategy(
|
|
|
262
266
|
|
|
263
267
|
let lowerPrice: Decimal, upperPrice: Decimal;
|
|
264
268
|
if (dex == 'ORCA') {
|
|
265
|
-
lowerPrice = tickIndexToPrice(lowerTickIndex.toNumber(), tokenADecimals, tokenBDecimals);
|
|
266
|
-
upperPrice = tickIndexToPrice(upperTickIndex.toNumber(), tokenADecimals, tokenBDecimals);
|
|
269
|
+
lowerPrice = new Decimal(tickIndexToPrice(lowerTickIndex.toNumber(), tokenADecimals, tokenBDecimals));
|
|
270
|
+
upperPrice = new Decimal(tickIndexToPrice(upperTickIndex.toNumber(), tokenADecimals, tokenBDecimals));
|
|
267
271
|
} else if (dex == 'RAYDIUM') {
|
|
268
|
-
lowerPrice =
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
+
lowerPrice = new Decimal(
|
|
273
|
+
orcaSqrtPriceToPrice(
|
|
274
|
+
BigInt(SqrtPriceMath.getSqrtPriceX64FromTick(lowerTickIndex.toNumber()).toString()),
|
|
275
|
+
tokenADecimals,
|
|
276
|
+
tokenBDecimals
|
|
277
|
+
)
|
|
272
278
|
);
|
|
273
279
|
|
|
274
|
-
upperPrice =
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
280
|
+
upperPrice = new Decimal(
|
|
281
|
+
orcaSqrtPriceToPrice(
|
|
282
|
+
BigInt(SqrtPriceMath.getSqrtPriceX64FromTick(upperTickIndex.toNumber()).toString()),
|
|
283
|
+
tokenADecimals,
|
|
284
|
+
tokenBDecimals
|
|
285
|
+
)
|
|
278
286
|
);
|
|
279
287
|
} else if (dex == 'METEORA') {
|
|
280
288
|
lowerPrice = getPriceOfBinByBinIdWithDecimals(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Decimal from 'decimal.js';
|
|
2
2
|
import { PositionRange, RebalanceFieldInfo, RebalanceFieldsDict } from '../utils/types';
|
|
3
3
|
import { Dex } from '../utils';
|
|
4
|
-
import { priceToTickIndex,
|
|
4
|
+
import { priceToTickIndex, sqrtPriceToPrice as orcaSqrtPriceToPrice, tickIndexToPrice } from '@orca-so/whirlpools-core';
|
|
5
5
|
import { RebalanceRaw } from '../@codegen/kliquidity/types';
|
|
6
6
|
import { RebalanceTypeLabelName } from './consts';
|
|
7
7
|
import { upsertManyRebalanceFieldInfos } from './utils';
|
|
@@ -111,20 +111,24 @@ export function getPositionRangeFromDriftParams(
|
|
|
111
111
|
const upperTickIndex = startMidTick.add(ticksAboveMid);
|
|
112
112
|
|
|
113
113
|
if (dex == 'ORCA') {
|
|
114
|
-
const lowerPrice = tickIndexToPrice(lowerTickIndex.toNumber(), tokenADecimals, tokenBDecimals);
|
|
115
|
-
const upperPrice = tickIndexToPrice(upperTickIndex.toNumber(), tokenADecimals, tokenBDecimals);
|
|
114
|
+
const lowerPrice = new Decimal(tickIndexToPrice(lowerTickIndex.toNumber(), tokenADecimals, tokenBDecimals));
|
|
115
|
+
const upperPrice = new Decimal(tickIndexToPrice(upperTickIndex.toNumber(), tokenADecimals, tokenBDecimals));
|
|
116
116
|
return { lowerPrice, upperPrice };
|
|
117
117
|
} else if (dex == 'RAYDIUM') {
|
|
118
|
-
const lowerPrice =
|
|
119
|
-
SqrtPriceMath.
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
const lowerPrice = new Decimal(
|
|
119
|
+
SqrtPriceMath.sqrtPriceX64ToPrice(
|
|
120
|
+
SqrtPriceMath.getSqrtPriceX64FromTick(lowerTickIndex.toNumber()),
|
|
121
|
+
tokenADecimals,
|
|
122
|
+
tokenBDecimals
|
|
123
|
+
)
|
|
122
124
|
);
|
|
123
125
|
|
|
124
|
-
const upperPrice =
|
|
125
|
-
SqrtPriceMath.
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
const upperPrice = new Decimal(
|
|
127
|
+
SqrtPriceMath.sqrtPriceX64ToPrice(
|
|
128
|
+
SqrtPriceMath.getSqrtPriceX64FromTick(upperTickIndex.toNumber()),
|
|
129
|
+
tokenADecimals,
|
|
130
|
+
tokenBDecimals
|
|
131
|
+
)
|
|
128
132
|
);
|
|
129
133
|
|
|
130
134
|
return { lowerPrice, upperPrice };
|
|
@@ -157,7 +161,7 @@ export function getDefaultDriftRebalanceFieldInfos(
|
|
|
157
161
|
tokenADecimals: number,
|
|
158
162
|
tokenBDecimals: number
|
|
159
163
|
): RebalanceFieldInfo[] {
|
|
160
|
-
const currentTickIndex = priceToTickIndex(price, tokenADecimals, tokenBDecimals);
|
|
164
|
+
const currentTickIndex = priceToTickIndex(price.toNumber(), tokenADecimals, tokenBDecimals);
|
|
161
165
|
const startMidTick = new Decimal(currentTickIndex);
|
|
162
166
|
|
|
163
167
|
return getDriftRebalanceFieldInfos(
|
|
@@ -217,19 +221,23 @@ export function readDriftRebalanceStateFromStrategy(
|
|
|
217
221
|
|
|
218
222
|
let lowerPrice: Decimal, upperPrice: Decimal;
|
|
219
223
|
if (dex == 'ORCA') {
|
|
220
|
-
lowerPrice = tickIndexToPrice(lowerTickIndex.toNumber(), tokenADecimals, tokenBDecimals);
|
|
221
|
-
upperPrice = tickIndexToPrice(upperTickIndex.toNumber(), tokenADecimals, tokenBDecimals);
|
|
224
|
+
lowerPrice = new Decimal(tickIndexToPrice(lowerTickIndex.toNumber(), tokenADecimals, tokenBDecimals));
|
|
225
|
+
upperPrice = new Decimal(tickIndexToPrice(upperTickIndex.toNumber(), tokenADecimals, tokenBDecimals));
|
|
222
226
|
} else if (dex == 'RAYDIUM') {
|
|
223
|
-
lowerPrice =
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
+
lowerPrice = new Decimal(
|
|
228
|
+
orcaSqrtPriceToPrice(
|
|
229
|
+
BigInt(SqrtPriceMath.getSqrtPriceX64FromTick(lowerTickIndex.toNumber()).toString()),
|
|
230
|
+
tokenADecimals,
|
|
231
|
+
tokenBDecimals
|
|
232
|
+
)
|
|
227
233
|
);
|
|
228
234
|
|
|
229
|
-
upperPrice =
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
235
|
+
upperPrice = new Decimal(
|
|
236
|
+
orcaSqrtPriceToPrice(
|
|
237
|
+
BigInt(SqrtPriceMath.getSqrtPriceX64FromTick(upperTickIndex.toNumber()).toString()),
|
|
238
|
+
tokenADecimals,
|
|
239
|
+
tokenBDecimals
|
|
240
|
+
)
|
|
233
241
|
);
|
|
234
242
|
} else if (dex == 'METEORA') {
|
|
235
243
|
lowerPrice = getPriceOfBinByBinIdWithDecimals(
|
|
@@ -4,8 +4,7 @@ import { DefaultLowerPercentageBPSDecimal, DefaultUpperPercentageBPSDecimal } fr
|
|
|
4
4
|
import { RebalanceRaw } from '../@codegen/kliquidity/types';
|
|
5
5
|
import { RebalanceTypeLabelName } from './consts';
|
|
6
6
|
import { Dex, readBigUint128LE } from '../utils';
|
|
7
|
-
import {
|
|
8
|
-
import BN from 'bn.js';
|
|
7
|
+
import { sqrtPriceToPrice as orcaSqrtPriceToPrice } from '@orca-so/whirlpools-core';
|
|
9
8
|
import { upsertManyRebalanceFieldInfos } from './utils';
|
|
10
9
|
import { getPriceRangeFromPriceAndDiffBPS, getResetRangeFromPriceAndDiffBPS } from './math_utils';
|
|
11
10
|
import { getPriceFromQ64Price } from '../utils/meteora';
|
|
@@ -273,9 +272,13 @@ export function readExpanderRebalanceStateFromStrategy(
|
|
|
273
272
|
|
|
274
273
|
let initialPrice: Decimal;
|
|
275
274
|
if (dex == 'ORCA') {
|
|
276
|
-
initialPrice =
|
|
275
|
+
initialPrice = new Decimal(
|
|
276
|
+
orcaSqrtPriceToPrice(BigInt(initialPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
277
|
+
);
|
|
277
278
|
} else if (dex == 'RAYDIUM') {
|
|
278
|
-
initialPrice =
|
|
279
|
+
initialPrice = new Decimal(
|
|
280
|
+
orcaSqrtPriceToPrice(BigInt(initialPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
281
|
+
);
|
|
279
282
|
} else if (dex == 'METEORA') {
|
|
280
283
|
initialPrice = getPriceFromQ64Price(new Decimal(initialPriceX64.toString()), tokenADecimals, tokenBDecimals);
|
|
281
284
|
} else {
|
|
@@ -5,8 +5,7 @@ import { RebalanceRaw } from '../@codegen/kliquidity/types';
|
|
|
5
5
|
import { RebalanceTypeLabelName } from './consts';
|
|
6
6
|
import { Dex, readBigUint128LE } from '../utils';
|
|
7
7
|
import { upsertManyRebalanceFieldInfos } from './utils';
|
|
8
|
-
import {
|
|
9
|
-
import BN from 'bn.js';
|
|
8
|
+
import { sqrtPriceToPrice as orcaSqrtPriceToPrice } from '@orca-so/whirlpools-core';
|
|
10
9
|
import { getPriceRangeFromPriceAndDiffBPS } from './math_utils';
|
|
11
10
|
import { getPriceFromQ64Price } from '../utils/meteora';
|
|
12
11
|
|
|
@@ -131,11 +130,19 @@ export function readPricePercentageRebalanceStateFromStrategy(
|
|
|
131
130
|
let lowerPrice: Decimal, upperPrice: Decimal;
|
|
132
131
|
|
|
133
132
|
if (dex == 'ORCA') {
|
|
134
|
-
lowerPrice =
|
|
135
|
-
|
|
133
|
+
lowerPrice = new Decimal(
|
|
134
|
+
orcaSqrtPriceToPrice(BigInt(lowerSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
135
|
+
);
|
|
136
|
+
upperPrice = new Decimal(
|
|
137
|
+
orcaSqrtPriceToPrice(BigInt(upperSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
138
|
+
);
|
|
136
139
|
} else if (dex == 'RAYDIUM') {
|
|
137
|
-
lowerPrice =
|
|
138
|
-
|
|
140
|
+
lowerPrice = new Decimal(
|
|
141
|
+
orcaSqrtPriceToPrice(BigInt(lowerSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
142
|
+
);
|
|
143
|
+
upperPrice = new Decimal(
|
|
144
|
+
orcaSqrtPriceToPrice(BigInt(upperSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
145
|
+
);
|
|
139
146
|
} else if (dex == 'METEORA') {
|
|
140
147
|
lowerPrice = getPriceFromQ64Price(new Decimal(lowerSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals);
|
|
141
148
|
upperPrice = getPriceFromQ64Price(new Decimal(upperSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals);
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
import { RebalanceRaw } from '../@codegen/kliquidity/types';
|
|
9
9
|
import { RebalanceTypeLabelName } from './consts';
|
|
10
10
|
import { Dex, readBigUint128LE } from '../utils';
|
|
11
|
-
import {
|
|
12
|
-
import BN from 'bn.js';
|
|
11
|
+
import { sqrtPriceToPrice as orcaSqrtPriceToPrice } from '@orca-so/whirlpools-core';
|
|
13
12
|
import { upsertManyRebalanceFieldInfos } from './utils';
|
|
14
13
|
import { getPriceRangeFromPriceAndDiffBPS, getResetRangeFromPriceAndDiffBPS } from './math_utils';
|
|
15
14
|
import { getPriceFromQ64Price } from '../utils/meteora';
|
|
@@ -223,11 +222,19 @@ export function readPricePercentageWithResetRebalanceStateFromStrategy(
|
|
|
223
222
|
let lowerResetPrice: Decimal, upperResetPrice: Decimal;
|
|
224
223
|
|
|
225
224
|
if (dex == 'ORCA') {
|
|
226
|
-
lowerResetPrice =
|
|
227
|
-
|
|
225
|
+
lowerResetPrice = new Decimal(
|
|
226
|
+
orcaSqrtPriceToPrice(BigInt(lowerResetSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
227
|
+
);
|
|
228
|
+
upperResetPrice = new Decimal(
|
|
229
|
+
orcaSqrtPriceToPrice(BigInt(upperResetSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
230
|
+
);
|
|
228
231
|
} else if (dex == 'RAYDIUM') {
|
|
229
|
-
lowerResetPrice =
|
|
230
|
-
|
|
232
|
+
lowerResetPrice = new Decimal(
|
|
233
|
+
orcaSqrtPriceToPrice(BigInt(lowerResetSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
234
|
+
);
|
|
235
|
+
upperResetPrice = new Decimal(
|
|
236
|
+
orcaSqrtPriceToPrice(BigInt(upperResetSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
237
|
+
);
|
|
231
238
|
} else if (dex == 'METEORA') {
|
|
232
239
|
lowerResetPrice = getPriceFromQ64Price(
|
|
233
240
|
new Decimal(lowerResetSqrtPriceX64.toString()),
|
|
@@ -2,7 +2,7 @@ import Decimal from 'decimal.js';
|
|
|
2
2
|
import { PositionRange, RebalanceFieldInfo, RebalanceFieldsDict } from '../utils/types';
|
|
3
3
|
import { FullBPSDecimal } from '../utils/CreationParameters';
|
|
4
4
|
import { Dex, readBigUint128LE } from '../utils';
|
|
5
|
-
import {
|
|
5
|
+
import { sqrtPriceToPrice as orcaSqrtPriceToPrice } from '@orca-so/whirlpools-core';
|
|
6
6
|
import BN from 'bn.js';
|
|
7
7
|
import { RebalanceRaw } from '../@codegen/kliquidity/types';
|
|
8
8
|
import { getPriceFromQ64Price } from '../utils/meteora';
|
|
@@ -60,12 +60,20 @@ export function getPositionRangeFromTakeProfitParams(
|
|
|
60
60
|
upperSqrtPriceX64: Decimal
|
|
61
61
|
): PositionRange {
|
|
62
62
|
if (dex == 'ORCA') {
|
|
63
|
-
const lowerPrice =
|
|
64
|
-
|
|
63
|
+
const lowerPrice = new Decimal(
|
|
64
|
+
orcaSqrtPriceToPrice(BigInt(lowerSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
65
|
+
);
|
|
66
|
+
const upperPrice = new Decimal(
|
|
67
|
+
orcaSqrtPriceToPrice(BigInt(upperSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
68
|
+
);
|
|
65
69
|
return { lowerPrice, upperPrice };
|
|
66
70
|
} else if (dex == 'RAYDIUM') {
|
|
67
|
-
const lowerPrice =
|
|
68
|
-
|
|
71
|
+
const lowerPrice = new Decimal(
|
|
72
|
+
orcaSqrtPriceToPrice(BigInt(lowerSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
73
|
+
);
|
|
74
|
+
const upperPrice = new Decimal(
|
|
75
|
+
orcaSqrtPriceToPrice(BigInt(upperSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals)
|
|
76
|
+
);
|
|
69
77
|
return { lowerPrice, upperPrice };
|
|
70
78
|
} else if (dex == 'METEORA') {
|
|
71
79
|
const lowerPrice = getPriceFromQ64Price(new Decimal(lowerSqrtPriceX64.toString()), tokenADecimals, tokenBDecimals);
|