@crypticdot/defituna-client 3.3.4 → 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 +90 -21
- package/dist/index.d.ts +90 -21
- package/dist/index.js +703 -428
- package/dist/index.mjs +465 -190
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -107,6 +107,8 @@ __export(index_exports, {
|
|
|
107
107
|
TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED: () => TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED,
|
|
108
108
|
TUNA_ERROR__BAD_DEBT: () => TUNA_ERROR__BAD_DEBT,
|
|
109
109
|
TUNA_ERROR__INCORRECT_POSITION_DIRECTION: () => TUNA_ERROR__INCORRECT_POSITION_DIRECTION,
|
|
110
|
+
TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT: () => TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT,
|
|
111
|
+
TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT: () => TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT,
|
|
110
112
|
TUNA_ERROR__INSUFFICIENT_LIQUIDITY: () => TUNA_ERROR__INSUFFICIENT_LIQUIDITY,
|
|
111
113
|
TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT: () => TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT,
|
|
112
114
|
TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE: () => TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE,
|
|
@@ -186,6 +188,7 @@ __export(index_exports, {
|
|
|
186
188
|
TunaPositionState: () => TunaPositionState,
|
|
187
189
|
UNLIMITED_SUPPLY_LIMIT: () => UNLIMITED_SUPPLY_LIMIT,
|
|
188
190
|
UPDATE_MARKET_DISCRIMINATOR: () => UPDATE_MARKET_DISCRIMINATOR,
|
|
191
|
+
UPDATE_MARKET_VAULTS_DISCRIMINATOR: () => UPDATE_MARKET_VAULTS_DISCRIMINATOR,
|
|
189
192
|
UPDATE_VAULT_DISCRIMINATOR: () => UPDATE_VAULT_DISCRIMINATOR,
|
|
190
193
|
VAULT_DISCRIMINATOR: () => VAULT_DISCRIMINATOR,
|
|
191
194
|
WITHDRAW_DISCRIMINATOR: () => WITHDRAW_DISCRIMINATOR,
|
|
@@ -545,6 +548,11 @@ __export(index_exports, {
|
|
|
545
548
|
getUpdateMarketInstructionDataCodec: () => getUpdateMarketInstructionDataCodec,
|
|
546
549
|
getUpdateMarketInstructionDataDecoder: () => getUpdateMarketInstructionDataDecoder,
|
|
547
550
|
getUpdateMarketInstructionDataEncoder: () => getUpdateMarketInstructionDataEncoder,
|
|
551
|
+
getUpdateMarketVaultsDiscriminatorBytes: () => getUpdateMarketVaultsDiscriminatorBytes,
|
|
552
|
+
getUpdateMarketVaultsInstruction: () => getUpdateMarketVaultsInstruction,
|
|
553
|
+
getUpdateMarketVaultsInstructionDataCodec: () => getUpdateMarketVaultsInstructionDataCodec,
|
|
554
|
+
getUpdateMarketVaultsInstructionDataDecoder: () => getUpdateMarketVaultsInstructionDataDecoder,
|
|
555
|
+
getUpdateMarketVaultsInstructionDataEncoder: () => getUpdateMarketVaultsInstructionDataEncoder,
|
|
548
556
|
getUpdateVaultDiscriminatorBytes: () => getUpdateVaultDiscriminatorBytes,
|
|
549
557
|
getUpdateVaultInstruction: () => getUpdateVaultInstruction,
|
|
550
558
|
getUpdateVaultInstructionDataCodec: () => getUpdateVaultInstructionDataCodec,
|
|
@@ -575,6 +583,8 @@ __export(index_exports, {
|
|
|
575
583
|
liquidateTunaLpPositionOrcaInstructions: () => liquidateTunaLpPositionOrcaInstructions,
|
|
576
584
|
liquidateTunaSpotPositionFusionInstruction: () => liquidateTunaSpotPositionFusionInstruction,
|
|
577
585
|
liquidateTunaSpotPositionFusionInstructions: () => liquidateTunaSpotPositionFusionInstructions,
|
|
586
|
+
liquidateTunaSpotPositionJupiterInstruction: () => liquidateTunaSpotPositionJupiterInstruction,
|
|
587
|
+
liquidateTunaSpotPositionJupiterInstructions: () => liquidateTunaSpotPositionJupiterInstructions,
|
|
578
588
|
liquidateTunaSpotPositionOrcaInstruction: () => liquidateTunaSpotPositionOrcaInstruction,
|
|
579
589
|
liquidateTunaSpotPositionOrcaInstructions: () => liquidateTunaSpotPositionOrcaInstructions,
|
|
580
590
|
modifyTunaSpotPositionFusionInstruction: () => modifyTunaSpotPositionFusionInstruction,
|
|
@@ -642,6 +652,7 @@ __export(index_exports, {
|
|
|
642
652
|
parseSetTunaLpPositionRebalanceThresholdInstruction: () => parseSetTunaLpPositionRebalanceThresholdInstruction,
|
|
643
653
|
parseSetTunaSpotPositionLimitOrdersInstruction: () => parseSetTunaSpotPositionLimitOrdersInstruction,
|
|
644
654
|
parseUpdateMarketInstruction: () => parseUpdateMarketInstruction,
|
|
655
|
+
parseUpdateMarketVaultsInstruction: () => parseUpdateMarketVaultsInstruction,
|
|
645
656
|
parseUpdateVaultInstruction: () => parseUpdateVaultInstruction,
|
|
646
657
|
parseWithdrawInstruction: () => parseWithdrawInstruction,
|
|
647
658
|
rebalanceTunaLpPositionFusionInstruction: () => rebalanceTunaLpPositionFusionInstruction,
|
|
@@ -914,7 +925,9 @@ function getMarketEncoder() {
|
|
|
914
925
|
["rebalanceProtocolFee", (0, import_kit8.getU32Encoder)()],
|
|
915
926
|
["spotPositionSizeLimitA", (0, import_kit8.getU64Encoder)()],
|
|
916
927
|
["spotPositionSizeLimitB", (0, import_kit8.getU64Encoder)()],
|
|
917
|
-
["
|
|
928
|
+
["vaultA", (0, import_kit8.getAddressEncoder)()],
|
|
929
|
+
["vaultB", (0, import_kit8.getAddressEncoder)()],
|
|
930
|
+
["reserved", (0, import_kit8.fixEncoderSize)((0, import_kit8.getBytesEncoder)(), 127)]
|
|
918
931
|
]),
|
|
919
932
|
(value) => ({ ...value, discriminator: MARKET_DISCRIMINATOR })
|
|
920
933
|
);
|
|
@@ -943,7 +956,9 @@ function getMarketDecoder() {
|
|
|
943
956
|
["rebalanceProtocolFee", (0, import_kit8.getU32Decoder)()],
|
|
944
957
|
["spotPositionSizeLimitA", (0, import_kit8.getU64Decoder)()],
|
|
945
958
|
["spotPositionSizeLimitB", (0, import_kit8.getU64Decoder)()],
|
|
946
|
-
["
|
|
959
|
+
["vaultA", (0, import_kit8.getAddressDecoder)()],
|
|
960
|
+
["vaultB", (0, import_kit8.getAddressDecoder)()],
|
|
961
|
+
["reserved", (0, import_kit8.fixDecoderSize)((0, import_kit8.getBytesDecoder)(), 127)]
|
|
947
962
|
]);
|
|
948
963
|
}
|
|
949
964
|
function getMarketCodec() {
|
|
@@ -1506,8 +1521,9 @@ var TunaInstruction = /* @__PURE__ */ ((TunaInstruction2) => {
|
|
|
1506
1521
|
TunaInstruction2[TunaInstruction2["SetTunaLpPositionRebalanceThreshold"] = 45] = "SetTunaLpPositionRebalanceThreshold";
|
|
1507
1522
|
TunaInstruction2[TunaInstruction2["SetTunaSpotPositionLimitOrders"] = 46] = "SetTunaSpotPositionLimitOrders";
|
|
1508
1523
|
TunaInstruction2[TunaInstruction2["UpdateMarket"] = 47] = "UpdateMarket";
|
|
1509
|
-
TunaInstruction2[TunaInstruction2["
|
|
1510
|
-
TunaInstruction2[TunaInstruction2["
|
|
1524
|
+
TunaInstruction2[TunaInstruction2["UpdateMarketVaults"] = 48] = "UpdateMarketVaults";
|
|
1525
|
+
TunaInstruction2[TunaInstruction2["UpdateVault"] = 49] = "UpdateVault";
|
|
1526
|
+
TunaInstruction2[TunaInstruction2["Withdraw"] = 50] = "Withdraw";
|
|
1511
1527
|
return TunaInstruction2;
|
|
1512
1528
|
})(TunaInstruction || {});
|
|
1513
1529
|
function identifyTunaInstruction(instruction) {
|
|
@@ -1944,6 +1960,15 @@ function identifyTunaInstruction(instruction) {
|
|
|
1944
1960
|
)) {
|
|
1945
1961
|
return 47 /* UpdateMarket */;
|
|
1946
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
|
+
}
|
|
1947
1972
|
if ((0, import_kit13.containsBytes)(
|
|
1948
1973
|
data,
|
|
1949
1974
|
(0, import_kit13.fixEncoderSize)((0, import_kit13.getBytesEncoder)(), 8).encode(
|
|
@@ -1951,7 +1976,7 @@ function identifyTunaInstruction(instruction) {
|
|
|
1951
1976
|
),
|
|
1952
1977
|
0
|
|
1953
1978
|
)) {
|
|
1954
|
-
return
|
|
1979
|
+
return 49 /* UpdateVault */;
|
|
1955
1980
|
}
|
|
1956
1981
|
if ((0, import_kit13.containsBytes)(
|
|
1957
1982
|
data,
|
|
@@ -1960,7 +1985,7 @@ function identifyTunaInstruction(instruction) {
|
|
|
1960
1985
|
),
|
|
1961
1986
|
0
|
|
1962
1987
|
)) {
|
|
1963
|
-
return
|
|
1988
|
+
return 50 /* Withdraw */;
|
|
1964
1989
|
}
|
|
1965
1990
|
throw new Error(
|
|
1966
1991
|
"The provided instruction could not be identified as a tuna instruction."
|
|
@@ -2032,10 +2057,12 @@ var TUNA_ERROR__M_A_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 6060;
|
|
|
2032
2057
|
var TUNA_ERROR__POSITION_SIZE_LIMIT_EXCEEDED = 6061;
|
|
2033
2058
|
var TUNA_ERROR__INVALID_JUPITER_ROUTE = 6062;
|
|
2034
2059
|
var TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT = 6063;
|
|
2035
|
-
var
|
|
2036
|
-
var
|
|
2037
|
-
var
|
|
2038
|
-
var
|
|
2060
|
+
var TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT = 6064;
|
|
2061
|
+
var TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT = 6065;
|
|
2062
|
+
var TUNA_ERROR__ACCOUNT_NOT_INITIALIZED = 6066;
|
|
2063
|
+
var TUNA_ERROR__INVALID_ACCOUNT_DISCRIMINATOR = 6067;
|
|
2064
|
+
var TUNA_ERROR__INVALID_POOL = 6068;
|
|
2065
|
+
var TUNA_ERROR__POSITION_IS_EMPTY = 6069;
|
|
2039
2066
|
var tunaErrorMessages;
|
|
2040
2067
|
if (process.env.NODE_ENV !== "production") {
|
|
2041
2068
|
tunaErrorMessages = {
|
|
@@ -2043,6 +2070,8 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
2043
2070
|
[TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED]: `Amount slippage exceeded`,
|
|
2044
2071
|
[TUNA_ERROR__BAD_DEBT]: `Bad debt is not allowed for the executed instruction`,
|
|
2045
2072
|
[TUNA_ERROR__INCORRECT_POSITION_DIRECTION]: `Incorrect position direction`,
|
|
2073
|
+
[TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT]: `Incorrect swap input amount`,
|
|
2074
|
+
[TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT]: `Incorrect swap output amount`,
|
|
2046
2075
|
[TUNA_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
|
|
2047
2076
|
[TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT]: `Insufficient swap output amount`,
|
|
2048
2077
|
[TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE]: `Interest rate is out of range`,
|
|
@@ -3284,7 +3313,6 @@ function getCreateMarketInstructionDataEncoder() {
|
|
|
3284
3313
|
return (0, import_kit24.transformEncoder)(
|
|
3285
3314
|
(0, import_kit24.getStructEncoder)([
|
|
3286
3315
|
["discriminator", (0, import_kit24.fixEncoderSize)((0, import_kit24.getBytesEncoder)(), 8)],
|
|
3287
|
-
["marketMaker", getMarketMakerEncoder()],
|
|
3288
3316
|
["addressLookupTable", (0, import_kit24.getAddressEncoder)()],
|
|
3289
3317
|
["maxLeverage", (0, import_kit24.getU32Encoder)()],
|
|
3290
3318
|
["protocolFee", (0, import_kit24.getU16Encoder)()],
|
|
@@ -3307,7 +3335,6 @@ function getCreateMarketInstructionDataEncoder() {
|
|
|
3307
3335
|
function getCreateMarketInstructionDataDecoder() {
|
|
3308
3336
|
return (0, import_kit24.getStructDecoder)([
|
|
3309
3337
|
["discriminator", (0, import_kit24.fixDecoderSize)((0, import_kit24.getBytesDecoder)(), 8)],
|
|
3310
|
-
["marketMaker", getMarketMakerDecoder()],
|
|
3311
3338
|
["addressLookupTable", (0, import_kit24.getAddressDecoder)()],
|
|
3312
3339
|
["maxLeverage", (0, import_kit24.getU32Decoder)()],
|
|
3313
3340
|
["protocolFee", (0, import_kit24.getU16Decoder)()],
|
|
@@ -3337,6 +3364,8 @@ function getCreateMarketInstruction(input, config) {
|
|
|
3337
3364
|
authority: { value: input.authority ?? null, isWritable: true },
|
|
3338
3365
|
tunaConfig: { value: input.tunaConfig ?? null, isWritable: false },
|
|
3339
3366
|
market: { value: input.market ?? null, isWritable: true },
|
|
3367
|
+
vaultA: { value: input.vaultA ?? null, isWritable: false },
|
|
3368
|
+
vaultB: { value: input.vaultB ?? null, isWritable: false },
|
|
3340
3369
|
pool: { value: input.pool ?? null, isWritable: false },
|
|
3341
3370
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
3342
3371
|
};
|
|
@@ -3351,6 +3380,8 @@ function getCreateMarketInstruction(input, config) {
|
|
|
3351
3380
|
getAccountMeta(accounts.authority),
|
|
3352
3381
|
getAccountMeta(accounts.tunaConfig),
|
|
3353
3382
|
getAccountMeta(accounts.market),
|
|
3383
|
+
getAccountMeta(accounts.vaultA),
|
|
3384
|
+
getAccountMeta(accounts.vaultB),
|
|
3354
3385
|
getAccountMeta(accounts.pool),
|
|
3355
3386
|
getAccountMeta(accounts.systemProgram)
|
|
3356
3387
|
],
|
|
@@ -3362,7 +3393,7 @@ function getCreateMarketInstruction(input, config) {
|
|
|
3362
3393
|
return instruction;
|
|
3363
3394
|
}
|
|
3364
3395
|
function parseCreateMarketInstruction(instruction) {
|
|
3365
|
-
if (instruction.accounts.length <
|
|
3396
|
+
if (instruction.accounts.length < 7) {
|
|
3366
3397
|
throw new Error("Not enough accounts");
|
|
3367
3398
|
}
|
|
3368
3399
|
let accountIndex = 0;
|
|
@@ -3377,6 +3408,8 @@ function parseCreateMarketInstruction(instruction) {
|
|
|
3377
3408
|
authority: getNextAccount(),
|
|
3378
3409
|
tunaConfig: getNextAccount(),
|
|
3379
3410
|
market: getNextAccount(),
|
|
3411
|
+
vaultA: getNextAccount(),
|
|
3412
|
+
vaultB: getNextAccount(),
|
|
3380
3413
|
pool: getNextAccount(),
|
|
3381
3414
|
systemProgram: getNextAccount()
|
|
3382
3415
|
},
|
|
@@ -8677,8 +8710,94 @@ function parseUpdateMarketInstruction(instruction) {
|
|
|
8677
8710
|
};
|
|
8678
8711
|
}
|
|
8679
8712
|
|
|
8680
|
-
// src/generated/instructions/
|
|
8713
|
+
// src/generated/instructions/updateMarketVaults.ts
|
|
8681
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");
|
|
8682
8801
|
var UPDATE_VAULT_DISCRIMINATOR = new Uint8Array([
|
|
8683
8802
|
67,
|
|
8684
8803
|
229,
|
|
@@ -8690,33 +8809,33 @@ var UPDATE_VAULT_DISCRIMINATOR = new Uint8Array([
|
|
|
8690
8809
|
60
|
|
8691
8810
|
]);
|
|
8692
8811
|
function getUpdateVaultDiscriminatorBytes() {
|
|
8693
|
-
return (0,
|
|
8812
|
+
return (0, import_kit65.fixEncoderSize)((0, import_kit65.getBytesEncoder)(), 8).encode(
|
|
8694
8813
|
UPDATE_VAULT_DISCRIMINATOR
|
|
8695
8814
|
);
|
|
8696
8815
|
}
|
|
8697
8816
|
function getUpdateVaultInstructionDataEncoder() {
|
|
8698
|
-
return (0,
|
|
8699
|
-
(0,
|
|
8700
|
-
["discriminator", (0,
|
|
8701
|
-
["interestRate", (0,
|
|
8702
|
-
["supplyLimit", (0,
|
|
8703
|
-
["pythOraclePriceUpdate", (0,
|
|
8704
|
-
["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)()]
|
|
8705
8824
|
]),
|
|
8706
8825
|
(value) => ({ ...value, discriminator: UPDATE_VAULT_DISCRIMINATOR })
|
|
8707
8826
|
);
|
|
8708
8827
|
}
|
|
8709
8828
|
function getUpdateVaultInstructionDataDecoder() {
|
|
8710
|
-
return (0,
|
|
8711
|
-
["discriminator", (0,
|
|
8712
|
-
["interestRate", (0,
|
|
8713
|
-
["supplyLimit", (0,
|
|
8714
|
-
["pythOraclePriceUpdate", (0,
|
|
8715
|
-
["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)()]
|
|
8716
8835
|
]);
|
|
8717
8836
|
}
|
|
8718
8837
|
function getUpdateVaultInstructionDataCodec() {
|
|
8719
|
-
return (0,
|
|
8838
|
+
return (0, import_kit65.combineCodec)(
|
|
8720
8839
|
getUpdateVaultInstructionDataEncoder(),
|
|
8721
8840
|
getUpdateVaultInstructionDataDecoder()
|
|
8722
8841
|
);
|
|
@@ -8766,7 +8885,7 @@ function parseUpdateVaultInstruction(instruction) {
|
|
|
8766
8885
|
}
|
|
8767
8886
|
|
|
8768
8887
|
// src/generated/instructions/withdraw.ts
|
|
8769
|
-
var
|
|
8888
|
+
var import_kit66 = require("@solana/kit");
|
|
8770
8889
|
var WITHDRAW_DISCRIMINATOR = new Uint8Array([
|
|
8771
8890
|
183,
|
|
8772
8891
|
18,
|
|
@@ -8778,27 +8897,27 @@ var WITHDRAW_DISCRIMINATOR = new Uint8Array([
|
|
|
8778
8897
|
34
|
|
8779
8898
|
]);
|
|
8780
8899
|
function getWithdrawDiscriminatorBytes() {
|
|
8781
|
-
return (0,
|
|
8900
|
+
return (0, import_kit66.fixEncoderSize)((0, import_kit66.getBytesEncoder)(), 8).encode(WITHDRAW_DISCRIMINATOR);
|
|
8782
8901
|
}
|
|
8783
8902
|
function getWithdrawInstructionDataEncoder() {
|
|
8784
|
-
return (0,
|
|
8785
|
-
(0,
|
|
8786
|
-
["discriminator", (0,
|
|
8787
|
-
["funds", (0,
|
|
8788
|
-
["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)()]
|
|
8789
8908
|
]),
|
|
8790
8909
|
(value) => ({ ...value, discriminator: WITHDRAW_DISCRIMINATOR })
|
|
8791
8910
|
);
|
|
8792
8911
|
}
|
|
8793
8912
|
function getWithdrawInstructionDataDecoder() {
|
|
8794
|
-
return (0,
|
|
8795
|
-
["discriminator", (0,
|
|
8796
|
-
["funds", (0,
|
|
8797
|
-
["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)()]
|
|
8798
8917
|
]);
|
|
8799
8918
|
}
|
|
8800
8919
|
function getWithdrawInstructionDataCodec() {
|
|
8801
|
-
return (0,
|
|
8920
|
+
return (0, import_kit66.combineCodec)(
|
|
8802
8921
|
getWithdrawInstructionDataEncoder(),
|
|
8803
8922
|
getWithdrawInstructionDataDecoder()
|
|
8804
8923
|
);
|
|
@@ -8869,11 +8988,11 @@ function parseWithdrawInstruction(instruction) {
|
|
|
8869
8988
|
}
|
|
8870
8989
|
|
|
8871
8990
|
// src/pda.ts
|
|
8872
|
-
var
|
|
8991
|
+
var import_kit68 = require("@solana/kit");
|
|
8873
8992
|
|
|
8874
8993
|
// src/consts.ts
|
|
8875
|
-
var
|
|
8876
|
-
var DEFAULT_ADDRESS = (0,
|
|
8994
|
+
var import_kit67 = require("@solana/kit");
|
|
8995
|
+
var DEFAULT_ADDRESS = (0, import_kit67.address)("11111111111111111111111111111111");
|
|
8877
8996
|
var HUNDRED_PERCENT = 1e6;
|
|
8878
8997
|
var HUNDRED_PERCENTn = 1000000n;
|
|
8879
8998
|
var LEVERAGE_ONE = HUNDRED_PERCENT;
|
|
@@ -8894,48 +9013,48 @@ var TUNA_POSITION_FLAGS_UPPER_LIMIT_ORDER_SWAP_TO_TOKEN_B = 1 << 3;
|
|
|
8894
9013
|
var TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD = 1 << 4;
|
|
8895
9014
|
var TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD_WITH_LEVERAGE = 1 << 5;
|
|
8896
9015
|
var TUNA_POSITION_FLAGS_ALLOW_REBALANCING = 1 << 6;
|
|
8897
|
-
var WP_NFT_UPDATE_AUTH = (0,
|
|
8898
|
-
var DEFAULT_PUSH_ORACLE_PROGRAM_ID = (0,
|
|
8899
|
-
var JUPITER_EVENT_AUTHORITY = (0,
|
|
8900
|
-
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");
|
|
8901
9020
|
var MIN_SQRT_PRICE = 4295048016n;
|
|
8902
9021
|
var MAX_SQRT_PRICE = 79226673515401279992447579055n;
|
|
8903
9022
|
|
|
8904
9023
|
// src/pda.ts
|
|
8905
9024
|
async function getTunaConfigAddress() {
|
|
8906
|
-
return await (0,
|
|
9025
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8907
9026
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8908
9027
|
seeds: ["tuna_config"]
|
|
8909
9028
|
});
|
|
8910
9029
|
}
|
|
8911
9030
|
async function getMarketAddress(pool) {
|
|
8912
|
-
return await (0,
|
|
9031
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8913
9032
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8914
|
-
seeds: ["market", (0,
|
|
9033
|
+
seeds: ["market", (0, import_kit68.getAddressEncoder)().encode(pool)]
|
|
8915
9034
|
});
|
|
8916
9035
|
}
|
|
8917
9036
|
async function getLendingVaultAddress(mint) {
|
|
8918
|
-
return await (0,
|
|
9037
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8919
9038
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8920
|
-
seeds: ["vault", (0,
|
|
9039
|
+
seeds: ["vault", (0, import_kit68.getAddressEncoder)().encode(mint)]
|
|
8921
9040
|
});
|
|
8922
9041
|
}
|
|
8923
9042
|
async function getLendingPositionAddress(authority, mint) {
|
|
8924
|
-
return await (0,
|
|
9043
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8925
9044
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8926
|
-
seeds: ["lending_position", (0,
|
|
9045
|
+
seeds: ["lending_position", (0, import_kit68.getAddressEncoder)().encode(authority), (0, import_kit68.getAddressEncoder)().encode(mint)]
|
|
8927
9046
|
});
|
|
8928
9047
|
}
|
|
8929
9048
|
async function getTunaLpPositionAddress(positionMint) {
|
|
8930
|
-
return await (0,
|
|
9049
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8931
9050
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8932
|
-
seeds: ["tuna_position", (0,
|
|
9051
|
+
seeds: ["tuna_position", (0, import_kit68.getAddressEncoder)().encode(positionMint)]
|
|
8933
9052
|
});
|
|
8934
9053
|
}
|
|
8935
9054
|
async function getTunaSpotPositionAddress(authority, pool) {
|
|
8936
|
-
return await (0,
|
|
9055
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8937
9056
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
8938
|
-
seeds: ["tuna_spot_position", (0,
|
|
9057
|
+
seeds: ["tuna_spot_position", (0, import_kit68.getAddressEncoder)().encode(authority), (0, import_kit68.getAddressEncoder)().encode(pool)]
|
|
8939
9058
|
});
|
|
8940
9059
|
}
|
|
8941
9060
|
async function getPythPriceUpdateAccountAddress(shardId, priceFeedId) {
|
|
@@ -8951,23 +9070,23 @@ async function getPythPriceUpdateAccountAddress(shardId, priceFeedId) {
|
|
|
8951
9070
|
}
|
|
8952
9071
|
const shardBuffer = Buffer.alloc(2);
|
|
8953
9072
|
shardBuffer.writeUint16LE(shardId, 0);
|
|
8954
|
-
return await (0,
|
|
9073
|
+
return await (0, import_kit68.getProgramDerivedAddress)({
|
|
8955
9074
|
programAddress: DEFAULT_PUSH_ORACLE_PROGRAM_ID,
|
|
8956
9075
|
seeds: [shardBuffer, priceFeedId]
|
|
8957
9076
|
});
|
|
8958
9077
|
}
|
|
8959
9078
|
|
|
8960
9079
|
// src/gpa/tunaLpPosition.ts
|
|
8961
|
-
var
|
|
9080
|
+
var import_kit70 = require("@solana/kit");
|
|
8962
9081
|
|
|
8963
9082
|
// src/gpa/utils.ts
|
|
8964
|
-
var
|
|
9083
|
+
var import_kit69 = require("@solana/kit");
|
|
8965
9084
|
async function fetchDecodedProgramAccounts(rpc, programAddress, filters, decoder) {
|
|
8966
9085
|
const accountInfos = await rpc.getProgramAccounts(programAddress, {
|
|
8967
9086
|
encoding: "base64",
|
|
8968
9087
|
filters
|
|
8969
9088
|
}).send();
|
|
8970
|
-
const encoder = (0,
|
|
9089
|
+
const encoder = (0, import_kit69.getBase64Encoder)();
|
|
8971
9090
|
const datas = accountInfos.map((x) => encoder.encode(x.account.data[0]));
|
|
8972
9091
|
const decoded = datas.map((x) => decoder.decode(x));
|
|
8973
9092
|
return decoded.map((data, i) => ({
|
|
@@ -8983,7 +9102,7 @@ function tunaLpPositionAuthorityFilter(address4) {
|
|
|
8983
9102
|
return {
|
|
8984
9103
|
memcmp: {
|
|
8985
9104
|
offset: 11n,
|
|
8986
|
-
bytes: (0,
|
|
9105
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getAddressEncoder)().encode(address4)),
|
|
8987
9106
|
encoding: "base58"
|
|
8988
9107
|
}
|
|
8989
9108
|
};
|
|
@@ -8992,7 +9111,7 @@ function tunaLpPositionPoolFilter(address4) {
|
|
|
8992
9111
|
return {
|
|
8993
9112
|
memcmp: {
|
|
8994
9113
|
offset: 43n,
|
|
8995
|
-
bytes: (0,
|
|
9114
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getAddressEncoder)().encode(address4)),
|
|
8996
9115
|
encoding: "base58"
|
|
8997
9116
|
}
|
|
8998
9117
|
};
|
|
@@ -9001,7 +9120,7 @@ function tunaLpPositionMintAFilter(address4) {
|
|
|
9001
9120
|
return {
|
|
9002
9121
|
memcmp: {
|
|
9003
9122
|
offset: 75n,
|
|
9004
|
-
bytes: (0,
|
|
9123
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getAddressEncoder)().encode(address4)),
|
|
9005
9124
|
encoding: "base58"
|
|
9006
9125
|
}
|
|
9007
9126
|
};
|
|
@@ -9010,7 +9129,7 @@ function tunaLpPositionMintBFilter(address4) {
|
|
|
9010
9129
|
return {
|
|
9011
9130
|
memcmp: {
|
|
9012
9131
|
offset: 107n,
|
|
9013
|
-
bytes: (0,
|
|
9132
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getAddressEncoder)().encode(address4)),
|
|
9014
9133
|
encoding: "base58"
|
|
9015
9134
|
}
|
|
9016
9135
|
};
|
|
@@ -9019,7 +9138,7 @@ function tunaLpPositionMintFilter(address4) {
|
|
|
9019
9138
|
return {
|
|
9020
9139
|
memcmp: {
|
|
9021
9140
|
offset: 139n,
|
|
9022
|
-
bytes: (0,
|
|
9141
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getAddressEncoder)().encode(address4)),
|
|
9023
9142
|
encoding: "base58"
|
|
9024
9143
|
}
|
|
9025
9144
|
};
|
|
@@ -9028,13 +9147,13 @@ function tunaLpPositionMarketMakerFilter(marketMaker) {
|
|
|
9028
9147
|
return {
|
|
9029
9148
|
memcmp: {
|
|
9030
9149
|
offset: 277n,
|
|
9031
|
-
bytes: (0,
|
|
9150
|
+
bytes: (0, import_kit70.getBase58Decoder)().decode((0, import_kit70.getI8Encoder)().encode(marketMaker)),
|
|
9032
9151
|
encoding: "base58"
|
|
9033
9152
|
}
|
|
9034
9153
|
};
|
|
9035
9154
|
}
|
|
9036
9155
|
async function fetchAllTunaLpPositionWithFilter(rpc, ...filters) {
|
|
9037
|
-
const discriminator = (0,
|
|
9156
|
+
const discriminator = (0, import_kit70.getBase58Decoder)().decode(TUNA_LP_POSITION_DISCRIMINATOR);
|
|
9038
9157
|
const discriminatorFilter = {
|
|
9039
9158
|
memcmp: {
|
|
9040
9159
|
offset: 0n,
|
|
@@ -9051,12 +9170,12 @@ async function fetchAllTunaLpPositionWithFilter(rpc, ...filters) {
|
|
|
9051
9170
|
}
|
|
9052
9171
|
|
|
9053
9172
|
// src/gpa/tunaSpotPosition.ts
|
|
9054
|
-
var
|
|
9173
|
+
var import_kit71 = require("@solana/kit");
|
|
9055
9174
|
function tunaSpotPositionAuthorityFilter(address4) {
|
|
9056
9175
|
return {
|
|
9057
9176
|
memcmp: {
|
|
9058
9177
|
offset: 11n,
|
|
9059
|
-
bytes: (0,
|
|
9178
|
+
bytes: (0, import_kit71.getBase58Decoder)().decode((0, import_kit71.getAddressEncoder)().encode(address4)),
|
|
9060
9179
|
encoding: "base58"
|
|
9061
9180
|
}
|
|
9062
9181
|
};
|
|
@@ -9065,7 +9184,7 @@ function tunaSpotPositionPoolFilter(address4) {
|
|
|
9065
9184
|
return {
|
|
9066
9185
|
memcmp: {
|
|
9067
9186
|
offset: 43n,
|
|
9068
|
-
bytes: (0,
|
|
9187
|
+
bytes: (0, import_kit71.getBase58Decoder)().decode((0, import_kit71.getAddressEncoder)().encode(address4)),
|
|
9069
9188
|
encoding: "base58"
|
|
9070
9189
|
}
|
|
9071
9190
|
};
|
|
@@ -9074,7 +9193,7 @@ function tunaSpotPositionMintAFilter(address4) {
|
|
|
9074
9193
|
return {
|
|
9075
9194
|
memcmp: {
|
|
9076
9195
|
offset: 75n,
|
|
9077
|
-
bytes: (0,
|
|
9196
|
+
bytes: (0, import_kit71.getBase58Decoder)().decode((0, import_kit71.getAddressEncoder)().encode(address4)),
|
|
9078
9197
|
encoding: "base58"
|
|
9079
9198
|
}
|
|
9080
9199
|
};
|
|
@@ -9083,13 +9202,13 @@ function tunaSpotPositionMintBFilter(address4) {
|
|
|
9083
9202
|
return {
|
|
9084
9203
|
memcmp: {
|
|
9085
9204
|
offset: 107n,
|
|
9086
|
-
bytes: (0,
|
|
9205
|
+
bytes: (0, import_kit71.getBase58Decoder)().decode((0, import_kit71.getAddressEncoder)().encode(address4)),
|
|
9087
9206
|
encoding: "base58"
|
|
9088
9207
|
}
|
|
9089
9208
|
};
|
|
9090
9209
|
}
|
|
9091
9210
|
async function fetchAllTunaSpotPositionWithFilter(rpc, ...filters) {
|
|
9092
|
-
const discriminator = (0,
|
|
9211
|
+
const discriminator = (0, import_kit71.getBase58Decoder)().decode(TUNA_SPOT_POSITION_DISCRIMINATOR);
|
|
9093
9212
|
const discriminatorFilter = {
|
|
9094
9213
|
memcmp: {
|
|
9095
9214
|
offset: 0n,
|
|
@@ -9106,12 +9225,12 @@ async function fetchAllTunaSpotPositionWithFilter(rpc, ...filters) {
|
|
|
9106
9225
|
}
|
|
9107
9226
|
|
|
9108
9227
|
// src/gpa/lendingPosition.ts
|
|
9109
|
-
var
|
|
9228
|
+
var import_kit72 = require("@solana/kit");
|
|
9110
9229
|
function lendingPositionAuthorityFilter(address4) {
|
|
9111
9230
|
return {
|
|
9112
9231
|
memcmp: {
|
|
9113
9232
|
offset: 11n,
|
|
9114
|
-
bytes: (0,
|
|
9233
|
+
bytes: (0, import_kit72.getBase58Decoder)().decode((0, import_kit72.getAddressEncoder)().encode(address4)),
|
|
9115
9234
|
encoding: "base58"
|
|
9116
9235
|
}
|
|
9117
9236
|
};
|
|
@@ -9120,13 +9239,13 @@ function lendingPositionMintFilter(address4) {
|
|
|
9120
9239
|
return {
|
|
9121
9240
|
memcmp: {
|
|
9122
9241
|
offset: 43n,
|
|
9123
|
-
bytes: (0,
|
|
9242
|
+
bytes: (0, import_kit72.getBase58Decoder)().decode((0, import_kit72.getAddressEncoder)().encode(address4)),
|
|
9124
9243
|
encoding: "base58"
|
|
9125
9244
|
}
|
|
9126
9245
|
};
|
|
9127
9246
|
}
|
|
9128
9247
|
async function fetchAllLendingPositionWithFilter(rpc, ...filters) {
|
|
9129
|
-
const discriminator = (0,
|
|
9248
|
+
const discriminator = (0, import_kit72.getBase58Decoder)().decode(LENDING_POSITION_DISCRIMINATOR);
|
|
9130
9249
|
const discriminatorFilter = {
|
|
9131
9250
|
memcmp: {
|
|
9132
9251
|
offset: 0n,
|
|
@@ -9143,9 +9262,9 @@ async function fetchAllLendingPositionWithFilter(rpc, ...filters) {
|
|
|
9143
9262
|
}
|
|
9144
9263
|
|
|
9145
9264
|
// src/gpa/market.ts
|
|
9146
|
-
var
|
|
9265
|
+
var import_kit73 = require("@solana/kit");
|
|
9147
9266
|
async function fetchAllMarketWithFilter(rpc, ...filters) {
|
|
9148
|
-
const discriminator = (0,
|
|
9267
|
+
const discriminator = (0, import_kit73.getBase58Decoder)().decode(MARKET_DISCRIMINATOR);
|
|
9149
9268
|
const discriminatorFilter = {
|
|
9150
9269
|
memcmp: {
|
|
9151
9270
|
offset: 0n,
|
|
@@ -9247,11 +9366,11 @@ var FusionUtils = class {
|
|
|
9247
9366
|
};
|
|
9248
9367
|
|
|
9249
9368
|
// src/utils/token.ts
|
|
9250
|
-
var
|
|
9369
|
+
var import_kit74 = require("@solana/kit");
|
|
9251
9370
|
var import_system = require("@solana-program/system");
|
|
9252
9371
|
var import_token = require("@solana-program/token");
|
|
9253
9372
|
var import_token_2022 = require("@solana-program/token-2022");
|
|
9254
|
-
var NATIVE_MINT = (0,
|
|
9373
|
+
var NATIVE_MINT = (0, import_kit74.address)("So11111111111111111111111111111111111111112");
|
|
9255
9374
|
async function getCreateAtaInstruction(mint, owner, payer, tokenProgram = import_token.TOKEN_PROGRAM_ADDRESS) {
|
|
9256
9375
|
const ata = (await (0, import_token.findAssociatedTokenPda)({
|
|
9257
9376
|
mint,
|
|
@@ -9438,7 +9557,7 @@ function calculateProtocolFee(collateralAmount, borrowAmount, protocolFeeRateOnC
|
|
|
9438
9557
|
// src/txbuilder/increaseTunaLpPositionOrca.ts
|
|
9439
9558
|
var import_whirlpools_client2 = require("@orca-so/whirlpools-client");
|
|
9440
9559
|
var import_whirlpools_core2 = require("@orca-so/whirlpools-core");
|
|
9441
|
-
var
|
|
9560
|
+
var import_kit75 = require("@solana/kit");
|
|
9442
9561
|
var import_memo = require("@solana-program/memo");
|
|
9443
9562
|
var import_token_20222 = require("@solana-program/token-2022");
|
|
9444
9563
|
var import_assert = __toESM(require("assert"));
|
|
@@ -9612,16 +9731,16 @@ async function increaseTunaLpPositionOrcaInstruction(authority, tunaPosition, tu
|
|
|
9612
9731
|
tunaPosition.data.tickUpperIndex
|
|
9613
9732
|
);
|
|
9614
9733
|
const remainingAccounts = [
|
|
9615
|
-
{ address: swapTickArrays[0], role:
|
|
9616
|
-
{ address: swapTickArrays[1], role:
|
|
9617
|
-
{ address: swapTickArrays[2], role:
|
|
9618
|
-
{ address: swapTickArrays[3], role:
|
|
9619
|
-
{ address: swapTickArrays[4], role:
|
|
9620
|
-
{ address: lowerTickArrayAddress, role:
|
|
9621
|
-
{ address: upperTickArrayAddress, role:
|
|
9622
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
9623
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
9624
|
-
{ 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 }
|
|
9625
9744
|
];
|
|
9626
9745
|
const remainingAccountsInfo = {
|
|
9627
9746
|
slices: [
|
|
@@ -9669,7 +9788,7 @@ async function increaseTunaLpPositionOrcaInstruction(authority, tunaPosition, tu
|
|
|
9669
9788
|
// src/txbuilder/increaseTunaLpPositionFusion.ts
|
|
9670
9789
|
var import_fusionamm_client2 = require("@crypticdot/fusionamm-client");
|
|
9671
9790
|
var import_fusionamm_core4 = require("@crypticdot/fusionamm-core");
|
|
9672
|
-
var
|
|
9791
|
+
var import_kit76 = require("@solana/kit");
|
|
9673
9792
|
var import_memo2 = require("@solana-program/memo");
|
|
9674
9793
|
var import_token_20223 = require("@solana-program/token-2022");
|
|
9675
9794
|
var import_assert2 = __toESM(require("assert"));
|
|
@@ -9848,15 +9967,15 @@ async function increaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
9848
9967
|
tunaPosition.data.tickUpperIndex
|
|
9849
9968
|
);
|
|
9850
9969
|
const remainingAccounts = [
|
|
9851
|
-
{ address: swapTickArrays[0], role:
|
|
9852
|
-
{ address: swapTickArrays[1], role:
|
|
9853
|
-
{ address: swapTickArrays[2], role:
|
|
9854
|
-
{ address: swapTickArrays[3], role:
|
|
9855
|
-
{ address: swapTickArrays[4], role:
|
|
9856
|
-
{ address: lowerTickArrayAddress, role:
|
|
9857
|
-
{ address: upperTickArrayAddress, role:
|
|
9858
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
9859
|
-
{ 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 }
|
|
9860
9979
|
];
|
|
9861
9980
|
const remainingAccountsInfo = {
|
|
9862
9981
|
slices: [
|
|
@@ -9994,7 +10113,7 @@ async function closeTunaLpPositionFusionInstruction(rpc, authority, positionMint
|
|
|
9994
10113
|
|
|
9995
10114
|
// src/txbuilder/collectAndCompoundFeesOrca.ts
|
|
9996
10115
|
var import_whirlpools_client4 = require("@orca-so/whirlpools-client");
|
|
9997
|
-
var
|
|
10116
|
+
var import_kit77 = require("@solana/kit");
|
|
9998
10117
|
var import_memo3 = require("@solana-program/memo");
|
|
9999
10118
|
var import_token_20226 = require("@solana-program/token-2022");
|
|
10000
10119
|
var import_assert5 = __toESM(require("assert"));
|
|
@@ -10092,16 +10211,16 @@ async function collectAndCompoundFeesOrcaInstruction(authority, tunaConfig, tuna
|
|
|
10092
10211
|
tunaPosition.data.tickUpperIndex
|
|
10093
10212
|
);
|
|
10094
10213
|
const remainingAccounts = [
|
|
10095
|
-
{ address: swapTickArrays[0], role:
|
|
10096
|
-
{ address: swapTickArrays[1], role:
|
|
10097
|
-
{ address: swapTickArrays[2], role:
|
|
10098
|
-
{ address: swapTickArrays[3], role:
|
|
10099
|
-
{ address: swapTickArrays[4], role:
|
|
10100
|
-
{ address: lowerTickArrayAddress, role:
|
|
10101
|
-
{ address: upperTickArrayAddress, role:
|
|
10102
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
10103
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
10104
|
-
{ 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 }
|
|
10105
10224
|
];
|
|
10106
10225
|
const remainingAccountsInfo = {
|
|
10107
10226
|
slices: [
|
|
@@ -10146,7 +10265,7 @@ async function collectAndCompoundFeesOrcaInstruction(authority, tunaConfig, tuna
|
|
|
10146
10265
|
|
|
10147
10266
|
// src/txbuilder/collectAndCompoundFeesFusion.ts
|
|
10148
10267
|
var import_fusionamm_client4 = require("@crypticdot/fusionamm-client");
|
|
10149
|
-
var
|
|
10268
|
+
var import_kit78 = require("@solana/kit");
|
|
10150
10269
|
var import_memo4 = require("@solana-program/memo");
|
|
10151
10270
|
var import_token_20227 = require("@solana-program/token-2022");
|
|
10152
10271
|
var import_assert6 = __toESM(require("assert"));
|
|
@@ -10243,15 +10362,15 @@ async function collectAndCompoundFeesFusionInstruction(authority, tunaConfig, tu
|
|
|
10243
10362
|
tunaPosition.data.tickUpperIndex
|
|
10244
10363
|
);
|
|
10245
10364
|
const remainingAccounts = [
|
|
10246
|
-
{ address: swapTickArrays[0], role:
|
|
10247
|
-
{ address: swapTickArrays[1], role:
|
|
10248
|
-
{ address: swapTickArrays[2], role:
|
|
10249
|
-
{ address: swapTickArrays[3], role:
|
|
10250
|
-
{ address: swapTickArrays[4], role:
|
|
10251
|
-
{ address: lowerTickArrayAddress, role:
|
|
10252
|
-
{ address: upperTickArrayAddress, role:
|
|
10253
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
10254
|
-
{ 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 }
|
|
10255
10374
|
];
|
|
10256
10375
|
const remainingAccountsInfo = {
|
|
10257
10376
|
slices: [
|
|
@@ -10295,7 +10414,7 @@ async function collectAndCompoundFeesFusionInstruction(authority, tunaConfig, tu
|
|
|
10295
10414
|
|
|
10296
10415
|
// src/txbuilder/collectFeesOrca.ts
|
|
10297
10416
|
var import_whirlpools_client5 = require("@orca-so/whirlpools-client");
|
|
10298
|
-
var
|
|
10417
|
+
var import_kit79 = require("@solana/kit");
|
|
10299
10418
|
var import_memo5 = require("@solana-program/memo");
|
|
10300
10419
|
var import_token_20228 = require("@solana-program/token-2022");
|
|
10301
10420
|
var import_assert7 = __toESM(require("assert"));
|
|
@@ -10371,10 +10490,10 @@ async function collectFeesOrcaInstruction(authority, tunaPosition, mintA, mintB,
|
|
|
10371
10490
|
tunaPosition.data.tickUpperIndex
|
|
10372
10491
|
);
|
|
10373
10492
|
const remainingAccounts = [
|
|
10374
|
-
{ address: lowerTickArrayAddress, role:
|
|
10375
|
-
{ address: upperTickArrayAddress, role:
|
|
10376
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
10377
|
-
{ 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 }
|
|
10378
10497
|
];
|
|
10379
10498
|
const remainingAccountsInfo = {
|
|
10380
10499
|
slices: [
|
|
@@ -10409,7 +10528,7 @@ async function collectFeesOrcaInstruction(authority, tunaPosition, mintA, mintB,
|
|
|
10409
10528
|
|
|
10410
10529
|
// src/txbuilder/collectFeesFusion.ts
|
|
10411
10530
|
var import_fusionamm_client5 = require("@crypticdot/fusionamm-client");
|
|
10412
|
-
var
|
|
10531
|
+
var import_kit80 = require("@solana/kit");
|
|
10413
10532
|
var import_memo6 = require("@solana-program/memo");
|
|
10414
10533
|
var import_token_20229 = require("@solana-program/token-2022");
|
|
10415
10534
|
var import_assert8 = __toESM(require("assert"));
|
|
@@ -10485,10 +10604,10 @@ async function collectFeesFusionInstruction(authority, tunaPosition, mintA, mint
|
|
|
10485
10604
|
tunaPosition.data.tickUpperIndex
|
|
10486
10605
|
);
|
|
10487
10606
|
const remainingAccounts = [
|
|
10488
|
-
{ address: lowerTickArrayAddress, role:
|
|
10489
|
-
{ address: upperTickArrayAddress, role:
|
|
10490
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
10491
|
-
{ 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 }
|
|
10492
10611
|
];
|
|
10493
10612
|
const remainingAccountsInfo = {
|
|
10494
10613
|
slices: [
|
|
@@ -10599,7 +10718,7 @@ async function openLendingPositionAndDepositInstructions(rpc, authority, mintAdd
|
|
|
10599
10718
|
// src/txbuilder/closeActiveTunaLpPositionOrca.ts
|
|
10600
10719
|
var import_whirlpools_client6 = require("@orca-so/whirlpools-client");
|
|
10601
10720
|
var import_whirlpools_core3 = require("@orca-so/whirlpools-core");
|
|
10602
|
-
var
|
|
10721
|
+
var import_kit81 = require("@solana/kit");
|
|
10603
10722
|
var import_token_202211 = require("@solana-program/token-2022");
|
|
10604
10723
|
var import_assert9 = __toESM(require("assert"));
|
|
10605
10724
|
async function closeActiveTunaLpPositionOrcaInstructions(rpc, authority, positionMint, args) {
|
|
@@ -10620,7 +10739,7 @@ async function closeActiveTunaLpPositionOrcaInstructions(rpc, authority, positio
|
|
|
10620
10739
|
const allMints = [mintA, mintB, ...rewardMints];
|
|
10621
10740
|
(0, import_assert9.default)(mintA.exists, "Token A account not found");
|
|
10622
10741
|
(0, import_assert9.default)(mintB.exists, "Token B account not found");
|
|
10623
|
-
(0,
|
|
10742
|
+
(0, import_kit81.assertAccountsExist)(rewardMints);
|
|
10624
10743
|
const lowerTickArrayStartIndex = (0, import_whirlpools_core3.getTickArrayStartTickIndex)(
|
|
10625
10744
|
tunaPosition.data.tickLowerIndex,
|
|
10626
10745
|
whirlpool.data.tickSpacing
|
|
@@ -10801,7 +10920,7 @@ async function closeActiveTunaLpPositionFusionInstructions(rpc, authority, posit
|
|
|
10801
10920
|
|
|
10802
10921
|
// src/txbuilder/modifyTunaSpotPositionOrca.ts
|
|
10803
10922
|
var import_whirlpools_client7 = require("@orca-so/whirlpools-client");
|
|
10804
|
-
var
|
|
10923
|
+
var import_kit82 = require("@solana/kit");
|
|
10805
10924
|
var import_memo8 = require("@solana-program/memo");
|
|
10806
10925
|
var import_token_202213 = require("@solana-program/token-2022");
|
|
10807
10926
|
var import_assert11 = __toESM(require("assert"));
|
|
@@ -10942,14 +11061,14 @@ async function modifyTunaSpotPositionOrcaInstruction(authority, tunaConfig, mint
|
|
|
10942
11061
|
}))[0];
|
|
10943
11062
|
const swapTickArrays = await OrcaUtils.getSwapTickArrayAddresses(pool);
|
|
10944
11063
|
const remainingAccounts = [
|
|
10945
|
-
{ address: swapTickArrays[0], role:
|
|
10946
|
-
{ address: swapTickArrays[1], role:
|
|
10947
|
-
{ address: swapTickArrays[2], role:
|
|
10948
|
-
{ address: swapTickArrays[3], role:
|
|
10949
|
-
{ address: swapTickArrays[4], role:
|
|
10950
|
-
{ address: pool.data.tokenVaultA, role:
|
|
10951
|
-
{ address: pool.data.tokenVaultB, role:
|
|
10952
|
-
{ 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 }
|
|
10953
11072
|
];
|
|
10954
11073
|
const remainingAccountsInfo = {
|
|
10955
11074
|
slices: [
|
|
@@ -10992,7 +11111,7 @@ async function modifyTunaSpotPositionOrcaInstruction(authority, tunaConfig, mint
|
|
|
10992
11111
|
|
|
10993
11112
|
// src/txbuilder/modifyTunaSpotPositionFusion.ts
|
|
10994
11113
|
var import_fusionamm_client7 = require("@crypticdot/fusionamm-client");
|
|
10995
|
-
var
|
|
11114
|
+
var import_kit83 = require("@solana/kit");
|
|
10996
11115
|
var import_memo9 = require("@solana-program/memo");
|
|
10997
11116
|
var import_token_202214 = require("@solana-program/token-2022");
|
|
10998
11117
|
var import_assert12 = __toESM(require("assert"));
|
|
@@ -11132,13 +11251,13 @@ async function modifyTunaSpotPositionFusionInstruction(authority, tunaConfig, mi
|
|
|
11132
11251
|
}))[0];
|
|
11133
11252
|
const swapTickArrays = await FusionUtils.getSwapTickArrayAddresses(pool);
|
|
11134
11253
|
const remainingAccounts = [
|
|
11135
|
-
{ address: swapTickArrays[0], role:
|
|
11136
|
-
{ address: swapTickArrays[1], role:
|
|
11137
|
-
{ address: swapTickArrays[2], role:
|
|
11138
|
-
{ address: swapTickArrays[3], role:
|
|
11139
|
-
{ address: swapTickArrays[4], role:
|
|
11140
|
-
{ address: pool.data.tokenVaultA, role:
|
|
11141
|
-
{ 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 }
|
|
11142
11261
|
];
|
|
11143
11262
|
const remainingAccountsInfo = {
|
|
11144
11263
|
slices: [
|
|
@@ -11182,7 +11301,6 @@ async function modifyTunaSpotPositionFusionInstruction(authority, tunaConfig, mi
|
|
|
11182
11301
|
var import_fusionamm_client8 = require("@crypticdot/fusionamm-client");
|
|
11183
11302
|
|
|
11184
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
|
|
11185
|
-
var import_kit83 = require("@solana/kit");
|
|
11186
11304
|
var import_kit84 = require("@solana/kit");
|
|
11187
11305
|
var import_kit85 = require("@solana/kit");
|
|
11188
11306
|
var import_kit86 = require("@solana/kit");
|
|
@@ -11216,6 +11334,7 @@ var import_kit113 = require("@solana/kit");
|
|
|
11216
11334
|
var import_kit114 = require("@solana/kit");
|
|
11217
11335
|
var import_kit115 = require("@solana/kit");
|
|
11218
11336
|
var import_kit116 = require("@solana/kit");
|
|
11337
|
+
var import_kit117 = require("@solana/kit");
|
|
11219
11338
|
var TOKEN_LEDGER_DISCRIMINATOR = new Uint8Array([
|
|
11220
11339
|
156,
|
|
11221
11340
|
247,
|
|
@@ -11623,7 +11742,7 @@ async function closeTunaSpotPositionInstruction(authority, poolAddress, mintA, m
|
|
|
11623
11742
|
}
|
|
11624
11743
|
|
|
11625
11744
|
// src/txbuilder/createMarket.ts
|
|
11626
|
-
async function createMarketInstruction(authority, pool, args) {
|
|
11745
|
+
async function createMarketInstruction(authority, pool, vaultA, vaultB, args) {
|
|
11627
11746
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
11628
11747
|
const marketAddress = (await getMarketAddress(pool))[0];
|
|
11629
11748
|
return getCreateMarketInstruction({
|
|
@@ -11631,6 +11750,8 @@ async function createMarketInstruction(authority, pool, args) {
|
|
|
11631
11750
|
tunaConfig,
|
|
11632
11751
|
market: marketAddress,
|
|
11633
11752
|
pool,
|
|
11753
|
+
vaultA,
|
|
11754
|
+
vaultB,
|
|
11634
11755
|
...args
|
|
11635
11756
|
});
|
|
11636
11757
|
}
|
|
@@ -11674,7 +11795,7 @@ async function createVaultInstructions(authority, mint, args) {
|
|
|
11674
11795
|
|
|
11675
11796
|
// src/txbuilder/liquidateTunaLpPositionOrca.ts
|
|
11676
11797
|
var import_whirlpools_client9 = require("@orca-so/whirlpools-client");
|
|
11677
|
-
var
|
|
11798
|
+
var import_kit118 = require("@solana/kit");
|
|
11678
11799
|
var import_memo11 = require("@solana-program/memo");
|
|
11679
11800
|
var import_token_202218 = require("@solana-program/token-2022");
|
|
11680
11801
|
async function liquidateTunaLpPositionOrcaInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, decreasePercent) {
|
|
@@ -11761,16 +11882,16 @@ async function liquidateTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
11761
11882
|
tunaPosition.data.tickUpperIndex
|
|
11762
11883
|
);
|
|
11763
11884
|
const remainingAccounts = [
|
|
11764
|
-
{ address: swapTickArrays[0], role:
|
|
11765
|
-
{ address: swapTickArrays[1], role:
|
|
11766
|
-
{ address: swapTickArrays[2], role:
|
|
11767
|
-
{ address: swapTickArrays[3], role:
|
|
11768
|
-
{ address: swapTickArrays[4], role:
|
|
11769
|
-
{ address: lowerTickArrayAddress, role:
|
|
11770
|
-
{ address: upperTickArrayAddress, role:
|
|
11771
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
11772
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
11773
|
-
{ 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 }
|
|
11774
11895
|
];
|
|
11775
11896
|
const remainingAccountsInfo = {
|
|
11776
11897
|
slices: [
|
|
@@ -11815,7 +11936,7 @@ async function liquidateTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
11815
11936
|
|
|
11816
11937
|
// src/txbuilder/liquidateTunaLpPositionFusion.ts
|
|
11817
11938
|
var import_fusionamm_client9 = require("@crypticdot/fusionamm-client");
|
|
11818
|
-
var
|
|
11939
|
+
var import_kit119 = require("@solana/kit");
|
|
11819
11940
|
var import_memo12 = require("@solana-program/memo");
|
|
11820
11941
|
var import_token_202219 = require("@solana-program/token-2022");
|
|
11821
11942
|
async function liquidateTunaLpPositionFusionInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, decreasePercent) {
|
|
@@ -11901,15 +12022,15 @@ async function liquidateTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
11901
12022
|
tunaPosition.data.tickUpperIndex
|
|
11902
12023
|
);
|
|
11903
12024
|
const remainingAccounts = [
|
|
11904
|
-
{ address: swapTickArrays[0], role:
|
|
11905
|
-
{ address: swapTickArrays[1], role:
|
|
11906
|
-
{ address: swapTickArrays[2], role:
|
|
11907
|
-
{ address: swapTickArrays[3], role:
|
|
11908
|
-
{ address: swapTickArrays[4], role:
|
|
11909
|
-
{ address: lowerTickArrayAddress, role:
|
|
11910
|
-
{ address: upperTickArrayAddress, role:
|
|
11911
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
11912
|
-
{ 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 }
|
|
11913
12034
|
];
|
|
11914
12035
|
const remainingAccountsInfo = {
|
|
11915
12036
|
slices: [
|
|
@@ -11953,7 +12074,7 @@ async function liquidateTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
11953
12074
|
|
|
11954
12075
|
// src/txbuilder/liquidateTunaSpotPositionFusion.ts
|
|
11955
12076
|
var import_fusionamm_client10 = require("@crypticdot/fusionamm-client");
|
|
11956
|
-
var
|
|
12077
|
+
var import_kit120 = require("@solana/kit");
|
|
11957
12078
|
var import_memo13 = require("@solana-program/memo");
|
|
11958
12079
|
var import_token_202220 = require("@solana-program/token-2022");
|
|
11959
12080
|
async function liquidateTunaSpotPositionFusionInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool, decreasePercent) {
|
|
@@ -12044,16 +12165,16 @@ async function liquidateTunaSpotPositionFusionInstruction(authority, tunaPositio
|
|
|
12044
12165
|
}))[0];
|
|
12045
12166
|
const swapTickArrays = await FusionUtils.getSwapTickArrayAddresses(fusionPool);
|
|
12046
12167
|
const remainingAccounts = [
|
|
12047
|
-
{ address: swapTickArrays[0], role:
|
|
12048
|
-
{ address: swapTickArrays[1], role:
|
|
12049
|
-
{ address: swapTickArrays[2], role:
|
|
12050
|
-
{ address: swapTickArrays[3], role:
|
|
12051
|
-
{ address: swapTickArrays[4], role:
|
|
12052
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
12053
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
12054
|
-
];
|
|
12055
|
-
const remainingAccountsInfo = {
|
|
12056
|
-
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: [
|
|
12057
12178
|
{ accountsType: 0 /* SwapTickArrays */, length: 5 },
|
|
12058
12179
|
{ accountsType: 3 /* PoolVaultTokenA */, length: 1 },
|
|
12059
12180
|
{ accountsType: 4 /* PoolVaultTokenB */, length: 1 }
|
|
@@ -12091,15 +12212,13 @@ async function liquidateTunaSpotPositionFusionInstruction(authority, tunaPositio
|
|
|
12091
12212
|
return ix;
|
|
12092
12213
|
}
|
|
12093
12214
|
|
|
12094
|
-
// src/txbuilder/
|
|
12095
|
-
var import_whirlpools_client10 = require("@orca-so/whirlpools-client");
|
|
12096
|
-
var import_kit120 = require("@solana/kit");
|
|
12215
|
+
// src/txbuilder/liquidateTunaSpotPositionJupiter.ts
|
|
12097
12216
|
var import_memo14 = require("@solana-program/memo");
|
|
12098
12217
|
var import_token_202221 = require("@solana-program/token-2022");
|
|
12099
|
-
async function
|
|
12218
|
+
async function liquidateTunaSpotPositionJupiterInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, poolAddress, remainingAccounts, args) {
|
|
12100
12219
|
const instructions = [];
|
|
12101
12220
|
const collateralTokenMint = tunaPosition.data.collateralToken == 0 /* A */ ? mintA : mintB;
|
|
12102
|
-
const useNativeSol = collateralTokenMint.address == NATIVE_MINT && decreasePercent == HUNDRED_PERCENT;
|
|
12221
|
+
const useNativeSol = collateralTokenMint.address == NATIVE_MINT && args.decreasePercent == HUNDRED_PERCENT;
|
|
12103
12222
|
if (!useNativeSol) {
|
|
12104
12223
|
const createPositionOwnerAtaInstructions = await getCreateAtaInstructions(
|
|
12105
12224
|
void 0,
|
|
@@ -12110,6 +12229,26 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
12110
12229
|
);
|
|
12111
12230
|
instructions.push(...createPositionOwnerAtaInstructions.init);
|
|
12112
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
|
+
}
|
|
12113
12252
|
const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
|
|
12114
12253
|
void 0,
|
|
12115
12254
|
authority,
|
|
@@ -12126,7 +12265,7 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
12126
12265
|
mintB.programAddress
|
|
12127
12266
|
);
|
|
12128
12267
|
instructions.push(...createFeeRecipientAtaBInstructions.init);
|
|
12129
|
-
const ix = await
|
|
12268
|
+
const ix = await liquidateTunaSpotPositionJupiterInstruction(
|
|
12130
12269
|
authority,
|
|
12131
12270
|
tunaPosition,
|
|
12132
12271
|
tunaConfig,
|
|
@@ -12134,15 +12273,15 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
12134
12273
|
mintB,
|
|
12135
12274
|
vaultA,
|
|
12136
12275
|
vaultB,
|
|
12137
|
-
|
|
12138
|
-
|
|
12276
|
+
poolAddress,
|
|
12277
|
+
remainingAccounts,
|
|
12278
|
+
args
|
|
12139
12279
|
);
|
|
12140
12280
|
instructions.push(ix);
|
|
12141
12281
|
return instructions;
|
|
12142
12282
|
}
|
|
12143
|
-
async function
|
|
12144
|
-
const marketAddress = (await getMarketAddress(
|
|
12145
|
-
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];
|
|
12146
12285
|
const tunaPositionOwnerAtaA = (await (0, import_token_202221.findAssociatedTokenPda)({
|
|
12147
12286
|
owner: tunaPosition.data.authority,
|
|
12148
12287
|
mint: mintA.address,
|
|
@@ -12183,16 +12322,141 @@ async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition,
|
|
|
12183
12322
|
mint: mintB.address,
|
|
12184
12323
|
tokenProgram: mintB.programAddress
|
|
12185
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];
|
|
12186
12450
|
const swapTickArrays = await OrcaUtils.getSwapTickArrayAddresses(whirlpool);
|
|
12187
12451
|
const remainingAccounts = [
|
|
12188
|
-
{ address: swapTickArrays[0], role:
|
|
12189
|
-
{ address: swapTickArrays[1], role:
|
|
12190
|
-
{ address: swapTickArrays[2], role:
|
|
12191
|
-
{ address: swapTickArrays[3], role:
|
|
12192
|
-
{ address: swapTickArrays[4], role:
|
|
12193
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
12194
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
12195
|
-
{ 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 }
|
|
12196
12460
|
];
|
|
12197
12461
|
const remainingAccountsInfo = {
|
|
12198
12462
|
slices: [
|
|
@@ -12226,7 +12490,7 @@ async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition,
|
|
|
12226
12490
|
feeRecipientAtaB,
|
|
12227
12491
|
whirlpool: whirlpool.address,
|
|
12228
12492
|
whirlpoolProgram: import_whirlpools_client10.WHIRLPOOL_PROGRAM_ADDRESS,
|
|
12229
|
-
memoProgram:
|
|
12493
|
+
memoProgram: import_memo15.MEMO_PROGRAM_ADDRESS,
|
|
12230
12494
|
decreasePercent,
|
|
12231
12495
|
remainingAccountsInfo
|
|
12232
12496
|
});
|
|
@@ -12236,28 +12500,28 @@ async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition,
|
|
|
12236
12500
|
|
|
12237
12501
|
// src/txbuilder/openTunaLpPositionOrca.ts
|
|
12238
12502
|
var import_whirlpools_client11 = require("@orca-so/whirlpools-client");
|
|
12239
|
-
var
|
|
12503
|
+
var import_token_202223 = require("@solana-program/token-2022");
|
|
12240
12504
|
var import_assert15 = __toESM(require("assert"));
|
|
12241
12505
|
async function openTunaLpPositionOrcaInstruction(rpc, authority, positionMint, whirlpoolAddress, args) {
|
|
12242
12506
|
const whirlpool = await (0, import_whirlpools_client11.fetchMaybeWhirlpool)(rpc, whirlpoolAddress);
|
|
12243
12507
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
12244
|
-
const [mintA, mintB] = await (0,
|
|
12508
|
+
const [mintA, mintB] = await (0, import_token_202223.fetchAllMaybeMint)(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
12245
12509
|
(0, import_assert15.default)(mintA.exists, "Token A account not found");
|
|
12246
12510
|
(0, import_assert15.default)(mintB.exists, "Token B account not found");
|
|
12247
12511
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12248
12512
|
const orcaPositionAddress = (await (0, import_whirlpools_client11.getPositionAddress)(positionMint.address))[0];
|
|
12249
12513
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
12250
|
-
const tunaPositionAta = (await (0,
|
|
12514
|
+
const tunaPositionAta = (await (0, import_token_202223.findAssociatedTokenPda)({
|
|
12251
12515
|
owner: tunaPositionAddress,
|
|
12252
12516
|
mint: positionMint.address,
|
|
12253
|
-
tokenProgram:
|
|
12517
|
+
tokenProgram: import_token_202223.TOKEN_2022_PROGRAM_ADDRESS
|
|
12254
12518
|
}))[0];
|
|
12255
|
-
const tunaPositionAtaA = (await (0,
|
|
12519
|
+
const tunaPositionAtaA = (await (0, import_token_202223.findAssociatedTokenPda)({
|
|
12256
12520
|
owner: tunaPositionAddress,
|
|
12257
12521
|
mint: mintA.address,
|
|
12258
12522
|
tokenProgram: mintA.programAddress
|
|
12259
12523
|
}))[0];
|
|
12260
|
-
const tunaPositionAtaB = (await (0,
|
|
12524
|
+
const tunaPositionAtaB = (await (0, import_token_202223.findAssociatedTokenPda)({
|
|
12261
12525
|
owner: tunaPositionAddress,
|
|
12262
12526
|
mint: mintB.address,
|
|
12263
12527
|
tokenProgram: mintB.programAddress
|
|
@@ -12278,8 +12542,8 @@ async function openTunaLpPositionOrcaInstruction(rpc, authority, positionMint, w
|
|
|
12278
12542
|
metadataUpdateAuth: WP_NFT_UPDATE_AUTH,
|
|
12279
12543
|
tokenProgramA: mintA.programAddress,
|
|
12280
12544
|
tokenProgramB: mintB.programAddress,
|
|
12281
|
-
associatedTokenProgram:
|
|
12282
|
-
token2022Program:
|
|
12545
|
+
associatedTokenProgram: import_token_202223.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
12546
|
+
token2022Program: import_token_202223.TOKEN_2022_PROGRAM_ADDRESS,
|
|
12283
12547
|
...args
|
|
12284
12548
|
});
|
|
12285
12549
|
}
|
|
@@ -12287,28 +12551,28 @@ async function openTunaLpPositionOrcaInstruction(rpc, authority, positionMint, w
|
|
|
12287
12551
|
// src/txbuilder/openTunaLpPositionFusion.ts
|
|
12288
12552
|
var import_fusionamm_client11 = require("@crypticdot/fusionamm-client");
|
|
12289
12553
|
var import_fusionamm_client12 = require("@crypticdot/fusionamm-client");
|
|
12290
|
-
var
|
|
12554
|
+
var import_token_202224 = require("@solana-program/token-2022");
|
|
12291
12555
|
var import_assert16 = __toESM(require("assert"));
|
|
12292
12556
|
async function openTunaLpPositionFusionInstruction(rpc, authority, positionMint, fusionPoolAddress, args) {
|
|
12293
12557
|
const fusionPool = await (0, import_fusionamm_client11.fetchMaybeFusionPool)(rpc, fusionPoolAddress);
|
|
12294
12558
|
if (!fusionPool.exists) throw new Error("Whirlpool account not found");
|
|
12295
|
-
const [mintA, mintB] = await (0,
|
|
12559
|
+
const [mintA, mintB] = await (0, import_token_202224.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
12296
12560
|
(0, import_assert16.default)(mintA.exists, "Token A account not found");
|
|
12297
12561
|
(0, import_assert16.default)(mintB.exists, "Token B account not found");
|
|
12298
12562
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
12299
12563
|
const fusionPositionAddress = (await (0, import_fusionamm_client11.getPositionAddress)(positionMint.address))[0];
|
|
12300
12564
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
12301
|
-
const tunaPositionAta = (await (0,
|
|
12565
|
+
const tunaPositionAta = (await (0, import_token_202224.findAssociatedTokenPda)({
|
|
12302
12566
|
owner: tunaPositionAddress,
|
|
12303
12567
|
mint: positionMint.address,
|
|
12304
|
-
tokenProgram:
|
|
12568
|
+
tokenProgram: import_token_202224.TOKEN_2022_PROGRAM_ADDRESS
|
|
12305
12569
|
}))[0];
|
|
12306
|
-
const tunaPositionAtaA = (await (0,
|
|
12570
|
+
const tunaPositionAtaA = (await (0, import_token_202224.findAssociatedTokenPda)({
|
|
12307
12571
|
owner: tunaPositionAddress,
|
|
12308
12572
|
mint: mintA.address,
|
|
12309
12573
|
tokenProgram: mintA.programAddress
|
|
12310
12574
|
}))[0];
|
|
12311
|
-
const tunaPositionAtaB = (await (0,
|
|
12575
|
+
const tunaPositionAtaB = (await (0, import_token_202224.findAssociatedTokenPda)({
|
|
12312
12576
|
owner: tunaPositionAddress,
|
|
12313
12577
|
mint: mintB.address,
|
|
12314
12578
|
tokenProgram: mintB.programAddress
|
|
@@ -12329,8 +12593,8 @@ async function openTunaLpPositionFusionInstruction(rpc, authority, positionMint,
|
|
|
12329
12593
|
metadataUpdateAuth: import_fusionamm_client12.FP_NFT_UPDATE_AUTH,
|
|
12330
12594
|
tokenProgramA: mintA.programAddress,
|
|
12331
12595
|
tokenProgramB: mintB.programAddress,
|
|
12332
|
-
associatedTokenProgram:
|
|
12333
|
-
token2022Program:
|
|
12596
|
+
associatedTokenProgram: import_token_202224.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
12597
|
+
token2022Program: import_token_202224.TOKEN_2022_PROGRAM_ADDRESS,
|
|
12334
12598
|
...args
|
|
12335
12599
|
});
|
|
12336
12600
|
}
|
|
@@ -12338,10 +12602,10 @@ async function openTunaLpPositionFusionInstruction(rpc, authority, positionMint,
|
|
|
12338
12602
|
// src/txbuilder/openAndIncreaseTunaLpPositionOrca.ts
|
|
12339
12603
|
var import_whirlpools_client12 = require("@orca-so/whirlpools-client");
|
|
12340
12604
|
var import_whirlpools_core4 = require("@orca-so/whirlpools-core");
|
|
12341
|
-
var
|
|
12605
|
+
var import_kit122 = require("@solana/kit");
|
|
12342
12606
|
var import_sysvars = require("@solana/sysvars");
|
|
12343
|
-
var
|
|
12344
|
-
var
|
|
12607
|
+
var import_memo16 = require("@solana-program/memo");
|
|
12608
|
+
var import_token_202225 = require("@solana-program/token-2022");
|
|
12345
12609
|
var import_assert17 = __toESM(require("assert"));
|
|
12346
12610
|
|
|
12347
12611
|
// src/utils/sysvar.ts
|
|
@@ -12360,13 +12624,13 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
|
|
|
12360
12624
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
12361
12625
|
const rent = await (0, import_sysvars.fetchSysvarRent)(rpc);
|
|
12362
12626
|
let nonRefundableRent = 0n;
|
|
12363
|
-
const positionMint = await (0,
|
|
12627
|
+
const positionMint = await (0, import_kit122.generateKeyPairSigner)();
|
|
12364
12628
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
12365
12629
|
const whirlpool = await (0, import_whirlpools_client12.fetchMaybeWhirlpool)(rpc, whirlpoolAddress);
|
|
12366
12630
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
12367
12631
|
const marketAddress = (await getMarketAddress(whirlpoolAddress))[0];
|
|
12368
12632
|
const market = await fetchMarket(rpc, marketAddress);
|
|
12369
|
-
const [mintA, mintB] = await (0,
|
|
12633
|
+
const [mintA, mintB] = await (0, import_token_202225.fetchAllMaybeMint)(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
12370
12634
|
(0, import_assert17.default)(mintA.exists, "Token A account not found");
|
|
12371
12635
|
(0, import_assert17.default)(mintB.exists, "Token B account not found");
|
|
12372
12636
|
const [vaultA, vaultB] = await fetchAllVault(rpc, [
|
|
@@ -12469,7 +12733,7 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
|
|
|
12469
12733
|
return {
|
|
12470
12734
|
instructions,
|
|
12471
12735
|
positionMint: positionMint.address,
|
|
12472
|
-
initializationCost: (0,
|
|
12736
|
+
initializationCost: (0, import_kit122.lamports)(nonRefundableRent)
|
|
12473
12737
|
};
|
|
12474
12738
|
}
|
|
12475
12739
|
async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionMint, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, args) {
|
|
@@ -12477,47 +12741,47 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
12477
12741
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12478
12742
|
const orcaPositionAddress = (await (0, import_whirlpools_client12.getPositionAddress)(positionMint.address))[0];
|
|
12479
12743
|
const orcaOracleAddress = (await (0, import_whirlpools_client12.getOracleAddress)(whirlpool.address))[0];
|
|
12480
|
-
const tunaPositionAta = (await (0,
|
|
12744
|
+
const tunaPositionAta = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12481
12745
|
owner: tunaPositionAddress,
|
|
12482
12746
|
mint: positionMint.address,
|
|
12483
|
-
tokenProgram:
|
|
12747
|
+
tokenProgram: import_token_202225.TOKEN_2022_PROGRAM_ADDRESS
|
|
12484
12748
|
}))[0];
|
|
12485
|
-
const tunaPositionOwnerAtaA = (await (0,
|
|
12749
|
+
const tunaPositionOwnerAtaA = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12486
12750
|
owner: authority.address,
|
|
12487
12751
|
mint: mintA.address,
|
|
12488
12752
|
tokenProgram: mintA.programAddress
|
|
12489
12753
|
}))[0];
|
|
12490
|
-
const tunaPositionOwnerAtaB = (await (0,
|
|
12754
|
+
const tunaPositionOwnerAtaB = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12491
12755
|
owner: authority.address,
|
|
12492
12756
|
mint: mintB.address,
|
|
12493
12757
|
tokenProgram: mintB.programAddress
|
|
12494
12758
|
}))[0];
|
|
12495
|
-
const tunaPositionAtaA = (await (0,
|
|
12759
|
+
const tunaPositionAtaA = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12496
12760
|
owner: tunaPositionAddress,
|
|
12497
12761
|
mint: mintA.address,
|
|
12498
12762
|
tokenProgram: mintA.programAddress
|
|
12499
12763
|
}))[0];
|
|
12500
|
-
const tunaPositionAtaB = (await (0,
|
|
12764
|
+
const tunaPositionAtaB = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12501
12765
|
owner: tunaPositionAddress,
|
|
12502
12766
|
mint: mintB.address,
|
|
12503
12767
|
tokenProgram: mintB.programAddress
|
|
12504
12768
|
}))[0];
|
|
12505
|
-
const vaultAAta = (await (0,
|
|
12769
|
+
const vaultAAta = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12506
12770
|
owner: vaultA.address,
|
|
12507
12771
|
mint: mintA.address,
|
|
12508
12772
|
tokenProgram: mintA.programAddress
|
|
12509
12773
|
}))[0];
|
|
12510
|
-
const vaultBAta = (await (0,
|
|
12774
|
+
const vaultBAta = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12511
12775
|
owner: vaultB.address,
|
|
12512
12776
|
mint: mintB.address,
|
|
12513
12777
|
tokenProgram: mintB.programAddress
|
|
12514
12778
|
}))[0];
|
|
12515
|
-
const feeRecipientAtaA = (await (0,
|
|
12779
|
+
const feeRecipientAtaA = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12516
12780
|
owner: tunaConfig.data.feeRecipient,
|
|
12517
12781
|
mint: mintA.address,
|
|
12518
12782
|
tokenProgram: mintA.programAddress
|
|
12519
12783
|
}))[0];
|
|
12520
|
-
const feeRecipientAtaB = (await (0,
|
|
12784
|
+
const feeRecipientAtaB = (await (0, import_token_202225.findAssociatedTokenPda)({
|
|
12521
12785
|
owner: tunaConfig.data.feeRecipient,
|
|
12522
12786
|
mint: mintB.address,
|
|
12523
12787
|
tokenProgram: mintB.programAddress
|
|
@@ -12526,16 +12790,16 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
12526
12790
|
const lowerTickArrayAddress = await OrcaUtils.getTickArrayAddressFromTickIndex(whirlpool, args.tickLowerIndex);
|
|
12527
12791
|
const upperTickArrayAddress = await OrcaUtils.getTickArrayAddressFromTickIndex(whirlpool, args.tickUpperIndex);
|
|
12528
12792
|
const remainingAccounts = [
|
|
12529
|
-
{ address: swapTickArrays[0], role:
|
|
12530
|
-
{ address: swapTickArrays[1], role:
|
|
12531
|
-
{ address: swapTickArrays[2], role:
|
|
12532
|
-
{ address: swapTickArrays[3], role:
|
|
12533
|
-
{ address: swapTickArrays[4], role:
|
|
12534
|
-
{ address: lowerTickArrayAddress, role:
|
|
12535
|
-
{ address: upperTickArrayAddress, role:
|
|
12536
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
12537
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
12538
|
-
{ 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 }
|
|
12539
12803
|
];
|
|
12540
12804
|
const remainingAccountsInfo = {
|
|
12541
12805
|
slices: [
|
|
@@ -12573,10 +12837,10 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
12573
12837
|
orcaPosition: orcaPositionAddress,
|
|
12574
12838
|
tokenProgramA: mintA.programAddress,
|
|
12575
12839
|
tokenProgramB: mintB.programAddress,
|
|
12576
|
-
memoProgram:
|
|
12840
|
+
memoProgram: import_memo16.MEMO_PROGRAM_ADDRESS,
|
|
12577
12841
|
metadataUpdateAuth: WP_NFT_UPDATE_AUTH,
|
|
12578
|
-
associatedTokenProgram:
|
|
12579
|
-
token2022Program:
|
|
12842
|
+
associatedTokenProgram: import_token_202225.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
12843
|
+
token2022Program: import_token_202225.TOKEN_2022_PROGRAM_ADDRESS,
|
|
12580
12844
|
...args,
|
|
12581
12845
|
remainingAccountsInfo
|
|
12582
12846
|
});
|
|
@@ -12587,10 +12851,10 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
12587
12851
|
// src/txbuilder/openAndIncreaseTunaLpPositionFusion.ts
|
|
12588
12852
|
var import_fusionamm_client13 = require("@crypticdot/fusionamm-client");
|
|
12589
12853
|
var import_fusionamm_core5 = require("@crypticdot/fusionamm-core");
|
|
12590
|
-
var
|
|
12854
|
+
var import_kit123 = require("@solana/kit");
|
|
12591
12855
|
var import_sysvars2 = require("@solana/sysvars");
|
|
12592
|
-
var
|
|
12593
|
-
var
|
|
12856
|
+
var import_memo17 = require("@solana-program/memo");
|
|
12857
|
+
var import_token_202226 = require("@solana-program/token-2022");
|
|
12594
12858
|
var import_assert18 = __toESM(require("assert"));
|
|
12595
12859
|
async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, fusionPoolAddress, args, createInstructions, cleanupInstructions) {
|
|
12596
12860
|
const instructions = [];
|
|
@@ -12598,13 +12862,13 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
|
|
|
12598
12862
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
12599
12863
|
const rent = await (0, import_sysvars2.fetchSysvarRent)(rpc);
|
|
12600
12864
|
let nonRefundableRent = 0n;
|
|
12601
|
-
const positionMint = await (0,
|
|
12865
|
+
const positionMint = await (0, import_kit123.generateKeyPairSigner)();
|
|
12602
12866
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
12603
12867
|
const fusionPool = await (0, import_fusionamm_client13.fetchMaybeFusionPool)(rpc, fusionPoolAddress);
|
|
12604
12868
|
if (!fusionPool.exists) throw new Error("FusionPool account not found");
|
|
12605
12869
|
const marketAddress = (await getMarketAddress(fusionPoolAddress))[0];
|
|
12606
12870
|
const market = await fetchMarket(rpc, marketAddress);
|
|
12607
|
-
const [mintA, mintB] = await (0,
|
|
12871
|
+
const [mintA, mintB] = await (0, import_token_202226.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
12608
12872
|
(0, import_assert18.default)(mintA.exists, "Token A account not found");
|
|
12609
12873
|
(0, import_assert18.default)(mintB.exists, "Token B account not found");
|
|
12610
12874
|
const [vaultA, vaultB] = await fetchAllVault(rpc, [
|
|
@@ -12705,54 +12969,54 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
|
|
|
12705
12969
|
return {
|
|
12706
12970
|
instructions,
|
|
12707
12971
|
positionMint: positionMint.address,
|
|
12708
|
-
initializationCost: (0,
|
|
12972
|
+
initializationCost: (0, import_kit123.lamports)(nonRefundableRent)
|
|
12709
12973
|
};
|
|
12710
12974
|
}
|
|
12711
12975
|
async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positionMint, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool, args) {
|
|
12712
12976
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
12713
12977
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
12714
12978
|
const fusionPositionAddress = (await (0, import_fusionamm_client13.getPositionAddress)(positionMint.address))[0];
|
|
12715
|
-
const tunaPositionAta = (await (0,
|
|
12979
|
+
const tunaPositionAta = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12716
12980
|
owner: tunaPositionAddress,
|
|
12717
12981
|
mint: positionMint.address,
|
|
12718
|
-
tokenProgram:
|
|
12982
|
+
tokenProgram: import_token_202226.TOKEN_2022_PROGRAM_ADDRESS
|
|
12719
12983
|
}))[0];
|
|
12720
|
-
const tunaPositionOwnerAtaA = (await (0,
|
|
12984
|
+
const tunaPositionOwnerAtaA = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12721
12985
|
owner: authority.address,
|
|
12722
12986
|
mint: mintA.address,
|
|
12723
12987
|
tokenProgram: mintA.programAddress
|
|
12724
12988
|
}))[0];
|
|
12725
|
-
const tunaPositionOwnerAtaB = (await (0,
|
|
12989
|
+
const tunaPositionOwnerAtaB = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12726
12990
|
owner: authority.address,
|
|
12727
12991
|
mint: mintB.address,
|
|
12728
12992
|
tokenProgram: mintB.programAddress
|
|
12729
12993
|
}))[0];
|
|
12730
|
-
const tunaPositionAtaA = (await (0,
|
|
12994
|
+
const tunaPositionAtaA = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12731
12995
|
owner: tunaPositionAddress,
|
|
12732
12996
|
mint: mintA.address,
|
|
12733
12997
|
tokenProgram: mintA.programAddress
|
|
12734
12998
|
}))[0];
|
|
12735
|
-
const tunaPositionAtaB = (await (0,
|
|
12999
|
+
const tunaPositionAtaB = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12736
13000
|
owner: tunaPositionAddress,
|
|
12737
13001
|
mint: mintB.address,
|
|
12738
13002
|
tokenProgram: mintB.programAddress
|
|
12739
13003
|
}))[0];
|
|
12740
|
-
const vaultAAta = (await (0,
|
|
13004
|
+
const vaultAAta = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12741
13005
|
owner: vaultA.address,
|
|
12742
13006
|
mint: mintA.address,
|
|
12743
13007
|
tokenProgram: mintA.programAddress
|
|
12744
13008
|
}))[0];
|
|
12745
|
-
const vaultBAta = (await (0,
|
|
13009
|
+
const vaultBAta = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12746
13010
|
owner: vaultB.address,
|
|
12747
13011
|
mint: mintB.address,
|
|
12748
13012
|
tokenProgram: mintB.programAddress
|
|
12749
13013
|
}))[0];
|
|
12750
|
-
const feeRecipientAtaA = (await (0,
|
|
13014
|
+
const feeRecipientAtaA = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12751
13015
|
owner: tunaConfig.data.feeRecipient,
|
|
12752
13016
|
mint: mintA.address,
|
|
12753
13017
|
tokenProgram: mintA.programAddress
|
|
12754
13018
|
}))[0];
|
|
12755
|
-
const feeRecipientAtaB = (await (0,
|
|
13019
|
+
const feeRecipientAtaB = (await (0, import_token_202226.findAssociatedTokenPda)({
|
|
12756
13020
|
owner: tunaConfig.data.feeRecipient,
|
|
12757
13021
|
mint: mintB.address,
|
|
12758
13022
|
tokenProgram: mintB.programAddress
|
|
@@ -12761,15 +13025,15 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
12761
13025
|
const lowerTickArrayAddress = await FusionUtils.getTickArrayAddressFromTickIndex(fusionPool, args.tickLowerIndex);
|
|
12762
13026
|
const upperTickArrayAddress = await FusionUtils.getTickArrayAddressFromTickIndex(fusionPool, args.tickUpperIndex);
|
|
12763
13027
|
const remainingAccounts = [
|
|
12764
|
-
{ address: swapTickArrays[0], role:
|
|
12765
|
-
{ address: swapTickArrays[1], role:
|
|
12766
|
-
{ address: swapTickArrays[2], role:
|
|
12767
|
-
{ address: swapTickArrays[3], role:
|
|
12768
|
-
{ address: swapTickArrays[4], role:
|
|
12769
|
-
{ address: lowerTickArrayAddress, role:
|
|
12770
|
-
{ address: upperTickArrayAddress, role:
|
|
12771
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
12772
|
-
{ 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 }
|
|
12773
13037
|
];
|
|
12774
13038
|
const remainingAccountsInfo = {
|
|
12775
13039
|
slices: [
|
|
@@ -12806,10 +13070,10 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
12806
13070
|
fusionPosition: fusionPositionAddress,
|
|
12807
13071
|
tokenProgramA: mintA.programAddress,
|
|
12808
13072
|
tokenProgramB: mintB.programAddress,
|
|
12809
|
-
memoProgram:
|
|
13073
|
+
memoProgram: import_memo17.MEMO_PROGRAM_ADDRESS,
|
|
12810
13074
|
metadataUpdateAuth: import_fusionamm_client13.FP_NFT_UPDATE_AUTH,
|
|
12811
|
-
associatedTokenProgram:
|
|
12812
|
-
token2022Program:
|
|
13075
|
+
associatedTokenProgram: import_token_202226.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
13076
|
+
token2022Program: import_token_202226.TOKEN_2022_PROGRAM_ADDRESS,
|
|
12813
13077
|
...args,
|
|
12814
13078
|
remainingAccountsInfo
|
|
12815
13079
|
});
|
|
@@ -12820,21 +13084,21 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
12820
13084
|
// src/txbuilder/openTunaSpotPosition.ts
|
|
12821
13085
|
var import_fusionamm_client14 = require("@crypticdot/fusionamm-client");
|
|
12822
13086
|
var import_whirlpools_client13 = require("@orca-so/whirlpools-client");
|
|
12823
|
-
var
|
|
12824
|
-
var
|
|
13087
|
+
var import_kit124 = require("@solana/kit");
|
|
13088
|
+
var import_token_202227 = require("@solana-program/token-2022");
|
|
12825
13089
|
var import_assert19 = __toESM(require("assert"));
|
|
12826
13090
|
async function openTunaSpotPositionInstructions(rpc, authority, poolAddress, args) {
|
|
12827
|
-
const poolAccount = await (0,
|
|
13091
|
+
const poolAccount = await (0, import_kit124.fetchEncodedAccount)(rpc, poolAddress);
|
|
12828
13092
|
(0, import_assert19.default)(poolAccount.exists, "Pool account not found");
|
|
12829
13093
|
let pool;
|
|
12830
13094
|
if (poolAccount.programAddress == import_fusionamm_client14.FUSIONAMM_PROGRAM_ADDRESS) {
|
|
12831
|
-
pool = (0,
|
|
13095
|
+
pool = (0, import_kit124.decodeAccount)(poolAccount, (0, import_fusionamm_client14.getFusionPoolDecoder)());
|
|
12832
13096
|
} else if (poolAccount.programAddress == import_whirlpools_client13.WHIRLPOOL_PROGRAM_ADDRESS) {
|
|
12833
|
-
pool = (0,
|
|
13097
|
+
pool = (0, import_kit124.decodeAccount)(poolAccount, (0, import_whirlpools_client13.getWhirlpoolDecoder)());
|
|
12834
13098
|
} else {
|
|
12835
13099
|
throw new Error("Incorrect Fusion or Orca pool account");
|
|
12836
13100
|
}
|
|
12837
|
-
const [mintA, mintB] = await (0,
|
|
13101
|
+
const [mintA, mintB] = await (0, import_token_202227.fetchAllMaybeMint)(rpc, [pool.data.tokenMintA, pool.data.tokenMintB]);
|
|
12838
13102
|
(0, import_assert19.default)(mintA.exists, "Token A account not found");
|
|
12839
13103
|
(0, import_assert19.default)(mintB.exists, "Token B account not found");
|
|
12840
13104
|
const ix = await openTunaSpotPositionInstruction(authority, mintA, mintB, poolAddress, args);
|
|
@@ -12842,12 +13106,12 @@ async function openTunaSpotPositionInstructions(rpc, authority, poolAddress, arg
|
|
|
12842
13106
|
}
|
|
12843
13107
|
async function openTunaSpotPositionInstruction(authority, mintA, mintB, poolAddress, args) {
|
|
12844
13108
|
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
12845
|
-
const tunaPositionAtaA = (await (0,
|
|
13109
|
+
const tunaPositionAtaA = (await (0, import_token_202227.findAssociatedTokenPda)({
|
|
12846
13110
|
owner: tunaPositionAddress,
|
|
12847
13111
|
mint: mintA.address,
|
|
12848
13112
|
tokenProgram: mintA.programAddress
|
|
12849
13113
|
}))[0];
|
|
12850
|
-
const tunaPositionAtaB = (await (0,
|
|
13114
|
+
const tunaPositionAtaB = (await (0, import_token_202227.findAssociatedTokenPda)({
|
|
12851
13115
|
owner: tunaPositionAddress,
|
|
12852
13116
|
mint: mintB.address,
|
|
12853
13117
|
tokenProgram: mintB.programAddress
|
|
@@ -12862,7 +13126,7 @@ async function openTunaSpotPositionInstruction(authority, mintA, mintB, poolAddr
|
|
|
12862
13126
|
tunaPositionAtaA,
|
|
12863
13127
|
tunaPositionAtaB,
|
|
12864
13128
|
pool: poolAddress,
|
|
12865
|
-
associatedTokenProgram:
|
|
13129
|
+
associatedTokenProgram: import_token_202227.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
12866
13130
|
...args
|
|
12867
13131
|
});
|
|
12868
13132
|
}
|
|
@@ -12870,9 +13134,9 @@ async function openTunaSpotPositionInstruction(authority, mintA, mintB, poolAddr
|
|
|
12870
13134
|
// src/txbuilder/decreaseTunaLpPositionOrca.ts
|
|
12871
13135
|
var import_whirlpools_client14 = require("@orca-so/whirlpools-client");
|
|
12872
13136
|
var import_whirlpools_core5 = require("@orca-so/whirlpools-core");
|
|
12873
|
-
var
|
|
12874
|
-
var
|
|
12875
|
-
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");
|
|
12876
13140
|
var import_assert20 = __toESM(require("assert"));
|
|
12877
13141
|
async function decreaseTunaLpPositionOrcaInstructions(rpc, authority, positionMint, args, createInstructions, cleanupInstructions) {
|
|
12878
13142
|
const tunaPosition = await fetchMaybeTunaLpPosition(rpc, (await getTunaLpPositionAddress(positionMint))[0]);
|
|
@@ -12884,7 +13148,7 @@ async function decreaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
|
|
|
12884
13148
|
(await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
|
|
12885
13149
|
(await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
|
|
12886
13150
|
]);
|
|
12887
|
-
const [mintA, mintB, ...rewardMints] = await (0,
|
|
13151
|
+
const [mintA, mintB, ...rewardMints] = await (0, import_token_202228.fetchAllMaybeMint)(rpc, [
|
|
12888
13152
|
whirlpool.data.tokenMintA,
|
|
12889
13153
|
whirlpool.data.tokenMintB,
|
|
12890
13154
|
...whirlpool.data.rewardInfos.map((x) => x.mint).filter((x) => x !== DEFAULT_ADDRESS)
|
|
@@ -12892,7 +13156,7 @@ async function decreaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
|
|
|
12892
13156
|
const allMints = [mintA, mintB, ...rewardMints];
|
|
12893
13157
|
(0, import_assert20.default)(mintA.exists, "Token A account not found");
|
|
12894
13158
|
(0, import_assert20.default)(mintB.exists, "Token B account not found");
|
|
12895
|
-
(0,
|
|
13159
|
+
(0, import_kit125.assertAccountsExist)(rewardMints);
|
|
12896
13160
|
const lowerTickArrayStartIndex = (0, import_whirlpools_core5.getTickArrayStartTickIndex)(
|
|
12897
13161
|
tunaPosition.data.tickLowerIndex,
|
|
12898
13162
|
whirlpool.data.tickSpacing
|
|
@@ -12960,37 +13224,37 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
12960
13224
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12961
13225
|
const orcaPositionAddress = (await (0, import_whirlpools_client14.getPositionAddress)(positionMint))[0];
|
|
12962
13226
|
const orcaOracleAddress = (await (0, import_whirlpools_client14.getOracleAddress)(whirlpool.address))[0];
|
|
12963
|
-
const tunaPositionAta = (await (0,
|
|
13227
|
+
const tunaPositionAta = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12964
13228
|
owner: tunaPosition.address,
|
|
12965
13229
|
mint: positionMint,
|
|
12966
|
-
tokenProgram:
|
|
13230
|
+
tokenProgram: import_token_202228.TOKEN_2022_PROGRAM_ADDRESS
|
|
12967
13231
|
}))[0];
|
|
12968
|
-
const tunaPositionOwnerAtaA = (await (0,
|
|
13232
|
+
const tunaPositionOwnerAtaA = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12969
13233
|
owner: authority.address,
|
|
12970
13234
|
mint: mintA.address,
|
|
12971
13235
|
tokenProgram: mintA.programAddress
|
|
12972
13236
|
}))[0];
|
|
12973
|
-
const tunaPositionOwnerAtaB = (await (0,
|
|
13237
|
+
const tunaPositionOwnerAtaB = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12974
13238
|
owner: authority.address,
|
|
12975
13239
|
mint: mintB.address,
|
|
12976
13240
|
tokenProgram: mintB.programAddress
|
|
12977
13241
|
}))[0];
|
|
12978
|
-
const tunaPositionAtaA = (await (0,
|
|
13242
|
+
const tunaPositionAtaA = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12979
13243
|
owner: tunaPosition.address,
|
|
12980
13244
|
mint: mintA.address,
|
|
12981
13245
|
tokenProgram: mintA.programAddress
|
|
12982
13246
|
}))[0];
|
|
12983
|
-
const tunaPositionAtaB = (await (0,
|
|
13247
|
+
const tunaPositionAtaB = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12984
13248
|
owner: tunaPosition.address,
|
|
12985
13249
|
mint: mintB.address,
|
|
12986
13250
|
tokenProgram: mintB.programAddress
|
|
12987
13251
|
}))[0];
|
|
12988
|
-
const vaultAAta = (await (0,
|
|
13252
|
+
const vaultAAta = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12989
13253
|
owner: vaultA.address,
|
|
12990
13254
|
mint: mintA.address,
|
|
12991
13255
|
tokenProgram: mintA.programAddress
|
|
12992
13256
|
}))[0];
|
|
12993
|
-
const vaultBAta = (await (0,
|
|
13257
|
+
const vaultBAta = (await (0, import_token_202228.findAssociatedTokenPda)({
|
|
12994
13258
|
owner: vaultB.address,
|
|
12995
13259
|
mint: mintB.address,
|
|
12996
13260
|
tokenProgram: mintB.programAddress
|
|
@@ -13005,30 +13269,30 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
13005
13269
|
tunaPosition.data.tickUpperIndex
|
|
13006
13270
|
);
|
|
13007
13271
|
const remainingAccounts = [
|
|
13008
|
-
{ address: swapTickArrays[0], role:
|
|
13009
|
-
{ address: swapTickArrays[1], role:
|
|
13010
|
-
{ address: swapTickArrays[2], role:
|
|
13011
|
-
{ address: swapTickArrays[3], role:
|
|
13012
|
-
{ address: swapTickArrays[4], role:
|
|
13013
|
-
{ address: lowerTickArrayAddress, role:
|
|
13014
|
-
{ address: upperTickArrayAddress, role:
|
|
13015
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
13016
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
13017
|
-
{ 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 }
|
|
13018
13282
|
];
|
|
13019
13283
|
for (const rewardIndex of rewardIndicesToClaim) {
|
|
13020
13284
|
const rewardInfo = whirlpool.data.rewardInfos[rewardIndex];
|
|
13021
13285
|
const rewardMint = rewardMints.find((mint) => mint.address == rewardInfo.mint);
|
|
13022
13286
|
(0, import_assert20.default)(rewardMint, "Reward mint not found in the provided reward mint accounts");
|
|
13023
|
-
const ownerAta = await (0,
|
|
13287
|
+
const ownerAta = await (0, import_token_202228.findAssociatedTokenPda)({
|
|
13024
13288
|
owner: authority.address,
|
|
13025
13289
|
mint: rewardMint.address,
|
|
13026
13290
|
tokenProgram: rewardMint.programAddress
|
|
13027
13291
|
});
|
|
13028
|
-
remainingAccounts.push({ address: rewardMint.address, role:
|
|
13029
|
-
remainingAccounts.push({ address: rewardMint.programAddress, role:
|
|
13030
|
-
remainingAccounts.push({ address: ownerAta[0], role:
|
|
13031
|
-
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 });
|
|
13032
13296
|
}
|
|
13033
13297
|
const remainingAccountsInfo = {
|
|
13034
13298
|
slices: [
|
|
@@ -13066,7 +13330,7 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
13066
13330
|
whirlpoolProgram: import_whirlpools_client14.WHIRLPOOL_PROGRAM_ADDRESS,
|
|
13067
13331
|
tokenProgramA: mintA.programAddress,
|
|
13068
13332
|
tokenProgramB: mintB.programAddress,
|
|
13069
|
-
memoProgram:
|
|
13333
|
+
memoProgram: import_memo18.MEMO_PROGRAM_ADDRESS,
|
|
13070
13334
|
...args,
|
|
13071
13335
|
remainingAccountsInfo
|
|
13072
13336
|
});
|
|
@@ -13076,9 +13340,9 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
13076
13340
|
|
|
13077
13341
|
// src/txbuilder/decreaseTunaLpPositionFusion.ts
|
|
13078
13342
|
var import_fusionamm_client15 = require("@crypticdot/fusionamm-client");
|
|
13079
|
-
var
|
|
13080
|
-
var
|
|
13081
|
-
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");
|
|
13082
13346
|
var import_assert21 = __toESM(require("assert"));
|
|
13083
13347
|
async function decreaseTunaLpPositionFusionInstructions(rpc, authority, positionMint, args, createInstructions, cleanupInstructions) {
|
|
13084
13348
|
const tunaPosition = await fetchMaybeTunaLpPosition(rpc, (await getTunaLpPositionAddress(positionMint))[0]);
|
|
@@ -13089,7 +13353,7 @@ async function decreaseTunaLpPositionFusionInstructions(rpc, authority, position
|
|
|
13089
13353
|
(await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
|
|
13090
13354
|
(await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
|
|
13091
13355
|
]);
|
|
13092
|
-
const [mintA, mintB] = await (0,
|
|
13356
|
+
const [mintA, mintB] = await (0, import_token_202229.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
13093
13357
|
(0, import_assert21.default)(mintA.exists, "Token A account not found");
|
|
13094
13358
|
(0, import_assert21.default)(mintB.exists, "Token B account not found");
|
|
13095
13359
|
const instructions = [];
|
|
@@ -13132,37 +13396,37 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13132
13396
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
13133
13397
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
13134
13398
|
const fusionPositionAddress = (await (0, import_fusionamm_client15.getPositionAddress)(positionMint))[0];
|
|
13135
|
-
const tunaPositionAta = (await (0,
|
|
13399
|
+
const tunaPositionAta = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13136
13400
|
owner: tunaPosition.address,
|
|
13137
13401
|
mint: positionMint,
|
|
13138
|
-
tokenProgram:
|
|
13402
|
+
tokenProgram: import_token_202229.TOKEN_2022_PROGRAM_ADDRESS
|
|
13139
13403
|
}))[0];
|
|
13140
|
-
const tunaPositionOwnerAtaA = (await (0,
|
|
13404
|
+
const tunaPositionOwnerAtaA = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13141
13405
|
owner: authority.address,
|
|
13142
13406
|
mint: mintA.address,
|
|
13143
13407
|
tokenProgram: mintA.programAddress
|
|
13144
13408
|
}))[0];
|
|
13145
|
-
const tunaPositionOwnerAtaB = (await (0,
|
|
13409
|
+
const tunaPositionOwnerAtaB = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13146
13410
|
owner: authority.address,
|
|
13147
13411
|
mint: mintB.address,
|
|
13148
13412
|
tokenProgram: mintB.programAddress
|
|
13149
13413
|
}))[0];
|
|
13150
|
-
const tunaPositionAtaA = (await (0,
|
|
13414
|
+
const tunaPositionAtaA = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13151
13415
|
owner: tunaPosition.address,
|
|
13152
13416
|
mint: mintA.address,
|
|
13153
13417
|
tokenProgram: mintA.programAddress
|
|
13154
13418
|
}))[0];
|
|
13155
|
-
const tunaPositionAtaB = (await (0,
|
|
13419
|
+
const tunaPositionAtaB = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13156
13420
|
owner: tunaPosition.address,
|
|
13157
13421
|
mint: mintB.address,
|
|
13158
13422
|
tokenProgram: mintB.programAddress
|
|
13159
13423
|
}))[0];
|
|
13160
|
-
const vaultAAta = (await (0,
|
|
13424
|
+
const vaultAAta = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13161
13425
|
owner: vaultA.address,
|
|
13162
13426
|
mint: mintA.address,
|
|
13163
13427
|
tokenProgram: mintA.programAddress
|
|
13164
13428
|
}))[0];
|
|
13165
|
-
const vaultBAta = (await (0,
|
|
13429
|
+
const vaultBAta = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13166
13430
|
owner: vaultB.address,
|
|
13167
13431
|
mint: mintB.address,
|
|
13168
13432
|
tokenProgram: mintB.programAddress
|
|
@@ -13177,15 +13441,15 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13177
13441
|
tunaPosition.data.tickUpperIndex
|
|
13178
13442
|
);
|
|
13179
13443
|
const remainingAccounts = [
|
|
13180
|
-
{ address: swapTickArrays[0], role:
|
|
13181
|
-
{ address: swapTickArrays[1], role:
|
|
13182
|
-
{ address: swapTickArrays[2], role:
|
|
13183
|
-
{ address: swapTickArrays[3], role:
|
|
13184
|
-
{ address: swapTickArrays[4], role:
|
|
13185
|
-
{ address: lowerTickArrayAddress, role:
|
|
13186
|
-
{ address: upperTickArrayAddress, role:
|
|
13187
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
13188
|
-
{ 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 }
|
|
13189
13453
|
];
|
|
13190
13454
|
const remainingAccountsInfo = {
|
|
13191
13455
|
slices: [
|
|
@@ -13219,7 +13483,7 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13219
13483
|
fusionammProgram: import_fusionamm_client15.FUSIONAMM_PROGRAM_ADDRESS,
|
|
13220
13484
|
tokenProgramA: mintA.programAddress,
|
|
13221
13485
|
tokenProgramB: mintB.programAddress,
|
|
13222
|
-
memoProgram:
|
|
13486
|
+
memoProgram: import_memo19.MEMO_PROGRAM_ADDRESS,
|
|
13223
13487
|
...args,
|
|
13224
13488
|
remainingAccountsInfo
|
|
13225
13489
|
});
|
|
@@ -13228,19 +13492,19 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13228
13492
|
}
|
|
13229
13493
|
|
|
13230
13494
|
// src/txbuilder/repayBadDebt.ts
|
|
13231
|
-
var
|
|
13232
|
-
var
|
|
13495
|
+
var import_memo20 = require("@solana-program/memo");
|
|
13496
|
+
var import_token_202230 = require("@solana-program/token-2022");
|
|
13233
13497
|
async function repayBadDebtInstruction(rpc, authority, mintAddress, funds, shares) {
|
|
13234
|
-
const mint = await (0,
|
|
13498
|
+
const mint = await (0, import_token_202230.fetchMaybeMint)(rpc, mintAddress);
|
|
13235
13499
|
if (!mint.exists) throw new Error("Mint account not found");
|
|
13236
13500
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
13237
13501
|
const vault = (await getLendingVaultAddress(mint.address))[0];
|
|
13238
|
-
const vaultAta = (await (0,
|
|
13502
|
+
const vaultAta = (await (0, import_token_202230.findAssociatedTokenPda)({
|
|
13239
13503
|
owner: vault,
|
|
13240
13504
|
mint: mint.address,
|
|
13241
13505
|
tokenProgram: mint.programAddress
|
|
13242
13506
|
}))[0];
|
|
13243
|
-
const authorityAta = (await (0,
|
|
13507
|
+
const authorityAta = (await (0, import_token_202230.findAssociatedTokenPda)({
|
|
13244
13508
|
owner: authority.address,
|
|
13245
13509
|
mint: mint.address,
|
|
13246
13510
|
tokenProgram: mint.programAddress
|
|
@@ -13253,7 +13517,7 @@ async function repayBadDebtInstruction(rpc, authority, mintAddress, funds, share
|
|
|
13253
13517
|
tunaConfig,
|
|
13254
13518
|
vault,
|
|
13255
13519
|
tokenProgram: mint.programAddress,
|
|
13256
|
-
memoProgram:
|
|
13520
|
+
memoProgram: import_memo20.MEMO_PROGRAM_ADDRESS,
|
|
13257
13521
|
funds,
|
|
13258
13522
|
shares
|
|
13259
13523
|
});
|
|
@@ -13285,20 +13549,20 @@ async function setTunaSpotPositionLimitOrdersInstruction(authority, poolAddress,
|
|
|
13285
13549
|
}
|
|
13286
13550
|
|
|
13287
13551
|
// src/txbuilder/resetTunaSpotPosition.ts
|
|
13288
|
-
var
|
|
13552
|
+
var import_token_202231 = require("@solana-program/token-2022");
|
|
13289
13553
|
var import_assert22 = __toESM(require("assert"));
|
|
13290
13554
|
async function resetTunaSpotPositionInstruction(rpc, authority, poolAddress, args) {
|
|
13291
13555
|
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
13292
13556
|
const tunaPosition = await fetchTunaSpotPosition(rpc, tunaPositionAddress);
|
|
13293
|
-
const [mintA, mintB] = await (0,
|
|
13557
|
+
const [mintA, mintB] = await (0, import_token_202231.fetchAllMaybeMint)(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
13294
13558
|
(0, import_assert22.default)(mintA.exists, "Token A not found");
|
|
13295
13559
|
(0, import_assert22.default)(mintB.exists, "Token B not found");
|
|
13296
|
-
const tunaPositionAtaA = (await (0,
|
|
13560
|
+
const tunaPositionAtaA = (await (0, import_token_202231.findAssociatedTokenPda)({
|
|
13297
13561
|
owner: tunaPositionAddress,
|
|
13298
13562
|
mint: mintA.address,
|
|
13299
13563
|
tokenProgram: mintA.programAddress
|
|
13300
13564
|
}))[0];
|
|
13301
|
-
const tunaPositionAtaB = (await (0,
|
|
13565
|
+
const tunaPositionAtaB = (await (0, import_token_202231.findAssociatedTokenPda)({
|
|
13302
13566
|
owner: tunaPositionAddress,
|
|
13303
13567
|
mint: mintB.address,
|
|
13304
13568
|
tokenProgram: mintB.programAddress
|
|
@@ -13339,11 +13603,11 @@ async function updateVaultInstruction(authority, mint, args) {
|
|
|
13339
13603
|
}
|
|
13340
13604
|
|
|
13341
13605
|
// src/txbuilder/withdraw.ts
|
|
13342
|
-
var
|
|
13343
|
-
var
|
|
13606
|
+
var import_memo21 = require("@solana-program/memo");
|
|
13607
|
+
var import_token_202232 = require("@solana-program/token-2022");
|
|
13344
13608
|
async function withdrawInstructions(rpc, authority, mintAddress, funds, shares) {
|
|
13345
13609
|
const instructions = [];
|
|
13346
|
-
const mint = await (0,
|
|
13610
|
+
const mint = await (0, import_token_202232.fetchMaybeMint)(rpc, mintAddress);
|
|
13347
13611
|
if (!mint.exists) throw new Error("Mint account not found");
|
|
13348
13612
|
const createUserAtaInstructions = await getCreateAtaInstructions(
|
|
13349
13613
|
rpc,
|
|
@@ -13362,12 +13626,12 @@ async function withdrawInstruction(authority, mint, funds, shares) {
|
|
|
13362
13626
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
13363
13627
|
const lendingPosition = (await getLendingPositionAddress(authority.address, mint.address))[0];
|
|
13364
13628
|
const vault = (await getLendingVaultAddress(mint.address))[0];
|
|
13365
|
-
const vaultAta = (await (0,
|
|
13629
|
+
const vaultAta = (await (0, import_token_202232.findAssociatedTokenPda)({
|
|
13366
13630
|
owner: vault,
|
|
13367
13631
|
mint: mint.address,
|
|
13368
13632
|
tokenProgram: mint.programAddress
|
|
13369
13633
|
}))[0];
|
|
13370
|
-
const authorityAta = (await (0,
|
|
13634
|
+
const authorityAta = (await (0, import_token_202232.findAssociatedTokenPda)({
|
|
13371
13635
|
owner: authority.address,
|
|
13372
13636
|
mint: mint.address,
|
|
13373
13637
|
tokenProgram: mint.programAddress
|
|
@@ -13381,7 +13645,7 @@ async function withdrawInstruction(authority, mint, funds, shares) {
|
|
|
13381
13645
|
vault,
|
|
13382
13646
|
vaultAta,
|
|
13383
13647
|
tokenProgram: mint.programAddress,
|
|
13384
|
-
memoProgram:
|
|
13648
|
+
memoProgram: import_memo21.MEMO_PROGRAM_ADDRESS,
|
|
13385
13649
|
funds,
|
|
13386
13650
|
shares
|
|
13387
13651
|
});
|
|
@@ -13390,26 +13654,26 @@ async function withdrawInstruction(authority, mint, funds, shares) {
|
|
|
13390
13654
|
// src/txbuilder/createMarketLookupTable.ts
|
|
13391
13655
|
var import_fusionamm_client16 = require("@crypticdot/fusionamm-client");
|
|
13392
13656
|
var import_whirlpools_client15 = require("@orca-so/whirlpools-client");
|
|
13393
|
-
var
|
|
13657
|
+
var import_kit127 = require("@solana/kit");
|
|
13394
13658
|
var import_address_lookup_table2 = require("@solana-program/address-lookup-table");
|
|
13395
|
-
var
|
|
13659
|
+
var import_memo22 = require("@solana-program/memo");
|
|
13396
13660
|
var import_system2 = require("@solana-program/system");
|
|
13397
13661
|
var import_token2 = require("@solana-program/token");
|
|
13398
|
-
var
|
|
13662
|
+
var import_token_202233 = require("@solana-program/token-2022");
|
|
13399
13663
|
async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
13400
13664
|
const tunaConfigAddress = (await getTunaConfigAddress())[0];
|
|
13401
13665
|
const marketAddress = (await getMarketAddress(poolAddress))[0];
|
|
13402
13666
|
const orcaOracleAddress = (await (0, import_whirlpools_client15.getOracleAddress)(poolAddress))[0];
|
|
13403
13667
|
const tunaConfig = await fetchTunaConfig(rpc, tunaConfigAddress);
|
|
13404
13668
|
const pool = marketMaker == 0 /* Orca */ ? await (0, import_whirlpools_client15.fetchWhirlpool)(rpc, poolAddress) : await (0, import_fusionamm_client16.fetchFusionPool)(rpc, poolAddress);
|
|
13405
|
-
const mintA = await (0,
|
|
13406
|
-
const mintB = await (0,
|
|
13407
|
-
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)({
|
|
13408
13672
|
owner: tunaConfig.data.feeRecipient,
|
|
13409
13673
|
mint: mintA.address,
|
|
13410
13674
|
tokenProgram: mintA.programAddress
|
|
13411
13675
|
}))[0];
|
|
13412
|
-
const feeRecipientAtaB = (await (0,
|
|
13676
|
+
const feeRecipientAtaB = (await (0, import_token_202233.findAssociatedTokenPda)({
|
|
13413
13677
|
owner: tunaConfig.data.feeRecipient,
|
|
13414
13678
|
mint: mintB.address,
|
|
13415
13679
|
tokenProgram: mintB.programAddress
|
|
@@ -13418,24 +13682,24 @@ async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
|
13418
13682
|
(await getLendingVaultAddress(mintA.address))[0],
|
|
13419
13683
|
(await getLendingVaultAddress(mintB.address))[0]
|
|
13420
13684
|
]);
|
|
13421
|
-
const vaultAAta = (await (0,
|
|
13685
|
+
const vaultAAta = (await (0, import_token_202233.findAssociatedTokenPda)({
|
|
13422
13686
|
owner: vaultA.address,
|
|
13423
13687
|
mint: mintA.address,
|
|
13424
13688
|
tokenProgram: mintA.programAddress
|
|
13425
13689
|
}))[0];
|
|
13426
|
-
const vaultBAta = (await (0,
|
|
13690
|
+
const vaultBAta = (await (0, import_token_202233.findAssociatedTokenPda)({
|
|
13427
13691
|
owner: vaultB.address,
|
|
13428
13692
|
mint: mintB.address,
|
|
13429
13693
|
tokenProgram: mintB.programAddress
|
|
13430
13694
|
}))[0];
|
|
13431
13695
|
const addresses = [
|
|
13432
13696
|
import_system2.SYSTEM_PROGRAM_ADDRESS,
|
|
13433
|
-
(0,
|
|
13434
|
-
|
|
13697
|
+
(0, import_kit127.address)("SysvarRent111111111111111111111111111111111"),
|
|
13698
|
+
import_token_202233.ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
13435
13699
|
import_token2.TOKEN_PROGRAM_ADDRESS,
|
|
13436
|
-
|
|
13700
|
+
import_token_202233.TOKEN_2022_PROGRAM_ADDRESS,
|
|
13437
13701
|
NATIVE_MINT,
|
|
13438
|
-
|
|
13702
|
+
import_memo22.MEMO_PROGRAM_ADDRESS,
|
|
13439
13703
|
tunaConfigAddress,
|
|
13440
13704
|
marketAddress,
|
|
13441
13705
|
mintA.address,
|
|
@@ -13490,15 +13754,15 @@ async function extendAddressLookupTableForMarketInstructions(rpc, poolAddress, m
|
|
|
13490
13754
|
}
|
|
13491
13755
|
|
|
13492
13756
|
// src/txbuilder/repayTunaLpPositionDebt.ts
|
|
13493
|
-
var
|
|
13494
|
-
var
|
|
13757
|
+
var import_memo23 = require("@solana-program/memo");
|
|
13758
|
+
var import_token_202234 = require("@solana-program/token-2022");
|
|
13495
13759
|
var import_assert23 = __toESM(require("assert"));
|
|
13496
13760
|
async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint, collateralA, collateralB, createInstructions, cleanupInstructions) {
|
|
13497
13761
|
const instructions = [];
|
|
13498
13762
|
if (!createInstructions) createInstructions = instructions;
|
|
13499
13763
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
13500
13764
|
const tunaPosition = await fetchTunaLpPosition(rpc, (await getTunaLpPositionAddress(positionMint))[0]);
|
|
13501
|
-
const [mintA, mintB] = await (0,
|
|
13765
|
+
const [mintA, mintB] = await (0, import_token_202234.fetchAllMaybeMint)(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
13502
13766
|
(0, import_assert23.default)(mintA.exists, "Token A not found");
|
|
13503
13767
|
(0, import_assert23.default)(mintB.exists, "Token B not found");
|
|
13504
13768
|
const marketAddress = (await getMarketAddress(tunaPosition.data.pool))[0];
|
|
@@ -13536,34 +13800,34 @@ async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint,
|
|
|
13536
13800
|
}
|
|
13537
13801
|
async function repayTunaLpPositionDebtInstruction(authority, positionMint, mintA, mintB, marketAddress, collateralA, collateralB) {
|
|
13538
13802
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint))[0];
|
|
13539
|
-
const tunaPositionOwnerAtaA = (await (0,
|
|
13803
|
+
const tunaPositionOwnerAtaA = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13540
13804
|
owner: authority.address,
|
|
13541
13805
|
mint: mintA.address,
|
|
13542
13806
|
tokenProgram: mintA.programAddress
|
|
13543
13807
|
}))[0];
|
|
13544
|
-
const tunaPositionOwnerAtaB = (await (0,
|
|
13808
|
+
const tunaPositionOwnerAtaB = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13545
13809
|
owner: authority.address,
|
|
13546
13810
|
mint: mintB.address,
|
|
13547
13811
|
tokenProgram: mintB.programAddress
|
|
13548
13812
|
}))[0];
|
|
13549
|
-
const tunaPositionAtaA = (await (0,
|
|
13813
|
+
const tunaPositionAtaA = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13550
13814
|
owner: tunaPositionAddress,
|
|
13551
13815
|
mint: mintA.address,
|
|
13552
13816
|
tokenProgram: mintA.programAddress
|
|
13553
13817
|
}))[0];
|
|
13554
|
-
const tunaPositionAtaB = (await (0,
|
|
13818
|
+
const tunaPositionAtaB = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13555
13819
|
owner: tunaPositionAddress,
|
|
13556
13820
|
mint: mintB.address,
|
|
13557
13821
|
tokenProgram: mintB.programAddress
|
|
13558
13822
|
}))[0];
|
|
13559
13823
|
const vaultAAddress = (await getLendingVaultAddress(mintA.address))[0];
|
|
13560
|
-
const vaultAAta = (await (0,
|
|
13824
|
+
const vaultAAta = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13561
13825
|
owner: vaultAAddress,
|
|
13562
13826
|
mint: mintA.address,
|
|
13563
13827
|
tokenProgram: mintA.programAddress
|
|
13564
13828
|
}))[0];
|
|
13565
13829
|
const vaultBAddress = (await getLendingVaultAddress(mintB.address))[0];
|
|
13566
|
-
const vaultBAta = (await (0,
|
|
13830
|
+
const vaultBAta = (await (0, import_token_202234.findAssociatedTokenPda)({
|
|
13567
13831
|
owner: vaultBAddress,
|
|
13568
13832
|
mint: mintB.address,
|
|
13569
13833
|
tokenProgram: mintB.programAddress
|
|
@@ -13571,7 +13835,7 @@ async function repayTunaLpPositionDebtInstruction(authority, positionMint, mintA
|
|
|
13571
13835
|
return getRepayTunaLpPositionDebtInstruction({
|
|
13572
13836
|
authority,
|
|
13573
13837
|
market: marketAddress,
|
|
13574
|
-
memoProgram:
|
|
13838
|
+
memoProgram: import_memo23.MEMO_PROGRAM_ADDRESS,
|
|
13575
13839
|
mintA: mintA.address,
|
|
13576
13840
|
mintB: mintB.address,
|
|
13577
13841
|
tokenProgramA: mintA.programAddress,
|
|
@@ -13592,10 +13856,10 @@ async function repayTunaLpPositionDebtInstruction(authority, positionMint, mintA
|
|
|
13592
13856
|
|
|
13593
13857
|
// src/txbuilder/rebalanceTunaLpPositionOrca.ts
|
|
13594
13858
|
var import_whirlpools_client16 = require("@orca-so/whirlpools-client");
|
|
13595
|
-
var
|
|
13859
|
+
var import_kit128 = require("@solana/kit");
|
|
13596
13860
|
var import_sysvars3 = require("@solana/sysvars");
|
|
13597
|
-
var
|
|
13598
|
-
var
|
|
13861
|
+
var import_memo24 = require("@solana-program/memo");
|
|
13862
|
+
var import_token_202235 = require("@solana-program/token-2022");
|
|
13599
13863
|
var import_assert24 = __toESM(require("assert"));
|
|
13600
13864
|
async function rebalanceTunaLpPositionOrcaInstructions(rpc, authority, positionMint, createInstructions, cleanupInstructions) {
|
|
13601
13865
|
const rent = await (0, import_sysvars3.fetchSysvarRent)(rpc);
|
|
@@ -13609,7 +13873,7 @@ async function rebalanceTunaLpPositionOrcaInstructions(rpc, authority, positionM
|
|
|
13609
13873
|
(await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
|
|
13610
13874
|
(await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
|
|
13611
13875
|
]);
|
|
13612
|
-
const [mintA, mintB] = await (0,
|
|
13876
|
+
const [mintA, mintB] = await (0, import_token_202235.fetchAllMaybeMint)(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
13613
13877
|
(0, import_assert24.default)(mintA.exists, "Token A account not found");
|
|
13614
13878
|
(0, import_assert24.default)(mintB.exists, "Token B account not found");
|
|
13615
13879
|
const instructions = [];
|
|
@@ -13675,7 +13939,7 @@ async function rebalanceTunaLpPositionOrcaInstructions(rpc, authority, positionM
|
|
|
13675
13939
|
cleanupInstructions.push(...internalCleanupInstructions);
|
|
13676
13940
|
return {
|
|
13677
13941
|
instructions,
|
|
13678
|
-
initializationCost: (0,
|
|
13942
|
+
initializationCost: (0, import_kit128.lamports)(nonRefundableRent)
|
|
13679
13943
|
};
|
|
13680
13944
|
}
|
|
13681
13945
|
async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool) {
|
|
@@ -13683,27 +13947,27 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
13683
13947
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
13684
13948
|
const orcaPositionAddress = (await (0, import_whirlpools_client16.getPositionAddress)(positionMint))[0];
|
|
13685
13949
|
const orcaOracleAddress = (await (0, import_whirlpools_client16.getOracleAddress)(whirlpool.address))[0];
|
|
13686
|
-
const tunaPositionAta = (await (0,
|
|
13950
|
+
const tunaPositionAta = (await (0, import_token_202235.findAssociatedTokenPda)({
|
|
13687
13951
|
owner: tunaPosition.address,
|
|
13688
13952
|
mint: positionMint,
|
|
13689
|
-
tokenProgram:
|
|
13953
|
+
tokenProgram: import_token_202235.TOKEN_2022_PROGRAM_ADDRESS
|
|
13690
13954
|
}))[0];
|
|
13691
|
-
const tunaPositionAtaA = (await (0,
|
|
13955
|
+
const tunaPositionAtaA = (await (0, import_token_202235.findAssociatedTokenPda)({
|
|
13692
13956
|
owner: tunaPosition.address,
|
|
13693
13957
|
mint: mintA.address,
|
|
13694
13958
|
tokenProgram: mintA.programAddress
|
|
13695
13959
|
}))[0];
|
|
13696
|
-
const tunaPositionAtaB = (await (0,
|
|
13960
|
+
const tunaPositionAtaB = (await (0, import_token_202235.findAssociatedTokenPda)({
|
|
13697
13961
|
owner: tunaPosition.address,
|
|
13698
13962
|
mint: mintB.address,
|
|
13699
13963
|
tokenProgram: mintB.programAddress
|
|
13700
13964
|
}))[0];
|
|
13701
|
-
const feeRecipientAtaA = (await (0,
|
|
13965
|
+
const feeRecipientAtaA = (await (0, import_token_202235.findAssociatedTokenPda)({
|
|
13702
13966
|
owner: tunaConfig.data.feeRecipient,
|
|
13703
13967
|
mint: mintA.address,
|
|
13704
13968
|
tokenProgram: mintA.programAddress
|
|
13705
13969
|
}))[0];
|
|
13706
|
-
const feeRecipientAtaB = (await (0,
|
|
13970
|
+
const feeRecipientAtaB = (await (0, import_token_202235.findAssociatedTokenPda)({
|
|
13707
13971
|
owner: tunaConfig.data.feeRecipient,
|
|
13708
13972
|
mint: mintB.address,
|
|
13709
13973
|
tokenProgram: mintB.programAddress
|
|
@@ -13719,18 +13983,18 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
13719
13983
|
);
|
|
13720
13984
|
const secondaryTickArrays = await OrcaUtils.getTickArraysForRebalancedPosition(whirlpool, tunaPosition);
|
|
13721
13985
|
const remainingAccounts = [
|
|
13722
|
-
{ address: swapTickArrays[0], role:
|
|
13723
|
-
{ address: swapTickArrays[1], role:
|
|
13724
|
-
{ address: swapTickArrays[2], role:
|
|
13725
|
-
{ address: swapTickArrays[3], role:
|
|
13726
|
-
{ address: swapTickArrays[4], role:
|
|
13727
|
-
{ address: lowerTickArrayAddress, role:
|
|
13728
|
-
{ address: upperTickArrayAddress, role:
|
|
13729
|
-
{ address: secondaryTickArrays.lowerTickArrayAddress, role:
|
|
13730
|
-
{ address: secondaryTickArrays.upperTickArrayAddress, role:
|
|
13731
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
13732
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
13733
|
-
{ 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 }
|
|
13734
13998
|
];
|
|
13735
13999
|
const remainingAccountsInfo = {
|
|
13736
14000
|
slices: [
|
|
@@ -13765,7 +14029,7 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
13765
14029
|
whirlpoolProgram: import_whirlpools_client16.WHIRLPOOL_PROGRAM_ADDRESS,
|
|
13766
14030
|
tokenProgramA: mintA.programAddress,
|
|
13767
14031
|
tokenProgramB: mintB.programAddress,
|
|
13768
|
-
memoProgram:
|
|
14032
|
+
memoProgram: import_memo24.MEMO_PROGRAM_ADDRESS,
|
|
13769
14033
|
remainingAccountsInfo
|
|
13770
14034
|
});
|
|
13771
14035
|
ix.accounts.push(...remainingAccounts);
|
|
@@ -13774,10 +14038,10 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
13774
14038
|
|
|
13775
14039
|
// src/txbuilder/rebalanceTunaLpPositionFusion.ts
|
|
13776
14040
|
var import_fusionamm_client17 = require("@crypticdot/fusionamm-client");
|
|
13777
|
-
var
|
|
14041
|
+
var import_kit129 = require("@solana/kit");
|
|
13778
14042
|
var import_sysvars4 = require("@solana/sysvars");
|
|
13779
|
-
var
|
|
13780
|
-
var
|
|
14043
|
+
var import_memo25 = require("@solana-program/memo");
|
|
14044
|
+
var import_token_202236 = require("@solana-program/token-2022");
|
|
13781
14045
|
var import_assert25 = __toESM(require("assert"));
|
|
13782
14046
|
async function rebalanceTunaLpPositionFusionInstructions(rpc, authority, positionMint, createInstructions, cleanupInstructions) {
|
|
13783
14047
|
const rent = await (0, import_sysvars4.fetchSysvarRent)(rpc);
|
|
@@ -13791,7 +14055,7 @@ async function rebalanceTunaLpPositionFusionInstructions(rpc, authority, positio
|
|
|
13791
14055
|
(await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
|
|
13792
14056
|
(await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
|
|
13793
14057
|
]);
|
|
13794
|
-
const [mintA, mintB] = await (0,
|
|
14058
|
+
const [mintA, mintB] = await (0, import_token_202236.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
13795
14059
|
(0, import_assert25.default)(mintA.exists, "Token A account not found");
|
|
13796
14060
|
(0, import_assert25.default)(mintB.exists, "Token B account not found");
|
|
13797
14061
|
const instructions = [];
|
|
@@ -13853,34 +14117,34 @@ async function rebalanceTunaLpPositionFusionInstructions(rpc, authority, positio
|
|
|
13853
14117
|
instructions.push(ix);
|
|
13854
14118
|
return {
|
|
13855
14119
|
instructions,
|
|
13856
|
-
initializationCost: (0,
|
|
14120
|
+
initializationCost: (0, import_kit129.lamports)(nonRefundableRent)
|
|
13857
14121
|
};
|
|
13858
14122
|
}
|
|
13859
14123
|
async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool) {
|
|
13860
14124
|
const positionMint = tunaPosition.data.positionMint;
|
|
13861
14125
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
13862
14126
|
const fusionPositionAddress = (await (0, import_fusionamm_client17.getPositionAddress)(positionMint))[0];
|
|
13863
|
-
const tunaPositionAta = (await (0,
|
|
14127
|
+
const tunaPositionAta = (await (0, import_token_202236.findAssociatedTokenPda)({
|
|
13864
14128
|
owner: tunaPosition.address,
|
|
13865
14129
|
mint: positionMint,
|
|
13866
|
-
tokenProgram:
|
|
14130
|
+
tokenProgram: import_token_202236.TOKEN_2022_PROGRAM_ADDRESS
|
|
13867
14131
|
}))[0];
|
|
13868
|
-
const tunaPositionAtaA = (await (0,
|
|
14132
|
+
const tunaPositionAtaA = (await (0, import_token_202236.findAssociatedTokenPda)({
|
|
13869
14133
|
owner: tunaPosition.address,
|
|
13870
14134
|
mint: mintA.address,
|
|
13871
14135
|
tokenProgram: mintA.programAddress
|
|
13872
14136
|
}))[0];
|
|
13873
|
-
const tunaPositionAtaB = (await (0,
|
|
14137
|
+
const tunaPositionAtaB = (await (0, import_token_202236.findAssociatedTokenPda)({
|
|
13874
14138
|
owner: tunaPosition.address,
|
|
13875
14139
|
mint: mintB.address,
|
|
13876
14140
|
tokenProgram: mintB.programAddress
|
|
13877
14141
|
}))[0];
|
|
13878
|
-
const feeRecipientAtaA = (await (0,
|
|
14142
|
+
const feeRecipientAtaA = (await (0, import_token_202236.findAssociatedTokenPda)({
|
|
13879
14143
|
owner: tunaConfig.data.feeRecipient,
|
|
13880
14144
|
mint: mintA.address,
|
|
13881
14145
|
tokenProgram: mintA.programAddress
|
|
13882
14146
|
}))[0];
|
|
13883
|
-
const feeRecipientAtaB = (await (0,
|
|
14147
|
+
const feeRecipientAtaB = (await (0, import_token_202236.findAssociatedTokenPda)({
|
|
13884
14148
|
owner: tunaConfig.data.feeRecipient,
|
|
13885
14149
|
mint: mintB.address,
|
|
13886
14150
|
tokenProgram: mintB.programAddress
|
|
@@ -13896,17 +14160,17 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13896
14160
|
);
|
|
13897
14161
|
const secondaryTickArrays = await FusionUtils.getTickArraysForRebalancedPosition(fusionPool, tunaPosition);
|
|
13898
14162
|
const remainingAccounts = [
|
|
13899
|
-
{ address: swapTickArrays[0], role:
|
|
13900
|
-
{ address: swapTickArrays[1], role:
|
|
13901
|
-
{ address: swapTickArrays[2], role:
|
|
13902
|
-
{ address: swapTickArrays[3], role:
|
|
13903
|
-
{ address: swapTickArrays[4], role:
|
|
13904
|
-
{ address: lowerTickArrayAddress, role:
|
|
13905
|
-
{ address: upperTickArrayAddress, role:
|
|
13906
|
-
{ address: secondaryTickArrays.lowerTickArrayAddress, role:
|
|
13907
|
-
{ address: secondaryTickArrays.upperTickArrayAddress, role:
|
|
13908
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
13909
|
-
{ 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 }
|
|
13910
14174
|
];
|
|
13911
14175
|
const remainingAccountsInfo = {
|
|
13912
14176
|
slices: [
|
|
@@ -13940,7 +14204,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13940
14204
|
fusionammProgram: import_fusionamm_client17.FUSIONAMM_PROGRAM_ADDRESS,
|
|
13941
14205
|
tokenProgramA: mintA.programAddress,
|
|
13942
14206
|
tokenProgramB: mintB.programAddress,
|
|
13943
|
-
memoProgram:
|
|
14207
|
+
memoProgram: import_memo25.MEMO_PROGRAM_ADDRESS,
|
|
13944
14208
|
remainingAccountsInfo
|
|
13945
14209
|
});
|
|
13946
14210
|
ix.accounts.push(...remainingAccounts);
|
|
@@ -14026,6 +14290,8 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
14026
14290
|
TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED,
|
|
14027
14291
|
TUNA_ERROR__BAD_DEBT,
|
|
14028
14292
|
TUNA_ERROR__INCORRECT_POSITION_DIRECTION,
|
|
14293
|
+
TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT,
|
|
14294
|
+
TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT,
|
|
14029
14295
|
TUNA_ERROR__INSUFFICIENT_LIQUIDITY,
|
|
14030
14296
|
TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT,
|
|
14031
14297
|
TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE,
|
|
@@ -14105,6 +14371,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
14105
14371
|
TunaPositionState,
|
|
14106
14372
|
UNLIMITED_SUPPLY_LIMIT,
|
|
14107
14373
|
UPDATE_MARKET_DISCRIMINATOR,
|
|
14374
|
+
UPDATE_MARKET_VAULTS_DISCRIMINATOR,
|
|
14108
14375
|
UPDATE_VAULT_DISCRIMINATOR,
|
|
14109
14376
|
VAULT_DISCRIMINATOR,
|
|
14110
14377
|
WITHDRAW_DISCRIMINATOR,
|
|
@@ -14464,6 +14731,11 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
14464
14731
|
getUpdateMarketInstructionDataCodec,
|
|
14465
14732
|
getUpdateMarketInstructionDataDecoder,
|
|
14466
14733
|
getUpdateMarketInstructionDataEncoder,
|
|
14734
|
+
getUpdateMarketVaultsDiscriminatorBytes,
|
|
14735
|
+
getUpdateMarketVaultsInstruction,
|
|
14736
|
+
getUpdateMarketVaultsInstructionDataCodec,
|
|
14737
|
+
getUpdateMarketVaultsInstructionDataDecoder,
|
|
14738
|
+
getUpdateMarketVaultsInstructionDataEncoder,
|
|
14467
14739
|
getUpdateVaultDiscriminatorBytes,
|
|
14468
14740
|
getUpdateVaultInstruction,
|
|
14469
14741
|
getUpdateVaultInstructionDataCodec,
|
|
@@ -14494,6 +14766,8 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
14494
14766
|
liquidateTunaLpPositionOrcaInstructions,
|
|
14495
14767
|
liquidateTunaSpotPositionFusionInstruction,
|
|
14496
14768
|
liquidateTunaSpotPositionFusionInstructions,
|
|
14769
|
+
liquidateTunaSpotPositionJupiterInstruction,
|
|
14770
|
+
liquidateTunaSpotPositionJupiterInstructions,
|
|
14497
14771
|
liquidateTunaSpotPositionOrcaInstruction,
|
|
14498
14772
|
liquidateTunaSpotPositionOrcaInstructions,
|
|
14499
14773
|
modifyTunaSpotPositionFusionInstruction,
|
|
@@ -14561,6 +14835,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
14561
14835
|
parseSetTunaLpPositionRebalanceThresholdInstruction,
|
|
14562
14836
|
parseSetTunaSpotPositionLimitOrdersInstruction,
|
|
14563
14837
|
parseUpdateMarketInstruction,
|
|
14838
|
+
parseUpdateMarketVaultsInstruction,
|
|
14564
14839
|
parseUpdateVaultInstruction,
|
|
14565
14840
|
parseWithdrawInstruction,
|
|
14566
14841
|
rebalanceTunaLpPositionFusionInstruction,
|