@crypticdot/defituna-client 3.1.18 → 3.2.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/dist/index.d.mts +33 -184
- package/dist/index.d.ts +33 -184
- package/dist/index.js +61 -321
- package/dist/index.mjs +346 -629
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -255,6 +255,7 @@ __export(index_exports, {
|
|
|
255
255
|
fetchTunaLpPosition: () => fetchTunaLpPosition,
|
|
256
256
|
fetchTunaSpotPosition: () => fetchTunaSpotPosition,
|
|
257
257
|
fetchVault: () => fetchVault,
|
|
258
|
+
fromPoolTokenFacade: () => fromPoolTokenFacade,
|
|
258
259
|
getAccountsTypeCodec: () => getAccountsTypeCodec,
|
|
259
260
|
getAccountsTypeDecoder: () => getAccountsTypeDecoder,
|
|
260
261
|
getAccountsTypeEncoder: () => getAccountsTypeEncoder,
|
|
@@ -325,7 +326,6 @@ __export(index_exports, {
|
|
|
325
326
|
getCreateVaultInstructionDataCodec: () => getCreateVaultInstructionDataCodec,
|
|
326
327
|
getCreateVaultInstructionDataDecoder: () => getCreateVaultInstructionDataDecoder,
|
|
327
328
|
getCreateVaultInstructionDataEncoder: () => getCreateVaultInstructionDataEncoder,
|
|
328
|
-
getDecreaseSpotPositionQuote: () => getDecreaseSpotPositionQuote,
|
|
329
329
|
getDecreaseTunaLpPositionFusionDiscriminatorBytes: () => getDecreaseTunaLpPositionFusionDiscriminatorBytes,
|
|
330
330
|
getDecreaseTunaLpPositionFusionInstruction: () => getDecreaseTunaLpPositionFusionInstruction,
|
|
331
331
|
getDecreaseTunaLpPositionFusionInstructionDataCodec: () => getDecreaseTunaLpPositionFusionInstructionDataCodec,
|
|
@@ -352,7 +352,6 @@ __export(index_exports, {
|
|
|
352
352
|
getDepositInstructionDataDecoder: () => getDepositInstructionDataDecoder,
|
|
353
353
|
getDepositInstructionDataEncoder: () => getDepositInstructionDataEncoder,
|
|
354
354
|
getIncreaseLpPositionQuote: () => getIncreaseLpPositionQuote,
|
|
355
|
-
getIncreaseSpotPositionQuote: () => getIncreaseSpotPositionQuote,
|
|
356
355
|
getIncreaseTunaLpPositionFusionDiscriminatorBytes: () => getIncreaseTunaLpPositionFusionDiscriminatorBytes,
|
|
357
356
|
getIncreaseTunaLpPositionFusionInstruction: () => getIncreaseTunaLpPositionFusionInstruction,
|
|
358
357
|
getIncreaseTunaLpPositionFusionInstructionDataCodec: () => getIncreaseTunaLpPositionFusionInstructionDataCodec,
|
|
@@ -400,7 +399,6 @@ __export(index_exports, {
|
|
|
400
399
|
getLiquidateTunaSpotPositionOrcaInstructionDataCodec: () => getLiquidateTunaSpotPositionOrcaInstructionDataCodec,
|
|
401
400
|
getLiquidateTunaSpotPositionOrcaInstructionDataDecoder: () => getLiquidateTunaSpotPositionOrcaInstructionDataDecoder,
|
|
402
401
|
getLiquidateTunaSpotPositionOrcaInstructionDataEncoder: () => getLiquidateTunaSpotPositionOrcaInstructionDataEncoder,
|
|
403
|
-
getLiquidationPrice: () => getLiquidationPrice,
|
|
404
402
|
getMarketAddress: () => getMarketAddress,
|
|
405
403
|
getMarketCodec: () => getMarketCodec,
|
|
406
404
|
getMarketDecoder: () => getMarketDecoder,
|
|
@@ -550,7 +548,6 @@ __export(index_exports, {
|
|
|
550
548
|
getSetTunaSpotPositionLimitOrdersInstructionDataCodec: () => getSetTunaSpotPositionLimitOrdersInstructionDataCodec,
|
|
551
549
|
getSetTunaSpotPositionLimitOrdersInstructionDataDecoder: () => getSetTunaSpotPositionLimitOrdersInstructionDataDecoder,
|
|
552
550
|
getSetTunaSpotPositionLimitOrdersInstructionDataEncoder: () => getSetTunaSpotPositionLimitOrdersInstructionDataEncoder,
|
|
553
|
-
getTradableAmount: () => getTradableAmount,
|
|
554
551
|
getTunaConfigAddress: () => getTunaConfigAddress,
|
|
555
552
|
getTunaConfigCodec: () => getTunaConfigCodec,
|
|
556
553
|
getTunaConfigDecoder: () => getTunaConfigDecoder,
|
|
@@ -614,6 +611,7 @@ __export(index_exports, {
|
|
|
614
611
|
liquidateTunaSpotPositionFusionInstructions: () => liquidateTunaSpotPositionFusionInstructions,
|
|
615
612
|
liquidateTunaSpotPositionOrcaInstruction: () => liquidateTunaSpotPositionOrcaInstruction,
|
|
616
613
|
liquidateTunaSpotPositionOrcaInstructions: () => liquidateTunaSpotPositionOrcaInstructions,
|
|
614
|
+
mulDiv: () => mulDiv,
|
|
617
615
|
openAndIncreaseTunaLpPositionFusionInstruction: () => openAndIncreaseTunaLpPositionFusionInstruction,
|
|
618
616
|
openAndIncreaseTunaLpPositionFusionInstructions: () => openAndIncreaseTunaLpPositionFusionInstructions,
|
|
619
617
|
openAndIncreaseTunaLpPositionOrcaInstruction: () => openAndIncreaseTunaLpPositionOrcaInstruction,
|
|
@@ -695,6 +693,7 @@ __export(index_exports, {
|
|
|
695
693
|
resetTunaSpotPositionInstruction: () => resetTunaSpotPositionInstruction,
|
|
696
694
|
setTunaLpPositionLimitOrdersInstruction: () => setTunaLpPositionLimitOrdersInstruction,
|
|
697
695
|
setTunaSpotPositionLimitOrdersInstruction: () => setTunaSpotPositionLimitOrdersInstruction,
|
|
696
|
+
toPoolTokenFacade: () => toPoolTokenFacade,
|
|
698
697
|
tunaLpPositionAuthorityFilter: () => tunaLpPositionAuthorityFilter,
|
|
699
698
|
tunaLpPositionMarketMakerFilter: () => tunaLpPositionMarketMakerFilter,
|
|
700
699
|
tunaLpPositionMintAFilter: () => tunaLpPositionMintAFilter,
|
|
@@ -2251,7 +2250,7 @@ function getCloseActiveTunaSpotPositionFusionInstructionDataEncoder() {
|
|
|
2251
2250
|
return (0, import_kit16.transformEncoder)(
|
|
2252
2251
|
(0, import_kit16.getStructEncoder)([
|
|
2253
2252
|
["discriminator", (0, import_kit16.fixEncoderSize)((0, import_kit16.getBytesEncoder)(), 8)],
|
|
2254
|
-
["
|
|
2253
|
+
["maxSwapAmountIn", (0, import_kit16.getU64Encoder)()],
|
|
2255
2254
|
["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
|
|
2256
2255
|
]),
|
|
2257
2256
|
(value) => ({
|
|
@@ -2263,7 +2262,7 @@ function getCloseActiveTunaSpotPositionFusionInstructionDataEncoder() {
|
|
|
2263
2262
|
function getCloseActiveTunaSpotPositionFusionInstructionDataDecoder() {
|
|
2264
2263
|
return (0, import_kit16.getStructDecoder)([
|
|
2265
2264
|
["discriminator", (0, import_kit16.fixDecoderSize)((0, import_kit16.getBytesDecoder)(), 8)],
|
|
2266
|
-
["
|
|
2265
|
+
["maxSwapAmountIn", (0, import_kit16.getU64Decoder)()],
|
|
2267
2266
|
["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
|
|
2268
2267
|
]);
|
|
2269
2268
|
}
|
|
@@ -2410,7 +2409,7 @@ function getCloseActiveTunaSpotPositionOrcaInstructionDataEncoder() {
|
|
|
2410
2409
|
return (0, import_kit17.transformEncoder)(
|
|
2411
2410
|
(0, import_kit17.getStructEncoder)([
|
|
2412
2411
|
["discriminator", (0, import_kit17.fixEncoderSize)((0, import_kit17.getBytesEncoder)(), 8)],
|
|
2413
|
-
["
|
|
2412
|
+
["maxSwapAmountIn", (0, import_kit17.getU64Encoder)()],
|
|
2414
2413
|
["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
|
|
2415
2414
|
]),
|
|
2416
2415
|
(value) => ({
|
|
@@ -2422,7 +2421,7 @@ function getCloseActiveTunaSpotPositionOrcaInstructionDataEncoder() {
|
|
|
2422
2421
|
function getCloseActiveTunaSpotPositionOrcaInstructionDataDecoder() {
|
|
2423
2422
|
return (0, import_kit17.getStructDecoder)([
|
|
2424
2423
|
["discriminator", (0, import_kit17.fixDecoderSize)((0, import_kit17.getBytesDecoder)(), 8)],
|
|
2425
|
-
["
|
|
2424
|
+
["maxSwapAmountIn", (0, import_kit17.getU64Decoder)()],
|
|
2426
2425
|
["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
|
|
2427
2426
|
]);
|
|
2428
2427
|
}
|
|
@@ -4363,7 +4362,7 @@ function getDecreaseTunaSpotPositionFusionInstructionDataEncoder() {
|
|
|
4363
4362
|
(0, import_kit31.getStructEncoder)([
|
|
4364
4363
|
["discriminator", (0, import_kit31.fixEncoderSize)((0, import_kit31.getBytesEncoder)(), 8)],
|
|
4365
4364
|
["withdrawPercent", (0, import_kit31.getU32Encoder)()],
|
|
4366
|
-
["
|
|
4365
|
+
["maxSwapAmountIn", (0, import_kit31.getU64Encoder)()],
|
|
4367
4366
|
["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
|
|
4368
4367
|
]),
|
|
4369
4368
|
(value) => ({
|
|
@@ -4376,7 +4375,7 @@ function getDecreaseTunaSpotPositionFusionInstructionDataDecoder() {
|
|
|
4376
4375
|
return (0, import_kit31.getStructDecoder)([
|
|
4377
4376
|
["discriminator", (0, import_kit31.fixDecoderSize)((0, import_kit31.getBytesDecoder)(), 8)],
|
|
4378
4377
|
["withdrawPercent", (0, import_kit31.getU32Decoder)()],
|
|
4379
|
-
["
|
|
4378
|
+
["maxSwapAmountIn", (0, import_kit31.getU64Decoder)()],
|
|
4380
4379
|
["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
|
|
4381
4380
|
]);
|
|
4382
4381
|
}
|
|
@@ -4539,7 +4538,7 @@ function getDecreaseTunaSpotPositionOrcaInstructionDataEncoder() {
|
|
|
4539
4538
|
(0, import_kit32.getStructEncoder)([
|
|
4540
4539
|
["discriminator", (0, import_kit32.fixEncoderSize)((0, import_kit32.getBytesEncoder)(), 8)],
|
|
4541
4540
|
["withdrawPercent", (0, import_kit32.getU32Encoder)()],
|
|
4542
|
-
["
|
|
4541
|
+
["maxSwapAmountIn", (0, import_kit32.getU64Encoder)()],
|
|
4543
4542
|
["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
|
|
4544
4543
|
]),
|
|
4545
4544
|
(value) => ({
|
|
@@ -4552,7 +4551,7 @@ function getDecreaseTunaSpotPositionOrcaInstructionDataDecoder() {
|
|
|
4552
4551
|
return (0, import_kit32.getStructDecoder)([
|
|
4553
4552
|
["discriminator", (0, import_kit32.fixDecoderSize)((0, import_kit32.getBytesDecoder)(), 8)],
|
|
4554
4553
|
["withdrawPercent", (0, import_kit32.getU32Decoder)()],
|
|
4555
|
-
["
|
|
4554
|
+
["maxSwapAmountIn", (0, import_kit32.getU64Decoder)()],
|
|
4556
4555
|
["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
|
|
4557
4556
|
]);
|
|
4558
4557
|
}
|
|
@@ -5205,7 +5204,7 @@ function getIncreaseTunaSpotPositionFusionInstructionDataEncoder() {
|
|
|
5205
5204
|
["discriminator", (0, import_kit36.fixEncoderSize)((0, import_kit36.getBytesEncoder)(), 8)],
|
|
5206
5205
|
["collateralAmount", (0, import_kit36.getU64Encoder)()],
|
|
5207
5206
|
["borrowAmount", (0, import_kit36.getU64Encoder)()],
|
|
5208
|
-
["
|
|
5207
|
+
["minSwapAmountOut", (0, import_kit36.getU64Encoder)()],
|
|
5209
5208
|
["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
|
|
5210
5209
|
]),
|
|
5211
5210
|
(value) => ({
|
|
@@ -5219,7 +5218,7 @@ function getIncreaseTunaSpotPositionFusionInstructionDataDecoder() {
|
|
|
5219
5218
|
["discriminator", (0, import_kit36.fixDecoderSize)((0, import_kit36.getBytesDecoder)(), 8)],
|
|
5220
5219
|
["collateralAmount", (0, import_kit36.getU64Decoder)()],
|
|
5221
5220
|
["borrowAmount", (0, import_kit36.getU64Decoder)()],
|
|
5222
|
-
["
|
|
5221
|
+
["minSwapAmountOut", (0, import_kit36.getU64Decoder)()],
|
|
5223
5222
|
["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
|
|
5224
5223
|
]);
|
|
5225
5224
|
}
|
|
@@ -5395,7 +5394,7 @@ function getIncreaseTunaSpotPositionOrcaInstructionDataEncoder() {
|
|
|
5395
5394
|
["discriminator", (0, import_kit37.fixEncoderSize)((0, import_kit37.getBytesEncoder)(), 8)],
|
|
5396
5395
|
["collateralAmount", (0, import_kit37.getU64Encoder)()],
|
|
5397
5396
|
["borrowAmount", (0, import_kit37.getU64Encoder)()],
|
|
5398
|
-
["
|
|
5397
|
+
["minSwapAmountOut", (0, import_kit37.getU64Encoder)()],
|
|
5399
5398
|
["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
|
|
5400
5399
|
]),
|
|
5401
5400
|
(value) => ({
|
|
@@ -5409,7 +5408,7 @@ function getIncreaseTunaSpotPositionOrcaInstructionDataDecoder() {
|
|
|
5409
5408
|
["discriminator", (0, import_kit37.fixDecoderSize)((0, import_kit37.getBytesDecoder)(), 8)],
|
|
5410
5409
|
["collateralAmount", (0, import_kit37.getU64Decoder)()],
|
|
5411
5410
|
["borrowAmount", (0, import_kit37.getU64Decoder)()],
|
|
5412
|
-
["
|
|
5411
|
+
["minSwapAmountOut", (0, import_kit37.getU64Decoder)()],
|
|
5413
5412
|
["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
|
|
5414
5413
|
]);
|
|
5415
5414
|
}
|
|
@@ -6745,10 +6744,7 @@ function getOpenAndIncreaseTunaSpotPositionFusionInstructionDataEncoder() {
|
|
|
6745
6744
|
["collateralToken", getPoolTokenEncoder()],
|
|
6746
6745
|
["collateralAmount", (0, import_kit44.getU64Encoder)()],
|
|
6747
6746
|
["borrowAmount", (0, import_kit44.getU64Encoder)()],
|
|
6748
|
-
["
|
|
6749
|
-
["upperLimitOrderSqrtPrice", (0, import_kit44.getU128Encoder)()],
|
|
6750
|
-
["flags", (0, import_kit44.getU32Encoder)()],
|
|
6751
|
-
["maxSwapSlippage", (0, import_kit44.getU32Encoder)()],
|
|
6747
|
+
["minSwapAmountOut", (0, import_kit44.getU64Encoder)()],
|
|
6752
6748
|
["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
|
|
6753
6749
|
]),
|
|
6754
6750
|
(value) => ({
|
|
@@ -6764,10 +6760,7 @@ function getOpenAndIncreaseTunaSpotPositionFusionInstructionDataDecoder() {
|
|
|
6764
6760
|
["collateralToken", getPoolTokenDecoder()],
|
|
6765
6761
|
["collateralAmount", (0, import_kit44.getU64Decoder)()],
|
|
6766
6762
|
["borrowAmount", (0, import_kit44.getU64Decoder)()],
|
|
6767
|
-
["
|
|
6768
|
-
["upperLimitOrderSqrtPrice", (0, import_kit44.getU128Decoder)()],
|
|
6769
|
-
["flags", (0, import_kit44.getU32Decoder)()],
|
|
6770
|
-
["maxSwapSlippage", (0, import_kit44.getU32Decoder)()],
|
|
6763
|
+
["minSwapAmountOut", (0, import_kit44.getU64Decoder)()],
|
|
6771
6764
|
["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
|
|
6772
6765
|
]);
|
|
6773
6766
|
}
|
|
@@ -6942,10 +6935,7 @@ function getOpenAndIncreaseTunaSpotPositionOrcaInstructionDataEncoder() {
|
|
|
6942
6935
|
["collateralToken", getPoolTokenEncoder()],
|
|
6943
6936
|
["collateralAmount", (0, import_kit45.getU64Encoder)()],
|
|
6944
6937
|
["borrowAmount", (0, import_kit45.getU64Encoder)()],
|
|
6945
|
-
["
|
|
6946
|
-
["upperLimitOrderSqrtPrice", (0, import_kit45.getU128Encoder)()],
|
|
6947
|
-
["flags", (0, import_kit45.getU32Encoder)()],
|
|
6948
|
-
["maxSwapSlippage", (0, import_kit45.getU32Encoder)()],
|
|
6938
|
+
["minSwapAmountOut", (0, import_kit45.getU64Encoder)()],
|
|
6949
6939
|
["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
|
|
6950
6940
|
]),
|
|
6951
6941
|
(value) => ({
|
|
@@ -6961,10 +6951,7 @@ function getOpenAndIncreaseTunaSpotPositionOrcaInstructionDataDecoder() {
|
|
|
6961
6951
|
["collateralToken", getPoolTokenDecoder()],
|
|
6962
6952
|
["collateralAmount", (0, import_kit45.getU64Decoder)()],
|
|
6963
6953
|
["borrowAmount", (0, import_kit45.getU64Decoder)()],
|
|
6964
|
-
["
|
|
6965
|
-
["upperLimitOrderSqrtPrice", (0, import_kit45.getU128Decoder)()],
|
|
6966
|
-
["flags", (0, import_kit45.getU32Decoder)()],
|
|
6967
|
-
["maxSwapSlippage", (0, import_kit45.getU32Decoder)()],
|
|
6954
|
+
["minSwapAmountOut", (0, import_kit45.getU64Decoder)()],
|
|
6968
6955
|
["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
|
|
6969
6956
|
]);
|
|
6970
6957
|
}
|
|
@@ -7565,10 +7552,7 @@ function getOpenTunaSpotPositionFusionInstructionDataEncoder() {
|
|
|
7565
7552
|
(0, import_kit49.getStructEncoder)([
|
|
7566
7553
|
["discriminator", (0, import_kit49.fixEncoderSize)((0, import_kit49.getBytesEncoder)(), 8)],
|
|
7567
7554
|
["positionToken", getPoolTokenEncoder()],
|
|
7568
|
-
["collateralToken", getPoolTokenEncoder()]
|
|
7569
|
-
["lowerLimitOrderSqrtPrice", (0, import_kit49.getU128Encoder)()],
|
|
7570
|
-
["upperLimitOrderSqrtPrice", (0, import_kit49.getU128Encoder)()],
|
|
7571
|
-
["flags", (0, import_kit49.getU32Encoder)()]
|
|
7555
|
+
["collateralToken", getPoolTokenEncoder()]
|
|
7572
7556
|
]),
|
|
7573
7557
|
(value) => ({
|
|
7574
7558
|
...value,
|
|
@@ -7580,10 +7564,7 @@ function getOpenTunaSpotPositionFusionInstructionDataDecoder() {
|
|
|
7580
7564
|
return (0, import_kit49.getStructDecoder)([
|
|
7581
7565
|
["discriminator", (0, import_kit49.fixDecoderSize)((0, import_kit49.getBytesDecoder)(), 8)],
|
|
7582
7566
|
["positionToken", getPoolTokenDecoder()],
|
|
7583
|
-
["collateralToken", getPoolTokenDecoder()]
|
|
7584
|
-
["lowerLimitOrderSqrtPrice", (0, import_kit49.getU128Decoder)()],
|
|
7585
|
-
["upperLimitOrderSqrtPrice", (0, import_kit49.getU128Decoder)()],
|
|
7586
|
-
["flags", (0, import_kit49.getU32Decoder)()]
|
|
7567
|
+
["collateralToken", getPoolTokenDecoder()]
|
|
7587
7568
|
]);
|
|
7588
7569
|
}
|
|
7589
7570
|
function getOpenTunaSpotPositionFusionInstructionDataCodec() {
|
|
@@ -7696,10 +7677,7 @@ function getOpenTunaSpotPositionOrcaInstructionDataEncoder() {
|
|
|
7696
7677
|
(0, import_kit50.getStructEncoder)([
|
|
7697
7678
|
["discriminator", (0, import_kit50.fixEncoderSize)((0, import_kit50.getBytesEncoder)(), 8)],
|
|
7698
7679
|
["positionToken", getPoolTokenEncoder()],
|
|
7699
|
-
["collateralToken", getPoolTokenEncoder()]
|
|
7700
|
-
["lowerLimitOrderSqrtPrice", (0, import_kit50.getU128Encoder)()],
|
|
7701
|
-
["upperLimitOrderSqrtPrice", (0, import_kit50.getU128Encoder)()],
|
|
7702
|
-
["flags", (0, import_kit50.getU32Encoder)()]
|
|
7680
|
+
["collateralToken", getPoolTokenEncoder()]
|
|
7703
7681
|
]),
|
|
7704
7682
|
(value) => ({
|
|
7705
7683
|
...value,
|
|
@@ -7711,10 +7689,7 @@ function getOpenTunaSpotPositionOrcaInstructionDataDecoder() {
|
|
|
7711
7689
|
return (0, import_kit50.getStructDecoder)([
|
|
7712
7690
|
["discriminator", (0, import_kit50.fixDecoderSize)((0, import_kit50.getBytesDecoder)(), 8)],
|
|
7713
7691
|
["positionToken", getPoolTokenDecoder()],
|
|
7714
|
-
["collateralToken", getPoolTokenDecoder()]
|
|
7715
|
-
["lowerLimitOrderSqrtPrice", (0, import_kit50.getU128Decoder)()],
|
|
7716
|
-
["upperLimitOrderSqrtPrice", (0, import_kit50.getU128Decoder)()],
|
|
7717
|
-
["flags", (0, import_kit50.getU32Decoder)()]
|
|
7692
|
+
["collateralToken", getPoolTokenDecoder()]
|
|
7718
7693
|
]);
|
|
7719
7694
|
}
|
|
7720
7695
|
function getOpenTunaSpotPositionOrcaInstructionDataCodec() {
|
|
@@ -8399,9 +8374,7 @@ function getResetTunaSpotPositionInstructionDataEncoder() {
|
|
|
8399
8374
|
(0, import_kit55.getStructEncoder)([
|
|
8400
8375
|
["discriminator", (0, import_kit55.fixEncoderSize)((0, import_kit55.getBytesEncoder)(), 8)],
|
|
8401
8376
|
["positionToken", getPoolTokenEncoder()],
|
|
8402
|
-
["collateralToken", getPoolTokenEncoder()]
|
|
8403
|
-
["lowerLimitOrderSqrtPrice", (0, import_kit55.getU128Encoder)()],
|
|
8404
|
-
["upperLimitOrderSqrtPrice", (0, import_kit55.getU128Encoder)()]
|
|
8377
|
+
["collateralToken", getPoolTokenEncoder()]
|
|
8405
8378
|
]),
|
|
8406
8379
|
(value) => ({
|
|
8407
8380
|
...value,
|
|
@@ -8413,9 +8386,7 @@ function getResetTunaSpotPositionInstructionDataDecoder() {
|
|
|
8413
8386
|
return (0, import_kit55.getStructDecoder)([
|
|
8414
8387
|
["discriminator", (0, import_kit55.fixDecoderSize)((0, import_kit55.getBytesDecoder)(), 8)],
|
|
8415
8388
|
["positionToken", getPoolTokenDecoder()],
|
|
8416
|
-
["collateralToken", getPoolTokenDecoder()]
|
|
8417
|
-
["lowerLimitOrderSqrtPrice", (0, import_kit55.getU128Decoder)()],
|
|
8418
|
-
["upperLimitOrderSqrtPrice", (0, import_kit55.getU128Decoder)()]
|
|
8389
|
+
["collateralToken", getPoolTokenDecoder()]
|
|
8419
8390
|
]);
|
|
8420
8391
|
}
|
|
8421
8392
|
function getResetTunaSpotPositionInstructionDataCodec() {
|
|
@@ -10037,6 +10008,15 @@ async function fetchAllMarketWithFilter(rpc, ...filters) {
|
|
|
10037
10008
|
return fetchDecodedProgramAccounts(rpc, TUNA_PROGRAM_ADDRESS, [discriminatorFilter, ...filters], getMarketDecoder());
|
|
10038
10009
|
}
|
|
10039
10010
|
|
|
10011
|
+
// src/utils/math.ts
|
|
10012
|
+
function mulDiv(x, y, d, roundUp = false) {
|
|
10013
|
+
if (!roundUp) {
|
|
10014
|
+
return x * y / d;
|
|
10015
|
+
} else {
|
|
10016
|
+
return (x * y + (d - 1n)) / d;
|
|
10017
|
+
}
|
|
10018
|
+
}
|
|
10019
|
+
|
|
10040
10020
|
// src/utils/orca.ts
|
|
10041
10021
|
var import_fusionamm_core = require("@crypticdot/fusionamm-core");
|
|
10042
10022
|
var import_whirlpools_client = require("@orca-so/whirlpools-client");
|
|
@@ -10291,263 +10271,6 @@ function calculateProtocolFee(collateralAmount, borrowAmount, protocolFeeRateOnC
|
|
|
10291
10271
|
return collateralAmount * BigInt(protocolFeeRateOnCollateral) / BigInt(HUNDRED_PERCENT) + borrowAmount * BigInt(protocolFeeRate) / BigInt(HUNDRED_PERCENT);
|
|
10292
10272
|
}
|
|
10293
10273
|
|
|
10294
|
-
// src/utils/spotPositionMath.ts
|
|
10295
|
-
var import_fusionamm_core4 = require("@crypticdot/fusionamm-core");
|
|
10296
|
-
function getIncreaseSpotPositionQuote(args) {
|
|
10297
|
-
const {
|
|
10298
|
-
fusionPool,
|
|
10299
|
-
tickArrays,
|
|
10300
|
-
leverage,
|
|
10301
|
-
protocolFeeRate,
|
|
10302
|
-
protocolFeeRateOnCollateral,
|
|
10303
|
-
increaseAmount,
|
|
10304
|
-
collateralToken,
|
|
10305
|
-
positionToken
|
|
10306
|
-
} = args;
|
|
10307
|
-
if (leverage < 1) {
|
|
10308
|
-
throw new Error("leverage must be greater or equal than 1.0");
|
|
10309
|
-
}
|
|
10310
|
-
if (protocolFeeRate < 0 || protocolFeeRate >= HUNDRED_PERCENT) {
|
|
10311
|
-
throw new Error("protocolFeeRate must be greater or equal than zero and less than HUNDRED_PERCENT");
|
|
10312
|
-
}
|
|
10313
|
-
if (protocolFeeRateOnCollateral < 0 || protocolFeeRateOnCollateral >= HUNDRED_PERCENT) {
|
|
10314
|
-
throw new Error("protocolFeeRate must be greater or equal than zero and less than HUNDRED_PERCENT");
|
|
10315
|
-
}
|
|
10316
|
-
if (increaseAmount <= 0) {
|
|
10317
|
-
throw new Error("increaseAmount must be greater than zero");
|
|
10318
|
-
}
|
|
10319
|
-
let borrow;
|
|
10320
|
-
let collateral;
|
|
10321
|
-
let estimatedAmount;
|
|
10322
|
-
let swapInputAmount;
|
|
10323
|
-
let nextSqrtPrice = fusionPool.sqrtPrice;
|
|
10324
|
-
if (positionToken != collateralToken) {
|
|
10325
|
-
const price = (0, import_fusionamm_core4.sqrtPriceToPrice)(fusionPool.sqrtPrice, 1, 1);
|
|
10326
|
-
borrow = BigInt(Math.ceil(Number(increaseAmount) * (leverage - 1) / leverage));
|
|
10327
|
-
collateral = increaseAmount - (0, import_fusionamm_core4.tryApplySwapFee)(applyTunaProtocolFee(borrow, protocolFeeRate), fusionPool.feeRate);
|
|
10328
|
-
collateral = (0, import_fusionamm_core4.tryReverseApplySwapFee)(collateral, fusionPool.feeRate);
|
|
10329
|
-
collateral = reverseApplyTunaProtocolFee(collateral, protocolFeeRateOnCollateral);
|
|
10330
|
-
swapInputAmount = increaseAmount;
|
|
10331
|
-
estimatedAmount = BigInt(
|
|
10332
|
-
Math.round(collateralToken == 0 /* A */ ? Number(increaseAmount) * price : Number(increaseAmount) / price)
|
|
10333
|
-
);
|
|
10334
|
-
} else {
|
|
10335
|
-
const price = (0, import_fusionamm_core4.sqrtPriceToPrice)(fusionPool.sqrtPrice, 1, 1);
|
|
10336
|
-
const positionToBorrowedTokenPrice = collateralToken == 0 /* A */ ? price : 1 / price;
|
|
10337
|
-
const borrowInPositionToken = Math.ceil(Number(increaseAmount) * (leverage - 1) / leverage);
|
|
10338
|
-
borrow = BigInt(Math.ceil(borrowInPositionToken * positionToBorrowedTokenPrice));
|
|
10339
|
-
const borrowInPositionTokenWithFeesApplied = (0, import_fusionamm_core4.tryApplySwapFee)(
|
|
10340
|
-
applyTunaProtocolFee(BigInt(Math.floor(borrowInPositionToken)), protocolFeeRate),
|
|
10341
|
-
fusionPool.feeRate
|
|
10342
|
-
);
|
|
10343
|
-
collateral = increaseAmount - borrowInPositionTokenWithFeesApplied;
|
|
10344
|
-
collateral = reverseApplyTunaProtocolFee(collateral, protocolFeeRateOnCollateral);
|
|
10345
|
-
swapInputAmount = applyTunaProtocolFee(borrow, protocolFeeRate);
|
|
10346
|
-
estimatedAmount = increaseAmount;
|
|
10347
|
-
}
|
|
10348
|
-
if (swapInputAmount > 0) {
|
|
10349
|
-
const is_token_a = positionToken == 1 /* B */;
|
|
10350
|
-
nextSqrtPrice = (0, import_fusionamm_core4.swapQuoteByInputToken)(swapInputAmount, is_token_a, 0, fusionPool, tickArrays).nextSqrtPrice;
|
|
10351
|
-
}
|
|
10352
|
-
const protocolFeeA = (collateralToken == 0 /* A */ ? collateral - applyTunaProtocolFee(collateral, protocolFeeRateOnCollateral) : 0n) + (positionToken == 1 /* B */ ? borrow - applyTunaProtocolFee(borrow, protocolFeeRate) : 0n);
|
|
10353
|
-
const protocolFeeB = (collateralToken == 1 /* B */ ? collateral - applyTunaProtocolFee(collateral, protocolFeeRateOnCollateral) : 0n) + (positionToken == 0 /* A */ ? borrow - applyTunaProtocolFee(borrow, protocolFeeRate) : 0n);
|
|
10354
|
-
const oldPrice = (0, import_fusionamm_core4.sqrtPriceToPrice)(fusionPool.sqrtPrice, 1, 1);
|
|
10355
|
-
const newPrice = (0, import_fusionamm_core4.sqrtPriceToPrice)(nextSqrtPrice, 1, 1);
|
|
10356
|
-
const priceImpact = Math.abs(newPrice / oldPrice - 1) * 100;
|
|
10357
|
-
return {
|
|
10358
|
-
collateral,
|
|
10359
|
-
borrow,
|
|
10360
|
-
swapInputAmount,
|
|
10361
|
-
estimatedAmount,
|
|
10362
|
-
protocolFeeA,
|
|
10363
|
-
protocolFeeB,
|
|
10364
|
-
priceImpact
|
|
10365
|
-
};
|
|
10366
|
-
}
|
|
10367
|
-
function getDecreaseSpotPositionQuote(args) {
|
|
10368
|
-
const {
|
|
10369
|
-
fusionPool,
|
|
10370
|
-
tickArrays,
|
|
10371
|
-
leverage,
|
|
10372
|
-
protocolFeeRate,
|
|
10373
|
-
protocolFeeRateOnCollateral,
|
|
10374
|
-
decreaseAmount,
|
|
10375
|
-
collateralToken,
|
|
10376
|
-
positionToken,
|
|
10377
|
-
positionAmount,
|
|
10378
|
-
positionDebt,
|
|
10379
|
-
reduceOnly
|
|
10380
|
-
} = args;
|
|
10381
|
-
if (leverage < 1) {
|
|
10382
|
-
throw new Error("leverage must be greater or equal than 1.0");
|
|
10383
|
-
}
|
|
10384
|
-
if (protocolFeeRate < 0 || protocolFeeRate >= HUNDRED_PERCENT) {
|
|
10385
|
-
throw new Error("protocolFeeRate must be greater or equal than zero and less than HUNDRED_PERCENT");
|
|
10386
|
-
}
|
|
10387
|
-
if (protocolFeeRateOnCollateral < 0 || protocolFeeRateOnCollateral >= HUNDRED_PERCENT) {
|
|
10388
|
-
throw new Error("protocolFeeRate must be greater or equal than zero and less than HUNDRED_PERCENT");
|
|
10389
|
-
}
|
|
10390
|
-
if (decreaseAmount <= 0) {
|
|
10391
|
-
throw new Error("decreaseAmount must be greater than zero");
|
|
10392
|
-
}
|
|
10393
|
-
let collateral = 0n;
|
|
10394
|
-
let borrow = 0n;
|
|
10395
|
-
let swapInputAmount = 0n;
|
|
10396
|
-
let estimatedAmount = 0n;
|
|
10397
|
-
let nextSqrtPrice = fusionPool.sqrtPrice;
|
|
10398
|
-
let newPositionToken = positionToken;
|
|
10399
|
-
let decreasePercent;
|
|
10400
|
-
const price = (0, import_fusionamm_core4.sqrtPriceToPrice)(fusionPool.sqrtPrice, 1, 1);
|
|
10401
|
-
const positionToOppositeTokenPrice = positionToken == 0 /* A */ ? price : 1 / price;
|
|
10402
|
-
let decreaseAmountInPositionToken = collateralToken == positionToken ? decreaseAmount : BigInt(Math.round(Number(decreaseAmount) / positionToOppositeTokenPrice));
|
|
10403
|
-
if (reduceOnly && decreaseAmountInPositionToken > positionAmount) {
|
|
10404
|
-
decreaseAmountInPositionToken = positionAmount;
|
|
10405
|
-
}
|
|
10406
|
-
if (decreaseAmountInPositionToken <= positionAmount) {
|
|
10407
|
-
decreasePercent = Math.min(
|
|
10408
|
-
Math.floor(Number(decreaseAmountInPositionToken) * HUNDRED_PERCENT / Number(positionAmount)),
|
|
10409
|
-
HUNDRED_PERCENT
|
|
10410
|
-
);
|
|
10411
|
-
estimatedAmount = positionAmount - decreaseAmountInPositionToken;
|
|
10412
|
-
if (collateralToken == positionToken) {
|
|
10413
|
-
if (positionDebt > 0) {
|
|
10414
|
-
const swapOut = BigInt(Math.floor(Number(positionDebt) * decreasePercent / HUNDRED_PERCENT));
|
|
10415
|
-
const swapQuote = (0, import_fusionamm_core4.swapQuoteByOutputToken)(swapOut, positionToken == 1 /* B */, 0, fusionPool, tickArrays);
|
|
10416
|
-
nextSqrtPrice = swapQuote.nextSqrtPrice;
|
|
10417
|
-
swapInputAmount = swapQuote.tokenEstIn;
|
|
10418
|
-
}
|
|
10419
|
-
} else {
|
|
10420
|
-
swapInputAmount = positionAmount - BigInt(Math.floor(Number(positionAmount) * (HUNDRED_PERCENT - decreasePercent) / HUNDRED_PERCENT));
|
|
10421
|
-
const swapQuote = (0, import_fusionamm_core4.swapQuoteByInputToken)(swapInputAmount, positionToken == 0 /* A */, 0, fusionPool, tickArrays);
|
|
10422
|
-
nextSqrtPrice = swapQuote.nextSqrtPrice;
|
|
10423
|
-
}
|
|
10424
|
-
} else {
|
|
10425
|
-
decreasePercent = HUNDRED_PERCENT;
|
|
10426
|
-
newPositionToken = positionToken == 0 /* A */ ? 1 /* B */ : 0 /* A */;
|
|
10427
|
-
const increaseAmount = decreaseAmountInPositionToken - positionAmount;
|
|
10428
|
-
if (positionToken == collateralToken) {
|
|
10429
|
-
estimatedAmount = BigInt(Math.round(Number(increaseAmount) * positionToOppositeTokenPrice));
|
|
10430
|
-
borrow = BigInt(Math.round(Number(increaseAmount) * (leverage - 1) / leverage));
|
|
10431
|
-
const borrowWithFeesApplied = (0, import_fusionamm_core4.tryApplySwapFee)(applyTunaProtocolFee(borrow, protocolFeeRate), fusionPool.feeRate);
|
|
10432
|
-
collateral = increaseAmount - borrowWithFeesApplied;
|
|
10433
|
-
if (positionDebt > 0) {
|
|
10434
|
-
const swapQuote2 = (0, import_fusionamm_core4.swapQuoteByOutputToken)(positionDebt, positionToken != 0 /* A */, 0, fusionPool, tickArrays);
|
|
10435
|
-
swapInputAmount = swapQuote2.tokenEstIn;
|
|
10436
|
-
}
|
|
10437
|
-
swapInputAmount += collateral + applyTunaProtocolFee(borrow, protocolFeeRate);
|
|
10438
|
-
const swapQuote = (0, import_fusionamm_core4.swapQuoteByInputToken)(swapInputAmount, positionToken == 0 /* A */, 0, fusionPool, tickArrays);
|
|
10439
|
-
nextSqrtPrice = swapQuote.nextSqrtPrice;
|
|
10440
|
-
collateral = reverseApplyTunaProtocolFee(collateral, protocolFeeRateOnCollateral);
|
|
10441
|
-
} else {
|
|
10442
|
-
estimatedAmount = BigInt(Math.round(Number(increaseAmount) * positionToOppositeTokenPrice));
|
|
10443
|
-
borrow = BigInt(Math.round(Number(increaseAmount) * (leverage - 1) / leverage));
|
|
10444
|
-
const borrowWithFeesApplied = (0, import_fusionamm_core4.tryApplySwapFee)(applyTunaProtocolFee(borrow, protocolFeeRate), fusionPool.feeRate);
|
|
10445
|
-
collateral = increaseAmount - borrowWithFeesApplied;
|
|
10446
|
-
collateral = BigInt(Math.round(Number(collateral) * positionToOppositeTokenPrice));
|
|
10447
|
-
collateral = reverseApplyTunaProtocolFee(collateral, protocolFeeRateOnCollateral);
|
|
10448
|
-
swapInputAmount = positionAmount + applyTunaProtocolFee(borrow, protocolFeeRate);
|
|
10449
|
-
const swapQuote = (0, import_fusionamm_core4.swapQuoteByInputToken)(swapInputAmount, positionToken == 0 /* A */, 0, fusionPool, tickArrays);
|
|
10450
|
-
nextSqrtPrice = swapQuote.nextSqrtPrice;
|
|
10451
|
-
}
|
|
10452
|
-
}
|
|
10453
|
-
const protocolFeeA = (collateralToken == 0 /* A */ ? collateral - applyTunaProtocolFee(collateral, protocolFeeRateOnCollateral) : 0n) + (positionToken == 1 /* B */ ? borrow - applyTunaProtocolFee(borrow, protocolFeeRate) : 0n);
|
|
10454
|
-
const protocolFeeB = (collateralToken == 1 /* B */ ? collateral - applyTunaProtocolFee(collateral, protocolFeeRateOnCollateral) : 0n) + (positionToken == 0 /* A */ ? borrow - applyTunaProtocolFee(borrow, protocolFeeRate) : 0n);
|
|
10455
|
-
const newPrice = (0, import_fusionamm_core4.sqrtPriceToPrice)(nextSqrtPrice, 1, 1);
|
|
10456
|
-
const priceImpact = Math.abs(newPrice / price - 1) * 100;
|
|
10457
|
-
return {
|
|
10458
|
-
decreasePercent,
|
|
10459
|
-
collateralToken,
|
|
10460
|
-
positionToken: newPositionToken,
|
|
10461
|
-
collateral,
|
|
10462
|
-
borrow,
|
|
10463
|
-
swapInputAmount,
|
|
10464
|
-
estimatedAmount,
|
|
10465
|
-
protocolFeeA,
|
|
10466
|
-
protocolFeeB,
|
|
10467
|
-
priceImpact
|
|
10468
|
-
};
|
|
10469
|
-
}
|
|
10470
|
-
function getTradableAmount(args) {
|
|
10471
|
-
const {
|
|
10472
|
-
collateralToken,
|
|
10473
|
-
newPositionToken,
|
|
10474
|
-
positionToken,
|
|
10475
|
-
positionAmount,
|
|
10476
|
-
positionDebt,
|
|
10477
|
-
reduceOnly,
|
|
10478
|
-
fusionPool,
|
|
10479
|
-
tickArrays,
|
|
10480
|
-
leverage,
|
|
10481
|
-
availableBalance,
|
|
10482
|
-
protocolFeeRate,
|
|
10483
|
-
protocolFeeRateOnCollateral
|
|
10484
|
-
} = args;
|
|
10485
|
-
if (leverage < 1) {
|
|
10486
|
-
throw new Error("leverage must be greater or equal than 1.0");
|
|
10487
|
-
}
|
|
10488
|
-
if (protocolFeeRateOnCollateral < 0 || protocolFeeRateOnCollateral >= HUNDRED_PERCENT) {
|
|
10489
|
-
throw new Error("protocolFeeRate must be greater or equal than zero and less than HUNDRED_PERCENT");
|
|
10490
|
-
}
|
|
10491
|
-
if (protocolFeeRate < 0 || protocolFeeRate >= HUNDRED_PERCENT) {
|
|
10492
|
-
throw new Error("protocolFeeRate must be greater or equal than zero and less than HUNDRED_PERCENT");
|
|
10493
|
-
}
|
|
10494
|
-
if (positionAmount == 0n && newPositionToken != positionToken) {
|
|
10495
|
-
throw new Error("positionToken must be set to newPositionToken if positionAmount is zero");
|
|
10496
|
-
}
|
|
10497
|
-
let availableToTrade = 0n;
|
|
10498
|
-
const addLeverage = (collateral) => {
|
|
10499
|
-
collateral = applyTunaProtocolFee(collateral, protocolFeeRateOnCollateral);
|
|
10500
|
-
if (collateralToken != newPositionToken) {
|
|
10501
|
-
collateral = (0, import_fusionamm_core4.tryApplySwapFee)(collateral, fusionPool.feeRate);
|
|
10502
|
-
}
|
|
10503
|
-
const feeMultiplier = (1 - protocolFeeRate / HUNDRED_PERCENT) * (1 - fusionPool.feeRate / 1e6);
|
|
10504
|
-
const total = Number(collateral) / (1 - feeMultiplier * (leverage - 1) / leverage);
|
|
10505
|
-
return BigInt(Math.floor(total));
|
|
10506
|
-
};
|
|
10507
|
-
if (newPositionToken == positionToken) {
|
|
10508
|
-
availableToTrade = addLeverage(availableBalance);
|
|
10509
|
-
} else {
|
|
10510
|
-
const price = (0, import_fusionamm_core4.sqrtPriceToPrice)(fusionPool.sqrtPrice, 1, 1);
|
|
10511
|
-
const positionToOppositeTokenPrice = positionToken == 0 /* A */ ? price : 1 / price;
|
|
10512
|
-
if (reduceOnly) {
|
|
10513
|
-
if (collateralToken == positionToken) {
|
|
10514
|
-
availableToTrade = positionAmount;
|
|
10515
|
-
} else {
|
|
10516
|
-
availableToTrade = BigInt(Math.round(Number(positionAmount) * positionToOppositeTokenPrice));
|
|
10517
|
-
}
|
|
10518
|
-
} else {
|
|
10519
|
-
const positionAmountInCollateralToken = collateralToken == positionToken ? positionAmount : BigInt(Math.round(Number(positionAmount) * positionToOppositeTokenPrice));
|
|
10520
|
-
let positionCollateral = collateralToken == positionToken ? positionAmount - (positionDebt > 0n ? (0, import_fusionamm_core4.swapQuoteByOutputToken)(positionDebt, positionToken == 1 /* B */, 0, fusionPool, tickArrays).tokenEstIn : 0n) : positionAmount > 0n ? (0, import_fusionamm_core4.swapQuoteByInputToken)(positionAmount, positionToken == 0 /* A */, 0, fusionPool, tickArrays).tokenEstOut - positionDebt : 0n;
|
|
10521
|
-
if (positionCollateral < 0n) positionCollateral = 0n;
|
|
10522
|
-
availableToTrade = positionAmountInCollateralToken + addLeverage(availableBalance + positionCollateral);
|
|
10523
|
-
}
|
|
10524
|
-
}
|
|
10525
|
-
return availableToTrade;
|
|
10526
|
-
}
|
|
10527
|
-
function getLiquidationPrice(positionToken, amount, debt, liquidationThreshold) {
|
|
10528
|
-
if (debt < 0) {
|
|
10529
|
-
throw new Error("debt must be greater or equal than zero");
|
|
10530
|
-
}
|
|
10531
|
-
if (amount < 0) {
|
|
10532
|
-
throw new Error("position amount must be greater or equal than zero");
|
|
10533
|
-
}
|
|
10534
|
-
if (liquidationThreshold <= 0 || liquidationThreshold >= 1) {
|
|
10535
|
-
throw new Error("liquidationThreshold must be greater than zero and less than one");
|
|
10536
|
-
}
|
|
10537
|
-
if (debt == 0 || amount == 0) return 0;
|
|
10538
|
-
if (positionToken == 0 /* A */) {
|
|
10539
|
-
return debt / (amount * liquidationThreshold);
|
|
10540
|
-
} else {
|
|
10541
|
-
return amount * liquidationThreshold / debt;
|
|
10542
|
-
}
|
|
10543
|
-
}
|
|
10544
|
-
function applyTunaProtocolFee(amount, protocolFeeRate) {
|
|
10545
|
-
return amount * BigInt(HUNDRED_PERCENT - protocolFeeRate) / BigInt(HUNDRED_PERCENT);
|
|
10546
|
-
}
|
|
10547
|
-
function reverseApplyTunaProtocolFee(amount, protocolFeeRate) {
|
|
10548
|
-
return amount * BigInt(HUNDRED_PERCENT) / BigInt(HUNDRED_PERCENT - protocolFeeRate);
|
|
10549
|
-
}
|
|
10550
|
-
|
|
10551
10274
|
// src/txbuilder/increaseTunaLpPositionOrca.ts
|
|
10552
10275
|
var import_whirlpools_client2 = require("@orca-so/whirlpools-client");
|
|
10553
10276
|
var import_whirlpools_core2 = require("@orca-so/whirlpools-core");
|
|
@@ -10781,7 +10504,7 @@ async function increaseTunaLpPositionOrcaInstruction(authority, tunaPosition, tu
|
|
|
10781
10504
|
|
|
10782
10505
|
// src/txbuilder/increaseTunaLpPositionFusion.ts
|
|
10783
10506
|
var import_fusionamm_client2 = require("@crypticdot/fusionamm-client");
|
|
10784
|
-
var
|
|
10507
|
+
var import_fusionamm_core4 = require("@crypticdot/fusionamm-core");
|
|
10785
10508
|
var import_kit80 = require("@solana/kit");
|
|
10786
10509
|
var import_memo2 = require("@solana-program/memo");
|
|
10787
10510
|
var import_token_20223 = require("@solana-program/token-2022");
|
|
@@ -10851,12 +10574,12 @@ async function increaseTunaLpPositionFusionInstructions(rpc, authority, position
|
|
|
10851
10574
|
mintB.programAddress
|
|
10852
10575
|
);
|
|
10853
10576
|
createInstructions.push(...createFeeRecipientAtaBInstructions.init);
|
|
10854
|
-
const lowerTickArrayStartIndex = (0,
|
|
10577
|
+
const lowerTickArrayStartIndex = (0, import_fusionamm_core4.getTickArrayStartTickIndex)(
|
|
10855
10578
|
tunaPosition.data.tickLowerIndex,
|
|
10856
10579
|
fusionPool.data.tickSpacing
|
|
10857
10580
|
);
|
|
10858
10581
|
const [lowerTickArrayAddress] = await (0, import_fusionamm_client2.getTickArrayAddress)(fusionPool.address, lowerTickArrayStartIndex);
|
|
10859
|
-
const upperTickArrayStartIndex = (0,
|
|
10582
|
+
const upperTickArrayStartIndex = (0, import_fusionamm_core4.getTickArrayStartTickIndex)(
|
|
10860
10583
|
tunaPosition.data.tickUpperIndex,
|
|
10861
10584
|
fusionPool.data.tickSpacing
|
|
10862
10585
|
);
|
|
@@ -13774,7 +13497,7 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
13774
13497
|
|
|
13775
13498
|
// src/txbuilder/openAndIncreaseTunaLpPositionFusion.ts
|
|
13776
13499
|
var import_fusionamm_client14 = require("@crypticdot/fusionamm-client");
|
|
13777
|
-
var
|
|
13500
|
+
var import_fusionamm_core5 = require("@crypticdot/fusionamm-core");
|
|
13778
13501
|
var import_kit97 = require("@solana/kit");
|
|
13779
13502
|
var import_sysvars2 = require("@solana/sysvars");
|
|
13780
13503
|
var import_memo19 = require("@solana-program/memo");
|
|
@@ -13846,9 +13569,9 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
|
|
|
13846
13569
|
mintB.programAddress
|
|
13847
13570
|
);
|
|
13848
13571
|
createInstructions.push(...createFeeRecipientAtaBInstructions.init);
|
|
13849
|
-
const lowerTickArrayIndex = (0,
|
|
13572
|
+
const lowerTickArrayIndex = (0, import_fusionamm_core5.getTickArrayStartTickIndex)(args.tickLowerIndex, fusionPool.data.tickSpacing);
|
|
13850
13573
|
const [lowerTickArrayAddress] = await (0, import_fusionamm_client14.getTickArrayAddress)(fusionPool.address, lowerTickArrayIndex);
|
|
13851
|
-
const upperTickArrayIndex = (0,
|
|
13574
|
+
const upperTickArrayIndex = (0, import_fusionamm_core5.getTickArrayStartTickIndex)(args.tickUpperIndex, fusionPool.data.tickSpacing);
|
|
13852
13575
|
const [upperTickArrayAddress] = await (0, import_fusionamm_client14.getTickArrayAddress)(fusionPool.address, upperTickArrayIndex);
|
|
13853
13576
|
const [lowerTickArray, upperTickArray] = await (0, import_fusionamm_client14.fetchAllMaybeTickArray)(rpc, [
|
|
13854
13577
|
lowerTickArrayAddress,
|
|
@@ -15471,6 +15194,24 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
15471
15194
|
ix.accounts.push(...remainingAccounts);
|
|
15472
15195
|
return ix;
|
|
15473
15196
|
}
|
|
15197
|
+
|
|
15198
|
+
// src/casts.ts
|
|
15199
|
+
function toPoolTokenFacade(token) {
|
|
15200
|
+
switch (token) {
|
|
15201
|
+
case 0 /* A */:
|
|
15202
|
+
return "a";
|
|
15203
|
+
case 1 /* B */:
|
|
15204
|
+
return "b";
|
|
15205
|
+
}
|
|
15206
|
+
}
|
|
15207
|
+
function fromPoolTokenFacade(token) {
|
|
15208
|
+
switch (token) {
|
|
15209
|
+
case "a":
|
|
15210
|
+
return 0 /* A */;
|
|
15211
|
+
case "b":
|
|
15212
|
+
return 1 /* B */;
|
|
15213
|
+
}
|
|
15214
|
+
}
|
|
15474
15215
|
// Annotate the CommonJS export names for ESM import in node:
|
|
15475
15216
|
0 && (module.exports = {
|
|
15476
15217
|
AccountsType,
|
|
@@ -15699,6 +15440,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
15699
15440
|
fetchTunaLpPosition,
|
|
15700
15441
|
fetchTunaSpotPosition,
|
|
15701
15442
|
fetchVault,
|
|
15443
|
+
fromPoolTokenFacade,
|
|
15702
15444
|
getAccountsTypeCodec,
|
|
15703
15445
|
getAccountsTypeDecoder,
|
|
15704
15446
|
getAccountsTypeEncoder,
|
|
@@ -15769,7 +15511,6 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
15769
15511
|
getCreateVaultInstructionDataCodec,
|
|
15770
15512
|
getCreateVaultInstructionDataDecoder,
|
|
15771
15513
|
getCreateVaultInstructionDataEncoder,
|
|
15772
|
-
getDecreaseSpotPositionQuote,
|
|
15773
15514
|
getDecreaseTunaLpPositionFusionDiscriminatorBytes,
|
|
15774
15515
|
getDecreaseTunaLpPositionFusionInstruction,
|
|
15775
15516
|
getDecreaseTunaLpPositionFusionInstructionDataCodec,
|
|
@@ -15796,7 +15537,6 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
15796
15537
|
getDepositInstructionDataDecoder,
|
|
15797
15538
|
getDepositInstructionDataEncoder,
|
|
15798
15539
|
getIncreaseLpPositionQuote,
|
|
15799
|
-
getIncreaseSpotPositionQuote,
|
|
15800
15540
|
getIncreaseTunaLpPositionFusionDiscriminatorBytes,
|
|
15801
15541
|
getIncreaseTunaLpPositionFusionInstruction,
|
|
15802
15542
|
getIncreaseTunaLpPositionFusionInstructionDataCodec,
|
|
@@ -15844,7 +15584,6 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
15844
15584
|
getLiquidateTunaSpotPositionOrcaInstructionDataCodec,
|
|
15845
15585
|
getLiquidateTunaSpotPositionOrcaInstructionDataDecoder,
|
|
15846
15586
|
getLiquidateTunaSpotPositionOrcaInstructionDataEncoder,
|
|
15847
|
-
getLiquidationPrice,
|
|
15848
15587
|
getMarketAddress,
|
|
15849
15588
|
getMarketCodec,
|
|
15850
15589
|
getMarketDecoder,
|
|
@@ -15994,7 +15733,6 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
15994
15733
|
getSetTunaSpotPositionLimitOrdersInstructionDataCodec,
|
|
15995
15734
|
getSetTunaSpotPositionLimitOrdersInstructionDataDecoder,
|
|
15996
15735
|
getSetTunaSpotPositionLimitOrdersInstructionDataEncoder,
|
|
15997
|
-
getTradableAmount,
|
|
15998
15736
|
getTunaConfigAddress,
|
|
15999
15737
|
getTunaConfigCodec,
|
|
16000
15738
|
getTunaConfigDecoder,
|
|
@@ -16058,6 +15796,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
16058
15796
|
liquidateTunaSpotPositionFusionInstructions,
|
|
16059
15797
|
liquidateTunaSpotPositionOrcaInstruction,
|
|
16060
15798
|
liquidateTunaSpotPositionOrcaInstructions,
|
|
15799
|
+
mulDiv,
|
|
16061
15800
|
openAndIncreaseTunaLpPositionFusionInstruction,
|
|
16062
15801
|
openAndIncreaseTunaLpPositionFusionInstructions,
|
|
16063
15802
|
openAndIncreaseTunaLpPositionOrcaInstruction,
|
|
@@ -16139,6 +15878,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
16139
15878
|
resetTunaSpotPositionInstruction,
|
|
16140
15879
|
setTunaLpPositionLimitOrdersInstruction,
|
|
16141
15880
|
setTunaSpotPositionLimitOrdersInstruction,
|
|
15881
|
+
toPoolTokenFacade,
|
|
16142
15882
|
tunaLpPositionAuthorityFilter,
|
|
16143
15883
|
tunaLpPositionMarketMakerFilter,
|
|
16144
15884
|
tunaLpPositionMintAFilter,
|