@crypticdot/defituna-client 3.3.5 → 3.3.6
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 +81 -16
- package/dist/index.d.ts +81 -16
- package/dist/index.js +691 -424
- package/dist/index.mjs +455 -186
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -188,6 +188,7 @@ __export(index_exports, {
|
|
|
188
188
|
TunaPositionState: () => TunaPositionState,
|
|
189
189
|
UNLIMITED_SUPPLY_LIMIT: () => UNLIMITED_SUPPLY_LIMIT,
|
|
190
190
|
UPDATE_MARKET_DISCRIMINATOR: () => UPDATE_MARKET_DISCRIMINATOR,
|
|
191
|
+
UPDATE_MARKET_VAULTS_DISCRIMINATOR: () => UPDATE_MARKET_VAULTS_DISCRIMINATOR,
|
|
191
192
|
UPDATE_VAULT_DISCRIMINATOR: () => UPDATE_VAULT_DISCRIMINATOR,
|
|
192
193
|
VAULT_DISCRIMINATOR: () => VAULT_DISCRIMINATOR,
|
|
193
194
|
WITHDRAW_DISCRIMINATOR: () => WITHDRAW_DISCRIMINATOR,
|
|
@@ -547,6 +548,11 @@ __export(index_exports, {
|
|
|
547
548
|
getUpdateMarketInstructionDataCodec: () => getUpdateMarketInstructionDataCodec,
|
|
548
549
|
getUpdateMarketInstructionDataDecoder: () => getUpdateMarketInstructionDataDecoder,
|
|
549
550
|
getUpdateMarketInstructionDataEncoder: () => getUpdateMarketInstructionDataEncoder,
|
|
551
|
+
getUpdateMarketVaultsDiscriminatorBytes: () => getUpdateMarketVaultsDiscriminatorBytes,
|
|
552
|
+
getUpdateMarketVaultsInstruction: () => getUpdateMarketVaultsInstruction,
|
|
553
|
+
getUpdateMarketVaultsInstructionDataCodec: () => getUpdateMarketVaultsInstructionDataCodec,
|
|
554
|
+
getUpdateMarketVaultsInstructionDataDecoder: () => getUpdateMarketVaultsInstructionDataDecoder,
|
|
555
|
+
getUpdateMarketVaultsInstructionDataEncoder: () => getUpdateMarketVaultsInstructionDataEncoder,
|
|
550
556
|
getUpdateVaultDiscriminatorBytes: () => getUpdateVaultDiscriminatorBytes,
|
|
551
557
|
getUpdateVaultInstruction: () => getUpdateVaultInstruction,
|
|
552
558
|
getUpdateVaultInstructionDataCodec: () => getUpdateVaultInstructionDataCodec,
|
|
@@ -577,6 +583,8 @@ __export(index_exports, {
|
|
|
577
583
|
liquidateTunaLpPositionOrcaInstructions: () => liquidateTunaLpPositionOrcaInstructions,
|
|
578
584
|
liquidateTunaSpotPositionFusionInstruction: () => liquidateTunaSpotPositionFusionInstruction,
|
|
579
585
|
liquidateTunaSpotPositionFusionInstructions: () => liquidateTunaSpotPositionFusionInstructions,
|
|
586
|
+
liquidateTunaSpotPositionJupiterInstruction: () => liquidateTunaSpotPositionJupiterInstruction,
|
|
587
|
+
liquidateTunaSpotPositionJupiterInstructions: () => liquidateTunaSpotPositionJupiterInstructions,
|
|
580
588
|
liquidateTunaSpotPositionOrcaInstruction: () => liquidateTunaSpotPositionOrcaInstruction,
|
|
581
589
|
liquidateTunaSpotPositionOrcaInstructions: () => liquidateTunaSpotPositionOrcaInstructions,
|
|
582
590
|
modifyTunaSpotPositionFusionInstruction: () => modifyTunaSpotPositionFusionInstruction,
|
|
@@ -644,6 +652,7 @@ __export(index_exports, {
|
|
|
644
652
|
parseSetTunaLpPositionRebalanceThresholdInstruction: () => parseSetTunaLpPositionRebalanceThresholdInstruction,
|
|
645
653
|
parseSetTunaSpotPositionLimitOrdersInstruction: () => parseSetTunaSpotPositionLimitOrdersInstruction,
|
|
646
654
|
parseUpdateMarketInstruction: () => parseUpdateMarketInstruction,
|
|
655
|
+
parseUpdateMarketVaultsInstruction: () => parseUpdateMarketVaultsInstruction,
|
|
647
656
|
parseUpdateVaultInstruction: () => parseUpdateVaultInstruction,
|
|
648
657
|
parseWithdrawInstruction: () => parseWithdrawInstruction,
|
|
649
658
|
rebalanceTunaLpPositionFusionInstruction: () => rebalanceTunaLpPositionFusionInstruction,
|
|
@@ -916,7 +925,9 @@ function getMarketEncoder() {
|
|
|
916
925
|
["rebalanceProtocolFee", (0, import_kit8.getU32Encoder)()],
|
|
917
926
|
["spotPositionSizeLimitA", (0, import_kit8.getU64Encoder)()],
|
|
918
927
|
["spotPositionSizeLimitB", (0, import_kit8.getU64Encoder)()],
|
|
919
|
-
["
|
|
928
|
+
["vaultA", (0, import_kit8.getAddressEncoder)()],
|
|
929
|
+
["vaultB", (0, import_kit8.getAddressEncoder)()],
|
|
930
|
+
["reserved", (0, import_kit8.fixEncoderSize)((0, import_kit8.getBytesEncoder)(), 127)]
|
|
920
931
|
]),
|
|
921
932
|
(value) => ({ ...value, discriminator: MARKET_DISCRIMINATOR })
|
|
922
933
|
);
|
|
@@ -945,7 +956,9 @@ function getMarketDecoder() {
|
|
|
945
956
|
["rebalanceProtocolFee", (0, import_kit8.getU32Decoder)()],
|
|
946
957
|
["spotPositionSizeLimitA", (0, import_kit8.getU64Decoder)()],
|
|
947
958
|
["spotPositionSizeLimitB", (0, import_kit8.getU64Decoder)()],
|
|
948
|
-
["
|
|
959
|
+
["vaultA", (0, import_kit8.getAddressDecoder)()],
|
|
960
|
+
["vaultB", (0, import_kit8.getAddressDecoder)()],
|
|
961
|
+
["reserved", (0, import_kit8.fixDecoderSize)((0, import_kit8.getBytesDecoder)(), 127)]
|
|
949
962
|
]);
|
|
950
963
|
}
|
|
951
964
|
function getMarketCodec() {
|
|
@@ -1508,8 +1521,9 @@ var TunaInstruction = /* @__PURE__ */ ((TunaInstruction2) => {
|
|
|
1508
1521
|
TunaInstruction2[TunaInstruction2["SetTunaLpPositionRebalanceThreshold"] = 45] = "SetTunaLpPositionRebalanceThreshold";
|
|
1509
1522
|
TunaInstruction2[TunaInstruction2["SetTunaSpotPositionLimitOrders"] = 46] = "SetTunaSpotPositionLimitOrders";
|
|
1510
1523
|
TunaInstruction2[TunaInstruction2["UpdateMarket"] = 47] = "UpdateMarket";
|
|
1511
|
-
TunaInstruction2[TunaInstruction2["
|
|
1512
|
-
TunaInstruction2[TunaInstruction2["
|
|
1524
|
+
TunaInstruction2[TunaInstruction2["UpdateMarketVaults"] = 48] = "UpdateMarketVaults";
|
|
1525
|
+
TunaInstruction2[TunaInstruction2["UpdateVault"] = 49] = "UpdateVault";
|
|
1526
|
+
TunaInstruction2[TunaInstruction2["Withdraw"] = 50] = "Withdraw";
|
|
1513
1527
|
return TunaInstruction2;
|
|
1514
1528
|
})(TunaInstruction || {});
|
|
1515
1529
|
function identifyTunaInstruction(instruction) {
|
|
@@ -1946,6 +1960,15 @@ function identifyTunaInstruction(instruction) {
|
|
|
1946
1960
|
)) {
|
|
1947
1961
|
return 47 /* UpdateMarket */;
|
|
1948
1962
|
}
|
|
1963
|
+
if ((0, import_kit13.containsBytes)(
|
|
1964
|
+
data,
|
|
1965
|
+
(0, import_kit13.fixEncoderSize)((0, import_kit13.getBytesEncoder)(), 8).encode(
|
|
1966
|
+
new Uint8Array([59, 187, 50, 173, 89, 41, 205, 228])
|
|
1967
|
+
),
|
|
1968
|
+
0
|
|
1969
|
+
)) {
|
|
1970
|
+
return 48 /* UpdateMarketVaults */;
|
|
1971
|
+
}
|
|
1949
1972
|
if ((0, import_kit13.containsBytes)(
|
|
1950
1973
|
data,
|
|
1951
1974
|
(0, import_kit13.fixEncoderSize)((0, import_kit13.getBytesEncoder)(), 8).encode(
|
|
@@ -1953,7 +1976,7 @@ function identifyTunaInstruction(instruction) {
|
|
|
1953
1976
|
),
|
|
1954
1977
|
0
|
|
1955
1978
|
)) {
|
|
1956
|
-
return
|
|
1979
|
+
return 49 /* UpdateVault */;
|
|
1957
1980
|
}
|
|
1958
1981
|
if ((0, import_kit13.containsBytes)(
|
|
1959
1982
|
data,
|
|
@@ -1962,7 +1985,7 @@ function identifyTunaInstruction(instruction) {
|
|
|
1962
1985
|
),
|
|
1963
1986
|
0
|
|
1964
1987
|
)) {
|
|
1965
|
-
return
|
|
1988
|
+
return 50 /* Withdraw */;
|
|
1966
1989
|
}
|
|
1967
1990
|
throw new Error(
|
|
1968
1991
|
"The provided instruction could not be identified as a tuna instruction."
|
|
@@ -3290,7 +3313,6 @@ function getCreateMarketInstructionDataEncoder() {
|
|
|
3290
3313
|
return (0, import_kit24.transformEncoder)(
|
|
3291
3314
|
(0, import_kit24.getStructEncoder)([
|
|
3292
3315
|
["discriminator", (0, import_kit24.fixEncoderSize)((0, import_kit24.getBytesEncoder)(), 8)],
|
|
3293
|
-
["marketMaker", getMarketMakerEncoder()],
|
|
3294
3316
|
["addressLookupTable", (0, import_kit24.getAddressEncoder)()],
|
|
3295
3317
|
["maxLeverage", (0, import_kit24.getU32Encoder)()],
|
|
3296
3318
|
["protocolFee", (0, import_kit24.getU16Encoder)()],
|
|
@@ -3313,7 +3335,6 @@ function getCreateMarketInstructionDataEncoder() {
|
|
|
3313
3335
|
function getCreateMarketInstructionDataDecoder() {
|
|
3314
3336
|
return (0, import_kit24.getStructDecoder)([
|
|
3315
3337
|
["discriminator", (0, import_kit24.fixDecoderSize)((0, import_kit24.getBytesDecoder)(), 8)],
|
|
3316
|
-
["marketMaker", getMarketMakerDecoder()],
|
|
3317
3338
|
["addressLookupTable", (0, import_kit24.getAddressDecoder)()],
|
|
3318
3339
|
["maxLeverage", (0, import_kit24.getU32Decoder)()],
|
|
3319
3340
|
["protocolFee", (0, import_kit24.getU16Decoder)()],
|
|
@@ -3343,6 +3364,8 @@ function getCreateMarketInstruction(input, config) {
|
|
|
3343
3364
|
authority: { value: input.authority ?? null, isWritable: true },
|
|
3344
3365
|
tunaConfig: { value: input.tunaConfig ?? null, isWritable: false },
|
|
3345
3366
|
market: { value: input.market ?? null, isWritable: true },
|
|
3367
|
+
vaultA: { value: input.vaultA ?? null, isWritable: false },
|
|
3368
|
+
vaultB: { value: input.vaultB ?? null, isWritable: false },
|
|
3346
3369
|
pool: { value: input.pool ?? null, isWritable: false },
|
|
3347
3370
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
3348
3371
|
};
|
|
@@ -3357,6 +3380,8 @@ function getCreateMarketInstruction(input, config) {
|
|
|
3357
3380
|
getAccountMeta(accounts.authority),
|
|
3358
3381
|
getAccountMeta(accounts.tunaConfig),
|
|
3359
3382
|
getAccountMeta(accounts.market),
|
|
3383
|
+
getAccountMeta(accounts.vaultA),
|
|
3384
|
+
getAccountMeta(accounts.vaultB),
|
|
3360
3385
|
getAccountMeta(accounts.pool),
|
|
3361
3386
|
getAccountMeta(accounts.systemProgram)
|
|
3362
3387
|
],
|
|
@@ -3368,7 +3393,7 @@ function getCreateMarketInstruction(input, config) {
|
|
|
3368
3393
|
return instruction;
|
|
3369
3394
|
}
|
|
3370
3395
|
function parseCreateMarketInstruction(instruction) {
|
|
3371
|
-
if (instruction.accounts.length <
|
|
3396
|
+
if (instruction.accounts.length < 7) {
|
|
3372
3397
|
throw new Error("Not enough accounts");
|
|
3373
3398
|
}
|
|
3374
3399
|
let accountIndex = 0;
|
|
@@ -3383,6 +3408,8 @@ function parseCreateMarketInstruction(instruction) {
|
|
|
3383
3408
|
authority: getNextAccount(),
|
|
3384
3409
|
tunaConfig: getNextAccount(),
|
|
3385
3410
|
market: getNextAccount(),
|
|
3411
|
+
vaultA: getNextAccount(),
|
|
3412
|
+
vaultB: getNextAccount(),
|
|
3386
3413
|
pool: getNextAccount(),
|
|
3387
3414
|
systemProgram: getNextAccount()
|
|
3388
3415
|
},
|
|
@@ -8683,8 +8710,94 @@ function parseUpdateMarketInstruction(instruction) {
|
|
|
8683
8710
|
};
|
|
8684
8711
|
}
|
|
8685
8712
|
|
|
8686
|
-
// src/generated/instructions/
|
|
8713
|
+
// src/generated/instructions/updateMarketVaults.ts
|
|
8687
8714
|
var import_kit64 = require("@solana/kit");
|
|
8715
|
+
var UPDATE_MARKET_VAULTS_DISCRIMINATOR = new Uint8Array([
|
|
8716
|
+
59,
|
|
8717
|
+
187,
|
|
8718
|
+
50,
|
|
8719
|
+
173,
|
|
8720
|
+
89,
|
|
8721
|
+
41,
|
|
8722
|
+
205,
|
|
8723
|
+
228
|
|
8724
|
+
]);
|
|
8725
|
+
function getUpdateMarketVaultsDiscriminatorBytes() {
|
|
8726
|
+
return (0, import_kit64.fixEncoderSize)((0, import_kit64.getBytesEncoder)(), 8).encode(
|
|
8727
|
+
UPDATE_MARKET_VAULTS_DISCRIMINATOR
|
|
8728
|
+
);
|
|
8729
|
+
}
|
|
8730
|
+
function getUpdateMarketVaultsInstructionDataEncoder() {
|
|
8731
|
+
return (0, import_kit64.transformEncoder)(
|
|
8732
|
+
(0, import_kit64.getStructEncoder)([
|
|
8733
|
+
["discriminator", (0, import_kit64.fixEncoderSize)((0, import_kit64.getBytesEncoder)(), 8)],
|
|
8734
|
+
["vaultA", (0, import_kit64.getAddressEncoder)()],
|
|
8735
|
+
["vaultB", (0, import_kit64.getAddressEncoder)()]
|
|
8736
|
+
]),
|
|
8737
|
+
(value) => ({ ...value, discriminator: UPDATE_MARKET_VAULTS_DISCRIMINATOR })
|
|
8738
|
+
);
|
|
8739
|
+
}
|
|
8740
|
+
function getUpdateMarketVaultsInstructionDataDecoder() {
|
|
8741
|
+
return (0, import_kit64.getStructDecoder)([
|
|
8742
|
+
["discriminator", (0, import_kit64.fixDecoderSize)((0, import_kit64.getBytesDecoder)(), 8)],
|
|
8743
|
+
["vaultA", (0, import_kit64.getAddressDecoder)()],
|
|
8744
|
+
["vaultB", (0, import_kit64.getAddressDecoder)()]
|
|
8745
|
+
]);
|
|
8746
|
+
}
|
|
8747
|
+
function getUpdateMarketVaultsInstructionDataCodec() {
|
|
8748
|
+
return (0, import_kit64.combineCodec)(
|
|
8749
|
+
getUpdateMarketVaultsInstructionDataEncoder(),
|
|
8750
|
+
getUpdateMarketVaultsInstructionDataDecoder()
|
|
8751
|
+
);
|
|
8752
|
+
}
|
|
8753
|
+
function getUpdateMarketVaultsInstruction(input, config) {
|
|
8754
|
+
const programAddress = config?.programAddress ?? TUNA_PROGRAM_ADDRESS;
|
|
8755
|
+
const originalAccounts = {
|
|
8756
|
+
authority: { value: input.authority ?? null, isWritable: true },
|
|
8757
|
+
tunaConfig: { value: input.tunaConfig ?? null, isWritable: false },
|
|
8758
|
+
market: { value: input.market ?? null, isWritable: true }
|
|
8759
|
+
};
|
|
8760
|
+
const accounts = originalAccounts;
|
|
8761
|
+
const args = { ...input };
|
|
8762
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
8763
|
+
const instruction = {
|
|
8764
|
+
accounts: [
|
|
8765
|
+
getAccountMeta(accounts.authority),
|
|
8766
|
+
getAccountMeta(accounts.tunaConfig),
|
|
8767
|
+
getAccountMeta(accounts.market)
|
|
8768
|
+
],
|
|
8769
|
+
programAddress,
|
|
8770
|
+
data: getUpdateMarketVaultsInstructionDataEncoder().encode(
|
|
8771
|
+
args
|
|
8772
|
+
)
|
|
8773
|
+
};
|
|
8774
|
+
return instruction;
|
|
8775
|
+
}
|
|
8776
|
+
function parseUpdateMarketVaultsInstruction(instruction) {
|
|
8777
|
+
if (instruction.accounts.length < 3) {
|
|
8778
|
+
throw new Error("Not enough accounts");
|
|
8779
|
+
}
|
|
8780
|
+
let accountIndex = 0;
|
|
8781
|
+
const getNextAccount = () => {
|
|
8782
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
8783
|
+
accountIndex += 1;
|
|
8784
|
+
return accountMeta;
|
|
8785
|
+
};
|
|
8786
|
+
return {
|
|
8787
|
+
programAddress: instruction.programAddress,
|
|
8788
|
+
accounts: {
|
|
8789
|
+
authority: getNextAccount(),
|
|
8790
|
+
tunaConfig: getNextAccount(),
|
|
8791
|
+
market: getNextAccount()
|
|
8792
|
+
},
|
|
8793
|
+
data: getUpdateMarketVaultsInstructionDataDecoder().decode(
|
|
8794
|
+
instruction.data
|
|
8795
|
+
)
|
|
8796
|
+
};
|
|
8797
|
+
}
|
|
8798
|
+
|
|
8799
|
+
// src/generated/instructions/updateVault.ts
|
|
8800
|
+
var import_kit65 = require("@solana/kit");
|
|
8688
8801
|
var UPDATE_VAULT_DISCRIMINATOR = new Uint8Array([
|
|
8689
8802
|
67,
|
|
8690
8803
|
229,
|
|
@@ -8696,33 +8809,33 @@ var UPDATE_VAULT_DISCRIMINATOR = new Uint8Array([
|
|
|
8696
8809
|
60
|
|
8697
8810
|
]);
|
|
8698
8811
|
function getUpdateVaultDiscriminatorBytes() {
|
|
8699
|
-
return (0,
|
|
8812
|
+
return (0, import_kit65.fixEncoderSize)((0, import_kit65.getBytesEncoder)(), 8).encode(
|
|
8700
8813
|
UPDATE_VAULT_DISCRIMINATOR
|
|
8701
8814
|
);
|
|
8702
8815
|
}
|
|
8703
8816
|
function getUpdateVaultInstructionDataEncoder() {
|
|
8704
|
-
return (0,
|
|
8705
|
-
(0,
|
|
8706
|
-
["discriminator", (0,
|
|
8707
|
-
["interestRate", (0,
|
|
8708
|
-
["supplyLimit", (0,
|
|
8709
|
-
["pythOraclePriceUpdate", (0,
|
|
8710
|
-
["pythOracleFeedId", (0,
|
|
8817
|
+
return (0, import_kit65.transformEncoder)(
|
|
8818
|
+
(0, import_kit65.getStructEncoder)([
|
|
8819
|
+
["discriminator", (0, import_kit65.fixEncoderSize)((0, import_kit65.getBytesEncoder)(), 8)],
|
|
8820
|
+
["interestRate", (0, import_kit65.getU64Encoder)()],
|
|
8821
|
+
["supplyLimit", (0, import_kit65.getU64Encoder)()],
|
|
8822
|
+
["pythOraclePriceUpdate", (0, import_kit65.getAddressEncoder)()],
|
|
8823
|
+
["pythOracleFeedId", (0, import_kit65.getAddressEncoder)()]
|
|
8711
8824
|
]),
|
|
8712
8825
|
(value) => ({ ...value, discriminator: UPDATE_VAULT_DISCRIMINATOR })
|
|
8713
8826
|
);
|
|
8714
8827
|
}
|
|
8715
8828
|
function getUpdateVaultInstructionDataDecoder() {
|
|
8716
|
-
return (0,
|
|
8717
|
-
["discriminator", (0,
|
|
8718
|
-
["interestRate", (0,
|
|
8719
|
-
["supplyLimit", (0,
|
|
8720
|
-
["pythOraclePriceUpdate", (0,
|
|
8721
|
-
["pythOracleFeedId", (0,
|
|
8829
|
+
return (0, import_kit65.getStructDecoder)([
|
|
8830
|
+
["discriminator", (0, import_kit65.fixDecoderSize)((0, import_kit65.getBytesDecoder)(), 8)],
|
|
8831
|
+
["interestRate", (0, import_kit65.getU64Decoder)()],
|
|
8832
|
+
["supplyLimit", (0, import_kit65.getU64Decoder)()],
|
|
8833
|
+
["pythOraclePriceUpdate", (0, import_kit65.getAddressDecoder)()],
|
|
8834
|
+
["pythOracleFeedId", (0, import_kit65.getAddressDecoder)()]
|
|
8722
8835
|
]);
|
|
8723
8836
|
}
|
|
8724
8837
|
function getUpdateVaultInstructionDataCodec() {
|
|
8725
|
-
return (0,
|
|
8838
|
+
return (0, import_kit65.combineCodec)(
|
|
8726
8839
|
getUpdateVaultInstructionDataEncoder(),
|
|
8727
8840
|
getUpdateVaultInstructionDataDecoder()
|
|
8728
8841
|
);
|
|
@@ -8772,7 +8885,7 @@ function parseUpdateVaultInstruction(instruction) {
|
|
|
8772
8885
|
}
|
|
8773
8886
|
|
|
8774
8887
|
// src/generated/instructions/withdraw.ts
|
|
8775
|
-
var
|
|
8888
|
+
var import_kit66 = require("@solana/kit");
|
|
8776
8889
|
var WITHDRAW_DISCRIMINATOR = new Uint8Array([
|
|
8777
8890
|
183,
|
|
8778
8891
|
18,
|
|
@@ -8784,27 +8897,27 @@ var WITHDRAW_DISCRIMINATOR = new Uint8Array([
|
|
|
8784
8897
|
34
|
|
8785
8898
|
]);
|
|
8786
8899
|
function getWithdrawDiscriminatorBytes() {
|
|
8787
|
-
return (0,
|
|
8900
|
+
return (0, import_kit66.fixEncoderSize)((0, import_kit66.getBytesEncoder)(), 8).encode(WITHDRAW_DISCRIMINATOR);
|
|
8788
8901
|
}
|
|
8789
8902
|
function getWithdrawInstructionDataEncoder() {
|
|
8790
|
-
return (0,
|
|
8791
|
-
(0,
|
|
8792
|
-
["discriminator", (0,
|
|
8793
|
-
["funds", (0,
|
|
8794
|
-
["shares", (0,
|
|
8903
|
+
return (0, import_kit66.transformEncoder)(
|
|
8904
|
+
(0, import_kit66.getStructEncoder)([
|
|
8905
|
+
["discriminator", (0, import_kit66.fixEncoderSize)((0, import_kit66.getBytesEncoder)(), 8)],
|
|
8906
|
+
["funds", (0, import_kit66.getU64Encoder)()],
|
|
8907
|
+
["shares", (0, import_kit66.getU64Encoder)()]
|
|
8795
8908
|
]),
|
|
8796
8909
|
(value) => ({ ...value, discriminator: WITHDRAW_DISCRIMINATOR })
|
|
8797
8910
|
);
|
|
8798
8911
|
}
|
|
8799
8912
|
function getWithdrawInstructionDataDecoder() {
|
|
8800
|
-
return (0,
|
|
8801
|
-
["discriminator", (0,
|
|
8802
|
-
["funds", (0,
|
|
8803
|
-
["shares", (0,
|
|
8913
|
+
return (0, import_kit66.getStructDecoder)([
|
|
8914
|
+
["discriminator", (0, import_kit66.fixDecoderSize)((0, import_kit66.getBytesDecoder)(), 8)],
|
|
8915
|
+
["funds", (0, import_kit66.getU64Decoder)()],
|
|
8916
|
+
["shares", (0, import_kit66.getU64Decoder)()]
|
|
8804
8917
|
]);
|
|
8805
8918
|
}
|
|
8806
8919
|
function getWithdrawInstructionDataCodec() {
|
|
8807
|
-
return (0,
|
|
8920
|
+
return (0, import_kit66.combineCodec)(
|
|
8808
8921
|
getWithdrawInstructionDataEncoder(),
|
|
8809
8922
|
getWithdrawInstructionDataDecoder()
|
|
8810
8923
|
);
|
|
@@ -8875,11 +8988,11 @@ function parseWithdrawInstruction(instruction) {
|
|
|
8875
8988
|
}
|
|
8876
8989
|
|
|
8877
8990
|
// src/pda.ts
|
|
8878
|
-
var
|
|
8991
|
+
var import_kit68 = require("@solana/kit");
|
|
8879
8992
|
|
|
8880
8993
|
// src/consts.ts
|
|
8881
|
-
var
|
|
8882
|
-
var DEFAULT_ADDRESS = (0,
|
|
8994
|
+
var import_kit67 = require("@solana/kit");
|
|
8995
|
+
var DEFAULT_ADDRESS = (0, import_kit67.address)("11111111111111111111111111111111");
|
|
8883
8996
|
var HUNDRED_PERCENT = 1e6;
|
|
8884
8997
|
var HUNDRED_PERCENTn = 1000000n;
|
|
8885
8998
|
var LEVERAGE_ONE = HUNDRED_PERCENT;
|
|
@@ -8900,48 +9013,48 @@ var TUNA_POSITION_FLAGS_UPPER_LIMIT_ORDER_SWAP_TO_TOKEN_B = 1 << 3;
|
|
|
8900
9013
|
var TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD = 1 << 4;
|
|
8901
9014
|
var TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD_WITH_LEVERAGE = 1 << 5;
|
|
8902
9015
|
var TUNA_POSITION_FLAGS_ALLOW_REBALANCING = 1 << 6;
|
|
8903
|
-
var WP_NFT_UPDATE_AUTH = (0,
|
|
8904
|
-
var DEFAULT_PUSH_ORACLE_PROGRAM_ID = (0,
|
|
8905
|
-
var JUPITER_EVENT_AUTHORITY = (0,
|
|
8906
|
-
var JUPITER_PROGRAM_AUTHORITY = (0,
|
|
9016
|
+
var WP_NFT_UPDATE_AUTH = (0, import_kit67.address)("3axbTs2z5GBy6usVbNVoqEgZMng3vZvMnAoX29BFfwhr");
|
|
9017
|
+
var DEFAULT_PUSH_ORACLE_PROGRAM_ID = (0, import_kit67.address)("pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT");
|
|
9018
|
+
var JUPITER_EVENT_AUTHORITY = (0, import_kit67.address)("D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf");
|
|
9019
|
+
var JUPITER_PROGRAM_AUTHORITY = (0, import_kit67.address)("9nnLbotNTcUhvbrsA6Mdkx45Sm82G35zo28AqUvjExn8");
|
|
8907
9020
|
var MIN_SQRT_PRICE = 4295048016n;
|
|
8908
9021
|
var MAX_SQRT_PRICE = 79226673515401279992447579055n;
|
|
8909
9022
|
|
|
8910
9023
|
// src/pda.ts
|
|
8911
9024
|
async function getTunaConfigAddress() {
|
|
8912
|
-
return await (0,
|
|
9025
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8913
9026
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8914
9027
|
seeds: ["tuna_config"]
|
|
8915
9028
|
});
|
|
8916
9029
|
}
|
|
8917
9030
|
async function getMarketAddress(pool) {
|
|
8918
|
-
return await (0,
|
|
9031
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8919
9032
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8920
|
-
seeds: ["market", (0,
|
|
9033
|
+
seeds: ["market", (0, import_kit68.getAddressEncoder)().encode(pool)]
|
|
8921
9034
|
});
|
|
8922
9035
|
}
|
|
8923
9036
|
async function getLendingVaultAddress(mint) {
|
|
8924
|
-
return await (0,
|
|
9037
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8925
9038
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8926
|
-
seeds: ["vault", (0,
|
|
9039
|
+
seeds: ["vault", (0, import_kit68.getAddressEncoder)().encode(mint)]
|
|
8927
9040
|
});
|
|
8928
9041
|
}
|
|
8929
9042
|
async function getLendingPositionAddress(authority, mint) {
|
|
8930
|
-
return await (0,
|
|
9043
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8931
9044
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8932
|
-
seeds: ["lending_position", (0,
|
|
9045
|
+
seeds: ["lending_position", (0, import_kit68.getAddressEncoder)().encode(authority), (0, import_kit68.getAddressEncoder)().encode(mint)]
|
|
8933
9046
|
});
|
|
8934
9047
|
}
|
|
8935
9048
|
async function getTunaLpPositionAddress(positionMint) {
|
|
8936
|
-
return await (0,
|
|
9049
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8937
9050
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8938
|
-
seeds: ["tuna_position", (0,
|
|
9051
|
+
seeds: ["tuna_position", (0, import_kit68.getAddressEncoder)().encode(positionMint)]
|
|
8939
9052
|
});
|
|
8940
9053
|
}
|
|
8941
9054
|
async function getTunaSpotPositionAddress(authority, pool) {
|
|
8942
|
-
return await (0,
|
|
9055
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8943
9056
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8944
|
-
seeds: ["tuna_spot_position", (0,
|
|
9057
|
+
seeds: ["tuna_spot_position", (0, import_kit68.getAddressEncoder)().encode(authority), (0, import_kit68.getAddressEncoder)().encode(pool)]
|
|
8945
9058
|
});
|
|
8946
9059
|
}
|
|
8947
9060
|
async function getPythPriceUpdateAccountAddress(shardId, priceFeedId) {
|
|
@@ -8957,23 +9070,23 @@ async function getPythPriceUpdateAccountAddress(shardId, priceFeedId) {
|
|
|
8957
9070
|
}
|
|
8958
9071
|
const shardBuffer = Buffer.alloc(2);
|
|
8959
9072
|
shardBuffer.writeUint16LE(shardId, 0);
|
|
8960
|
-
return await (0,
|
|
9073
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8961
9074
|
programAddress: DEFAULT_PUSH_ORACLE_PROGRAM_ID,
|
|
8962
9075
|
seeds: [shardBuffer, priceFeedId]
|
|
8963
9076
|
});
|
|
8964
9077
|
}
|
|
8965
9078
|
|
|
8966
9079
|
// src/gpa/tunaLpPosition.ts
|
|
8967
|
-
var
|
|
9080
|
+
var import_kit70 = require("@solana/kit");
|
|
8968
9081
|
|
|
8969
9082
|
// src/gpa/utils.ts
|
|
8970
|
-
var
|
|
9083
|
+
var import_kit69 = require("@solana/kit");
|
|
8971
9084
|
async function fetchDecodedProgramAccounts(rpc, programAddress, filters, decoder) {
|
|
8972
9085
|
const accountInfos = await rpc.getProgramAccounts(programAddress, {
|
|
8973
9086
|
encoding: "base64",
|
|
8974
9087
|
filters
|
|
8975
9088
|
}).send();
|
|
8976
|
-
const encoder = (0,
|
|
9089
|
+
const encoder = (0, import_kit69.getBase64Encoder)();
|
|
8977
9090
|
const datas = accountInfos.map((x) => encoder.encode(x.account.data[0]));
|
|
8978
9091
|
const decoded = datas.map((x) => decoder.decode(x));
|
|
8979
9092
|
return decoded.map((data, i) => ({
|
|
@@ -8989,7 +9102,7 @@ function tunaLpPositionAuthorityFilter(address4) {
|
|
|
8989
9102
|
return {
|
|
8990
9103
|
memcmp: {
|
|
8991
9104
|
offset: 11n,
|
|
8992
|
-
bytes: (0,
|
|
9105
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getAddressEncoder)().encode(address4)),
|
|
8993
9106
|
encoding: "base58"
|
|
8994
9107
|
}
|
|
8995
9108
|
};
|
|
@@ -8998,7 +9111,7 @@ function tunaLpPositionPoolFilter(address4) {
|
|
|
8998
9111
|
return {
|
|
8999
9112
|
memcmp: {
|
|
9000
9113
|
offset: 43n,
|
|
9001
|
-
bytes: (0,
|
|
9114
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getAddressEncoder)().encode(address4)),
|
|
9002
9115
|
encoding: "base58"
|
|
9003
9116
|
}
|
|
9004
9117
|
};
|
|
@@ -9007,7 +9120,7 @@ function tunaLpPositionMintAFilter(address4) {
|
|
|
9007
9120
|
return {
|
|
9008
9121
|
memcmp: {
|
|
9009
9122
|
offset: 75n,
|
|
9010
|
-
bytes: (0,
|
|
9123
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getAddressEncoder)().encode(address4)),
|
|
9011
9124
|
encoding: "base58"
|
|
9012
9125
|
}
|
|
9013
9126
|
};
|
|
@@ -9016,7 +9129,7 @@ function tunaLpPositionMintBFilter(address4) {
|
|
|
9016
9129
|
return {
|
|
9017
9130
|
memcmp: {
|
|
9018
9131
|
offset: 107n,
|
|
9019
|
-
bytes: (0,
|
|
9132
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getAddressEncoder)().encode(address4)),
|
|
9020
9133
|
encoding: "base58"
|
|
9021
9134
|
}
|
|
9022
9135
|
};
|
|
@@ -9025,7 +9138,7 @@ function tunaLpPositionMintFilter(address4) {
|
|
|
9025
9138
|
return {
|
|
9026
9139
|
memcmp: {
|
|
9027
9140
|
offset: 139n,
|
|
9028
|
-
bytes: (0,
|
|
9141
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getAddressEncoder)().encode(address4)),
|
|
9029
9142
|
encoding: "base58"
|
|
9030
9143
|
}
|
|
9031
9144
|
};
|
|
@@ -9034,13 +9147,13 @@ function tunaLpPositionMarketMakerFilter(marketMaker) {
|
|
|
9034
9147
|
return {
|
|
9035
9148
|
memcmp: {
|
|
9036
9149
|
offset: 277n,
|
|
9037
|
-
bytes: (0,
|
|
9150
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getI8Encoder)().encode(marketMaker)),
|
|
9038
9151
|
encoding: "base58"
|
|
9039
9152
|
}
|
|
9040
9153
|
};
|
|
9041
9154
|
}
|
|
9042
9155
|
async function fetchAllTunaLpPositionWithFilter(rpc, ...filters) {
|
|
9043
|
-
const discriminator = (0,
|
|
9156
|
+
const discriminator = (0, import_kit70.getBase58Decoder)().decode(TUNA_LP_POSITION_DISCRIMINATOR);
|
|
9044
9157
|
const discriminatorFilter = {
|
|
9045
9158
|
memcmp: {
|
|
9046
9159
|
offset: 0n,
|
|
@@ -9057,12 +9170,12 @@ async function fetchAllTunaLpPositionWithFilter(rpc, ...filters) {
|
|
|
9057
9170
|
}
|
|
9058
9171
|
|
|
9059
9172
|
// src/gpa/tunaSpotPosition.ts
|
|
9060
|
-
var
|
|
9173
|
+
var import_kit71 = require("@solana/kit");
|
|
9061
9174
|
function tunaSpotPositionAuthorityFilter(address4) {
|
|
9062
9175
|
return {
|
|
9063
9176
|
memcmp: {
|
|
9064
9177
|
offset: 11n,
|
|
9065
|
-
bytes: (0,
|
|
9178
|
+
bytes: (0, import_kit71.getBase58Decoder)().decode((0, import_kit71.getAddressEncoder)().encode(address4)),
|
|
9066
9179
|
encoding: "base58"
|
|
9067
9180
|
}
|
|
9068
9181
|
};
|
|
@@ -9071,7 +9184,7 @@ function tunaSpotPositionPoolFilter(address4) {
|
|
|
9071
9184
|
return {
|
|
9072
9185
|
memcmp: {
|
|
9073
9186
|
offset: 43n,
|
|
9074
|
-
bytes: (0,
|
|
9187
|
+
bytes: (0, import_kit71.getBase58Decoder)().decode((0, import_kit71.getAddressEncoder)().encode(address4)),
|
|
9075
9188
|
encoding: "base58"
|
|
9076
9189
|
}
|
|
9077
9190
|
};
|
|
@@ -9080,7 +9193,7 @@ function tunaSpotPositionMintAFilter(address4) {
|
|
|
9080
9193
|
return {
|
|
9081
9194
|
memcmp: {
|
|
9082
9195
|
offset: 75n,
|
|
9083
|
-
bytes: (0,
|
|
9196
|
+
bytes: (0, import_kit71.getBase58Decoder)().decode((0, import_kit71.getAddressEncoder)().encode(address4)),
|
|
9084
9197
|
encoding: "base58"
|
|
9085
9198
|
}
|
|
9086
9199
|
};
|
|
@@ -9089,13 +9202,13 @@ function tunaSpotPositionMintBFilter(address4) {
|
|
|
9089
9202
|
return {
|
|
9090
9203
|
memcmp: {
|
|
9091
9204
|
offset: 107n,
|
|
9092
|
-
bytes: (0,
|
|
9205
|
+
bytes: (0, import_kit71.getBase58Decoder)().decode((0, import_kit71.getAddressEncoder)().encode(address4)),
|
|
9093
9206
|
encoding: "base58"
|
|
9094
9207
|
}
|
|
9095
9208
|
};
|
|
9096
9209
|
}
|
|
9097
9210
|
async function fetchAllTunaSpotPositionWithFilter(rpc, ...filters) {
|
|
9098
|
-
const discriminator = (0,
|
|
9211
|
+
const discriminator = (0, import_kit71.getBase58Decoder)().decode(TUNA_SPOT_POSITION_DISCRIMINATOR);
|
|
9099
9212
|
const discriminatorFilter = {
|
|
9100
9213
|
memcmp: {
|
|
9101
9214
|
offset: 0n,
|
|
@@ -9112,12 +9225,12 @@ async function fetchAllTunaSpotPositionWithFilter(rpc, ...filters) {
|
|
|
9112
9225
|
}
|
|
9113
9226
|
|
|
9114
9227
|
// src/gpa/lendingPosition.ts
|
|
9115
|
-
var
|
|
9228
|
+
var import_kit72 = require("@solana/kit");
|
|
9116
9229
|
function lendingPositionAuthorityFilter(address4) {
|
|
9117
9230
|
return {
|
|
9118
9231
|
memcmp: {
|
|
9119
9232
|
offset: 11n,
|
|
9120
|
-
bytes: (0,
|
|
9233
|
+
bytes: (0, import_kit72.getBase58Decoder)().decode((0, import_kit72.getAddressEncoder)().encode(address4)),
|
|
9121
9234
|
encoding: "base58"
|
|
9122
9235
|
}
|
|
9123
9236
|
};
|
|
@@ -9126,13 +9239,13 @@ function lendingPositionMintFilter(address4) {
|
|
|
9126
9239
|
return {
|
|
9127
9240
|
memcmp: {
|
|
9128
9241
|
offset: 43n,
|
|
9129
|
-
bytes: (0,
|
|
9242
|
+
bytes: (0, import_kit72.getBase58Decoder)().decode((0, import_kit72.getAddressEncoder)().encode(address4)),
|
|
9130
9243
|
encoding: "base58"
|
|
9131
9244
|
}
|
|
9132
9245
|
};
|
|
9133
9246
|
}
|
|
9134
9247
|
async function fetchAllLendingPositionWithFilter(rpc, ...filters) {
|
|
9135
|
-
const discriminator = (0,
|
|
9248
|
+
const discriminator = (0, import_kit72.getBase58Decoder)().decode(LENDING_POSITION_DISCRIMINATOR);
|
|
9136
9249
|
const discriminatorFilter = {
|
|
9137
9250
|
memcmp: {
|
|
9138
9251
|
offset: 0n,
|
|
@@ -9149,9 +9262,9 @@ async function fetchAllLendingPositionWithFilter(rpc, ...filters) {
|
|
|
9149
9262
|
}
|
|
9150
9263
|
|
|
9151
9264
|
// src/gpa/market.ts
|
|
9152
|
-
var
|
|
9265
|
+
var import_kit73 = require("@solana/kit");
|
|
9153
9266
|
async function fetchAllMarketWithFilter(rpc, ...filters) {
|
|
9154
|
-
const discriminator = (0,
|
|
9267
|
+
const discriminator = (0, import_kit73.getBase58Decoder)().decode(MARKET_DISCRIMINATOR);
|
|
9155
9268
|
const discriminatorFilter = {
|
|
9156
9269
|
memcmp: {
|
|
9157
9270
|
offset: 0n,
|
|
@@ -9253,11 +9366,11 @@ var FusionUtils = class {
|
|
|
9253
9366
|
};
|
|
9254
9367
|
|
|
9255
9368
|
// src/utils/token.ts
|
|
9256
|
-
var
|
|
9369
|
+
var import_kit74 = require("@solana/kit");
|
|
9257
9370
|
var import_system = require("@solana-program/system");
|
|
9258
9371
|
var import_token = require("@solana-program/token");
|
|
9259
9372
|
var import_token_2022 = require("@solana-program/token-2022");
|
|
9260
|
-
var NATIVE_MINT = (0,
|
|
9373
|
+
var NATIVE_MINT = (0, import_kit74.address)("So11111111111111111111111111111111111111112");
|
|
9261
9374
|
async function getCreateAtaInstruction(mint, owner, payer, tokenProgram = import_token.TOKEN_PROGRAM_ADDRESS) {
|
|
9262
9375
|
const ata = (await (0, import_token.findAssociatedTokenPda)({
|
|
9263
9376
|
mint,
|
|
@@ -9444,7 +9557,7 @@ function calculateProtocolFee(collateralAmount, borrowAmount, protocolFeeRateOnC
|
|
|
9444
9557
|
// src/txbuilder/increaseTunaLpPositionOrca.ts
|
|
9445
9558
|
var import_whirlpools_client2 = require("@orca-so/whirlpools-client");
|
|
9446
9559
|
var import_whirlpools_core2 = require("@orca-so/whirlpools-core");
|
|
9447
|
-
var
|
|
9560
|
+
var import_kit75 = require("@solana/kit");
|
|
9448
9561
|
var import_memo = require("@solana-program/memo");
|
|
9449
9562
|
var import_token_20222 = require("@solana-program/token-2022");
|
|
9450
9563
|
var import_assert = __toESM(require("assert"));
|
|
@@ -9618,16 +9731,16 @@ async function increaseTunaLpPositionOrcaInstruction(authority, tunaPosition, tu
|
|
|
9618
9731
|
tunaPosition.data.tickUpperIndex
|
|
9619
9732
|
);
|
|
9620
9733
|
const remainingAccounts = [
|
|
9621
|
-
{ address: swapTickArrays[0], role:
|
|
9622
|
-
{ address: swapTickArrays[1], role:
|
|
9623
|
-
{ address: swapTickArrays[2], role:
|
|
9624
|
-
{ address: swapTickArrays[3], role:
|
|
9625
|
-
{ address: swapTickArrays[4], role:
|
|
9626
|
-
{ address: lowerTickArrayAddress, role:
|
|
9627
|
-
{ address: upperTickArrayAddress, role:
|
|
9628
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
9629
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
9630
|
-
{ address: orcaOracleAddress, role:
|
|
9734
|
+
{ address: swapTickArrays[0], role: import_kit75.AccountRole.WRITABLE },
|
|
9735
|
+
{ address: swapTickArrays[1], role: import_kit75.AccountRole.WRITABLE },
|
|
9736
|
+
{ address: swapTickArrays[2], role: import_kit75.AccountRole.WRITABLE },
|
|
9737
|
+
{ address: swapTickArrays[3], role: import_kit75.AccountRole.WRITABLE },
|
|
9738
|
+
{ address: swapTickArrays[4], role: import_kit75.AccountRole.WRITABLE },
|
|
9739
|
+
{ address: lowerTickArrayAddress, role: import_kit75.AccountRole.WRITABLE },
|
|
9740
|
+
{ address: upperTickArrayAddress, role: import_kit75.AccountRole.WRITABLE },
|
|
9741
|
+
{ address: whirlpool.data.tokenVaultA, role: import_kit75.AccountRole.WRITABLE },
|
|
9742
|
+
{ address: whirlpool.data.tokenVaultB, role: import_kit75.AccountRole.WRITABLE },
|
|
9743
|
+
{ address: orcaOracleAddress, role: import_kit75.AccountRole.WRITABLE }
|
|
9631
9744
|
];
|
|
9632
9745
|
const remainingAccountsInfo = {
|
|
9633
9746
|
slices: [
|
|
@@ -9675,7 +9788,7 @@ async function increaseTunaLpPositionOrcaInstruction(authority, tunaPosition, tu
|
|
|
9675
9788
|
// src/txbuilder/increaseTunaLpPositionFusion.ts
|
|
9676
9789
|
var import_fusionamm_client2 = require("@crypticdot/fusionamm-client");
|
|
9677
9790
|
var import_fusionamm_core4 = require("@crypticdot/fusionamm-core");
|
|
9678
|
-
var
|
|
9791
|
+
var import_kit76 = require("@solana/kit");
|
|
9679
9792
|
var import_memo2 = require("@solana-program/memo");
|
|
9680
9793
|
var import_token_20223 = require("@solana-program/token-2022");
|
|
9681
9794
|
var import_assert2 = __toESM(require("assert"));
|
|
@@ -9854,15 +9967,15 @@ async function increaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
9854
9967
|
tunaPosition.data.tickUpperIndex
|
|
9855
9968
|
);
|
|
9856
9969
|
const remainingAccounts = [
|
|
9857
|
-
{ address: swapTickArrays[0], role:
|
|
9858
|
-
{ address: swapTickArrays[1], role:
|
|
9859
|
-
{ address: swapTickArrays[2], role:
|
|
9860
|
-
{ address: swapTickArrays[3], role:
|
|
9861
|
-
{ address: swapTickArrays[4], role:
|
|
9862
|
-
{ address: lowerTickArrayAddress, role:
|
|
9863
|
-
{ address: upperTickArrayAddress, role:
|
|
9864
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
9865
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
9970
|
+
{ address: swapTickArrays[0], role: import_kit76.AccountRole.WRITABLE },
|
|
9971
|
+
{ address: swapTickArrays[1], role: import_kit76.AccountRole.WRITABLE },
|
|
9972
|
+
{ address: swapTickArrays[2], role: import_kit76.AccountRole.WRITABLE },
|
|
9973
|
+
{ address: swapTickArrays[3], role: import_kit76.AccountRole.WRITABLE },
|
|
9974
|
+
{ address: swapTickArrays[4], role: import_kit76.AccountRole.WRITABLE },
|
|
9975
|
+
{ address: lowerTickArrayAddress, role: import_kit76.AccountRole.WRITABLE },
|
|
9976
|
+
{ address: upperTickArrayAddress, role: import_kit76.AccountRole.WRITABLE },
|
|
9977
|
+
{ address: fusionPool.data.tokenVaultA, role: import_kit76.AccountRole.WRITABLE },
|
|
9978
|
+
{ address: fusionPool.data.tokenVaultB, role: import_kit76.AccountRole.WRITABLE }
|
|
9866
9979
|
];
|
|
9867
9980
|
const remainingAccountsInfo = {
|
|
9868
9981
|
slices: [
|
|
@@ -10000,7 +10113,7 @@ async function closeTunaLpPositionFusionInstruction(rpc, authority, positionMint
|
|
|
10000
10113
|
|
|
10001
10114
|
// src/txbuilder/collectAndCompoundFeesOrca.ts
|
|
10002
10115
|
var import_whirlpools_client4 = require("@orca-so/whirlpools-client");
|
|
10003
|
-
var
|
|
10116
|
+
var import_kit77 = require("@solana/kit");
|
|
10004
10117
|
var import_memo3 = require("@solana-program/memo");
|
|
10005
10118
|
var import_token_20226 = require("@solana-program/token-2022");
|
|
10006
10119
|
var import_assert5 = __toESM(require("assert"));
|
|
@@ -10098,16 +10211,16 @@ async function collectAndCompoundFeesOrcaInstruction(authority, tunaConfig, tuna
|
|
|
10098
10211
|
tunaPosition.data.tickUpperIndex
|
|
10099
10212
|
);
|
|
10100
10213
|
const remainingAccounts = [
|
|
10101
|
-
{ address: swapTickArrays[0], role:
|
|
10102
|
-
{ address: swapTickArrays[1], role:
|
|
10103
|
-
{ address: swapTickArrays[2], role:
|
|
10104
|
-
{ address: swapTickArrays[3], role:
|
|
10105
|
-
{ address: swapTickArrays[4], role:
|
|
10106
|
-
{ address: lowerTickArrayAddress, role:
|
|
10107
|
-
{ address: upperTickArrayAddress, role:
|
|
10108
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
10109
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
10110
|
-
{ address: orcaOracleAddress, role:
|
|
10214
|
+
{ address: swapTickArrays[0], role: import_kit77.AccountRole.WRITABLE },
|
|
10215
|
+
{ address: swapTickArrays[1], role: import_kit77.AccountRole.WRITABLE },
|
|
10216
|
+
{ address: swapTickArrays[2], role: import_kit77.AccountRole.WRITABLE },
|
|
10217
|
+
{ address: swapTickArrays[3], role: import_kit77.AccountRole.WRITABLE },
|
|
10218
|
+
{ address: swapTickArrays[4], role: import_kit77.AccountRole.WRITABLE },
|
|
10219
|
+
{ address: lowerTickArrayAddress, role: import_kit77.AccountRole.WRITABLE },
|
|
10220
|
+
{ address: upperTickArrayAddress, role: import_kit77.AccountRole.WRITABLE },
|
|
10221
|
+
{ address: whirlpool.data.tokenVaultA, role: import_kit77.AccountRole.WRITABLE },
|
|
10222
|
+
{ address: whirlpool.data.tokenVaultB, role: import_kit77.AccountRole.WRITABLE },
|
|
10223
|
+
{ address: orcaOracleAddress, role: import_kit77.AccountRole.WRITABLE }
|
|
10111
10224
|
];
|
|
10112
10225
|
const remainingAccountsInfo = {
|
|
10113
10226
|
slices: [
|
|
@@ -10152,7 +10265,7 @@ async function collectAndCompoundFeesOrcaInstruction(authority, tunaConfig, tuna
|
|
|
10152
10265
|
|
|
10153
10266
|
// src/txbuilder/collectAndCompoundFeesFusion.ts
|
|
10154
10267
|
var import_fusionamm_client4 = require("@crypticdot/fusionamm-client");
|
|
10155
|
-
var
|
|
10268
|
+
var import_kit78 = require("@solana/kit");
|
|
10156
10269
|
var import_memo4 = require("@solana-program/memo");
|
|
10157
10270
|
var import_token_20227 = require("@solana-program/token-2022");
|
|
10158
10271
|
var import_assert6 = __toESM(require("assert"));
|
|
@@ -10249,15 +10362,15 @@ async function collectAndCompoundFeesFusionInstruction(authority, tunaConfig, tu
|
|
|
10249
10362
|
tunaPosition.data.tickUpperIndex
|
|
10250
10363
|
);
|
|
10251
10364
|
const remainingAccounts = [
|
|
10252
|
-
{ address: swapTickArrays[0], role:
|
|
10253
|
-
{ address: swapTickArrays[1], role:
|
|
10254
|
-
{ address: swapTickArrays[2], role:
|
|
10255
|
-
{ address: swapTickArrays[3], role:
|
|
10256
|
-
{ address: swapTickArrays[4], role:
|
|
10257
|
-
{ address: lowerTickArrayAddress, role:
|
|
10258
|
-
{ address: upperTickArrayAddress, role:
|
|
10259
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
10260
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
10365
|
+
{ address: swapTickArrays[0], role: import_kit78.AccountRole.WRITABLE },
|
|
10366
|
+
{ address: swapTickArrays[1], role: import_kit78.AccountRole.WRITABLE },
|
|
10367
|
+
{ address: swapTickArrays[2], role: import_kit78.AccountRole.WRITABLE },
|
|
10368
|
+
{ address: swapTickArrays[3], role: import_kit78.AccountRole.WRITABLE },
|
|
10369
|
+
{ address: swapTickArrays[4], role: import_kit78.AccountRole.WRITABLE },
|
|
10370
|
+
{ address: lowerTickArrayAddress, role: import_kit78.AccountRole.WRITABLE },
|
|
10371
|
+
{ address: upperTickArrayAddress, role: import_kit78.AccountRole.WRITABLE },
|
|
10372
|
+
{ address: fusionPool.data.tokenVaultA, role: import_kit78.AccountRole.WRITABLE },
|
|
10373
|
+
{ address: fusionPool.data.tokenVaultB, role: import_kit78.AccountRole.WRITABLE }
|
|
10261
10374
|
];
|
|
10262
10375
|
const remainingAccountsInfo = {
|
|
10263
10376
|
slices: [
|
|
@@ -10301,7 +10414,7 @@ async function collectAndCompoundFeesFusionInstruction(authority, tunaConfig, tu
|
|
|
10301
10414
|
|
|
10302
10415
|
// src/txbuilder/collectFeesOrca.ts
|
|
10303
10416
|
var import_whirlpools_client5 = require("@orca-so/whirlpools-client");
|
|
10304
|
-
var
|
|
10417
|
+
var import_kit79 = require("@solana/kit");
|
|
10305
10418
|
var import_memo5 = require("@solana-program/memo");
|
|
10306
10419
|
var import_token_20228 = require("@solana-program/token-2022");
|
|
10307
10420
|
var import_assert7 = __toESM(require("assert"));
|
|
@@ -10377,10 +10490,10 @@ async function collectFeesOrcaInstruction(authority, tunaPosition, mintA, mintB,
|
|
|
10377
10490
|
tunaPosition.data.tickUpperIndex
|
|
10378
10491
|
);
|
|
10379
10492
|
const remainingAccounts = [
|
|
10380
|
-
{ address: lowerTickArrayAddress, role:
|
|
10381
|
-
{ address: upperTickArrayAddress, role:
|
|
10382
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
10383
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
10493
|
+
{ address: lowerTickArrayAddress, role: import_kit79.AccountRole.WRITABLE },
|
|
10494
|
+
{ address: upperTickArrayAddress, role: import_kit79.AccountRole.WRITABLE },
|
|
10495
|
+
{ address: whirlpool.data.tokenVaultA, role: import_kit79.AccountRole.WRITABLE },
|
|
10496
|
+
{ address: whirlpool.data.tokenVaultB, role: import_kit79.AccountRole.WRITABLE }
|
|
10384
10497
|
];
|
|
10385
10498
|
const remainingAccountsInfo = {
|
|
10386
10499
|
slices: [
|
|
@@ -10415,7 +10528,7 @@ async function collectFeesOrcaInstruction(authority, tunaPosition, mintA, mintB,
|
|
|
10415
10528
|
|
|
10416
10529
|
// src/txbuilder/collectFeesFusion.ts
|
|
10417
10530
|
var import_fusionamm_client5 = require("@crypticdot/fusionamm-client");
|
|
10418
|
-
var
|
|
10531
|
+
var import_kit80 = require("@solana/kit");
|
|
10419
10532
|
var import_memo6 = require("@solana-program/memo");
|
|
10420
10533
|
var import_token_20229 = require("@solana-program/token-2022");
|
|
10421
10534
|
var import_assert8 = __toESM(require("assert"));
|
|
@@ -10491,10 +10604,10 @@ async function collectFeesFusionInstruction(authority, tunaPosition, mintA, mint
|
|
|
10491
10604
|
tunaPosition.data.tickUpperIndex
|
|
10492
10605
|
);
|
|
10493
10606
|
const remainingAccounts = [
|
|
10494
|
-
{ address: lowerTickArrayAddress, role:
|
|
10495
|
-
{ address: upperTickArrayAddress, role:
|
|
10496
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
10497
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
10607
|
+
{ address: lowerTickArrayAddress, role: import_kit80.AccountRole.WRITABLE },
|
|
10608
|
+
{ address: upperTickArrayAddress, role: import_kit80.AccountRole.WRITABLE },
|
|
10609
|
+
{ address: fusionPool.data.tokenVaultA, role: import_kit80.AccountRole.WRITABLE },
|
|
10610
|
+
{ address: fusionPool.data.tokenVaultB, role: import_kit80.AccountRole.WRITABLE }
|
|
10498
10611
|
];
|
|
10499
10612
|
const remainingAccountsInfo = {
|
|
10500
10613
|
slices: [
|
|
@@ -10605,7 +10718,7 @@ async function openLendingPositionAndDepositInstructions(rpc, authority, mintAdd
|
|
|
10605
10718
|
// src/txbuilder/closeActiveTunaLpPositionOrca.ts
|
|
10606
10719
|
var import_whirlpools_client6 = require("@orca-so/whirlpools-client");
|
|
10607
10720
|
var import_whirlpools_core3 = require("@orca-so/whirlpools-core");
|
|
10608
|
-
var
|
|
10721
|
+
var import_kit81 = require("@solana/kit");
|
|
10609
10722
|
var import_token_202211 = require("@solana-program/token-2022");
|
|
10610
10723
|
var import_assert9 = __toESM(require("assert"));
|
|
10611
10724
|
async function closeActiveTunaLpPositionOrcaInstructions(rpc, authority, positionMint, args) {
|
|
@@ -10626,7 +10739,7 @@ async function closeActiveTunaLpPositionOrcaInstructions(rpc, authority, positio
|
|
|
10626
10739
|
const allMints = [mintA, mintB, ...rewardMints];
|
|
10627
10740
|
(0, import_assert9.default)(mintA.exists, "Token A account not found");
|
|
10628
10741
|
(0, import_assert9.default)(mintB.exists, "Token B account not found");
|
|
10629
|
-
(0,
|
|
10742
|
+
(0, import_kit81.assertAccountsExist)(rewardMints);
|
|
10630
10743
|
const lowerTickArrayStartIndex = (0, import_whirlpools_core3.getTickArrayStartTickIndex)(
|
|
10631
10744
|
tunaPosition.data.tickLowerIndex,
|
|
10632
10745
|
whirlpool.data.tickSpacing
|
|
@@ -10807,7 +10920,7 @@ async function closeActiveTunaLpPositionFusionInstructions(rpc, authority, posit
|
|
|
10807
10920
|
|
|
10808
10921
|
// src/txbuilder/modifyTunaSpotPositionOrca.ts
|
|
10809
10922
|
var import_whirlpools_client7 = require("@orca-so/whirlpools-client");
|
|
10810
|
-
var
|
|
10923
|
+
var import_kit82 = require("@solana/kit");
|
|
10811
10924
|
var import_memo8 = require("@solana-program/memo");
|
|
10812
10925
|
var import_token_202213 = require("@solana-program/token-2022");
|
|
10813
10926
|
var import_assert11 = __toESM(require("assert"));
|
|
@@ -10948,14 +11061,14 @@ async function modifyTunaSpotPositionOrcaInstruction(authority, tunaConfig, mint
|
|
|
10948
11061
|
}))[0];
|
|
10949
11062
|
const swapTickArrays = await OrcaUtils.getSwapTickArrayAddresses(pool);
|
|
10950
11063
|
const remainingAccounts = [
|
|
10951
|
-
{ address: swapTickArrays[0], role:
|
|
10952
|
-
{ address: swapTickArrays[1], role:
|
|
10953
|
-
{ address: swapTickArrays[2], role:
|
|
10954
|
-
{ address: swapTickArrays[3], role:
|
|
10955
|
-
{ address: swapTickArrays[4], role:
|
|
10956
|
-
{ address: pool.data.tokenVaultA, role:
|
|
10957
|
-
{ address: pool.data.tokenVaultB, role:
|
|
10958
|
-
{ address: orcaOracleAddress, role:
|
|
11064
|
+
{ address: swapTickArrays[0], role: import_kit82.AccountRole.WRITABLE },
|
|
11065
|
+
{ address: swapTickArrays[1], role: import_kit82.AccountRole.WRITABLE },
|
|
11066
|
+
{ address: swapTickArrays[2], role: import_kit82.AccountRole.WRITABLE },
|
|
11067
|
+
{ address: swapTickArrays[3], role: import_kit82.AccountRole.WRITABLE },
|
|
11068
|
+
{ address: swapTickArrays[4], role: import_kit82.AccountRole.WRITABLE },
|
|
11069
|
+
{ address: pool.data.tokenVaultA, role: import_kit82.AccountRole.WRITABLE },
|
|
11070
|
+
{ address: pool.data.tokenVaultB, role: import_kit82.AccountRole.WRITABLE },
|
|
11071
|
+
{ address: orcaOracleAddress, role: import_kit82.AccountRole.WRITABLE }
|
|
10959
11072
|
];
|
|
10960
11073
|
const remainingAccountsInfo = {
|
|
10961
11074
|
slices: [
|
|
@@ -10998,7 +11111,7 @@ async function modifyTunaSpotPositionOrcaInstruction(authority, tunaConfig, mint
|
|
|
10998
11111
|
|
|
10999
11112
|
// src/txbuilder/modifyTunaSpotPositionFusion.ts
|
|
11000
11113
|
var import_fusionamm_client7 = require("@crypticdot/fusionamm-client");
|
|
11001
|
-
var
|
|
11114
|
+
var import_kit83 = require("@solana/kit");
|
|
11002
11115
|
var import_memo9 = require("@solana-program/memo");
|
|
11003
11116
|
var import_token_202214 = require("@solana-program/token-2022");
|
|
11004
11117
|
var import_assert12 = __toESM(require("assert"));
|
|
@@ -11138,13 +11251,13 @@ async function modifyTunaSpotPositionFusionInstruction(authority, tunaConfig, mi
|
|
|
11138
11251
|
}))[0];
|
|
11139
11252
|
const swapTickArrays = await FusionUtils.getSwapTickArrayAddresses(pool);
|
|
11140
11253
|
const remainingAccounts = [
|
|
11141
|
-
{ address: swapTickArrays[0], role:
|
|
11142
|
-
{ address: swapTickArrays[1], role:
|
|
11143
|
-
{ address: swapTickArrays[2], role:
|
|
11144
|
-
{ address: swapTickArrays[3], role:
|
|
11145
|
-
{ address: swapTickArrays[4], role:
|
|
11146
|
-
{ address: pool.data.tokenVaultA, role:
|
|
11147
|
-
{ address: pool.data.tokenVaultB, role:
|
|
11254
|
+
{ address: swapTickArrays[0], role: import_kit83.AccountRole.WRITABLE },
|
|
11255
|
+
{ address: swapTickArrays[1], role: import_kit83.AccountRole.WRITABLE },
|
|
11256
|
+
{ address: swapTickArrays[2], role: import_kit83.AccountRole.WRITABLE },
|
|
11257
|
+
{ address: swapTickArrays[3], role: import_kit83.AccountRole.WRITABLE },
|
|
11258
|
+
{ address: swapTickArrays[4], role: import_kit83.AccountRole.WRITABLE },
|
|
11259
|
+
{ address: pool.data.tokenVaultA, role: import_kit83.AccountRole.WRITABLE },
|
|
11260
|
+
{ address: pool.data.tokenVaultB, role: import_kit83.AccountRole.WRITABLE }
|
|
11148
11261
|
];
|
|
11149
11262
|
const remainingAccountsInfo = {
|
|
11150
11263
|
slices: [
|
|
@@ -11188,7 +11301,6 @@ async function modifyTunaSpotPositionFusionInstruction(authority, tunaConfig, mi
|
|
|
11188
11301
|
var import_fusionamm_client8 = require("@crypticdot/fusionamm-client");
|
|
11189
11302
|
|
|
11190
11303
|
// ../../node_modules/.pnpm/@crypticdot+jupiter-solana-client@1.0.0_fastestsmallesttextencoderdecoder@1.0.22_typesc_c15ee540b6a974c893a6f86bc9defff2/node_modules/@crypticdot/jupiter-solana-client/dist/index.mjs
|
|
11191
|
-
var import_kit83 = require("@solana/kit");
|
|
11192
11304
|
var import_kit84 = require("@solana/kit");
|
|
11193
11305
|
var import_kit85 = require("@solana/kit");
|
|
11194
11306
|
var import_kit86 = require("@solana/kit");
|
|
@@ -11222,6 +11334,7 @@ var import_kit113 = require("@solana/kit");
|
|
|
11222
11334
|
var import_kit114 = require("@solana/kit");
|
|
11223
11335
|
var import_kit115 = require("@solana/kit");
|
|
11224
11336
|
var import_kit116 = require("@solana/kit");
|
|
11337
|
+
var import_kit117 = require("@solana/kit");
|
|
11225
11338
|
var TOKEN_LEDGER_DISCRIMINATOR = new Uint8Array([
|
|
11226
11339
|
156,
|
|
11227
11340
|
247,
|
|
@@ -11629,7 +11742,7 @@ async function closeTunaSpotPositionInstruction(authority, poolAddress, mintA, m
|
|
|
11629
11742
|
}
|
|
11630
11743
|
|
|
11631
11744
|
// src/txbuilder/createMarket.ts
|
|
11632
|
-
async function createMarketInstruction(authority, pool, args) {
|
|
11745
|
+
async function createMarketInstruction(authority, pool, vaultA, vaultB, args) {
|
|
11633
11746
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
11634
11747
|
const marketAddress = (await getMarketAddress(pool))[0];
|
|
11635
11748
|
return getCreateMarketInstruction({
|
|
@@ -11637,6 +11750,8 @@ async function createMarketInstruction(authority, pool, args) {
|
|
|
11637
11750
|
tunaConfig,
|
|
11638
11751
|
market: marketAddress,
|
|
11639
11752
|
pool,
|
|
11753
|
+
vaultA,
|
|
11754
|
+
vaultB,
|
|
11640
11755
|
...args
|
|
11641
11756
|
});
|
|
11642
11757
|
}
|
|
@@ -11680,7 +11795,7 @@ async function createVaultInstructions(authority, mint, args) {
|
|
|
11680
11795
|
|
|
11681
11796
|
// src/txbuilder/liquidateTunaLpPositionOrca.ts
|
|
11682
11797
|
var import_whirlpools_client9 = require("@orca-so/whirlpools-client");
|
|
11683
|
-
var
|
|
11798
|
+
var import_kit118 = require("@solana/kit");
|
|
11684
11799
|
var import_memo11 = require("@solana-program/memo");
|
|
11685
11800
|
var import_token_202218 = require("@solana-program/token-2022");
|
|
11686
11801
|
async function liquidateTunaLpPositionOrcaInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, decreasePercent) {
|
|
@@ -11767,16 +11882,16 @@ async function liquidateTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
11767
11882
|
tunaPosition.data.tickUpperIndex
|
|
11768
11883
|
);
|
|
11769
11884
|
const remainingAccounts = [
|
|
11770
|
-
{ address: swapTickArrays[0], role:
|
|
11771
|
-
{ address: swapTickArrays[1], role:
|
|
11772
|
-
{ address: swapTickArrays[2], role:
|
|
11773
|
-
{ address: swapTickArrays[3], role:
|
|
11774
|
-
{ address: swapTickArrays[4], role:
|
|
11775
|
-
{ address: lowerTickArrayAddress, role:
|
|
11776
|
-
{ address: upperTickArrayAddress, role:
|
|
11777
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
11778
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
11779
|
-
{ address: orcaOracleAddress, role:
|
|
11885
|
+
{ address: swapTickArrays[0], role: import_kit118.AccountRole.WRITABLE },
|
|
11886
|
+
{ address: swapTickArrays[1], role: import_kit118.AccountRole.WRITABLE },
|
|
11887
|
+
{ address: swapTickArrays[2], role: import_kit118.AccountRole.WRITABLE },
|
|
11888
|
+
{ address: swapTickArrays[3], role: import_kit118.AccountRole.WRITABLE },
|
|
11889
|
+
{ address: swapTickArrays[4], role: import_kit118.AccountRole.WRITABLE },
|
|
11890
|
+
{ address: lowerTickArrayAddress, role: import_kit118.AccountRole.WRITABLE },
|
|
11891
|
+
{ address: upperTickArrayAddress, role: import_kit118.AccountRole.WRITABLE },
|
|
11892
|
+
{ address: whirlpool.data.tokenVaultA, role: import_kit118.AccountRole.WRITABLE },
|
|
11893
|
+
{ address: whirlpool.data.tokenVaultB, role: import_kit118.AccountRole.WRITABLE },
|
|
11894
|
+
{ address: orcaOracleAddress, role: import_kit118.AccountRole.WRITABLE }
|
|
11780
11895
|
];
|
|
11781
11896
|
const remainingAccountsInfo = {
|
|
11782
11897
|
slices: [
|
|
@@ -11821,7 +11936,7 @@ async function liquidateTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
11821
11936
|
|
|
11822
11937
|
// src/txbuilder/liquidateTunaLpPositionFusion.ts
|
|
11823
11938
|
var import_fusionamm_client9 = require("@crypticdot/fusionamm-client");
|
|
11824
|
-
var
|
|
11939
|
+
var import_kit119 = require("@solana/kit");
|
|
11825
11940
|
var import_memo12 = require("@solana-program/memo");
|
|
11826
11941
|
var import_token_202219 = require("@solana-program/token-2022");
|
|
11827
11942
|
async function liquidateTunaLpPositionFusionInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, decreasePercent) {
|
|
@@ -11907,15 +12022,15 @@ async function liquidateTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
11907
12022
|
tunaPosition.data.tickUpperIndex
|
|
11908
12023
|
);
|
|
11909
12024
|
const remainingAccounts = [
|
|
11910
|
-
{ address: swapTickArrays[0], role:
|
|
11911
|
-
{ address: swapTickArrays[1], role:
|
|
11912
|
-
{ address: swapTickArrays[2], role:
|
|
11913
|
-
{ address: swapTickArrays[3], role:
|
|
11914
|
-
{ address: swapTickArrays[4], role:
|
|
11915
|
-
{ address: lowerTickArrayAddress, role:
|
|
11916
|
-
{ address: upperTickArrayAddress, role:
|
|
11917
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
11918
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
12025
|
+
{ address: swapTickArrays[0], role: import_kit119.AccountRole.WRITABLE },
|
|
12026
|
+
{ address: swapTickArrays[1], role: import_kit119.AccountRole.WRITABLE },
|
|
12027
|
+
{ address: swapTickArrays[2], role: import_kit119.AccountRole.WRITABLE },
|
|
12028
|
+
{ address: swapTickArrays[3], role: import_kit119.AccountRole.WRITABLE },
|
|
12029
|
+
{ address: swapTickArrays[4], role: import_kit119.AccountRole.WRITABLE },
|
|
12030
|
+
{ address: lowerTickArrayAddress, role: import_kit119.AccountRole.WRITABLE },
|
|
12031
|
+
{ address: upperTickArrayAddress, role: import_kit119.AccountRole.WRITABLE },
|
|
12032
|
+
{ address: fusionPool.data.tokenVaultA, role: import_kit119.AccountRole.WRITABLE },
|
|
12033
|
+
{ address: fusionPool.data.tokenVaultB, role: import_kit119.AccountRole.WRITABLE }
|
|
11919
12034
|
];
|
|
11920
12035
|
const remainingAccountsInfo = {
|
|
11921
12036
|
slices: [
|
|
@@ -11959,7 +12074,7 @@ async function liquidateTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
11959
12074
|
|
|
11960
12075
|
// src/txbuilder/liquidateTunaSpotPositionFusion.ts
|
|
11961
12076
|
var import_fusionamm_client10 = require("@crypticdot/fusionamm-client");
|
|
11962
|
-
var
|
|
12077
|
+
var import_kit120 = require("@solana/kit");
|
|
11963
12078
|
var import_memo13 = require("@solana-program/memo");
|
|
11964
12079
|
var import_token_202220 = require("@solana-program/token-2022");
|
|
11965
12080
|
async function liquidateTunaSpotPositionFusionInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool, decreasePercent) {
|
|
@@ -12050,16 +12165,16 @@ async function liquidateTunaSpotPositionFusionInstruction(authority, tunaPositio
|
|
|
12050
12165
|
}))[0];
|
|
12051
12166
|
const swapTickArrays = await FusionUtils.getSwapTickArrayAddresses(fusionPool);
|
|
12052
12167
|
const remainingAccounts = [
|
|
12053
|
-
{ address: swapTickArrays[0], role:
|
|
12054
|
-
{ address: swapTickArrays[1], role:
|
|
12055
|
-
{ address: swapTickArrays[2], role:
|
|
12056
|
-
{ address: swapTickArrays[3], role:
|
|
12057
|
-
{ address: swapTickArrays[4], role:
|
|
12058
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
12059
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
12060
|
-
];
|
|
12061
|
-
const remainingAccountsInfo = {
|
|
12062
|
-
slices: [
|
|
12168
|
+
{ address: swapTickArrays[0], role: import_kit120.AccountRole.WRITABLE },
|
|
12169
|
+
{ address: swapTickArrays[1], role: import_kit120.AccountRole.WRITABLE },
|
|
12170
|
+
{ address: swapTickArrays[2], role: import_kit120.AccountRole.WRITABLE },
|
|
12171
|
+
{ address: swapTickArrays[3], role: import_kit120.AccountRole.WRITABLE },
|
|
12172
|
+
{ address: swapTickArrays[4], role: import_kit120.AccountRole.WRITABLE },
|
|
12173
|
+
{ address: fusionPool.data.tokenVaultA, role: import_kit120.AccountRole.WRITABLE },
|
|
12174
|
+
{ address: fusionPool.data.tokenVaultB, role: import_kit120.AccountRole.WRITABLE }
|
|
12175
|
+
];
|
|
12176
|
+
const remainingAccountsInfo = {
|
|
12177
|
+
slices: [
|
|
12063
12178
|
{ accountsType: 0 /* SwapTickArrays */, length: 5 },
|
|
12064
12179
|
{ accountsType: 3 /* PoolVaultTokenA */, length: 1 },
|
|
12065
12180
|
{ accountsType: 4 /* PoolVaultTokenB */, length: 1 }
|
|
@@ -12097,15 +12212,13 @@ async function liquidateTunaSpotPositionFusionInstruction(authority, tunaPositio
|
|
|
12097
12212
|
return ix;
|
|
12098
12213
|
}
|
|
12099
12214
|
|
|
12100
|
-
// src/txbuilder/
|
|
12101
|
-
var import_whirlpools_client10 = require("@orca-so/whirlpools-client");
|
|
12102
|
-
var import_kit120 = require("@solana/kit");
|
|
12215
|
+
// src/txbuilder/liquidateTunaSpotPositionJupiter.ts
|
|
12103
12216
|
var import_memo14 = require("@solana-program/memo");
|
|
12104
12217
|
var import_token_202221 = require("@solana-program/token-2022");
|
|
12105
|
-
async function
|
|
12218
|
+
async function liquidateTunaSpotPositionJupiterInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, poolAddress, remainingAccounts, args) {
|
|
12106
12219
|
const instructions = [];
|
|
12107
12220
|
const collateralTokenMint = tunaPosition.data.collateralToken == 0 /* A */ ? mintA : mintB;
|
|
12108
|
-
const useNativeSol = collateralTokenMint.address == NATIVE_MINT && decreasePercent == HUNDRED_PERCENT;
|
|
12221
|
+
const useNativeSol = collateralTokenMint.address == NATIVE_MINT && args.decreasePercent == HUNDRED_PERCENT;
|
|
12109
12222
|
if (!useNativeSol) {
|
|
12110
12223
|
const createPositionOwnerAtaInstructions = await getCreateAtaInstructions(
|
|
12111
12224
|
void 0,
|
|
@@ -12116,6 +12229,26 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
12116
12229
|
);
|
|
12117
12230
|
instructions.push(...createPositionOwnerAtaInstructions.init);
|
|
12118
12231
|
}
|
|
12232
|
+
if (mintA.address != NATIVE_MINT || args.decreasePercent < HUNDRED_PERCENT) {
|
|
12233
|
+
const createUserAtaAInstructions = await getCreateAtaInstructions(
|
|
12234
|
+
void 0,
|
|
12235
|
+
authority,
|
|
12236
|
+
mintA.address,
|
|
12237
|
+
authority.address,
|
|
12238
|
+
mintA.programAddress
|
|
12239
|
+
);
|
|
12240
|
+
instructions.push(...createUserAtaAInstructions.init);
|
|
12241
|
+
}
|
|
12242
|
+
if (mintB.address != NATIVE_MINT || args.decreasePercent < HUNDRED_PERCENT) {
|
|
12243
|
+
const createUserAtaBInstructions = await getCreateAtaInstructions(
|
|
12244
|
+
void 0,
|
|
12245
|
+
authority,
|
|
12246
|
+
mintB.address,
|
|
12247
|
+
authority.address,
|
|
12248
|
+
mintB.programAddress
|
|
12249
|
+
);
|
|
12250
|
+
instructions.push(...createUserAtaBInstructions.init);
|
|
12251
|
+
}
|
|
12119
12252
|
const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
|
|
12120
12253
|
void 0,
|
|
12121
12254
|
authority,
|
|
@@ -12132,7 +12265,7 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
12132
12265
|
mintB.programAddress
|
|
12133
12266
|
);
|
|
12134
12267
|
instructions.push(...createFeeRecipientAtaBInstructions.init);
|
|
12135
|
-
const ix = await
|
|
12268
|
+
const ix = await liquidateTunaSpotPositionJupiterInstruction(
|
|
12136
12269
|
authority,
|
|
12137
12270
|
tunaPosition,
|
|
12138
12271
|
tunaConfig,
|
|
@@ -12140,15 +12273,15 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
12140
12273
|
mintB,
|
|
12141
12274
|
vaultA,
|
|
12142
12275
|
vaultB,
|
|
12143
|
-
|
|
12144
|
-
|
|
12276
|
+
poolAddress,
|
|
12277
|
+
remainingAccounts,
|
|
12278
|
+
args
|
|
12145
12279
|
);
|
|
12146
12280
|
instructions.push(ix);
|
|
12147
12281
|
return instructions;
|
|
12148
12282
|
}
|
|
12149
|
-
async function
|
|
12150
|
-
const marketAddress = (await getMarketAddress(
|
|
12151
|
-
const orcaOracleAddress = (await (0, import_whirlpools_client10.getOracleAddress)(whirlpool.address))[0];
|
|
12283
|
+
async function liquidateTunaSpotPositionJupiterInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, poolAddress, remainingAccounts, args) {
|
|
12284
|
+
const marketAddress = (await getMarketAddress(poolAddress))[0];
|
|
12152
12285
|
const tunaPositionOwnerAtaA = (await (0, import_token_202221.findAssociatedTokenPda)({
|
|
12153
12286
|
owner: tunaPosition.data.authority,
|
|
12154
12287
|
mint: mintA.address,
|
|
@@ -12189,16 +12322,141 @@ async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition,
|
|
|
12189
12322
|
mint: mintB.address,
|
|
12190
12323
|
tokenProgram: mintB.programAddress
|
|
12191
12324
|
}))[0];
|
|
12325
|
+
const ix = getLiquidateTunaSpotPositionJupiterInstruction({
|
|
12326
|
+
authority,
|
|
12327
|
+
tunaConfig: tunaConfig.address,
|
|
12328
|
+
mintA: mintA.address,
|
|
12329
|
+
mintB: mintB.address,
|
|
12330
|
+
tokenProgramA: mintA.programAddress,
|
|
12331
|
+
tokenProgramB: mintB.programAddress,
|
|
12332
|
+
market: marketAddress,
|
|
12333
|
+
pythOraclePriceFeedA: vaultA.data.pythOraclePriceUpdate,
|
|
12334
|
+
pythOraclePriceFeedB: vaultB.data.pythOraclePriceUpdate,
|
|
12335
|
+
vaultA: vaultA.address,
|
|
12336
|
+
vaultAAta,
|
|
12337
|
+
vaultB: vaultB.address,
|
|
12338
|
+
vaultBAta,
|
|
12339
|
+
tunaPosition: tunaPosition.address,
|
|
12340
|
+
tunaPositionAtaA,
|
|
12341
|
+
tunaPositionAtaB,
|
|
12342
|
+
tunaPositionOwner: tunaPosition.data.authority,
|
|
12343
|
+
tunaPositionOwnerAtaA,
|
|
12344
|
+
tunaPositionOwnerAtaB,
|
|
12345
|
+
feeRecipientAtaA,
|
|
12346
|
+
feeRecipientAtaB,
|
|
12347
|
+
pool: poolAddress,
|
|
12348
|
+
jupiterProgram: JUPITER_PROGRAM_ADDRESS,
|
|
12349
|
+
jupiterEventAuthority: JUPITER_EVENT_AUTHORITY,
|
|
12350
|
+
jupiterProgramAuthority: JUPITER_PROGRAM_AUTHORITY,
|
|
12351
|
+
memoProgram: import_memo14.MEMO_PROGRAM_ADDRESS,
|
|
12352
|
+
...args
|
|
12353
|
+
});
|
|
12354
|
+
ix.accounts.push(...remainingAccounts);
|
|
12355
|
+
return ix;
|
|
12356
|
+
}
|
|
12357
|
+
|
|
12358
|
+
// src/txbuilder/liquidateTunaSpotPositionOrca.ts
|
|
12359
|
+
var import_whirlpools_client10 = require("@orca-so/whirlpools-client");
|
|
12360
|
+
var import_kit121 = require("@solana/kit");
|
|
12361
|
+
var import_memo15 = require("@solana-program/memo");
|
|
12362
|
+
var import_token_202222 = require("@solana-program/token-2022");
|
|
12363
|
+
async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, decreasePercent) {
|
|
12364
|
+
const instructions = [];
|
|
12365
|
+
const collateralTokenMint = tunaPosition.data.collateralToken == 0 /* A */ ? mintA : mintB;
|
|
12366
|
+
const useNativeSol = collateralTokenMint.address == NATIVE_MINT && decreasePercent == HUNDRED_PERCENT;
|
|
12367
|
+
if (!useNativeSol) {
|
|
12368
|
+
const createPositionOwnerAtaInstructions = await getCreateAtaInstructions(
|
|
12369
|
+
void 0,
|
|
12370
|
+
authority,
|
|
12371
|
+
collateralTokenMint.address,
|
|
12372
|
+
tunaPosition.data.authority,
|
|
12373
|
+
collateralTokenMint.programAddress
|
|
12374
|
+
);
|
|
12375
|
+
instructions.push(...createPositionOwnerAtaInstructions.init);
|
|
12376
|
+
}
|
|
12377
|
+
const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
|
|
12378
|
+
void 0,
|
|
12379
|
+
authority,
|
|
12380
|
+
mintA.address,
|
|
12381
|
+
tunaConfig.data.feeRecipient,
|
|
12382
|
+
mintA.programAddress
|
|
12383
|
+
);
|
|
12384
|
+
instructions.push(...createFeeRecipientAtaAInstructions.init);
|
|
12385
|
+
const createFeeRecipientAtaBInstructions = await getCreateAtaInstructions(
|
|
12386
|
+
void 0,
|
|
12387
|
+
authority,
|
|
12388
|
+
mintB.address,
|
|
12389
|
+
tunaConfig.data.feeRecipient,
|
|
12390
|
+
mintB.programAddress
|
|
12391
|
+
);
|
|
12392
|
+
instructions.push(...createFeeRecipientAtaBInstructions.init);
|
|
12393
|
+
const ix = await liquidateTunaSpotPositionOrcaInstruction(
|
|
12394
|
+
authority,
|
|
12395
|
+
tunaPosition,
|
|
12396
|
+
tunaConfig,
|
|
12397
|
+
mintA,
|
|
12398
|
+
mintB,
|
|
12399
|
+
vaultA,
|
|
12400
|
+
vaultB,
|
|
12401
|
+
whirlpool,
|
|
12402
|
+
decreasePercent
|
|
12403
|
+
);
|
|
12404
|
+
instructions.push(ix);
|
|
12405
|
+
return instructions;
|
|
12406
|
+
}
|
|
12407
|
+
async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, decreasePercent) {
|
|
12408
|
+
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12409
|
+
const orcaOracleAddress = (await (0, import_whirlpools_client10.getOracleAddress)(whirlpool.address))[0];
|
|
12410
|
+
const tunaPositionOwnerAtaA = (await (0, import_token_202222.findAssociatedTokenPda)({
|
|
12411
|
+
owner: tunaPosition.data.authority,
|
|
12412
|
+
mint: mintA.address,
|
|
12413
|
+
tokenProgram: mintA.programAddress
|
|
12414
|
+
}))[0];
|
|
12415
|
+
const tunaPositionOwnerAtaB = (await (0, import_token_202222.findAssociatedTokenPda)({
|
|
12416
|
+
owner: tunaPosition.data.authority,
|
|
12417
|
+
mint: mintB.address,
|
|
12418
|
+
tokenProgram: mintB.programAddress
|
|
12419
|
+
}))[0];
|
|
12420
|
+
const tunaPositionAtaA = (await (0, import_token_202222.findAssociatedTokenPda)({
|
|
12421
|
+
owner: tunaPosition.address,
|
|
12422
|
+
mint: mintA.address,
|
|
12423
|
+
tokenProgram: mintA.programAddress
|
|
12424
|
+
}))[0];
|
|
12425
|
+
const tunaPositionAtaB = (await (0, import_token_202222.findAssociatedTokenPda)({
|
|
12426
|
+
owner: tunaPosition.address,
|
|
12427
|
+
mint: mintB.address,
|
|
12428
|
+
tokenProgram: mintB.programAddress
|
|
12429
|
+
}))[0];
|
|
12430
|
+
const feeRecipientAtaA = (await (0, import_token_202222.findAssociatedTokenPda)({
|
|
12431
|
+
owner: tunaConfig.data.feeRecipient,
|
|
12432
|
+
mint: mintA.address,
|
|
12433
|
+
tokenProgram: mintA.programAddress
|
|
12434
|
+
}))[0];
|
|
12435
|
+
const feeRecipientAtaB = (await (0, import_token_202222.findAssociatedTokenPda)({
|
|
12436
|
+
owner: tunaConfig.data.feeRecipient,
|
|
12437
|
+
mint: mintB.address,
|
|
12438
|
+
tokenProgram: mintB.programAddress
|
|
12439
|
+
}))[0];
|
|
12440
|
+
const vaultAAta = (await (0, import_token_202222.findAssociatedTokenPda)({
|
|
12441
|
+
owner: vaultA.address,
|
|
12442
|
+
mint: mintA.address,
|
|
12443
|
+
tokenProgram: mintA.programAddress
|
|
12444
|
+
}))[0];
|
|
12445
|
+
const vaultBAta = (await (0, import_token_202222.findAssociatedTokenPda)({
|
|
12446
|
+
owner: vaultB.address,
|
|
12447
|
+
mint: mintB.address,
|
|
12448
|
+
tokenProgram: mintB.programAddress
|
|
12449
|
+
}))[0];
|
|
12192
12450
|
const swapTickArrays = await OrcaUtils.getSwapTickArrayAddresses(whirlpool);
|
|
12193
12451
|
const remainingAccounts = [
|
|
12194
|
-
{ address: swapTickArrays[0], role:
|
|
12195
|
-
{ address: swapTickArrays[1], role:
|
|
12196
|
-
{ address: swapTickArrays[2], role:
|
|
12197
|
-
{ address: swapTickArrays[3], role:
|
|
12198
|
-
{ address: swapTickArrays[4], role:
|
|
12199
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
12200
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
12201
|
-
{ address: orcaOracleAddress, role:
|
|
12452
|
+
{ address: swapTickArrays[0], role: import_kit121.AccountRole.WRITABLE },
|
|
12453
|
+
{ address: swapTickArrays[1], role: import_kit121.AccountRole.WRITABLE },
|
|
12454
|
+
{ address: swapTickArrays[2], role: import_kit121.AccountRole.WRITABLE },
|
|
12455
|
+
{ address: swapTickArrays[3], role: import_kit121.AccountRole.WRITABLE },
|
|
12456
|
+
{ address: swapTickArrays[4], role: import_kit121.AccountRole.WRITABLE },
|
|
12457
|
+
{ address: whirlpool.data.tokenVaultA, role: import_kit121.AccountRole.WRITABLE },
|
|
12458
|
+
{ address: whirlpool.data.tokenVaultB, role: import_kit121.AccountRole.WRITABLE },
|
|
12459
|
+
{ address: orcaOracleAddress, role: import_kit121.AccountRole.WRITABLE }
|
|
12202
12460
|
];
|
|
12203
12461
|
const remainingAccountsInfo = {
|
|
12204
12462
|
slices: [
|
|
@@ -12232,7 +12490,7 @@ async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition,
|
|
|
12232
12490
|
feeRecipientAtaB,
|
|
12233
12491
|
whirlpool: whirlpool.address,
|
|
12234
12492
|
whirlpoolProgram: import_whirlpools_client10.WHIRLPOOL_PROGRAM_ADDRESS,
|
|
12235
|
-
memoProgram:
|
|
12493
|
+
memoProgram: import_memo15.MEMO_PROGRAM_ADDRESS,
|
|
12236
12494
|
decreasePercent,
|
|
12237
12495
|
remainingAccountsInfo
|
|
12238
12496
|
});
|
|
@@ -12242,28 +12500,28 @@ async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition,
|
|
|
12242
12500
|
|
|
12243
12501
|
// src/txbuilder/openTunaLpPositionOrca.ts
|
|
12244
12502
|
var import_whirlpools_client11 = require("@orca-so/whirlpools-client");
|
|
12245
|
-
var
|
|
12503
|
+
var import_token_202223 = require("@solana-program/token-2022");
|
|
12246
12504
|
var import_assert15 = __toESM(require("assert"));
|
|
12247
12505
|
async function openTunaLpPositionOrcaInstruction(rpc, authority, positionMint, whirlpoolAddress, args) {
|
|
12248
12506
|
const whirlpool = await (0, import_whirlpools_client11.fetchMaybeWhirlpool)(rpc, whirlpoolAddress);
|
|
12249
12507
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
12250
|
-
const [mintA, mintB] = await (0,
|
|
12508
|
+
const [mintA, mintB] = await (0, import_token_202223.fetchAllMaybeMint)(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
12251
12509
|
(0, import_assert15.default)(mintA.exists, "Token A account not found");
|
|
12252
12510
|
(0, import_assert15.default)(mintB.exists, "Token B account not found");
|
|
12253
12511
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12254
12512
|
const orcaPositionAddress = (await (0, import_whirlpools_client11.getPositionAddress)(positionMint.address))[0];
|
|
12255
12513
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
12256
|
-
const tunaPositionAta = (await (0,
|
|
12514
|
+
const tunaPositionAta = (await (0, import_token_202223.findAssociatedTokenPda)({
|
|
12257
12515
|
owner: tunaPositionAddress,
|
|
12258
12516
|
mint: positionMint.address,
|
|
12259
|
-
tokenProgram:
|
|
12517
|
+
tokenProgram: import_token_202223.TOKEN_2022_PROGRAM_ADDRESS
|
|
12260
12518
|
}))[0];
|
|
12261
|
-
const tunaPositionAtaA = (await (0,
|
|
12519
|
+
const tunaPositionAtaA = (await (0, import_token_202223.findAssociatedTokenPda)({
|
|
12262
12520
|
owner: tunaPositionAddress,
|
|
12263
12521
|
mint: mintA.address,
|
|
12264
12522
|
tokenProgram: mintA.programAddress
|
|
12265
12523
|
}))[0];
|
|
12266
|
-
const tunaPositionAtaB = (await (0,
|
|
12524
|
+
const tunaPositionAtaB = (await (0, import_token_202223.findAssociatedTokenPda)({
|
|
12267
12525
|
owner: tunaPositionAddress,
|
|
12268
12526
|
mint: mintB.address,
|
|
12269
12527
|
tokenProgram: mintB.programAddress
|
|
@@ -12284,8 +12542,8 @@ async function openTunaLpPositionOrcaInstruction(rpc, authority, positionMint, w
|
|
|
12284
12542
|
metadataUpdateAuth: WP_NFT_UPDATE_AUTH,
|
|
12285
12543
|
tokenProgramA: mintA.programAddress,
|
|
12286
12544
|
tokenProgramB: mintB.programAddress,
|
|
12287
|
-
associatedTokenProgram:
|
|
12288
|
-
token2022Program:
|
|
12545
|
+
associatedTokenProgram: import_token_202223.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
12546
|
+
token2022Program: import_token_202223.TOKEN_2022_PROGRAM_ADDRESS,
|
|
12289
12547
|
...args
|
|
12290
12548
|
});
|
|
12291
12549
|
}
|
|
@@ -12293,28 +12551,28 @@ async function openTunaLpPositionOrcaInstruction(rpc, authority, positionMint, w
|
|
|
12293
12551
|
// src/txbuilder/openTunaLpPositionFusion.ts
|
|
12294
12552
|
var import_fusionamm_client11 = require("@crypticdot/fusionamm-client");
|
|
12295
12553
|
var import_fusionamm_client12 = require("@crypticdot/fusionamm-client");
|
|
12296
|
-
var
|
|
12554
|
+
var import_token_202224 = require("@solana-program/token-2022");
|
|
12297
12555
|
var import_assert16 = __toESM(require("assert"));
|
|
12298
12556
|
async function openTunaLpPositionFusionInstruction(rpc, authority, positionMint, fusionPoolAddress, args) {
|
|
12299
12557
|
const fusionPool = await (0, import_fusionamm_client11.fetchMaybeFusionPool)(rpc, fusionPoolAddress);
|
|
12300
12558
|
if (!fusionPool.exists) throw new Error("Whirlpool account not found");
|
|
12301
|
-
const [mintA, mintB] = await (0,
|
|
12559
|
+
const [mintA, mintB] = await (0, import_token_202224.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
12302
12560
|
(0, import_assert16.default)(mintA.exists, "Token A account not found");
|
|
12303
12561
|
(0, import_assert16.default)(mintB.exists, "Token B account not found");
|
|
12304
12562
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
12305
12563
|
const fusionPositionAddress = (await (0, import_fusionamm_client11.getPositionAddress)(positionMint.address))[0];
|
|
12306
12564
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
12307
|
-
const tunaPositionAta = (await (0,
|
|
12565
|
+
const tunaPositionAta = (await (0, import_token_202224.findAssociatedTokenPda)({
|
|
12308
12566
|
owner: tunaPositionAddress,
|
|
12309
12567
|
mint: positionMint.address,
|
|
12310
|
-
tokenProgram:
|
|
12568
|
+
tokenProgram: import_token_202224.TOKEN_2022_PROGRAM_ADDRESS
|
|
12311
12569
|
}))[0];
|
|
12312
|
-
const tunaPositionAtaA = (await (0,
|
|
12570
|
+
const tunaPositionAtaA = (await (0, import_token_202224.findAssociatedTokenPda)({
|
|
12313
12571
|
owner: tunaPositionAddress,
|
|
12314
12572
|
mint: mintA.address,
|
|
12315
12573
|
tokenProgram: mintA.programAddress
|
|
12316
12574
|
}))[0];
|
|
12317
|
-
const tunaPositionAtaB = (await (0,
|
|
12575
|
+
const tunaPositionAtaB = (await (0, import_token_202224.findAssociatedTokenPda)({
|
|
12318
12576
|
owner: tunaPositionAddress,
|
|
12319
12577
|
mint: mintB.address,
|
|
12320
12578
|
tokenProgram: mintB.programAddress
|
|
@@ -12335,8 +12593,8 @@ async function openTunaLpPositionFusionInstruction(rpc, authority, positionMint,
|
|
|
12335
12593
|
metadataUpdateAuth: import_fusionamm_client12.FP_NFT_UPDATE_AUTH,
|
|
12336
12594
|
tokenProgramA: mintA.programAddress,
|
|
12337
12595
|
tokenProgramB: mintB.programAddress,
|
|
12338
|
-
associatedTokenProgram:
|
|
12339
|
-
token2022Program:
|
|
12596
|
+
associatedTokenProgram: import_token_202224.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
12597
|
+
token2022Program: import_token_202224.TOKEN_2022_PROGRAM_ADDRESS,
|
|
12340
12598
|
...args
|
|
12341
12599
|
});
|
|
12342
12600
|
}
|
|
@@ -12344,10 +12602,10 @@ async function openTunaLpPositionFusionInstruction(rpc, authority, positionMint,
|
|
|
12344
12602
|
// src/txbuilder/openAndIncreaseTunaLpPositionOrca.ts
|
|
12345
12603
|
var import_whirlpools_client12 = require("@orca-so/whirlpools-client");
|
|
12346
12604
|
var import_whirlpools_core4 = require("@orca-so/whirlpools-core");
|
|
12347
|
-
var
|
|
12605
|
+
var import_kit122 = require("@solana/kit");
|
|
12348
12606
|
var import_sysvars = require("@solana/sysvars");
|
|
12349
|
-
var
|
|
12350
|
-
var
|
|
12607
|
+
var import_memo16 = require("@solana-program/memo");
|
|
12608
|
+
var import_token_202225 = require("@solana-program/token-2022");
|
|
12351
12609
|
var import_assert17 = __toESM(require("assert"));
|
|
12352
12610
|
|
|
12353
12611
|
// src/utils/sysvar.ts
|
|
@@ -12366,13 +12624,13 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
|
|
|
12366
12624
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
12367
12625
|
const rent = await (0, import_sysvars.fetchSysvarRent)(rpc);
|
|
12368
12626
|
let nonRefundableRent = 0n;
|
|
12369
|
-
const positionMint = await (0,
|
|
12627
|
+
const positionMint = await (0, import_kit122.generateKeyPairSigner)();
|
|
12370
12628
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
12371
12629
|
const whirlpool = await (0, import_whirlpools_client12.fetchMaybeWhirlpool)(rpc, whirlpoolAddress);
|
|
12372
12630
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
12373
12631
|
const marketAddress = (await getMarketAddress(whirlpoolAddress))[0];
|
|
12374
12632
|
const market = await fetchMarket(rpc, marketAddress);
|
|
12375
|
-
const [mintA, mintB] = await (0,
|
|
12633
|
+
const [mintA, mintB] = await (0, import_token_202225.fetchAllMaybeMint)(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
12376
12634
|
(0, import_assert17.default)(mintA.exists, "Token A account not found");
|
|
12377
12635
|
(0, import_assert17.default)(mintB.exists, "Token B account not found");
|
|
12378
12636
|
const [vaultA, vaultB] = await fetchAllVault(rpc, [
|
|
@@ -12475,7 +12733,7 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
|
|
|
12475
12733
|
return {
|
|
12476
12734
|
instructions,
|
|
12477
12735
|
positionMint: positionMint.address,
|
|
12478
|
-
initializationCost: (0,
|
|
12736
|
+
initializationCost: (0, import_kit122.lamports)(nonRefundableRent)
|
|
12479
12737
|
};
|
|
12480
12738
|
}
|
|
12481
12739
|
async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionMint, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, args) {
|
|
@@ -12483,47 +12741,47 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
12483
12741
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12484
12742
|
const orcaPositionAddress = (await (0, import_whirlpools_client12.getPositionAddress)(positionMint.address))[0];
|
|
12485
12743
|
const orcaOracleAddress = (await (0, import_whirlpools_client12.getOracleAddress)(whirlpool.address))[0];
|
|
12486
|
-
const tunaPositionAta = (await (0,
|
|
12744
|
+
const tunaPositionAta = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12487
12745
|
owner: tunaPositionAddress,
|
|
12488
12746
|
mint: positionMint.address,
|
|
12489
|
-
tokenProgram:
|
|
12747
|
+
tokenProgram: import_token_202225.TOKEN_2022_PROGRAM_ADDRESS
|
|
12490
12748
|
}))[0];
|
|
12491
|
-
const tunaPositionOwnerAtaA = (await (0,
|
|
12749
|
+
const tunaPositionOwnerAtaA = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12492
12750
|
owner: authority.address,
|
|
12493
12751
|
mint: mintA.address,
|
|
12494
12752
|
tokenProgram: mintA.programAddress
|
|
12495
12753
|
}))[0];
|
|
12496
|
-
const tunaPositionOwnerAtaB = (await (0,
|
|
12754
|
+
const tunaPositionOwnerAtaB = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12497
12755
|
owner: authority.address,
|
|
12498
12756
|
mint: mintB.address,
|
|
12499
12757
|
tokenProgram: mintB.programAddress
|
|
12500
12758
|
}))[0];
|
|
12501
|
-
const tunaPositionAtaA = (await (0,
|
|
12759
|
+
const tunaPositionAtaA = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12502
12760
|
owner: tunaPositionAddress,
|
|
12503
12761
|
mint: mintA.address,
|
|
12504
12762
|
tokenProgram: mintA.programAddress
|
|
12505
12763
|
}))[0];
|
|
12506
|
-
const tunaPositionAtaB = (await (0,
|
|
12764
|
+
const tunaPositionAtaB = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12507
12765
|
owner: tunaPositionAddress,
|
|
12508
12766
|
mint: mintB.address,
|
|
12509
12767
|
tokenProgram: mintB.programAddress
|
|
12510
12768
|
}))[0];
|
|
12511
|
-
const vaultAAta = (await (0,
|
|
12769
|
+
const vaultAAta = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12512
12770
|
owner: vaultA.address,
|
|
12513
12771
|
mint: mintA.address,
|
|
12514
12772
|
tokenProgram: mintA.programAddress
|
|
12515
12773
|
}))[0];
|
|
12516
|
-
const vaultBAta = (await (0,
|
|
12774
|
+
const vaultBAta = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12517
12775
|
owner: vaultB.address,
|
|
12518
12776
|
mint: mintB.address,
|
|
12519
12777
|
tokenProgram: mintB.programAddress
|
|
12520
12778
|
}))[0];
|
|
12521
|
-
const feeRecipientAtaA = (await (0,
|
|
12779
|
+
const feeRecipientAtaA = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12522
12780
|
owner: tunaConfig.data.feeRecipient,
|
|
12523
12781
|
mint: mintA.address,
|
|
12524
12782
|
tokenProgram: mintA.programAddress
|
|
12525
12783
|
}))[0];
|
|
12526
|
-
const feeRecipientAtaB = (await (0,
|
|
12784
|
+
const feeRecipientAtaB = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12527
12785
|
owner: tunaConfig.data.feeRecipient,
|
|
12528
12786
|
mint: mintB.address,
|
|
12529
12787
|
tokenProgram: mintB.programAddress
|
|
@@ -12532,16 +12790,16 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
12532
12790
|
const lowerTickArrayAddress = await OrcaUtils.getTickArrayAddressFromTickIndex(whirlpool, args.tickLowerIndex);
|
|
12533
12791
|
const upperTickArrayAddress = await OrcaUtils.getTickArrayAddressFromTickIndex(whirlpool, args.tickUpperIndex);
|
|
12534
12792
|
const remainingAccounts = [
|
|
12535
|
-
{ address: swapTickArrays[0], role:
|
|
12536
|
-
{ address: swapTickArrays[1], role:
|
|
12537
|
-
{ address: swapTickArrays[2], role:
|
|
12538
|
-
{ address: swapTickArrays[3], role:
|
|
12539
|
-
{ address: swapTickArrays[4], role:
|
|
12540
|
-
{ address: lowerTickArrayAddress, role:
|
|
12541
|
-
{ address: upperTickArrayAddress, role:
|
|
12542
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
12543
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
12544
|
-
{ address: orcaOracleAddress, role:
|
|
12793
|
+
{ address: swapTickArrays[0], role: import_kit122.AccountRole.WRITABLE },
|
|
12794
|
+
{ address: swapTickArrays[1], role: import_kit122.AccountRole.WRITABLE },
|
|
12795
|
+
{ address: swapTickArrays[2], role: import_kit122.AccountRole.WRITABLE },
|
|
12796
|
+
{ address: swapTickArrays[3], role: import_kit122.AccountRole.WRITABLE },
|
|
12797
|
+
{ address: swapTickArrays[4], role: import_kit122.AccountRole.WRITABLE },
|
|
12798
|
+
{ address: lowerTickArrayAddress, role: import_kit122.AccountRole.WRITABLE },
|
|
12799
|
+
{ address: upperTickArrayAddress, role: import_kit122.AccountRole.WRITABLE },
|
|
12800
|
+
{ address: whirlpool.data.tokenVaultA, role: import_kit122.AccountRole.WRITABLE },
|
|
12801
|
+
{ address: whirlpool.data.tokenVaultB, role: import_kit122.AccountRole.WRITABLE },
|
|
12802
|
+
{ address: orcaOracleAddress, role: import_kit122.AccountRole.WRITABLE }
|
|
12545
12803
|
];
|
|
12546
12804
|
const remainingAccountsInfo = {
|
|
12547
12805
|
slices: [
|
|
@@ -12579,10 +12837,10 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
12579
12837
|
orcaPosition: orcaPositionAddress,
|
|
12580
12838
|
tokenProgramA: mintA.programAddress,
|
|
12581
12839
|
tokenProgramB: mintB.programAddress,
|
|
12582
|
-
memoProgram:
|
|
12840
|
+
memoProgram: import_memo16.MEMO_PROGRAM_ADDRESS,
|
|
12583
12841
|
metadataUpdateAuth: WP_NFT_UPDATE_AUTH,
|
|
12584
|
-
associatedTokenProgram:
|
|
12585
|
-
token2022Program:
|
|
12842
|
+
associatedTokenProgram: import_token_202225.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
12843
|
+
token2022Program: import_token_202225.TOKEN_2022_PROGRAM_ADDRESS,
|
|
12586
12844
|
...args,
|
|
12587
12845
|
remainingAccountsInfo
|
|
12588
12846
|
});
|
|
@@ -12593,10 +12851,10 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
12593
12851
|
// src/txbuilder/openAndIncreaseTunaLpPositionFusion.ts
|
|
12594
12852
|
var import_fusionamm_client13 = require("@crypticdot/fusionamm-client");
|
|
12595
12853
|
var import_fusionamm_core5 = require("@crypticdot/fusionamm-core");
|
|
12596
|
-
var
|
|
12854
|
+
var import_kit123 = require("@solana/kit");
|
|
12597
12855
|
var import_sysvars2 = require("@solana/sysvars");
|
|
12598
|
-
var
|
|
12599
|
-
var
|
|
12856
|
+
var import_memo17 = require("@solana-program/memo");
|
|
12857
|
+
var import_token_202226 = require("@solana-program/token-2022");
|
|
12600
12858
|
var import_assert18 = __toESM(require("assert"));
|
|
12601
12859
|
async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, fusionPoolAddress, args, createInstructions, cleanupInstructions) {
|
|
12602
12860
|
const instructions = [];
|
|
@@ -12604,13 +12862,13 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
|
|
|
12604
12862
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
12605
12863
|
const rent = await (0, import_sysvars2.fetchSysvarRent)(rpc);
|
|
12606
12864
|
let nonRefundableRent = 0n;
|
|
12607
|
-
const positionMint = await (0,
|
|
12865
|
+
const positionMint = await (0, import_kit123.generateKeyPairSigner)();
|
|
12608
12866
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
12609
12867
|
const fusionPool = await (0, import_fusionamm_client13.fetchMaybeFusionPool)(rpc, fusionPoolAddress);
|
|
12610
12868
|
if (!fusionPool.exists) throw new Error("FusionPool account not found");
|
|
12611
12869
|
const marketAddress = (await getMarketAddress(fusionPoolAddress))[0];
|
|
12612
12870
|
const market = await fetchMarket(rpc, marketAddress);
|
|
12613
|
-
const [mintA, mintB] = await (0,
|
|
12871
|
+
const [mintA, mintB] = await (0, import_token_202226.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
12614
12872
|
(0, import_assert18.default)(mintA.exists, "Token A account not found");
|
|
12615
12873
|
(0, import_assert18.default)(mintB.exists, "Token B account not found");
|
|
12616
12874
|
const [vaultA, vaultB] = await fetchAllVault(rpc, [
|
|
@@ -12711,54 +12969,54 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
|
|
|
12711
12969
|
return {
|
|
12712
12970
|
instructions,
|
|
12713
12971
|
positionMint: positionMint.address,
|
|
12714
|
-
initializationCost: (0,
|
|
12972
|
+
initializationCost: (0, import_kit123.lamports)(nonRefundableRent)
|
|
12715
12973
|
};
|
|
12716
12974
|
}
|
|
12717
12975
|
async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positionMint, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool, args) {
|
|
12718
12976
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
12719
12977
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
12720
12978
|
const fusionPositionAddress = (await (0, import_fusionamm_client13.getPositionAddress)(positionMint.address))[0];
|
|
12721
|
-
const tunaPositionAta = (await (0,
|
|
12979
|
+
const tunaPositionAta = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12722
12980
|
owner: tunaPositionAddress,
|
|
12723
12981
|
mint: positionMint.address,
|
|
12724
|
-
tokenProgram:
|
|
12982
|
+
tokenProgram: import_token_202226.TOKEN_2022_PROGRAM_ADDRESS
|
|
12725
12983
|
}))[0];
|
|
12726
|
-
const tunaPositionOwnerAtaA = (await (0,
|
|
12984
|
+
const tunaPositionOwnerAtaA = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12727
12985
|
owner: authority.address,
|
|
12728
12986
|
mint: mintA.address,
|
|
12729
12987
|
tokenProgram: mintA.programAddress
|
|
12730
12988
|
}))[0];
|
|
12731
|
-
const tunaPositionOwnerAtaB = (await (0,
|
|
12989
|
+
const tunaPositionOwnerAtaB = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12732
12990
|
owner: authority.address,
|
|
12733
12991
|
mint: mintB.address,
|
|
12734
12992
|
tokenProgram: mintB.programAddress
|
|
12735
12993
|
}))[0];
|
|
12736
|
-
const tunaPositionAtaA = (await (0,
|
|
12994
|
+
const tunaPositionAtaA = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12737
12995
|
owner: tunaPositionAddress,
|
|
12738
12996
|
mint: mintA.address,
|
|
12739
12997
|
tokenProgram: mintA.programAddress
|
|
12740
12998
|
}))[0];
|
|
12741
|
-
const tunaPositionAtaB = (await (0,
|
|
12999
|
+
const tunaPositionAtaB = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12742
13000
|
owner: tunaPositionAddress,
|
|
12743
13001
|
mint: mintB.address,
|
|
12744
13002
|
tokenProgram: mintB.programAddress
|
|
12745
13003
|
}))[0];
|
|
12746
|
-
const vaultAAta = (await (0,
|
|
13004
|
+
const vaultAAta = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12747
13005
|
owner: vaultA.address,
|
|
12748
13006
|
mint: mintA.address,
|
|
12749
13007
|
tokenProgram: mintA.programAddress
|
|
12750
13008
|
}))[0];
|
|
12751
|
-
const vaultBAta = (await (0,
|
|
13009
|
+
const vaultBAta = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12752
13010
|
owner: vaultB.address,
|
|
12753
13011
|
mint: mintB.address,
|
|
12754
13012
|
tokenProgram: mintB.programAddress
|
|
12755
13013
|
}))[0];
|
|
12756
|
-
const feeRecipientAtaA = (await (0,
|
|
13014
|
+
const feeRecipientAtaA = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12757
13015
|
owner: tunaConfig.data.feeRecipient,
|
|
12758
13016
|
mint: mintA.address,
|
|
12759
13017
|
tokenProgram: mintA.programAddress
|
|
12760
13018
|
}))[0];
|
|
12761
|
-
const feeRecipientAtaB = (await (0,
|
|
13019
|
+
const feeRecipientAtaB = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12762
13020
|
owner: tunaConfig.data.feeRecipient,
|
|
12763
13021
|
mint: mintB.address,
|
|
12764
13022
|
tokenProgram: mintB.programAddress
|
|
@@ -12767,15 +13025,15 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
12767
13025
|
const lowerTickArrayAddress = await FusionUtils.getTickArrayAddressFromTickIndex(fusionPool, args.tickLowerIndex);
|
|
12768
13026
|
const upperTickArrayAddress = await FusionUtils.getTickArrayAddressFromTickIndex(fusionPool, args.tickUpperIndex);
|
|
12769
13027
|
const remainingAccounts = [
|
|
12770
|
-
{ address: swapTickArrays[0], role:
|
|
12771
|
-
{ address: swapTickArrays[1], role:
|
|
12772
|
-
{ address: swapTickArrays[2], role:
|
|
12773
|
-
{ address: swapTickArrays[3], role:
|
|
12774
|
-
{ address: swapTickArrays[4], role:
|
|
12775
|
-
{ address: lowerTickArrayAddress, role:
|
|
12776
|
-
{ address: upperTickArrayAddress, role:
|
|
12777
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
12778
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
13028
|
+
{ address: swapTickArrays[0], role: import_kit123.AccountRole.WRITABLE },
|
|
13029
|
+
{ address: swapTickArrays[1], role: import_kit123.AccountRole.WRITABLE },
|
|
13030
|
+
{ address: swapTickArrays[2], role: import_kit123.AccountRole.WRITABLE },
|
|
13031
|
+
{ address: swapTickArrays[3], role: import_kit123.AccountRole.WRITABLE },
|
|
13032
|
+
{ address: swapTickArrays[4], role: import_kit123.AccountRole.WRITABLE },
|
|
13033
|
+
{ address: lowerTickArrayAddress, role: import_kit123.AccountRole.WRITABLE },
|
|
13034
|
+
{ address: upperTickArrayAddress, role: import_kit123.AccountRole.WRITABLE },
|
|
13035
|
+
{ address: fusionPool.data.tokenVaultA, role: import_kit123.AccountRole.WRITABLE },
|
|
13036
|
+
{ address: fusionPool.data.tokenVaultB, role: import_kit123.AccountRole.WRITABLE }
|
|
12779
13037
|
];
|
|
12780
13038
|
const remainingAccountsInfo = {
|
|
12781
13039
|
slices: [
|
|
@@ -12812,10 +13070,10 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
12812
13070
|
fusionPosition: fusionPositionAddress,
|
|
12813
13071
|
tokenProgramA: mintA.programAddress,
|
|
12814
13072
|
tokenProgramB: mintB.programAddress,
|
|
12815
|
-
memoProgram:
|
|
13073
|
+
memoProgram: import_memo17.MEMO_PROGRAM_ADDRESS,
|
|
12816
13074
|
metadataUpdateAuth: import_fusionamm_client13.FP_NFT_UPDATE_AUTH,
|
|
12817
|
-
associatedTokenProgram:
|
|
12818
|
-
token2022Program:
|
|
13075
|
+
associatedTokenProgram: import_token_202226.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
13076
|
+
token2022Program: import_token_202226.TOKEN_2022_PROGRAM_ADDRESS,
|
|
12819
13077
|
...args,
|
|
12820
13078
|
remainingAccountsInfo
|
|
12821
13079
|
});
|
|
@@ -12826,21 +13084,21 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
12826
13084
|
// src/txbuilder/openTunaSpotPosition.ts
|
|
12827
13085
|
var import_fusionamm_client14 = require("@crypticdot/fusionamm-client");
|
|
12828
13086
|
var import_whirlpools_client13 = require("@orca-so/whirlpools-client");
|
|
12829
|
-
var
|
|
12830
|
-
var
|
|
13087
|
+
var import_kit124 = require("@solana/kit");
|
|
13088
|
+
var import_token_202227 = require("@solana-program/token-2022");
|
|
12831
13089
|
var import_assert19 = __toESM(require("assert"));
|
|
12832
13090
|
async function openTunaSpotPositionInstructions(rpc, authority, poolAddress, args) {
|
|
12833
|
-
const poolAccount = await (0,
|
|
13091
|
+
const poolAccount = await (0, import_kit124.fetchEncodedAccount)(rpc, poolAddress);
|
|
12834
13092
|
(0, import_assert19.default)(poolAccount.exists, "Pool account not found");
|
|
12835
13093
|
let pool;
|
|
12836
13094
|
if (poolAccount.programAddress == import_fusionamm_client14.FUSIONAMM_PROGRAM_ADDRESS) {
|
|
12837
|
-
pool = (0,
|
|
13095
|
+
pool = (0, import_kit124.decodeAccount)(poolAccount, (0, import_fusionamm_client14.getFusionPoolDecoder)());
|
|
12838
13096
|
} else if (poolAccount.programAddress == import_whirlpools_client13.WHIRLPOOL_PROGRAM_ADDRESS) {
|
|
12839
|
-
pool = (0,
|
|
13097
|
+
pool = (0, import_kit124.decodeAccount)(poolAccount, (0, import_whirlpools_client13.getWhirlpoolDecoder)());
|
|
12840
13098
|
} else {
|
|
12841
13099
|
throw new Error("Incorrect Fusion or Orca pool account");
|
|
12842
13100
|
}
|
|
12843
|
-
const [mintA, mintB] = await (0,
|
|
13101
|
+
const [mintA, mintB] = await (0, import_token_202227.fetchAllMaybeMint)(rpc, [pool.data.tokenMintA, pool.data.tokenMintB]);
|
|
12844
13102
|
(0, import_assert19.default)(mintA.exists, "Token A account not found");
|
|
12845
13103
|
(0, import_assert19.default)(mintB.exists, "Token B account not found");
|
|
12846
13104
|
const ix = await openTunaSpotPositionInstruction(authority, mintA, mintB, poolAddress, args);
|
|
@@ -12848,12 +13106,12 @@ async function openTunaSpotPositionInstructions(rpc, authority, poolAddress, arg
|
|
|
12848
13106
|
}
|
|
12849
13107
|
async function openTunaSpotPositionInstruction(authority, mintA, mintB, poolAddress, args) {
|
|
12850
13108
|
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
12851
|
-
const tunaPositionAtaA = (await (0,
|
|
13109
|
+
const tunaPositionAtaA = (await (0, import_token_202227.findAssociatedTokenPda)({
|
|
12852
13110
|
owner: tunaPositionAddress,
|
|
12853
13111
|
mint: mintA.address,
|
|
12854
13112
|
tokenProgram: mintA.programAddress
|
|
12855
13113
|
}))[0];
|
|
12856
|
-
const tunaPositionAtaB = (await (0,
|
|
13114
|
+
const tunaPositionAtaB = (await (0, import_token_202227.findAssociatedTokenPda)({
|
|
12857
13115
|
owner: tunaPositionAddress,
|
|
12858
13116
|
mint: mintB.address,
|
|
12859
13117
|
tokenProgram: mintB.programAddress
|
|
@@ -12868,7 +13126,7 @@ async function openTunaSpotPositionInstruction(authority, mintA, mintB, poolAddr
|
|
|
12868
13126
|
tunaPositionAtaA,
|
|
12869
13127
|
tunaPositionAtaB,
|
|
12870
13128
|
pool: poolAddress,
|
|
12871
|
-
associatedTokenProgram:
|
|
13129
|
+
associatedTokenProgram: import_token_202227.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
12872
13130
|
...args
|
|
12873
13131
|
});
|
|
12874
13132
|
}
|
|
@@ -12876,9 +13134,9 @@ async function openTunaSpotPositionInstruction(authority, mintA, mintB, poolAddr
|
|
|
12876
13134
|
// src/txbuilder/decreaseTunaLpPositionOrca.ts
|
|
12877
13135
|
var import_whirlpools_client14 = require("@orca-so/whirlpools-client");
|
|
12878
13136
|
var import_whirlpools_core5 = require("@orca-so/whirlpools-core");
|
|
12879
|
-
var
|
|
12880
|
-
var
|
|
12881
|
-
var
|
|
13137
|
+
var import_kit125 = require("@solana/kit");
|
|
13138
|
+
var import_memo18 = require("@solana-program/memo");
|
|
13139
|
+
var import_token_202228 = require("@solana-program/token-2022");
|
|
12882
13140
|
var import_assert20 = __toESM(require("assert"));
|
|
12883
13141
|
async function decreaseTunaLpPositionOrcaInstructions(rpc, authority, positionMint, args, createInstructions, cleanupInstructions) {
|
|
12884
13142
|
const tunaPosition = await fetchMaybeTunaLpPosition(rpc, (await getTunaLpPositionAddress(positionMint))[0]);
|
|
@@ -12890,7 +13148,7 @@ async function decreaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
|
|
|
12890
13148
|
(await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
|
|
12891
13149
|
(await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
|
|
12892
13150
|
]);
|
|
12893
|
-
const [mintA, mintB, ...rewardMints] = await (0,
|
|
13151
|
+
const [mintA, mintB, ...rewardMints] = await (0, import_token_202228.fetchAllMaybeMint)(rpc, [
|
|
12894
13152
|
whirlpool.data.tokenMintA,
|
|
12895
13153
|
whirlpool.data.tokenMintB,
|
|
12896
13154
|
...whirlpool.data.rewardInfos.map((x) => x.mint).filter((x) => x !== DEFAULT_ADDRESS)
|
|
@@ -12898,7 +13156,7 @@ async function decreaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
|
|
|
12898
13156
|
const allMints = [mintA, mintB, ...rewardMints];
|
|
12899
13157
|
(0, import_assert20.default)(mintA.exists, "Token A account not found");
|
|
12900
13158
|
(0, import_assert20.default)(mintB.exists, "Token B account not found");
|
|
12901
|
-
(0,
|
|
13159
|
+
(0, import_kit125.assertAccountsExist)(rewardMints);
|
|
12902
13160
|
const lowerTickArrayStartIndex = (0, import_whirlpools_core5.getTickArrayStartTickIndex)(
|
|
12903
13161
|
tunaPosition.data.tickLowerIndex,
|
|
12904
13162
|
whirlpool.data.tickSpacing
|
|
@@ -12966,37 +13224,37 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
12966
13224
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12967
13225
|
const orcaPositionAddress = (await (0, import_whirlpools_client14.getPositionAddress)(positionMint))[0];
|
|
12968
13226
|
const orcaOracleAddress = (await (0, import_whirlpools_client14.getOracleAddress)(whirlpool.address))[0];
|
|
12969
|
-
const tunaPositionAta = (await (0,
|
|
13227
|
+
const tunaPositionAta = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12970
13228
|
owner: tunaPosition.address,
|
|
12971
13229
|
mint: positionMint,
|
|
12972
|
-
tokenProgram:
|
|
13230
|
+
tokenProgram: import_token_202228.TOKEN_2022_PROGRAM_ADDRESS
|
|
12973
13231
|
}))[0];
|
|
12974
|
-
const tunaPositionOwnerAtaA = (await (0,
|
|
13232
|
+
const tunaPositionOwnerAtaA = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12975
13233
|
owner: authority.address,
|
|
12976
13234
|
mint: mintA.address,
|
|
12977
13235
|
tokenProgram: mintA.programAddress
|
|
12978
13236
|
}))[0];
|
|
12979
|
-
const tunaPositionOwnerAtaB = (await (0,
|
|
13237
|
+
const tunaPositionOwnerAtaB = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12980
13238
|
owner: authority.address,
|
|
12981
13239
|
mint: mintB.address,
|
|
12982
13240
|
tokenProgram: mintB.programAddress
|
|
12983
13241
|
}))[0];
|
|
12984
|
-
const tunaPositionAtaA = (await (0,
|
|
13242
|
+
const tunaPositionAtaA = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12985
13243
|
owner: tunaPosition.address,
|
|
12986
13244
|
mint: mintA.address,
|
|
12987
13245
|
tokenProgram: mintA.programAddress
|
|
12988
13246
|
}))[0];
|
|
12989
|
-
const tunaPositionAtaB = (await (0,
|
|
13247
|
+
const tunaPositionAtaB = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12990
13248
|
owner: tunaPosition.address,
|
|
12991
13249
|
mint: mintB.address,
|
|
12992
13250
|
tokenProgram: mintB.programAddress
|
|
12993
13251
|
}))[0];
|
|
12994
|
-
const vaultAAta = (await (0,
|
|
13252
|
+
const vaultAAta = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12995
13253
|
owner: vaultA.address,
|
|
12996
13254
|
mint: mintA.address,
|
|
12997
13255
|
tokenProgram: mintA.programAddress
|
|
12998
13256
|
}))[0];
|
|
12999
|
-
const vaultBAta = (await (0,
|
|
13257
|
+
const vaultBAta = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
13000
13258
|
owner: vaultB.address,
|
|
13001
13259
|
mint: mintB.address,
|
|
13002
13260
|
tokenProgram: mintB.programAddress
|
|
@@ -13011,30 +13269,30 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
13011
13269
|
tunaPosition.data.tickUpperIndex
|
|
13012
13270
|
);
|
|
13013
13271
|
const remainingAccounts = [
|
|
13014
|
-
{ address: swapTickArrays[0], role:
|
|
13015
|
-
{ address: swapTickArrays[1], role:
|
|
13016
|
-
{ address: swapTickArrays[2], role:
|
|
13017
|
-
{ address: swapTickArrays[3], role:
|
|
13018
|
-
{ address: swapTickArrays[4], role:
|
|
13019
|
-
{ address: lowerTickArrayAddress, role:
|
|
13020
|
-
{ address: upperTickArrayAddress, role:
|
|
13021
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
13022
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
13023
|
-
{ address: orcaOracleAddress, role:
|
|
13272
|
+
{ address: swapTickArrays[0], role: import_kit125.AccountRole.WRITABLE },
|
|
13273
|
+
{ address: swapTickArrays[1], role: import_kit125.AccountRole.WRITABLE },
|
|
13274
|
+
{ address: swapTickArrays[2], role: import_kit125.AccountRole.WRITABLE },
|
|
13275
|
+
{ address: swapTickArrays[3], role: import_kit125.AccountRole.WRITABLE },
|
|
13276
|
+
{ address: swapTickArrays[4], role: import_kit125.AccountRole.WRITABLE },
|
|
13277
|
+
{ address: lowerTickArrayAddress, role: import_kit125.AccountRole.WRITABLE },
|
|
13278
|
+
{ address: upperTickArrayAddress, role: import_kit125.AccountRole.WRITABLE },
|
|
13279
|
+
{ address: whirlpool.data.tokenVaultA, role: import_kit125.AccountRole.WRITABLE },
|
|
13280
|
+
{ address: whirlpool.data.tokenVaultB, role: import_kit125.AccountRole.WRITABLE },
|
|
13281
|
+
{ address: orcaOracleAddress, role: import_kit125.AccountRole.WRITABLE }
|
|
13024
13282
|
];
|
|
13025
13283
|
for (const rewardIndex of rewardIndicesToClaim) {
|
|
13026
13284
|
const rewardInfo = whirlpool.data.rewardInfos[rewardIndex];
|
|
13027
13285
|
const rewardMint = rewardMints.find((mint) => mint.address == rewardInfo.mint);
|
|
13028
13286
|
(0, import_assert20.default)(rewardMint, "Reward mint not found in the provided reward mint accounts");
|
|
13029
|
-
const ownerAta = await (0,
|
|
13287
|
+
const ownerAta = await (0, import_token_202228.findAssociatedTokenPda)({
|
|
13030
13288
|
owner: authority.address,
|
|
13031
13289
|
mint: rewardMint.address,
|
|
13032
13290
|
tokenProgram: rewardMint.programAddress
|
|
13033
13291
|
});
|
|
13034
|
-
remainingAccounts.push({ address: rewardMint.address, role:
|
|
13035
|
-
remainingAccounts.push({ address: rewardMint.programAddress, role:
|
|
13036
|
-
remainingAccounts.push({ address: ownerAta[0], role:
|
|
13037
|
-
remainingAccounts.push({ address: rewardInfo.vault, role:
|
|
13292
|
+
remainingAccounts.push({ address: rewardMint.address, role: import_kit125.AccountRole.READONLY });
|
|
13293
|
+
remainingAccounts.push({ address: rewardMint.programAddress, role: import_kit125.AccountRole.READONLY });
|
|
13294
|
+
remainingAccounts.push({ address: ownerAta[0], role: import_kit125.AccountRole.WRITABLE });
|
|
13295
|
+
remainingAccounts.push({ address: rewardInfo.vault, role: import_kit125.AccountRole.WRITABLE });
|
|
13038
13296
|
}
|
|
13039
13297
|
const remainingAccountsInfo = {
|
|
13040
13298
|
slices: [
|
|
@@ -13072,7 +13330,7 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
13072
13330
|
whirlpoolProgram: import_whirlpools_client14.WHIRLPOOL_PROGRAM_ADDRESS,
|
|
13073
13331
|
tokenProgramA: mintA.programAddress,
|
|
13074
13332
|
tokenProgramB: mintB.programAddress,
|
|
13075
|
-
memoProgram:
|
|
13333
|
+
memoProgram: import_memo18.MEMO_PROGRAM_ADDRESS,
|
|
13076
13334
|
...args,
|
|
13077
13335
|
remainingAccountsInfo
|
|
13078
13336
|
});
|
|
@@ -13082,9 +13340,9 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
13082
13340
|
|
|
13083
13341
|
// src/txbuilder/decreaseTunaLpPositionFusion.ts
|
|
13084
13342
|
var import_fusionamm_client15 = require("@crypticdot/fusionamm-client");
|
|
13085
|
-
var
|
|
13086
|
-
var
|
|
13087
|
-
var
|
|
13343
|
+
var import_kit126 = require("@solana/kit");
|
|
13344
|
+
var import_memo19 = require("@solana-program/memo");
|
|
13345
|
+
var import_token_202229 = require("@solana-program/token-2022");
|
|
13088
13346
|
var import_assert21 = __toESM(require("assert"));
|
|
13089
13347
|
async function decreaseTunaLpPositionFusionInstructions(rpc, authority, positionMint, args, createInstructions, cleanupInstructions) {
|
|
13090
13348
|
const tunaPosition = await fetchMaybeTunaLpPosition(rpc, (await getTunaLpPositionAddress(positionMint))[0]);
|
|
@@ -13095,7 +13353,7 @@ async function decreaseTunaLpPositionFusionInstructions(rpc, authority, position
|
|
|
13095
13353
|
(await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
|
|
13096
13354
|
(await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
|
|
13097
13355
|
]);
|
|
13098
|
-
const [mintA, mintB] = await (0,
|
|
13356
|
+
const [mintA, mintB] = await (0, import_token_202229.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
13099
13357
|
(0, import_assert21.default)(mintA.exists, "Token A account not found");
|
|
13100
13358
|
(0, import_assert21.default)(mintB.exists, "Token B account not found");
|
|
13101
13359
|
const instructions = [];
|
|
@@ -13138,37 +13396,37 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13138
13396
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
13139
13397
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
13140
13398
|
const fusionPositionAddress = (await (0, import_fusionamm_client15.getPositionAddress)(positionMint))[0];
|
|
13141
|
-
const tunaPositionAta = (await (0,
|
|
13399
|
+
const tunaPositionAta = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13142
13400
|
owner: tunaPosition.address,
|
|
13143
13401
|
mint: positionMint,
|
|
13144
|
-
tokenProgram:
|
|
13402
|
+
tokenProgram: import_token_202229.TOKEN_2022_PROGRAM_ADDRESS
|
|
13145
13403
|
}))[0];
|
|
13146
|
-
const tunaPositionOwnerAtaA = (await (0,
|
|
13404
|
+
const tunaPositionOwnerAtaA = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13147
13405
|
owner: authority.address,
|
|
13148
13406
|
mint: mintA.address,
|
|
13149
13407
|
tokenProgram: mintA.programAddress
|
|
13150
13408
|
}))[0];
|
|
13151
|
-
const tunaPositionOwnerAtaB = (await (0,
|
|
13409
|
+
const tunaPositionOwnerAtaB = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13152
13410
|
owner: authority.address,
|
|
13153
13411
|
mint: mintB.address,
|
|
13154
13412
|
tokenProgram: mintB.programAddress
|
|
13155
13413
|
}))[0];
|
|
13156
|
-
const tunaPositionAtaA = (await (0,
|
|
13414
|
+
const tunaPositionAtaA = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13157
13415
|
owner: tunaPosition.address,
|
|
13158
13416
|
mint: mintA.address,
|
|
13159
13417
|
tokenProgram: mintA.programAddress
|
|
13160
13418
|
}))[0];
|
|
13161
|
-
const tunaPositionAtaB = (await (0,
|
|
13419
|
+
const tunaPositionAtaB = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13162
13420
|
owner: tunaPosition.address,
|
|
13163
13421
|
mint: mintB.address,
|
|
13164
13422
|
tokenProgram: mintB.programAddress
|
|
13165
13423
|
}))[0];
|
|
13166
|
-
const vaultAAta = (await (0,
|
|
13424
|
+
const vaultAAta = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13167
13425
|
owner: vaultA.address,
|
|
13168
13426
|
mint: mintA.address,
|
|
13169
13427
|
tokenProgram: mintA.programAddress
|
|
13170
13428
|
}))[0];
|
|
13171
|
-
const vaultBAta = (await (0,
|
|
13429
|
+
const vaultBAta = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13172
13430
|
owner: vaultB.address,
|
|
13173
13431
|
mint: mintB.address,
|
|
13174
13432
|
tokenProgram: mintB.programAddress
|
|
@@ -13183,15 +13441,15 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13183
13441
|
tunaPosition.data.tickUpperIndex
|
|
13184
13442
|
);
|
|
13185
13443
|
const remainingAccounts = [
|
|
13186
|
-
{ address: swapTickArrays[0], role:
|
|
13187
|
-
{ address: swapTickArrays[1], role:
|
|
13188
|
-
{ address: swapTickArrays[2], role:
|
|
13189
|
-
{ address: swapTickArrays[3], role:
|
|
13190
|
-
{ address: swapTickArrays[4], role:
|
|
13191
|
-
{ address: lowerTickArrayAddress, role:
|
|
13192
|
-
{ address: upperTickArrayAddress, role:
|
|
13193
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
13194
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
13444
|
+
{ address: swapTickArrays[0], role: import_kit126.AccountRole.WRITABLE },
|
|
13445
|
+
{ address: swapTickArrays[1], role: import_kit126.AccountRole.WRITABLE },
|
|
13446
|
+
{ address: swapTickArrays[2], role: import_kit126.AccountRole.WRITABLE },
|
|
13447
|
+
{ address: swapTickArrays[3], role: import_kit126.AccountRole.WRITABLE },
|
|
13448
|
+
{ address: swapTickArrays[4], role: import_kit126.AccountRole.WRITABLE },
|
|
13449
|
+
{ address: lowerTickArrayAddress, role: import_kit126.AccountRole.WRITABLE },
|
|
13450
|
+
{ address: upperTickArrayAddress, role: import_kit126.AccountRole.WRITABLE },
|
|
13451
|
+
{ address: fusionPool.data.tokenVaultA, role: import_kit126.AccountRole.WRITABLE },
|
|
13452
|
+
{ address: fusionPool.data.tokenVaultB, role: import_kit126.AccountRole.WRITABLE }
|
|
13195
13453
|
];
|
|
13196
13454
|
const remainingAccountsInfo = {
|
|
13197
13455
|
slices: [
|
|
@@ -13225,7 +13483,7 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13225
13483
|
fusionammProgram: import_fusionamm_client15.FUSIONAMM_PROGRAM_ADDRESS,
|
|
13226
13484
|
tokenProgramA: mintA.programAddress,
|
|
13227
13485
|
tokenProgramB: mintB.programAddress,
|
|
13228
|
-
memoProgram:
|
|
13486
|
+
memoProgram: import_memo19.MEMO_PROGRAM_ADDRESS,
|
|
13229
13487
|
...args,
|
|
13230
13488
|
remainingAccountsInfo
|
|
13231
13489
|
});
|
|
@@ -13234,19 +13492,19 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13234
13492
|
}
|
|
13235
13493
|
|
|
13236
13494
|
// src/txbuilder/repayBadDebt.ts
|
|
13237
|
-
var
|
|
13238
|
-
var
|
|
13495
|
+
var import_memo20 = require("@solana-program/memo");
|
|
13496
|
+
var import_token_202230 = require("@solana-program/token-2022");
|
|
13239
13497
|
async function repayBadDebtInstruction(rpc, authority, mintAddress, funds, shares) {
|
|
13240
|
-
const mint = await (0,
|
|
13498
|
+
const mint = await (0, import_token_202230.fetchMaybeMint)(rpc, mintAddress);
|
|
13241
13499
|
if (!mint.exists) throw new Error("Mint account not found");
|
|
13242
13500
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
13243
13501
|
const vault = (await getLendingVaultAddress(mint.address))[0];
|
|
13244
|
-
const vaultAta = (await (0,
|
|
13502
|
+
const vaultAta = (await (0, import_token_202230.findAssociatedTokenPda)({
|
|
13245
13503
|
owner: vault,
|
|
13246
13504
|
mint: mint.address,
|
|
13247
13505
|
tokenProgram: mint.programAddress
|
|
13248
13506
|
}))[0];
|
|
13249
|
-
const authorityAta = (await (0,
|
|
13507
|
+
const authorityAta = (await (0, import_token_202230.findAssociatedTokenPda)({
|
|
13250
13508
|
owner: authority.address,
|
|
13251
13509
|
mint: mint.address,
|
|
13252
13510
|
tokenProgram: mint.programAddress
|
|
@@ -13259,7 +13517,7 @@ async function repayBadDebtInstruction(rpc, authority, mintAddress, funds, share
|
|
|
13259
13517
|
tunaConfig,
|
|
13260
13518
|
vault,
|
|
13261
13519
|
tokenProgram: mint.programAddress,
|
|
13262
|
-
memoProgram:
|
|
13520
|
+
memoProgram: import_memo20.MEMO_PROGRAM_ADDRESS,
|
|
13263
13521
|
funds,
|
|
13264
13522
|
shares
|
|
13265
13523
|
});
|
|
@@ -13291,20 +13549,20 @@ async function setTunaSpotPositionLimitOrdersInstruction(authority, poolAddress,
|
|
|
13291
13549
|
}
|
|
13292
13550
|
|
|
13293
13551
|
// src/txbuilder/resetTunaSpotPosition.ts
|
|
13294
|
-
var
|
|
13552
|
+
var import_token_202231 = require("@solana-program/token-2022");
|
|
13295
13553
|
var import_assert22 = __toESM(require("assert"));
|
|
13296
13554
|
async function resetTunaSpotPositionInstruction(rpc, authority, poolAddress, args) {
|
|
13297
13555
|
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
13298
13556
|
const tunaPosition = await fetchTunaSpotPosition(rpc, tunaPositionAddress);
|
|
13299
|
-
const [mintA, mintB] = await (0,
|
|
13557
|
+
const [mintA, mintB] = await (0, import_token_202231.fetchAllMaybeMint)(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
13300
13558
|
(0, import_assert22.default)(mintA.exists, "Token A not found");
|
|
13301
13559
|
(0, import_assert22.default)(mintB.exists, "Token B not found");
|
|
13302
|
-
const tunaPositionAtaA = (await (0,
|
|
13560
|
+
const tunaPositionAtaA = (await (0, import_token_202231.findAssociatedTokenPda)({
|
|
13303
13561
|
owner: tunaPositionAddress,
|
|
13304
13562
|
mint: mintA.address,
|
|
13305
13563
|
tokenProgram: mintA.programAddress
|
|
13306
13564
|
}))[0];
|
|
13307
|
-
const tunaPositionAtaB = (await (0,
|
|
13565
|
+
const tunaPositionAtaB = (await (0, import_token_202231.findAssociatedTokenPda)({
|
|
13308
13566
|
owner: tunaPositionAddress,
|
|
13309
13567
|
mint: mintB.address,
|
|
13310
13568
|
tokenProgram: mintB.programAddress
|
|
@@ -13345,11 +13603,11 @@ async function updateVaultInstruction(authority, mint, args) {
|
|
|
13345
13603
|
}
|
|
13346
13604
|
|
|
13347
13605
|
// src/txbuilder/withdraw.ts
|
|
13348
|
-
var
|
|
13349
|
-
var
|
|
13606
|
+
var import_memo21 = require("@solana-program/memo");
|
|
13607
|
+
var import_token_202232 = require("@solana-program/token-2022");
|
|
13350
13608
|
async function withdrawInstructions(rpc, authority, mintAddress, funds, shares) {
|
|
13351
13609
|
const instructions = [];
|
|
13352
|
-
const mint = await (0,
|
|
13610
|
+
const mint = await (0, import_token_202232.fetchMaybeMint)(rpc, mintAddress);
|
|
13353
13611
|
if (!mint.exists) throw new Error("Mint account not found");
|
|
13354
13612
|
const createUserAtaInstructions = await getCreateAtaInstructions(
|
|
13355
13613
|
rpc,
|
|
@@ -13368,12 +13626,12 @@ async function withdrawInstruction(authority, mint, funds, shares) {
|
|
|
13368
13626
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
13369
13627
|
const lendingPosition = (await getLendingPositionAddress(authority.address, mint.address))[0];
|
|
13370
13628
|
const vault = (await getLendingVaultAddress(mint.address))[0];
|
|
13371
|
-
const vaultAta = (await (0,
|
|
13629
|
+
const vaultAta = (await (0, import_token_202232.findAssociatedTokenPda)({
|
|
13372
13630
|
owner: vault,
|
|
13373
13631
|
mint: mint.address,
|
|
13374
13632
|
tokenProgram: mint.programAddress
|
|
13375
13633
|
}))[0];
|
|
13376
|
-
const authorityAta = (await (0,
|
|
13634
|
+
const authorityAta = (await (0, import_token_202232.findAssociatedTokenPda)({
|
|
13377
13635
|
owner: authority.address,
|
|
13378
13636
|
mint: mint.address,
|
|
13379
13637
|
tokenProgram: mint.programAddress
|
|
@@ -13387,7 +13645,7 @@ async function withdrawInstruction(authority, mint, funds, shares) {
|
|
|
13387
13645
|
vault,
|
|
13388
13646
|
vaultAta,
|
|
13389
13647
|
tokenProgram: mint.programAddress,
|
|
13390
|
-
memoProgram:
|
|
13648
|
+
memoProgram: import_memo21.MEMO_PROGRAM_ADDRESS,
|
|
13391
13649
|
funds,
|
|
13392
13650
|
shares
|
|
13393
13651
|
});
|
|
@@ -13396,26 +13654,26 @@ async function withdrawInstruction(authority, mint, funds, shares) {
|
|
|
13396
13654
|
// src/txbuilder/createMarketLookupTable.ts
|
|
13397
13655
|
var import_fusionamm_client16 = require("@crypticdot/fusionamm-client");
|
|
13398
13656
|
var import_whirlpools_client15 = require("@orca-so/whirlpools-client");
|
|
13399
|
-
var
|
|
13657
|
+
var import_kit127 = require("@solana/kit");
|
|
13400
13658
|
var import_address_lookup_table2 = require("@solana-program/address-lookup-table");
|
|
13401
|
-
var
|
|
13659
|
+
var import_memo22 = require("@solana-program/memo");
|
|
13402
13660
|
var import_system2 = require("@solana-program/system");
|
|
13403
13661
|
var import_token2 = require("@solana-program/token");
|
|
13404
|
-
var
|
|
13662
|
+
var import_token_202233 = require("@solana-program/token-2022");
|
|
13405
13663
|
async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
13406
13664
|
const tunaConfigAddress = (await getTunaConfigAddress())[0];
|
|
13407
13665
|
const marketAddress = (await getMarketAddress(poolAddress))[0];
|
|
13408
13666
|
const orcaOracleAddress = (await (0, import_whirlpools_client15.getOracleAddress)(poolAddress))[0];
|
|
13409
13667
|
const tunaConfig = await fetchTunaConfig(rpc, tunaConfigAddress);
|
|
13410
13668
|
const pool = marketMaker == 0 /* Orca */ ? await (0, import_whirlpools_client15.fetchWhirlpool)(rpc, poolAddress) : await (0, import_fusionamm_client16.fetchFusionPool)(rpc, poolAddress);
|
|
13411
|
-
const mintA = await (0,
|
|
13412
|
-
const mintB = await (0,
|
|
13413
|
-
const feeRecipientAtaA = (await (0,
|
|
13669
|
+
const mintA = await (0, import_token_202233.fetchMint)(rpc, pool.data.tokenMintA);
|
|
13670
|
+
const mintB = await (0, import_token_202233.fetchMint)(rpc, pool.data.tokenMintB);
|
|
13671
|
+
const feeRecipientAtaA = (await (0, import_token_202233.findAssociatedTokenPda)({
|
|
13414
13672
|
owner: tunaConfig.data.feeRecipient,
|
|
13415
13673
|
mint: mintA.address,
|
|
13416
13674
|
tokenProgram: mintA.programAddress
|
|
13417
13675
|
}))[0];
|
|
13418
|
-
const feeRecipientAtaB = (await (0,
|
|
13676
|
+
const feeRecipientAtaB = (await (0, import_token_202233.findAssociatedTokenPda)({
|
|
13419
13677
|
owner: tunaConfig.data.feeRecipient,
|
|
13420
13678
|
mint: mintB.address,
|
|
13421
13679
|
tokenProgram: mintB.programAddress
|
|
@@ -13424,24 +13682,24 @@ async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
|
13424
13682
|
(await getLendingVaultAddress(mintA.address))[0],
|
|
13425
13683
|
(await getLendingVaultAddress(mintB.address))[0]
|
|
13426
13684
|
]);
|
|
13427
|
-
const vaultAAta = (await (0,
|
|
13685
|
+
const vaultAAta = (await (0, import_token_202233.findAssociatedTokenPda)({
|
|
13428
13686
|
owner: vaultA.address,
|
|
13429
13687
|
mint: mintA.address,
|
|
13430
13688
|
tokenProgram: mintA.programAddress
|
|
13431
13689
|
}))[0];
|
|
13432
|
-
const vaultBAta = (await (0,
|
|
13690
|
+
const vaultBAta = (await (0, import_token_202233.findAssociatedTokenPda)({
|
|
13433
13691
|
owner: vaultB.address,
|
|
13434
13692
|
mint: mintB.address,
|
|
13435
13693
|
tokenProgram: mintB.programAddress
|
|
13436
13694
|
}))[0];
|
|
13437
13695
|
const addresses = [
|
|
13438
13696
|
import_system2.SYSTEM_PROGRAM_ADDRESS,
|
|
13439
|
-
(0,
|
|
13440
|
-
|
|
13697
|
+
(0, import_kit127.address)("SysvarRent111111111111111111111111111111111"),
|
|
13698
|
+
import_token_202233.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
13441
13699
|
import_token2.TOKEN_PROGRAM_ADDRESS,
|
|
13442
|
-
|
|
13700
|
+
import_token_202233.TOKEN_2022_PROGRAM_ADDRESS,
|
|
13443
13701
|
NATIVE_MINT,
|
|
13444
|
-
|
|
13702
|
+
import_memo22.MEMO_PROGRAM_ADDRESS,
|
|
13445
13703
|
tunaConfigAddress,
|
|
13446
13704
|
marketAddress,
|
|
13447
13705
|
mintA.address,
|
|
@@ -13496,15 +13754,15 @@ async function extendAddressLookupTableForMarketInstructions(rpc, poolAddress, m
|
|
|
13496
13754
|
}
|
|
13497
13755
|
|
|
13498
13756
|
// src/txbuilder/repayTunaLpPositionDebt.ts
|
|
13499
|
-
var
|
|
13500
|
-
var
|
|
13757
|
+
var import_memo23 = require("@solana-program/memo");
|
|
13758
|
+
var import_token_202234 = require("@solana-program/token-2022");
|
|
13501
13759
|
var import_assert23 = __toESM(require("assert"));
|
|
13502
13760
|
async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint, collateralA, collateralB, createInstructions, cleanupInstructions) {
|
|
13503
13761
|
const instructions = [];
|
|
13504
13762
|
if (!createInstructions) createInstructions = instructions;
|
|
13505
13763
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
13506
13764
|
const tunaPosition = await fetchTunaLpPosition(rpc, (await getTunaLpPositionAddress(positionMint))[0]);
|
|
13507
|
-
const [mintA, mintB] = await (0,
|
|
13765
|
+
const [mintA, mintB] = await (0, import_token_202234.fetchAllMaybeMint)(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
13508
13766
|
(0, import_assert23.default)(mintA.exists, "Token A not found");
|
|
13509
13767
|
(0, import_assert23.default)(mintB.exists, "Token B not found");
|
|
13510
13768
|
const marketAddress = (await getMarketAddress(tunaPosition.data.pool))[0];
|
|
@@ -13542,34 +13800,34 @@ async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint,
|
|
|
13542
13800
|
}
|
|
13543
13801
|
async function repayTunaLpPositionDebtInstruction(authority, positionMint, mintA, mintB, marketAddress, collateralA, collateralB) {
|
|
13544
13802
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint))[0];
|
|
13545
|
-
const tunaPositionOwnerAtaA = (await (0,
|
|
13803
|
+
const tunaPositionOwnerAtaA = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13546
13804
|
owner: authority.address,
|
|
13547
13805
|
mint: mintA.address,
|
|
13548
13806
|
tokenProgram: mintA.programAddress
|
|
13549
13807
|
}))[0];
|
|
13550
|
-
const tunaPositionOwnerAtaB = (await (0,
|
|
13808
|
+
const tunaPositionOwnerAtaB = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13551
13809
|
owner: authority.address,
|
|
13552
13810
|
mint: mintB.address,
|
|
13553
13811
|
tokenProgram: mintB.programAddress
|
|
13554
13812
|
}))[0];
|
|
13555
|
-
const tunaPositionAtaA = (await (0,
|
|
13813
|
+
const tunaPositionAtaA = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13556
13814
|
owner: tunaPositionAddress,
|
|
13557
13815
|
mint: mintA.address,
|
|
13558
13816
|
tokenProgram: mintA.programAddress
|
|
13559
13817
|
}))[0];
|
|
13560
|
-
const tunaPositionAtaB = (await (0,
|
|
13818
|
+
const tunaPositionAtaB = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13561
13819
|
owner: tunaPositionAddress,
|
|
13562
13820
|
mint: mintB.address,
|
|
13563
13821
|
tokenProgram: mintB.programAddress
|
|
13564
13822
|
}))[0];
|
|
13565
13823
|
const vaultAAddress = (await getLendingVaultAddress(mintA.address))[0];
|
|
13566
|
-
const vaultAAta = (await (0,
|
|
13824
|
+
const vaultAAta = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13567
13825
|
owner: vaultAAddress,
|
|
13568
13826
|
mint: mintA.address,
|
|
13569
13827
|
tokenProgram: mintA.programAddress
|
|
13570
13828
|
}))[0];
|
|
13571
13829
|
const vaultBAddress = (await getLendingVaultAddress(mintB.address))[0];
|
|
13572
|
-
const vaultBAta = (await (0,
|
|
13830
|
+
const vaultBAta = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13573
13831
|
owner: vaultBAddress,
|
|
13574
13832
|
mint: mintB.address,
|
|
13575
13833
|
tokenProgram: mintB.programAddress
|
|
@@ -13577,7 +13835,7 @@ async function repayTunaLpPositionDebtInstruction(authority, positionMint, mintA
|
|
|
13577
13835
|
return getRepayTunaLpPositionDebtInstruction({
|
|
13578
13836
|
authority,
|
|
13579
13837
|
market: marketAddress,
|
|
13580
|
-
memoProgram:
|
|
13838
|
+
memoProgram: import_memo23.MEMO_PROGRAM_ADDRESS,
|
|
13581
13839
|
mintA: mintA.address,
|
|
13582
13840
|
mintB: mintB.address,
|
|
13583
13841
|
tokenProgramA: mintA.programAddress,
|
|
@@ -13598,10 +13856,10 @@ async function repayTunaLpPositionDebtInstruction(authority, positionMint, mintA
|
|
|
13598
13856
|
|
|
13599
13857
|
// src/txbuilder/rebalanceTunaLpPositionOrca.ts
|
|
13600
13858
|
var import_whirlpools_client16 = require("@orca-so/whirlpools-client");
|
|
13601
|
-
var
|
|
13859
|
+
var import_kit128 = require("@solana/kit");
|
|
13602
13860
|
var import_sysvars3 = require("@solana/sysvars");
|
|
13603
|
-
var
|
|
13604
|
-
var
|
|
13861
|
+
var import_memo24 = require("@solana-program/memo");
|
|
13862
|
+
var import_token_202235 = require("@solana-program/token-2022");
|
|
13605
13863
|
var import_assert24 = __toESM(require("assert"));
|
|
13606
13864
|
async function rebalanceTunaLpPositionOrcaInstructions(rpc, authority, positionMint, createInstructions, cleanupInstructions) {
|
|
13607
13865
|
const rent = await (0, import_sysvars3.fetchSysvarRent)(rpc);
|
|
@@ -13615,7 +13873,7 @@ async function rebalanceTunaLpPositionOrcaInstructions(rpc, authority, positionM
|
|
|
13615
13873
|
(await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
|
|
13616
13874
|
(await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
|
|
13617
13875
|
]);
|
|
13618
|
-
const [mintA, mintB] = await (0,
|
|
13876
|
+
const [mintA, mintB] = await (0, import_token_202235.fetchAllMaybeMint)(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
13619
13877
|
(0, import_assert24.default)(mintA.exists, "Token A account not found");
|
|
13620
13878
|
(0, import_assert24.default)(mintB.exists, "Token B account not found");
|
|
13621
13879
|
const instructions = [];
|
|
@@ -13681,7 +13939,7 @@ async function rebalanceTunaLpPositionOrcaInstructions(rpc, authority, positionM
|
|
|
13681
13939
|
cleanupInstructions.push(...internalCleanupInstructions);
|
|
13682
13940
|
return {
|
|
13683
13941
|
instructions,
|
|
13684
|
-
initializationCost: (0,
|
|
13942
|
+
initializationCost: (0, import_kit128.lamports)(nonRefundableRent)
|
|
13685
13943
|
};
|
|
13686
13944
|
}
|
|
13687
13945
|
async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool) {
|
|
@@ -13689,27 +13947,27 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
13689
13947
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
13690
13948
|
const orcaPositionAddress = (await (0, import_whirlpools_client16.getPositionAddress)(positionMint))[0];
|
|
13691
13949
|
const orcaOracleAddress = (await (0, import_whirlpools_client16.getOracleAddress)(whirlpool.address))[0];
|
|
13692
|
-
const tunaPositionAta = (await (0,
|
|
13950
|
+
const tunaPositionAta = (await (0, import_token_202235.findAssociatedTokenPda)({
|
|
13693
13951
|
owner: tunaPosition.address,
|
|
13694
13952
|
mint: positionMint,
|
|
13695
|
-
tokenProgram:
|
|
13953
|
+
tokenProgram: import_token_202235.TOKEN_2022_PROGRAM_ADDRESS
|
|
13696
13954
|
}))[0];
|
|
13697
|
-
const tunaPositionAtaA = (await (0,
|
|
13955
|
+
const tunaPositionAtaA = (await (0, import_token_202235.findAssociatedTokenPda)({
|
|
13698
13956
|
owner: tunaPosition.address,
|
|
13699
13957
|
mint: mintA.address,
|
|
13700
13958
|
tokenProgram: mintA.programAddress
|
|
13701
13959
|
}))[0];
|
|
13702
|
-
const tunaPositionAtaB = (await (0,
|
|
13960
|
+
const tunaPositionAtaB = (await (0, import_token_202235.findAssociatedTokenPda)({
|
|
13703
13961
|
owner: tunaPosition.address,
|
|
13704
13962
|
mint: mintB.address,
|
|
13705
13963
|
tokenProgram: mintB.programAddress
|
|
13706
13964
|
}))[0];
|
|
13707
|
-
const feeRecipientAtaA = (await (0,
|
|
13965
|
+
const feeRecipientAtaA = (await (0, import_token_202235.findAssociatedTokenPda)({
|
|
13708
13966
|
owner: tunaConfig.data.feeRecipient,
|
|
13709
13967
|
mint: mintA.address,
|
|
13710
13968
|
tokenProgram: mintA.programAddress
|
|
13711
13969
|
}))[0];
|
|
13712
|
-
const feeRecipientAtaB = (await (0,
|
|
13970
|
+
const feeRecipientAtaB = (await (0, import_token_202235.findAssociatedTokenPda)({
|
|
13713
13971
|
owner: tunaConfig.data.feeRecipient,
|
|
13714
13972
|
mint: mintB.address,
|
|
13715
13973
|
tokenProgram: mintB.programAddress
|
|
@@ -13725,18 +13983,18 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
13725
13983
|
);
|
|
13726
13984
|
const secondaryTickArrays = await OrcaUtils.getTickArraysForRebalancedPosition(whirlpool, tunaPosition);
|
|
13727
13985
|
const remainingAccounts = [
|
|
13728
|
-
{ address: swapTickArrays[0], role:
|
|
13729
|
-
{ address: swapTickArrays[1], role:
|
|
13730
|
-
{ address: swapTickArrays[2], role:
|
|
13731
|
-
{ address: swapTickArrays[3], role:
|
|
13732
|
-
{ address: swapTickArrays[4], role:
|
|
13733
|
-
{ address: lowerTickArrayAddress, role:
|
|
13734
|
-
{ address: upperTickArrayAddress, role:
|
|
13735
|
-
{ address: secondaryTickArrays.lowerTickArrayAddress, role:
|
|
13736
|
-
{ address: secondaryTickArrays.upperTickArrayAddress, role:
|
|
13737
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
13738
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
13739
|
-
{ address: orcaOracleAddress, role:
|
|
13986
|
+
{ address: swapTickArrays[0], role: import_kit128.AccountRole.WRITABLE },
|
|
13987
|
+
{ address: swapTickArrays[1], role: import_kit128.AccountRole.WRITABLE },
|
|
13988
|
+
{ address: swapTickArrays[2], role: import_kit128.AccountRole.WRITABLE },
|
|
13989
|
+
{ address: swapTickArrays[3], role: import_kit128.AccountRole.WRITABLE },
|
|
13990
|
+
{ address: swapTickArrays[4], role: import_kit128.AccountRole.WRITABLE },
|
|
13991
|
+
{ address: lowerTickArrayAddress, role: import_kit128.AccountRole.WRITABLE },
|
|
13992
|
+
{ address: upperTickArrayAddress, role: import_kit128.AccountRole.WRITABLE },
|
|
13993
|
+
{ address: secondaryTickArrays.lowerTickArrayAddress, role: import_kit128.AccountRole.WRITABLE },
|
|
13994
|
+
{ address: secondaryTickArrays.upperTickArrayAddress, role: import_kit128.AccountRole.WRITABLE },
|
|
13995
|
+
{ address: whirlpool.data.tokenVaultA, role: import_kit128.AccountRole.WRITABLE },
|
|
13996
|
+
{ address: whirlpool.data.tokenVaultB, role: import_kit128.AccountRole.WRITABLE },
|
|
13997
|
+
{ address: orcaOracleAddress, role: import_kit128.AccountRole.WRITABLE }
|
|
13740
13998
|
];
|
|
13741
13999
|
const remainingAccountsInfo = {
|
|
13742
14000
|
slices: [
|
|
@@ -13771,7 +14029,7 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
13771
14029
|
whirlpoolProgram: import_whirlpools_client16.WHIRLPOOL_PROGRAM_ADDRESS,
|
|
13772
14030
|
tokenProgramA: mintA.programAddress,
|
|
13773
14031
|
tokenProgramB: mintB.programAddress,
|
|
13774
|
-
memoProgram:
|
|
14032
|
+
memoProgram: import_memo24.MEMO_PROGRAM_ADDRESS,
|
|
13775
14033
|
remainingAccountsInfo
|
|
13776
14034
|
});
|
|
13777
14035
|
ix.accounts.push(...remainingAccounts);
|
|
@@ -13780,10 +14038,10 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
13780
14038
|
|
|
13781
14039
|
// src/txbuilder/rebalanceTunaLpPositionFusion.ts
|
|
13782
14040
|
var import_fusionamm_client17 = require("@crypticdot/fusionamm-client");
|
|
13783
|
-
var
|
|
14041
|
+
var import_kit129 = require("@solana/kit");
|
|
13784
14042
|
var import_sysvars4 = require("@solana/sysvars");
|
|
13785
|
-
var
|
|
13786
|
-
var
|
|
14043
|
+
var import_memo25 = require("@solana-program/memo");
|
|
14044
|
+
var import_token_202236 = require("@solana-program/token-2022");
|
|
13787
14045
|
var import_assert25 = __toESM(require("assert"));
|
|
13788
14046
|
async function rebalanceTunaLpPositionFusionInstructions(rpc, authority, positionMint, createInstructions, cleanupInstructions) {
|
|
13789
14047
|
const rent = await (0, import_sysvars4.fetchSysvarRent)(rpc);
|
|
@@ -13797,7 +14055,7 @@ async function rebalanceTunaLpPositionFusionInstructions(rpc, authority, positio
|
|
|
13797
14055
|
(await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
|
|
13798
14056
|
(await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
|
|
13799
14057
|
]);
|
|
13800
|
-
const [mintA, mintB] = await (0,
|
|
14058
|
+
const [mintA, mintB] = await (0, import_token_202236.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
13801
14059
|
(0, import_assert25.default)(mintA.exists, "Token A account not found");
|
|
13802
14060
|
(0, import_assert25.default)(mintB.exists, "Token B account not found");
|
|
13803
14061
|
const instructions = [];
|
|
@@ -13859,34 +14117,34 @@ async function rebalanceTunaLpPositionFusionInstructions(rpc, authority, positio
|
|
|
13859
14117
|
instructions.push(ix);
|
|
13860
14118
|
return {
|
|
13861
14119
|
instructions,
|
|
13862
|
-
initializationCost: (0,
|
|
14120
|
+
initializationCost: (0, import_kit129.lamports)(nonRefundableRent)
|
|
13863
14121
|
};
|
|
13864
14122
|
}
|
|
13865
14123
|
async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool) {
|
|
13866
14124
|
const positionMint = tunaPosition.data.positionMint;
|
|
13867
14125
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
13868
14126
|
const fusionPositionAddress = (await (0, import_fusionamm_client17.getPositionAddress)(positionMint))[0];
|
|
13869
|
-
const tunaPositionAta = (await (0,
|
|
14127
|
+
const tunaPositionAta = (await (0, import_token_202236.findAssociatedTokenPda)({
|
|
13870
14128
|
owner: tunaPosition.address,
|
|
13871
14129
|
mint: positionMint,
|
|
13872
|
-
tokenProgram:
|
|
14130
|
+
tokenProgram: import_token_202236.TOKEN_2022_PROGRAM_ADDRESS
|
|
13873
14131
|
}))[0];
|
|
13874
|
-
const tunaPositionAtaA = (await (0,
|
|
14132
|
+
const tunaPositionAtaA = (await (0, import_token_202236.findAssociatedTokenPda)({
|
|
13875
14133
|
owner: tunaPosition.address,
|
|
13876
14134
|
mint: mintA.address,
|
|
13877
14135
|
tokenProgram: mintA.programAddress
|
|
13878
14136
|
}))[0];
|
|
13879
|
-
const tunaPositionAtaB = (await (0,
|
|
14137
|
+
const tunaPositionAtaB = (await (0, import_token_202236.findAssociatedTokenPda)({
|
|
13880
14138
|
owner: tunaPosition.address,
|
|
13881
14139
|
mint: mintB.address,
|
|
13882
14140
|
tokenProgram: mintB.programAddress
|
|
13883
14141
|
}))[0];
|
|
13884
|
-
const feeRecipientAtaA = (await (0,
|
|
14142
|
+
const feeRecipientAtaA = (await (0, import_token_202236.findAssociatedTokenPda)({
|
|
13885
14143
|
owner: tunaConfig.data.feeRecipient,
|
|
13886
14144
|
mint: mintA.address,
|
|
13887
14145
|
tokenProgram: mintA.programAddress
|
|
13888
14146
|
}))[0];
|
|
13889
|
-
const feeRecipientAtaB = (await (0,
|
|
14147
|
+
const feeRecipientAtaB = (await (0, import_token_202236.findAssociatedTokenPda)({
|
|
13890
14148
|
owner: tunaConfig.data.feeRecipient,
|
|
13891
14149
|
mint: mintB.address,
|
|
13892
14150
|
tokenProgram: mintB.programAddress
|
|
@@ -13902,17 +14160,17 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13902
14160
|
);
|
|
13903
14161
|
const secondaryTickArrays = await FusionUtils.getTickArraysForRebalancedPosition(fusionPool, tunaPosition);
|
|
13904
14162
|
const remainingAccounts = [
|
|
13905
|
-
{ address: swapTickArrays[0], role:
|
|
13906
|
-
{ address: swapTickArrays[1], role:
|
|
13907
|
-
{ address: swapTickArrays[2], role:
|
|
13908
|
-
{ address: swapTickArrays[3], role:
|
|
13909
|
-
{ address: swapTickArrays[4], role:
|
|
13910
|
-
{ address: lowerTickArrayAddress, role:
|
|
13911
|
-
{ address: upperTickArrayAddress, role:
|
|
13912
|
-
{ address: secondaryTickArrays.lowerTickArrayAddress, role:
|
|
13913
|
-
{ address: secondaryTickArrays.upperTickArrayAddress, role:
|
|
13914
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
13915
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
14163
|
+
{ address: swapTickArrays[0], role: import_kit129.AccountRole.WRITABLE },
|
|
14164
|
+
{ address: swapTickArrays[1], role: import_kit129.AccountRole.WRITABLE },
|
|
14165
|
+
{ address: swapTickArrays[2], role: import_kit129.AccountRole.WRITABLE },
|
|
14166
|
+
{ address: swapTickArrays[3], role: import_kit129.AccountRole.WRITABLE },
|
|
14167
|
+
{ address: swapTickArrays[4], role: import_kit129.AccountRole.WRITABLE },
|
|
14168
|
+
{ address: lowerTickArrayAddress, role: import_kit129.AccountRole.WRITABLE },
|
|
14169
|
+
{ address: upperTickArrayAddress, role: import_kit129.AccountRole.WRITABLE },
|
|
14170
|
+
{ address: secondaryTickArrays.lowerTickArrayAddress, role: import_kit129.AccountRole.WRITABLE },
|
|
14171
|
+
{ address: secondaryTickArrays.upperTickArrayAddress, role: import_kit129.AccountRole.WRITABLE },
|
|
14172
|
+
{ address: fusionPool.data.tokenVaultA, role: import_kit129.AccountRole.WRITABLE },
|
|
14173
|
+
{ address: fusionPool.data.tokenVaultB, role: import_kit129.AccountRole.WRITABLE }
|
|
13916
14174
|
];
|
|
13917
14175
|
const remainingAccountsInfo = {
|
|
13918
14176
|
slices: [
|
|
@@ -13946,7 +14204,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13946
14204
|
fusionammProgram: import_fusionamm_client17.FUSIONAMM_PROGRAM_ADDRESS,
|
|
13947
14205
|
tokenProgramA: mintA.programAddress,
|
|
13948
14206
|
tokenProgramB: mintB.programAddress,
|
|
13949
|
-
memoProgram:
|
|
14207
|
+
memoProgram: import_memo25.MEMO_PROGRAM_ADDRESS,
|
|
13950
14208
|
remainingAccountsInfo
|
|
13951
14209
|
});
|
|
13952
14210
|
ix.accounts.push(...remainingAccounts);
|
|
@@ -14113,6 +14371,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
14113
14371
|
TunaPositionState,
|
|
14114
14372
|
UNLIMITED_SUPPLY_LIMIT,
|
|
14115
14373
|
UPDATE_MARKET_DISCRIMINATOR,
|
|
14374
|
+
UPDATE_MARKET_VAULTS_DISCRIMINATOR,
|
|
14116
14375
|
UPDATE_VAULT_DISCRIMINATOR,
|
|
14117
14376
|
VAULT_DISCRIMINATOR,
|
|
14118
14377
|
WITHDRAW_DISCRIMINATOR,
|
|
@@ -14472,6 +14731,11 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
14472
14731
|
getUpdateMarketInstructionDataCodec,
|
|
14473
14732
|
getUpdateMarketInstructionDataDecoder,
|
|
14474
14733
|
getUpdateMarketInstructionDataEncoder,
|
|
14734
|
+
getUpdateMarketVaultsDiscriminatorBytes,
|
|
14735
|
+
getUpdateMarketVaultsInstruction,
|
|
14736
|
+
getUpdateMarketVaultsInstructionDataCodec,
|
|
14737
|
+
getUpdateMarketVaultsInstructionDataDecoder,
|
|
14738
|
+
getUpdateMarketVaultsInstructionDataEncoder,
|
|
14475
14739
|
getUpdateVaultDiscriminatorBytes,
|
|
14476
14740
|
getUpdateVaultInstruction,
|
|
14477
14741
|
getUpdateVaultInstructionDataCodec,
|
|
@@ -14502,6 +14766,8 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
14502
14766
|
liquidateTunaLpPositionOrcaInstructions,
|
|
14503
14767
|
liquidateTunaSpotPositionFusionInstruction,
|
|
14504
14768
|
liquidateTunaSpotPositionFusionInstructions,
|
|
14769
|
+
liquidateTunaSpotPositionJupiterInstruction,
|
|
14770
|
+
liquidateTunaSpotPositionJupiterInstructions,
|
|
14505
14771
|
liquidateTunaSpotPositionOrcaInstruction,
|
|
14506
14772
|
liquidateTunaSpotPositionOrcaInstructions,
|
|
14507
14773
|
modifyTunaSpotPositionFusionInstruction,
|
|
@@ -14569,6 +14835,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
14569
14835
|
parseSetTunaLpPositionRebalanceThresholdInstruction,
|
|
14570
14836
|
parseSetTunaSpotPositionLimitOrdersInstruction,
|
|
14571
14837
|
parseUpdateMarketInstruction,
|
|
14838
|
+
parseUpdateMarketVaultsInstruction,
|
|
14572
14839
|
parseUpdateVaultInstruction,
|
|
14573
14840
|
parseWithdrawInstruction,
|
|
14574
14841
|
rebalanceTunaLpPositionFusionInstruction,
|