@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.mjs
CHANGED
|
@@ -312,7 +312,9 @@ function getMarketEncoder() {
|
|
|
312
312
|
["rebalanceProtocolFee", getU32Encoder()],
|
|
313
313
|
["spotPositionSizeLimitA", getU64Encoder2()],
|
|
314
314
|
["spotPositionSizeLimitB", getU64Encoder2()],
|
|
315
|
-
["
|
|
315
|
+
["vaultA", getAddressEncoder2()],
|
|
316
|
+
["vaultB", getAddressEncoder2()],
|
|
317
|
+
["reserved", fixEncoderSize2(getBytesEncoder2(), 127)]
|
|
316
318
|
]),
|
|
317
319
|
(value) => ({ ...value, discriminator: MARKET_DISCRIMINATOR })
|
|
318
320
|
);
|
|
@@ -341,7 +343,9 @@ function getMarketDecoder() {
|
|
|
341
343
|
["rebalanceProtocolFee", getU32Decoder()],
|
|
342
344
|
["spotPositionSizeLimitA", getU64Decoder2()],
|
|
343
345
|
["spotPositionSizeLimitB", getU64Decoder2()],
|
|
344
|
-
["
|
|
346
|
+
["vaultA", getAddressDecoder2()],
|
|
347
|
+
["vaultB", getAddressDecoder2()],
|
|
348
|
+
["reserved", fixDecoderSize2(getBytesDecoder2(), 127)]
|
|
345
349
|
]);
|
|
346
350
|
}
|
|
347
351
|
function getMarketCodec() {
|
|
@@ -1006,8 +1010,9 @@ var TunaInstruction = /* @__PURE__ */ ((TunaInstruction2) => {
|
|
|
1006
1010
|
TunaInstruction2[TunaInstruction2["SetTunaLpPositionRebalanceThreshold"] = 45] = "SetTunaLpPositionRebalanceThreshold";
|
|
1007
1011
|
TunaInstruction2[TunaInstruction2["SetTunaSpotPositionLimitOrders"] = 46] = "SetTunaSpotPositionLimitOrders";
|
|
1008
1012
|
TunaInstruction2[TunaInstruction2["UpdateMarket"] = 47] = "UpdateMarket";
|
|
1009
|
-
TunaInstruction2[TunaInstruction2["
|
|
1010
|
-
TunaInstruction2[TunaInstruction2["
|
|
1013
|
+
TunaInstruction2[TunaInstruction2["UpdateMarketVaults"] = 48] = "UpdateMarketVaults";
|
|
1014
|
+
TunaInstruction2[TunaInstruction2["UpdateVault"] = 49] = "UpdateVault";
|
|
1015
|
+
TunaInstruction2[TunaInstruction2["Withdraw"] = 50] = "Withdraw";
|
|
1011
1016
|
return TunaInstruction2;
|
|
1012
1017
|
})(TunaInstruction || {});
|
|
1013
1018
|
function identifyTunaInstruction(instruction) {
|
|
@@ -1444,6 +1449,15 @@ function identifyTunaInstruction(instruction) {
|
|
|
1444
1449
|
)) {
|
|
1445
1450
|
return 47 /* UpdateMarket */;
|
|
1446
1451
|
}
|
|
1452
|
+
if (containsBytes(
|
|
1453
|
+
data,
|
|
1454
|
+
fixEncoderSize7(getBytesEncoder7(), 8).encode(
|
|
1455
|
+
new Uint8Array([59, 187, 50, 173, 89, 41, 205, 228])
|
|
1456
|
+
),
|
|
1457
|
+
0
|
|
1458
|
+
)) {
|
|
1459
|
+
return 48 /* UpdateMarketVaults */;
|
|
1460
|
+
}
|
|
1447
1461
|
if (containsBytes(
|
|
1448
1462
|
data,
|
|
1449
1463
|
fixEncoderSize7(getBytesEncoder7(), 8).encode(
|
|
@@ -1451,7 +1465,7 @@ function identifyTunaInstruction(instruction) {
|
|
|
1451
1465
|
),
|
|
1452
1466
|
0
|
|
1453
1467
|
)) {
|
|
1454
|
-
return
|
|
1468
|
+
return 49 /* UpdateVault */;
|
|
1455
1469
|
}
|
|
1456
1470
|
if (containsBytes(
|
|
1457
1471
|
data,
|
|
@@ -1460,7 +1474,7 @@ function identifyTunaInstruction(instruction) {
|
|
|
1460
1474
|
),
|
|
1461
1475
|
0
|
|
1462
1476
|
)) {
|
|
1463
|
-
return
|
|
1477
|
+
return 50 /* Withdraw */;
|
|
1464
1478
|
}
|
|
1465
1479
|
throw new Error(
|
|
1466
1480
|
"The provided instruction could not be identified as a tuna instruction."
|
|
@@ -1532,10 +1546,12 @@ var TUNA_ERROR__M_A_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 6060;
|
|
|
1532
1546
|
var TUNA_ERROR__POSITION_SIZE_LIMIT_EXCEEDED = 6061;
|
|
1533
1547
|
var TUNA_ERROR__INVALID_JUPITER_ROUTE = 6062;
|
|
1534
1548
|
var TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT = 6063;
|
|
1535
|
-
var
|
|
1536
|
-
var
|
|
1537
|
-
var
|
|
1538
|
-
var
|
|
1549
|
+
var TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT = 6064;
|
|
1550
|
+
var TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT = 6065;
|
|
1551
|
+
var TUNA_ERROR__ACCOUNT_NOT_INITIALIZED = 6066;
|
|
1552
|
+
var TUNA_ERROR__INVALID_ACCOUNT_DISCRIMINATOR = 6067;
|
|
1553
|
+
var TUNA_ERROR__INVALID_POOL = 6068;
|
|
1554
|
+
var TUNA_ERROR__POSITION_IS_EMPTY = 6069;
|
|
1539
1555
|
var tunaErrorMessages;
|
|
1540
1556
|
if (process.env.NODE_ENV !== "production") {
|
|
1541
1557
|
tunaErrorMessages = {
|
|
@@ -1543,6 +1559,8 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
1543
1559
|
[TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED]: `Amount slippage exceeded`,
|
|
1544
1560
|
[TUNA_ERROR__BAD_DEBT]: `Bad debt is not allowed for the executed instruction`,
|
|
1545
1561
|
[TUNA_ERROR__INCORRECT_POSITION_DIRECTION]: `Incorrect position direction`,
|
|
1562
|
+
[TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT]: `Incorrect swap input amount`,
|
|
1563
|
+
[TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT]: `Incorrect swap output amount`,
|
|
1546
1564
|
[TUNA_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
|
|
1547
1565
|
[TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT]: `Insufficient swap output amount`,
|
|
1548
1566
|
[TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE]: `Interest rate is out of range`,
|
|
@@ -2886,7 +2904,6 @@ function getCreateMarketInstructionDataEncoder() {
|
|
|
2886
2904
|
return transformEncoder15(
|
|
2887
2905
|
getStructEncoder17([
|
|
2888
2906
|
["discriminator", fixEncoderSize16(getBytesEncoder16(), 8)],
|
|
2889
|
-
["marketMaker", getMarketMakerEncoder()],
|
|
2890
2907
|
["addressLookupTable", getAddressEncoder7()],
|
|
2891
2908
|
["maxLeverage", getU32Encoder5()],
|
|
2892
2909
|
["protocolFee", getU16Encoder7()],
|
|
@@ -2909,7 +2926,6 @@ function getCreateMarketInstructionDataEncoder() {
|
|
|
2909
2926
|
function getCreateMarketInstructionDataDecoder() {
|
|
2910
2927
|
return getStructDecoder17([
|
|
2911
2928
|
["discriminator", fixDecoderSize15(getBytesDecoder15(), 8)],
|
|
2912
|
-
["marketMaker", getMarketMakerDecoder()],
|
|
2913
2929
|
["addressLookupTable", getAddressDecoder7()],
|
|
2914
2930
|
["maxLeverage", getU32Decoder5()],
|
|
2915
2931
|
["protocolFee", getU16Decoder7()],
|
|
@@ -2939,6 +2955,8 @@ function getCreateMarketInstruction(input, config) {
|
|
|
2939
2955
|
authority: { value: input.authority ?? null, isWritable: true },
|
|
2940
2956
|
tunaConfig: { value: input.tunaConfig ?? null, isWritable: false },
|
|
2941
2957
|
market: { value: input.market ?? null, isWritable: true },
|
|
2958
|
+
vaultA: { value: input.vaultA ?? null, isWritable: false },
|
|
2959
|
+
vaultB: { value: input.vaultB ?? null, isWritable: false },
|
|
2942
2960
|
pool: { value: input.pool ?? null, isWritable: false },
|
|
2943
2961
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false }
|
|
2944
2962
|
};
|
|
@@ -2953,6 +2971,8 @@ function getCreateMarketInstruction(input, config) {
|
|
|
2953
2971
|
getAccountMeta(accounts.authority),
|
|
2954
2972
|
getAccountMeta(accounts.tunaConfig),
|
|
2955
2973
|
getAccountMeta(accounts.market),
|
|
2974
|
+
getAccountMeta(accounts.vaultA),
|
|
2975
|
+
getAccountMeta(accounts.vaultB),
|
|
2956
2976
|
getAccountMeta(accounts.pool),
|
|
2957
2977
|
getAccountMeta(accounts.systemProgram)
|
|
2958
2978
|
],
|
|
@@ -2964,7 +2984,7 @@ function getCreateMarketInstruction(input, config) {
|
|
|
2964
2984
|
return instruction;
|
|
2965
2985
|
}
|
|
2966
2986
|
function parseCreateMarketInstruction(instruction) {
|
|
2967
|
-
if (instruction.accounts.length <
|
|
2987
|
+
if (instruction.accounts.length < 7) {
|
|
2968
2988
|
throw new Error("Not enough accounts");
|
|
2969
2989
|
}
|
|
2970
2990
|
let accountIndex = 0;
|
|
@@ -2979,6 +2999,8 @@ function parseCreateMarketInstruction(instruction) {
|
|
|
2979
2999
|
authority: getNextAccount(),
|
|
2980
3000
|
tunaConfig: getNextAccount(),
|
|
2981
3001
|
market: getNextAccount(),
|
|
3002
|
+
vaultA: getNextAccount(),
|
|
3003
|
+
vaultB: getNextAccount(),
|
|
2982
3004
|
pool: getNextAccount(),
|
|
2983
3005
|
systemProgram: getNextAccount()
|
|
2984
3006
|
},
|
|
@@ -8754,7 +8776,7 @@ function parseUpdateMarketInstruction(instruction) {
|
|
|
8754
8776
|
};
|
|
8755
8777
|
}
|
|
8756
8778
|
|
|
8757
|
-
// src/generated/instructions/
|
|
8779
|
+
// src/generated/instructions/updateMarketVaults.ts
|
|
8758
8780
|
import {
|
|
8759
8781
|
combineCodec as combineCodec61,
|
|
8760
8782
|
fixDecoderSize as fixDecoderSize55,
|
|
@@ -8765,9 +8787,106 @@ import {
|
|
|
8765
8787
|
getBytesEncoder as getBytesEncoder56,
|
|
8766
8788
|
getStructDecoder as getStructDecoder57,
|
|
8767
8789
|
getStructEncoder as getStructEncoder57,
|
|
8790
|
+
transformEncoder as transformEncoder55
|
|
8791
|
+
} from "@solana/kit";
|
|
8792
|
+
var UPDATE_MARKET_VAULTS_DISCRIMINATOR = new Uint8Array([
|
|
8793
|
+
59,
|
|
8794
|
+
187,
|
|
8795
|
+
50,
|
|
8796
|
+
173,
|
|
8797
|
+
89,
|
|
8798
|
+
41,
|
|
8799
|
+
205,
|
|
8800
|
+
228
|
|
8801
|
+
]);
|
|
8802
|
+
function getUpdateMarketVaultsDiscriminatorBytes() {
|
|
8803
|
+
return fixEncoderSize56(getBytesEncoder56(), 8).encode(
|
|
8804
|
+
UPDATE_MARKET_VAULTS_DISCRIMINATOR
|
|
8805
|
+
);
|
|
8806
|
+
}
|
|
8807
|
+
function getUpdateMarketVaultsInstructionDataEncoder() {
|
|
8808
|
+
return transformEncoder55(
|
|
8809
|
+
getStructEncoder57([
|
|
8810
|
+
["discriminator", fixEncoderSize56(getBytesEncoder56(), 8)],
|
|
8811
|
+
["vaultA", getAddressEncoder15()],
|
|
8812
|
+
["vaultB", getAddressEncoder15()]
|
|
8813
|
+
]),
|
|
8814
|
+
(value) => ({ ...value, discriminator: UPDATE_MARKET_VAULTS_DISCRIMINATOR })
|
|
8815
|
+
);
|
|
8816
|
+
}
|
|
8817
|
+
function getUpdateMarketVaultsInstructionDataDecoder() {
|
|
8818
|
+
return getStructDecoder57([
|
|
8819
|
+
["discriminator", fixDecoderSize55(getBytesDecoder55(), 8)],
|
|
8820
|
+
["vaultA", getAddressDecoder15()],
|
|
8821
|
+
["vaultB", getAddressDecoder15()]
|
|
8822
|
+
]);
|
|
8823
|
+
}
|
|
8824
|
+
function getUpdateMarketVaultsInstructionDataCodec() {
|
|
8825
|
+
return combineCodec61(
|
|
8826
|
+
getUpdateMarketVaultsInstructionDataEncoder(),
|
|
8827
|
+
getUpdateMarketVaultsInstructionDataDecoder()
|
|
8828
|
+
);
|
|
8829
|
+
}
|
|
8830
|
+
function getUpdateMarketVaultsInstruction(input, config) {
|
|
8831
|
+
const programAddress = config?.programAddress ?? TUNA_PROGRAM_ADDRESS;
|
|
8832
|
+
const originalAccounts = {
|
|
8833
|
+
authority: { value: input.authority ?? null, isWritable: true },
|
|
8834
|
+
tunaConfig: { value: input.tunaConfig ?? null, isWritable: false },
|
|
8835
|
+
market: { value: input.market ?? null, isWritable: true }
|
|
8836
|
+
};
|
|
8837
|
+
const accounts = originalAccounts;
|
|
8838
|
+
const args = { ...input };
|
|
8839
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
8840
|
+
const instruction = {
|
|
8841
|
+
accounts: [
|
|
8842
|
+
getAccountMeta(accounts.authority),
|
|
8843
|
+
getAccountMeta(accounts.tunaConfig),
|
|
8844
|
+
getAccountMeta(accounts.market)
|
|
8845
|
+
],
|
|
8846
|
+
programAddress,
|
|
8847
|
+
data: getUpdateMarketVaultsInstructionDataEncoder().encode(
|
|
8848
|
+
args
|
|
8849
|
+
)
|
|
8850
|
+
};
|
|
8851
|
+
return instruction;
|
|
8852
|
+
}
|
|
8853
|
+
function parseUpdateMarketVaultsInstruction(instruction) {
|
|
8854
|
+
if (instruction.accounts.length < 3) {
|
|
8855
|
+
throw new Error("Not enough accounts");
|
|
8856
|
+
}
|
|
8857
|
+
let accountIndex = 0;
|
|
8858
|
+
const getNextAccount = () => {
|
|
8859
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
8860
|
+
accountIndex += 1;
|
|
8861
|
+
return accountMeta;
|
|
8862
|
+
};
|
|
8863
|
+
return {
|
|
8864
|
+
programAddress: instruction.programAddress,
|
|
8865
|
+
accounts: {
|
|
8866
|
+
authority: getNextAccount(),
|
|
8867
|
+
tunaConfig: getNextAccount(),
|
|
8868
|
+
market: getNextAccount()
|
|
8869
|
+
},
|
|
8870
|
+
data: getUpdateMarketVaultsInstructionDataDecoder().decode(
|
|
8871
|
+
instruction.data
|
|
8872
|
+
)
|
|
8873
|
+
};
|
|
8874
|
+
}
|
|
8875
|
+
|
|
8876
|
+
// src/generated/instructions/updateVault.ts
|
|
8877
|
+
import {
|
|
8878
|
+
combineCodec as combineCodec62,
|
|
8879
|
+
fixDecoderSize as fixDecoderSize56,
|
|
8880
|
+
fixEncoderSize as fixEncoderSize57,
|
|
8881
|
+
getAddressDecoder as getAddressDecoder16,
|
|
8882
|
+
getAddressEncoder as getAddressEncoder16,
|
|
8883
|
+
getBytesDecoder as getBytesDecoder56,
|
|
8884
|
+
getBytesEncoder as getBytesEncoder57,
|
|
8885
|
+
getStructDecoder as getStructDecoder58,
|
|
8886
|
+
getStructEncoder as getStructEncoder58,
|
|
8768
8887
|
getU64Decoder as getU64Decoder21,
|
|
8769
8888
|
getU64Encoder as getU64Encoder21,
|
|
8770
|
-
transformEncoder as
|
|
8889
|
+
transformEncoder as transformEncoder56
|
|
8771
8890
|
} from "@solana/kit";
|
|
8772
8891
|
var UPDATE_VAULT_DISCRIMINATOR = new Uint8Array([
|
|
8773
8892
|
67,
|
|
@@ -8780,33 +8899,33 @@ var UPDATE_VAULT_DISCRIMINATOR = new Uint8Array([
|
|
|
8780
8899
|
60
|
|
8781
8900
|
]);
|
|
8782
8901
|
function getUpdateVaultDiscriminatorBytes() {
|
|
8783
|
-
return
|
|
8902
|
+
return fixEncoderSize57(getBytesEncoder57(), 8).encode(
|
|
8784
8903
|
UPDATE_VAULT_DISCRIMINATOR
|
|
8785
8904
|
);
|
|
8786
8905
|
}
|
|
8787
8906
|
function getUpdateVaultInstructionDataEncoder() {
|
|
8788
|
-
return
|
|
8789
|
-
|
|
8790
|
-
["discriminator",
|
|
8907
|
+
return transformEncoder56(
|
|
8908
|
+
getStructEncoder58([
|
|
8909
|
+
["discriminator", fixEncoderSize57(getBytesEncoder57(), 8)],
|
|
8791
8910
|
["interestRate", getU64Encoder21()],
|
|
8792
8911
|
["supplyLimit", getU64Encoder21()],
|
|
8793
|
-
["pythOraclePriceUpdate",
|
|
8794
|
-
["pythOracleFeedId",
|
|
8912
|
+
["pythOraclePriceUpdate", getAddressEncoder16()],
|
|
8913
|
+
["pythOracleFeedId", getAddressEncoder16()]
|
|
8795
8914
|
]),
|
|
8796
8915
|
(value) => ({ ...value, discriminator: UPDATE_VAULT_DISCRIMINATOR })
|
|
8797
8916
|
);
|
|
8798
8917
|
}
|
|
8799
8918
|
function getUpdateVaultInstructionDataDecoder() {
|
|
8800
|
-
return
|
|
8801
|
-
["discriminator",
|
|
8919
|
+
return getStructDecoder58([
|
|
8920
|
+
["discriminator", fixDecoderSize56(getBytesDecoder56(), 8)],
|
|
8802
8921
|
["interestRate", getU64Decoder21()],
|
|
8803
8922
|
["supplyLimit", getU64Decoder21()],
|
|
8804
|
-
["pythOraclePriceUpdate",
|
|
8805
|
-
["pythOracleFeedId",
|
|
8923
|
+
["pythOraclePriceUpdate", getAddressDecoder16()],
|
|
8924
|
+
["pythOracleFeedId", getAddressDecoder16()]
|
|
8806
8925
|
]);
|
|
8807
8926
|
}
|
|
8808
8927
|
function getUpdateVaultInstructionDataCodec() {
|
|
8809
|
-
return
|
|
8928
|
+
return combineCodec62(
|
|
8810
8929
|
getUpdateVaultInstructionDataEncoder(),
|
|
8811
8930
|
getUpdateVaultInstructionDataDecoder()
|
|
8812
8931
|
);
|
|
@@ -8857,16 +8976,16 @@ function parseUpdateVaultInstruction(instruction) {
|
|
|
8857
8976
|
|
|
8858
8977
|
// src/generated/instructions/withdraw.ts
|
|
8859
8978
|
import {
|
|
8860
|
-
combineCodec as
|
|
8861
|
-
fixDecoderSize as
|
|
8862
|
-
fixEncoderSize as
|
|
8863
|
-
getBytesDecoder as
|
|
8864
|
-
getBytesEncoder as
|
|
8865
|
-
getStructDecoder as
|
|
8866
|
-
getStructEncoder as
|
|
8979
|
+
combineCodec as combineCodec63,
|
|
8980
|
+
fixDecoderSize as fixDecoderSize57,
|
|
8981
|
+
fixEncoderSize as fixEncoderSize58,
|
|
8982
|
+
getBytesDecoder as getBytesDecoder57,
|
|
8983
|
+
getBytesEncoder as getBytesEncoder58,
|
|
8984
|
+
getStructDecoder as getStructDecoder59,
|
|
8985
|
+
getStructEncoder as getStructEncoder59,
|
|
8867
8986
|
getU64Decoder as getU64Decoder22,
|
|
8868
8987
|
getU64Encoder as getU64Encoder22,
|
|
8869
|
-
transformEncoder as
|
|
8988
|
+
transformEncoder as transformEncoder57
|
|
8870
8989
|
} from "@solana/kit";
|
|
8871
8990
|
var WITHDRAW_DISCRIMINATOR = new Uint8Array([
|
|
8872
8991
|
183,
|
|
@@ -8879,12 +8998,12 @@ var WITHDRAW_DISCRIMINATOR = new Uint8Array([
|
|
|
8879
8998
|
34
|
|
8880
8999
|
]);
|
|
8881
9000
|
function getWithdrawDiscriminatorBytes() {
|
|
8882
|
-
return
|
|
9001
|
+
return fixEncoderSize58(getBytesEncoder58(), 8).encode(WITHDRAW_DISCRIMINATOR);
|
|
8883
9002
|
}
|
|
8884
9003
|
function getWithdrawInstructionDataEncoder() {
|
|
8885
|
-
return
|
|
8886
|
-
|
|
8887
|
-
["discriminator",
|
|
9004
|
+
return transformEncoder57(
|
|
9005
|
+
getStructEncoder59([
|
|
9006
|
+
["discriminator", fixEncoderSize58(getBytesEncoder58(), 8)],
|
|
8888
9007
|
["funds", getU64Encoder22()],
|
|
8889
9008
|
["shares", getU64Encoder22()]
|
|
8890
9009
|
]),
|
|
@@ -8892,14 +9011,14 @@ function getWithdrawInstructionDataEncoder() {
|
|
|
8892
9011
|
);
|
|
8893
9012
|
}
|
|
8894
9013
|
function getWithdrawInstructionDataDecoder() {
|
|
8895
|
-
return
|
|
8896
|
-
["discriminator",
|
|
9014
|
+
return getStructDecoder59([
|
|
9015
|
+
["discriminator", fixDecoderSize57(getBytesDecoder57(), 8)],
|
|
8897
9016
|
["funds", getU64Decoder22()],
|
|
8898
9017
|
["shares", getU64Decoder22()]
|
|
8899
9018
|
]);
|
|
8900
9019
|
}
|
|
8901
9020
|
function getWithdrawInstructionDataCodec() {
|
|
8902
|
-
return
|
|
9021
|
+
return combineCodec63(
|
|
8903
9022
|
getWithdrawInstructionDataEncoder(),
|
|
8904
9023
|
getWithdrawInstructionDataDecoder()
|
|
8905
9024
|
);
|
|
@@ -8970,7 +9089,7 @@ function parseWithdrawInstruction(instruction) {
|
|
|
8970
9089
|
}
|
|
8971
9090
|
|
|
8972
9091
|
// src/pda.ts
|
|
8973
|
-
import { getAddressEncoder as
|
|
9092
|
+
import { getAddressEncoder as getAddressEncoder17, getProgramDerivedAddress } from "@solana/kit";
|
|
8974
9093
|
|
|
8975
9094
|
// src/consts.ts
|
|
8976
9095
|
import { address } from "@solana/kit";
|
|
@@ -9012,31 +9131,31 @@ async function getTunaConfigAddress() {
|
|
|
9012
9131
|
async function getMarketAddress(pool) {
|
|
9013
9132
|
return await getProgramDerivedAddress({
|
|
9014
9133
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9015
|
-
seeds: ["market",
|
|
9134
|
+
seeds: ["market", getAddressEncoder17().encode(pool)]
|
|
9016
9135
|
});
|
|
9017
9136
|
}
|
|
9018
9137
|
async function getLendingVaultAddress(mint) {
|
|
9019
9138
|
return await getProgramDerivedAddress({
|
|
9020
9139
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9021
|
-
seeds: ["vault",
|
|
9140
|
+
seeds: ["vault", getAddressEncoder17().encode(mint)]
|
|
9022
9141
|
});
|
|
9023
9142
|
}
|
|
9024
9143
|
async function getLendingPositionAddress(authority, mint) {
|
|
9025
9144
|
return await getProgramDerivedAddress({
|
|
9026
9145
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9027
|
-
seeds: ["lending_position",
|
|
9146
|
+
seeds: ["lending_position", getAddressEncoder17().encode(authority), getAddressEncoder17().encode(mint)]
|
|
9028
9147
|
});
|
|
9029
9148
|
}
|
|
9030
9149
|
async function getTunaLpPositionAddress(positionMint) {
|
|
9031
9150
|
return await getProgramDerivedAddress({
|
|
9032
9151
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9033
|
-
seeds: ["tuna_position",
|
|
9152
|
+
seeds: ["tuna_position", getAddressEncoder17().encode(positionMint)]
|
|
9034
9153
|
});
|
|
9035
9154
|
}
|
|
9036
9155
|
async function getTunaSpotPositionAddress(authority, pool) {
|
|
9037
9156
|
return await getProgramDerivedAddress({
|
|
9038
9157
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9039
|
-
seeds: ["tuna_spot_position",
|
|
9158
|
+
seeds: ["tuna_spot_position", getAddressEncoder17().encode(authority), getAddressEncoder17().encode(pool)]
|
|
9040
9159
|
});
|
|
9041
9160
|
}
|
|
9042
9161
|
async function getPythPriceUpdateAccountAddress(shardId, priceFeedId) {
|
|
@@ -9060,7 +9179,7 @@ async function getPythPriceUpdateAccountAddress(shardId, priceFeedId) {
|
|
|
9060
9179
|
|
|
9061
9180
|
// src/gpa/tunaLpPosition.ts
|
|
9062
9181
|
import {
|
|
9063
|
-
getAddressEncoder as
|
|
9182
|
+
getAddressEncoder as getAddressEncoder18,
|
|
9064
9183
|
getBase58Decoder,
|
|
9065
9184
|
getI8Encoder
|
|
9066
9185
|
} from "@solana/kit";
|
|
@@ -9088,7 +9207,7 @@ function tunaLpPositionAuthorityFilter(address4) {
|
|
|
9088
9207
|
return {
|
|
9089
9208
|
memcmp: {
|
|
9090
9209
|
offset: 11n,
|
|
9091
|
-
bytes: getBase58Decoder().decode(
|
|
9210
|
+
bytes: getBase58Decoder().decode(getAddressEncoder18().encode(address4)),
|
|
9092
9211
|
encoding: "base58"
|
|
9093
9212
|
}
|
|
9094
9213
|
};
|
|
@@ -9097,7 +9216,7 @@ function tunaLpPositionPoolFilter(address4) {
|
|
|
9097
9216
|
return {
|
|
9098
9217
|
memcmp: {
|
|
9099
9218
|
offset: 43n,
|
|
9100
|
-
bytes: getBase58Decoder().decode(
|
|
9219
|
+
bytes: getBase58Decoder().decode(getAddressEncoder18().encode(address4)),
|
|
9101
9220
|
encoding: "base58"
|
|
9102
9221
|
}
|
|
9103
9222
|
};
|
|
@@ -9106,7 +9225,7 @@ function tunaLpPositionMintAFilter(address4) {
|
|
|
9106
9225
|
return {
|
|
9107
9226
|
memcmp: {
|
|
9108
9227
|
offset: 75n,
|
|
9109
|
-
bytes: getBase58Decoder().decode(
|
|
9228
|
+
bytes: getBase58Decoder().decode(getAddressEncoder18().encode(address4)),
|
|
9110
9229
|
encoding: "base58"
|
|
9111
9230
|
}
|
|
9112
9231
|
};
|
|
@@ -9115,7 +9234,7 @@ function tunaLpPositionMintBFilter(address4) {
|
|
|
9115
9234
|
return {
|
|
9116
9235
|
memcmp: {
|
|
9117
9236
|
offset: 107n,
|
|
9118
|
-
bytes: getBase58Decoder().decode(
|
|
9237
|
+
bytes: getBase58Decoder().decode(getAddressEncoder18().encode(address4)),
|
|
9119
9238
|
encoding: "base58"
|
|
9120
9239
|
}
|
|
9121
9240
|
};
|
|
@@ -9124,7 +9243,7 @@ function tunaLpPositionMintFilter(address4) {
|
|
|
9124
9243
|
return {
|
|
9125
9244
|
memcmp: {
|
|
9126
9245
|
offset: 139n,
|
|
9127
|
-
bytes: getBase58Decoder().decode(
|
|
9246
|
+
bytes: getBase58Decoder().decode(getAddressEncoder18().encode(address4)),
|
|
9128
9247
|
encoding: "base58"
|
|
9129
9248
|
}
|
|
9130
9249
|
};
|
|
@@ -9157,14 +9276,14 @@ async function fetchAllTunaLpPositionWithFilter(rpc, ...filters) {
|
|
|
9157
9276
|
|
|
9158
9277
|
// src/gpa/tunaSpotPosition.ts
|
|
9159
9278
|
import {
|
|
9160
|
-
getAddressEncoder as
|
|
9279
|
+
getAddressEncoder as getAddressEncoder19,
|
|
9161
9280
|
getBase58Decoder as getBase58Decoder2
|
|
9162
9281
|
} from "@solana/kit";
|
|
9163
9282
|
function tunaSpotPositionAuthorityFilter(address4) {
|
|
9164
9283
|
return {
|
|
9165
9284
|
memcmp: {
|
|
9166
9285
|
offset: 11n,
|
|
9167
|
-
bytes: getBase58Decoder2().decode(
|
|
9286
|
+
bytes: getBase58Decoder2().decode(getAddressEncoder19().encode(address4)),
|
|
9168
9287
|
encoding: "base58"
|
|
9169
9288
|
}
|
|
9170
9289
|
};
|
|
@@ -9173,7 +9292,7 @@ function tunaSpotPositionPoolFilter(address4) {
|
|
|
9173
9292
|
return {
|
|
9174
9293
|
memcmp: {
|
|
9175
9294
|
offset: 43n,
|
|
9176
|
-
bytes: getBase58Decoder2().decode(
|
|
9295
|
+
bytes: getBase58Decoder2().decode(getAddressEncoder19().encode(address4)),
|
|
9177
9296
|
encoding: "base58"
|
|
9178
9297
|
}
|
|
9179
9298
|
};
|
|
@@ -9182,7 +9301,7 @@ function tunaSpotPositionMintAFilter(address4) {
|
|
|
9182
9301
|
return {
|
|
9183
9302
|
memcmp: {
|
|
9184
9303
|
offset: 75n,
|
|
9185
|
-
bytes: getBase58Decoder2().decode(
|
|
9304
|
+
bytes: getBase58Decoder2().decode(getAddressEncoder19().encode(address4)),
|
|
9186
9305
|
encoding: "base58"
|
|
9187
9306
|
}
|
|
9188
9307
|
};
|
|
@@ -9191,7 +9310,7 @@ function tunaSpotPositionMintBFilter(address4) {
|
|
|
9191
9310
|
return {
|
|
9192
9311
|
memcmp: {
|
|
9193
9312
|
offset: 107n,
|
|
9194
|
-
bytes: getBase58Decoder2().decode(
|
|
9313
|
+
bytes: getBase58Decoder2().decode(getAddressEncoder19().encode(address4)),
|
|
9195
9314
|
encoding: "base58"
|
|
9196
9315
|
}
|
|
9197
9316
|
};
|
|
@@ -9215,14 +9334,14 @@ async function fetchAllTunaSpotPositionWithFilter(rpc, ...filters) {
|
|
|
9215
9334
|
|
|
9216
9335
|
// src/gpa/lendingPosition.ts
|
|
9217
9336
|
import {
|
|
9218
|
-
getAddressEncoder as
|
|
9337
|
+
getAddressEncoder as getAddressEncoder20,
|
|
9219
9338
|
getBase58Decoder as getBase58Decoder3
|
|
9220
9339
|
} from "@solana/kit";
|
|
9221
9340
|
function lendingPositionAuthorityFilter(address4) {
|
|
9222
9341
|
return {
|
|
9223
9342
|
memcmp: {
|
|
9224
9343
|
offset: 11n,
|
|
9225
|
-
bytes: getBase58Decoder3().decode(
|
|
9344
|
+
bytes: getBase58Decoder3().decode(getAddressEncoder20().encode(address4)),
|
|
9226
9345
|
encoding: "base58"
|
|
9227
9346
|
}
|
|
9228
9347
|
};
|
|
@@ -9231,7 +9350,7 @@ function lendingPositionMintFilter(address4) {
|
|
|
9231
9350
|
return {
|
|
9232
9351
|
memcmp: {
|
|
9233
9352
|
offset: 43n,
|
|
9234
|
-
bytes: getBase58Decoder3().decode(
|
|
9353
|
+
bytes: getBase58Decoder3().decode(getAddressEncoder20().encode(address4)),
|
|
9235
9354
|
encoding: "base58"
|
|
9236
9355
|
}
|
|
9237
9356
|
};
|
|
@@ -11409,21 +11528,21 @@ import { fetchFusionPool as fetchFusionPool2 } from "@crypticdot/fusionamm-clien
|
|
|
11409
11528
|
import {
|
|
11410
11529
|
assertAccountExists as assertAccountExists7,
|
|
11411
11530
|
assertAccountsExist as assertAccountsExist8,
|
|
11412
|
-
combineCodec as
|
|
11531
|
+
combineCodec as combineCodec64,
|
|
11413
11532
|
decodeAccount as decodeAccount7,
|
|
11414
11533
|
fetchEncodedAccount as fetchEncodedAccount7,
|
|
11415
11534
|
fetchEncodedAccounts as fetchEncodedAccounts7,
|
|
11416
|
-
fixDecoderSize as
|
|
11417
|
-
fixEncoderSize as
|
|
11418
|
-
getAddressDecoder as
|
|
11419
|
-
getAddressEncoder as
|
|
11420
|
-
getBytesDecoder as
|
|
11421
|
-
getBytesEncoder as
|
|
11422
|
-
getStructDecoder as
|
|
11423
|
-
getStructEncoder as
|
|
11535
|
+
fixDecoderSize as fixDecoderSize58,
|
|
11536
|
+
fixEncoderSize as fixEncoderSize59,
|
|
11537
|
+
getAddressDecoder as getAddressDecoder17,
|
|
11538
|
+
getAddressEncoder as getAddressEncoder21,
|
|
11539
|
+
getBytesDecoder as getBytesDecoder58,
|
|
11540
|
+
getBytesEncoder as getBytesEncoder59,
|
|
11541
|
+
getStructDecoder as getStructDecoder60,
|
|
11542
|
+
getStructEncoder as getStructEncoder60,
|
|
11424
11543
|
getU64Decoder as getU64Decoder23,
|
|
11425
11544
|
getU64Encoder as getU64Encoder23,
|
|
11426
|
-
transformEncoder as
|
|
11545
|
+
transformEncoder as transformEncoder58
|
|
11427
11546
|
} from "@solana/kit";
|
|
11428
11547
|
import {
|
|
11429
11548
|
isProgramError as isProgramError2
|
|
@@ -11468,11 +11587,11 @@ import {
|
|
|
11468
11587
|
import {
|
|
11469
11588
|
combineCodec as combineCodec410,
|
|
11470
11589
|
fixDecoderSize as fixDecoderSize410,
|
|
11471
|
-
fixEncoderSize as
|
|
11590
|
+
fixEncoderSize as fixEncoderSize510,
|
|
11472
11591
|
getBooleanDecoder as getBooleanDecoder9,
|
|
11473
11592
|
getBooleanEncoder as getBooleanEncoder9,
|
|
11474
11593
|
getBytesDecoder as getBytesDecoder410,
|
|
11475
|
-
getBytesEncoder as
|
|
11594
|
+
getBytesEncoder as getBytesEncoder510,
|
|
11476
11595
|
getStructDecoder as getStructDecoder410,
|
|
11477
11596
|
getStructEncoder as getStructEncoder410,
|
|
11478
11597
|
getU8Decoder as getU8Decoder32,
|
|
@@ -11481,18 +11600,18 @@ import {
|
|
|
11481
11600
|
} from "@solana/kit";
|
|
11482
11601
|
import {
|
|
11483
11602
|
combineCodec as combineCodec510,
|
|
11484
|
-
fixDecoderSize as
|
|
11603
|
+
fixDecoderSize as fixDecoderSize59,
|
|
11485
11604
|
fixEncoderSize as fixEncoderSize62,
|
|
11486
11605
|
getAddressEncoder as getAddressEncoder32,
|
|
11487
|
-
getBytesDecoder as
|
|
11606
|
+
getBytesDecoder as getBytesDecoder59,
|
|
11488
11607
|
getBytesEncoder as getBytesEncoder62,
|
|
11489
11608
|
getProgramDerivedAddress as getProgramDerivedAddress22,
|
|
11490
11609
|
getStructDecoder as getStructDecoder510,
|
|
11491
11610
|
getStructEncoder as getStructEncoder510,
|
|
11492
|
-
transformEncoder as
|
|
11611
|
+
transformEncoder as transformEncoder59
|
|
11493
11612
|
} from "@solana/kit";
|
|
11494
11613
|
import {
|
|
11495
|
-
combineCodec as
|
|
11614
|
+
combineCodec as combineCodec65,
|
|
11496
11615
|
fixDecoderSize as fixDecoderSize62,
|
|
11497
11616
|
fixEncoderSize as fixEncoderSize72,
|
|
11498
11617
|
getAddressEncoder as getAddressEncoder42,
|
|
@@ -12216,7 +12335,7 @@ async function closeTunaSpotPositionInstruction(authority, poolAddress, mintA, m
|
|
|
12216
12335
|
}
|
|
12217
12336
|
|
|
12218
12337
|
// src/txbuilder/createMarket.ts
|
|
12219
|
-
async function createMarketInstruction(authority, pool, args) {
|
|
12338
|
+
async function createMarketInstruction(authority, pool, vaultA, vaultB, args) {
|
|
12220
12339
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
12221
12340
|
const marketAddress = (await getMarketAddress(pool))[0];
|
|
12222
12341
|
return getCreateMarketInstruction({
|
|
@@ -12224,6 +12343,8 @@ async function createMarketInstruction(authority, pool, args) {
|
|
|
12224
12343
|
tunaConfig,
|
|
12225
12344
|
market: marketAddress,
|
|
12226
12345
|
pool,
|
|
12346
|
+
vaultA,
|
|
12347
|
+
vaultB,
|
|
12227
12348
|
...args
|
|
12228
12349
|
});
|
|
12229
12350
|
}
|
|
@@ -12684,11 +12805,154 @@ async function liquidateTunaSpotPositionFusionInstruction(authority, tunaPositio
|
|
|
12684
12805
|
return ix;
|
|
12685
12806
|
}
|
|
12686
12807
|
|
|
12808
|
+
// src/txbuilder/liquidateTunaSpotPositionJupiter.ts
|
|
12809
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS14 } from "@solana-program/memo";
|
|
12810
|
+
import { findAssociatedTokenPda as findAssociatedTokenPda21 } from "@solana-program/token-2022";
|
|
12811
|
+
async function liquidateTunaSpotPositionJupiterInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, poolAddress, remainingAccounts, args) {
|
|
12812
|
+
const instructions = [];
|
|
12813
|
+
const collateralTokenMint = tunaPosition.data.collateralToken == 0 /* A */ ? mintA : mintB;
|
|
12814
|
+
const useNativeSol = collateralTokenMint.address == NATIVE_MINT && args.decreasePercent == HUNDRED_PERCENT;
|
|
12815
|
+
if (!useNativeSol) {
|
|
12816
|
+
const createPositionOwnerAtaInstructions = await getCreateAtaInstructions(
|
|
12817
|
+
void 0,
|
|
12818
|
+
authority,
|
|
12819
|
+
collateralTokenMint.address,
|
|
12820
|
+
tunaPosition.data.authority,
|
|
12821
|
+
collateralTokenMint.programAddress
|
|
12822
|
+
);
|
|
12823
|
+
instructions.push(...createPositionOwnerAtaInstructions.init);
|
|
12824
|
+
}
|
|
12825
|
+
if (mintA.address != NATIVE_MINT || args.decreasePercent < HUNDRED_PERCENT) {
|
|
12826
|
+
const createUserAtaAInstructions = await getCreateAtaInstructions(
|
|
12827
|
+
void 0,
|
|
12828
|
+
authority,
|
|
12829
|
+
mintA.address,
|
|
12830
|
+
authority.address,
|
|
12831
|
+
mintA.programAddress
|
|
12832
|
+
);
|
|
12833
|
+
instructions.push(...createUserAtaAInstructions.init);
|
|
12834
|
+
}
|
|
12835
|
+
if (mintB.address != NATIVE_MINT || args.decreasePercent < HUNDRED_PERCENT) {
|
|
12836
|
+
const createUserAtaBInstructions = await getCreateAtaInstructions(
|
|
12837
|
+
void 0,
|
|
12838
|
+
authority,
|
|
12839
|
+
mintB.address,
|
|
12840
|
+
authority.address,
|
|
12841
|
+
mintB.programAddress
|
|
12842
|
+
);
|
|
12843
|
+
instructions.push(...createUserAtaBInstructions.init);
|
|
12844
|
+
}
|
|
12845
|
+
const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
|
|
12846
|
+
void 0,
|
|
12847
|
+
authority,
|
|
12848
|
+
mintA.address,
|
|
12849
|
+
tunaConfig.data.feeRecipient,
|
|
12850
|
+
mintA.programAddress
|
|
12851
|
+
);
|
|
12852
|
+
instructions.push(...createFeeRecipientAtaAInstructions.init);
|
|
12853
|
+
const createFeeRecipientAtaBInstructions = await getCreateAtaInstructions(
|
|
12854
|
+
void 0,
|
|
12855
|
+
authority,
|
|
12856
|
+
mintB.address,
|
|
12857
|
+
tunaConfig.data.feeRecipient,
|
|
12858
|
+
mintB.programAddress
|
|
12859
|
+
);
|
|
12860
|
+
instructions.push(...createFeeRecipientAtaBInstructions.init);
|
|
12861
|
+
const ix = await liquidateTunaSpotPositionJupiterInstruction(
|
|
12862
|
+
authority,
|
|
12863
|
+
tunaPosition,
|
|
12864
|
+
tunaConfig,
|
|
12865
|
+
mintA,
|
|
12866
|
+
mintB,
|
|
12867
|
+
vaultA,
|
|
12868
|
+
vaultB,
|
|
12869
|
+
poolAddress,
|
|
12870
|
+
remainingAccounts,
|
|
12871
|
+
args
|
|
12872
|
+
);
|
|
12873
|
+
instructions.push(ix);
|
|
12874
|
+
return instructions;
|
|
12875
|
+
}
|
|
12876
|
+
async function liquidateTunaSpotPositionJupiterInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, poolAddress, remainingAccounts, args) {
|
|
12877
|
+
const marketAddress = (await getMarketAddress(poolAddress))[0];
|
|
12878
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda21({
|
|
12879
|
+
owner: tunaPosition.data.authority,
|
|
12880
|
+
mint: mintA.address,
|
|
12881
|
+
tokenProgram: mintA.programAddress
|
|
12882
|
+
}))[0];
|
|
12883
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda21({
|
|
12884
|
+
owner: tunaPosition.data.authority,
|
|
12885
|
+
mint: mintB.address,
|
|
12886
|
+
tokenProgram: mintB.programAddress
|
|
12887
|
+
}))[0];
|
|
12888
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda21({
|
|
12889
|
+
owner: tunaPosition.address,
|
|
12890
|
+
mint: mintA.address,
|
|
12891
|
+
tokenProgram: mintA.programAddress
|
|
12892
|
+
}))[0];
|
|
12893
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda21({
|
|
12894
|
+
owner: tunaPosition.address,
|
|
12895
|
+
mint: mintB.address,
|
|
12896
|
+
tokenProgram: mintB.programAddress
|
|
12897
|
+
}))[0];
|
|
12898
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda21({
|
|
12899
|
+
owner: tunaConfig.data.feeRecipient,
|
|
12900
|
+
mint: mintA.address,
|
|
12901
|
+
tokenProgram: mintA.programAddress
|
|
12902
|
+
}))[0];
|
|
12903
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda21({
|
|
12904
|
+
owner: tunaConfig.data.feeRecipient,
|
|
12905
|
+
mint: mintB.address,
|
|
12906
|
+
tokenProgram: mintB.programAddress
|
|
12907
|
+
}))[0];
|
|
12908
|
+
const vaultAAta = (await findAssociatedTokenPda21({
|
|
12909
|
+
owner: vaultA.address,
|
|
12910
|
+
mint: mintA.address,
|
|
12911
|
+
tokenProgram: mintA.programAddress
|
|
12912
|
+
}))[0];
|
|
12913
|
+
const vaultBAta = (await findAssociatedTokenPda21({
|
|
12914
|
+
owner: vaultB.address,
|
|
12915
|
+
mint: mintB.address,
|
|
12916
|
+
tokenProgram: mintB.programAddress
|
|
12917
|
+
}))[0];
|
|
12918
|
+
const ix = getLiquidateTunaSpotPositionJupiterInstruction({
|
|
12919
|
+
authority,
|
|
12920
|
+
tunaConfig: tunaConfig.address,
|
|
12921
|
+
mintA: mintA.address,
|
|
12922
|
+
mintB: mintB.address,
|
|
12923
|
+
tokenProgramA: mintA.programAddress,
|
|
12924
|
+
tokenProgramB: mintB.programAddress,
|
|
12925
|
+
market: marketAddress,
|
|
12926
|
+
pythOraclePriceFeedA: vaultA.data.pythOraclePriceUpdate,
|
|
12927
|
+
pythOraclePriceFeedB: vaultB.data.pythOraclePriceUpdate,
|
|
12928
|
+
vaultA: vaultA.address,
|
|
12929
|
+
vaultAAta,
|
|
12930
|
+
vaultB: vaultB.address,
|
|
12931
|
+
vaultBAta,
|
|
12932
|
+
tunaPosition: tunaPosition.address,
|
|
12933
|
+
tunaPositionAtaA,
|
|
12934
|
+
tunaPositionAtaB,
|
|
12935
|
+
tunaPositionOwner: tunaPosition.data.authority,
|
|
12936
|
+
tunaPositionOwnerAtaA,
|
|
12937
|
+
tunaPositionOwnerAtaB,
|
|
12938
|
+
feeRecipientAtaA,
|
|
12939
|
+
feeRecipientAtaB,
|
|
12940
|
+
pool: poolAddress,
|
|
12941
|
+
jupiterProgram: JUPITER_PROGRAM_ADDRESS,
|
|
12942
|
+
jupiterEventAuthority: JUPITER_EVENT_AUTHORITY,
|
|
12943
|
+
jupiterProgramAuthority: JUPITER_PROGRAM_AUTHORITY,
|
|
12944
|
+
memoProgram: MEMO_PROGRAM_ADDRESS14,
|
|
12945
|
+
...args
|
|
12946
|
+
});
|
|
12947
|
+
ix.accounts.push(...remainingAccounts);
|
|
12948
|
+
return ix;
|
|
12949
|
+
}
|
|
12950
|
+
|
|
12687
12951
|
// src/txbuilder/liquidateTunaSpotPositionOrca.ts
|
|
12688
12952
|
import { getOracleAddress as getOracleAddress5, WHIRLPOOL_PROGRAM_ADDRESS as WHIRLPOOL_PROGRAM_ADDRESS8 } from "@orca-so/whirlpools-client";
|
|
12689
12953
|
import { AccountRole as AccountRole14 } from "@solana/kit";
|
|
12690
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
12691
|
-
import { findAssociatedTokenPda as
|
|
12954
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS15 } from "@solana-program/memo";
|
|
12955
|
+
import { findAssociatedTokenPda as findAssociatedTokenPda22 } from "@solana-program/token-2022";
|
|
12692
12956
|
async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, decreasePercent) {
|
|
12693
12957
|
const instructions = [];
|
|
12694
12958
|
const collateralTokenMint = tunaPosition.data.collateralToken == 0 /* A */ ? mintA : mintB;
|
|
@@ -12736,42 +13000,42 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
12736
13000
|
async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, decreasePercent) {
|
|
12737
13001
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12738
13002
|
const orcaOracleAddress = (await getOracleAddress5(whirlpool.address))[0];
|
|
12739
|
-
const tunaPositionOwnerAtaA = (await
|
|
13003
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda22({
|
|
12740
13004
|
owner: tunaPosition.data.authority,
|
|
12741
13005
|
mint: mintA.address,
|
|
12742
13006
|
tokenProgram: mintA.programAddress
|
|
12743
13007
|
}))[0];
|
|
12744
|
-
const tunaPositionOwnerAtaB = (await
|
|
13008
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda22({
|
|
12745
13009
|
owner: tunaPosition.data.authority,
|
|
12746
13010
|
mint: mintB.address,
|
|
12747
13011
|
tokenProgram: mintB.programAddress
|
|
12748
13012
|
}))[0];
|
|
12749
|
-
const tunaPositionAtaA = (await
|
|
13013
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda22({
|
|
12750
13014
|
owner: tunaPosition.address,
|
|
12751
13015
|
mint: mintA.address,
|
|
12752
13016
|
tokenProgram: mintA.programAddress
|
|
12753
13017
|
}))[0];
|
|
12754
|
-
const tunaPositionAtaB = (await
|
|
13018
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda22({
|
|
12755
13019
|
owner: tunaPosition.address,
|
|
12756
13020
|
mint: mintB.address,
|
|
12757
13021
|
tokenProgram: mintB.programAddress
|
|
12758
13022
|
}))[0];
|
|
12759
|
-
const feeRecipientAtaA = (await
|
|
13023
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda22({
|
|
12760
13024
|
owner: tunaConfig.data.feeRecipient,
|
|
12761
13025
|
mint: mintA.address,
|
|
12762
13026
|
tokenProgram: mintA.programAddress
|
|
12763
13027
|
}))[0];
|
|
12764
|
-
const feeRecipientAtaB = (await
|
|
13028
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda22({
|
|
12765
13029
|
owner: tunaConfig.data.feeRecipient,
|
|
12766
13030
|
mint: mintB.address,
|
|
12767
13031
|
tokenProgram: mintB.programAddress
|
|
12768
13032
|
}))[0];
|
|
12769
|
-
const vaultAAta = (await
|
|
13033
|
+
const vaultAAta = (await findAssociatedTokenPda22({
|
|
12770
13034
|
owner: vaultA.address,
|
|
12771
13035
|
mint: mintA.address,
|
|
12772
13036
|
tokenProgram: mintA.programAddress
|
|
12773
13037
|
}))[0];
|
|
12774
|
-
const vaultBAta = (await
|
|
13038
|
+
const vaultBAta = (await findAssociatedTokenPda22({
|
|
12775
13039
|
owner: vaultB.address,
|
|
12776
13040
|
mint: mintB.address,
|
|
12777
13041
|
tokenProgram: mintB.programAddress
|
|
@@ -12819,7 +13083,7 @@ async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition,
|
|
|
12819
13083
|
feeRecipientAtaB,
|
|
12820
13084
|
whirlpool: whirlpool.address,
|
|
12821
13085
|
whirlpoolProgram: WHIRLPOOL_PROGRAM_ADDRESS8,
|
|
12822
|
-
memoProgram:
|
|
13086
|
+
memoProgram: MEMO_PROGRAM_ADDRESS15,
|
|
12823
13087
|
decreasePercent,
|
|
12824
13088
|
remainingAccountsInfo
|
|
12825
13089
|
});
|
|
@@ -12832,7 +13096,7 @@ import { fetchMaybeWhirlpool as fetchMaybeWhirlpool6, getPositionAddress as getP
|
|
|
12832
13096
|
import {
|
|
12833
13097
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
12834
13098
|
fetchAllMaybeMint as fetchAllMaybeMint15,
|
|
12835
|
-
findAssociatedTokenPda as
|
|
13099
|
+
findAssociatedTokenPda as findAssociatedTokenPda23,
|
|
12836
13100
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS13
|
|
12837
13101
|
} from "@solana-program/token-2022";
|
|
12838
13102
|
import assert15 from "assert";
|
|
@@ -12845,17 +13109,17 @@ async function openTunaLpPositionOrcaInstruction(rpc, authority, positionMint, w
|
|
|
12845
13109
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12846
13110
|
const orcaPositionAddress = (await getPositionAddress13(positionMint.address))[0];
|
|
12847
13111
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
12848
|
-
const tunaPositionAta = (await
|
|
13112
|
+
const tunaPositionAta = (await findAssociatedTokenPda23({
|
|
12849
13113
|
owner: tunaPositionAddress,
|
|
12850
13114
|
mint: positionMint.address,
|
|
12851
13115
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS13
|
|
12852
13116
|
}))[0];
|
|
12853
|
-
const tunaPositionAtaA = (await
|
|
13117
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda23({
|
|
12854
13118
|
owner: tunaPositionAddress,
|
|
12855
13119
|
mint: mintA.address,
|
|
12856
13120
|
tokenProgram: mintA.programAddress
|
|
12857
13121
|
}))[0];
|
|
12858
|
-
const tunaPositionAtaB = (await
|
|
13122
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda23({
|
|
12859
13123
|
owner: tunaPositionAddress,
|
|
12860
13124
|
mint: mintB.address,
|
|
12861
13125
|
tokenProgram: mintB.programAddress
|
|
@@ -12888,7 +13152,7 @@ import { FP_NFT_UPDATE_AUTH } from "@crypticdot/fusionamm-client";
|
|
|
12888
13152
|
import {
|
|
12889
13153
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS as ASSOCIATED_TOKEN_PROGRAM_ADDRESS2,
|
|
12890
13154
|
fetchAllMaybeMint as fetchAllMaybeMint16,
|
|
12891
|
-
findAssociatedTokenPda as
|
|
13155
|
+
findAssociatedTokenPda as findAssociatedTokenPda24,
|
|
12892
13156
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS14
|
|
12893
13157
|
} from "@solana-program/token-2022";
|
|
12894
13158
|
import assert16 from "assert";
|
|
@@ -12901,17 +13165,17 @@ async function openTunaLpPositionFusionInstruction(rpc, authority, positionMint,
|
|
|
12901
13165
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
12902
13166
|
const fusionPositionAddress = (await getPositionAddress14(positionMint.address))[0];
|
|
12903
13167
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
12904
|
-
const tunaPositionAta = (await
|
|
13168
|
+
const tunaPositionAta = (await findAssociatedTokenPda24({
|
|
12905
13169
|
owner: tunaPositionAddress,
|
|
12906
13170
|
mint: positionMint.address,
|
|
12907
13171
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS14
|
|
12908
13172
|
}))[0];
|
|
12909
|
-
const tunaPositionAtaA = (await
|
|
13173
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda24({
|
|
12910
13174
|
owner: tunaPositionAddress,
|
|
12911
13175
|
mint: mintA.address,
|
|
12912
13176
|
tokenProgram: mintA.programAddress
|
|
12913
13177
|
}))[0];
|
|
12914
|
-
const tunaPositionAtaB = (await
|
|
13178
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda24({
|
|
12915
13179
|
owner: tunaPositionAddress,
|
|
12916
13180
|
mint: mintB.address,
|
|
12917
13181
|
tokenProgram: mintB.programAddress
|
|
@@ -12956,11 +13220,11 @@ import {
|
|
|
12956
13220
|
lamports
|
|
12957
13221
|
} from "@solana/kit";
|
|
12958
13222
|
import { fetchSysvarRent } from "@solana/sysvars";
|
|
12959
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
13223
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS16 } from "@solana-program/memo";
|
|
12960
13224
|
import {
|
|
12961
13225
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS as ASSOCIATED_TOKEN_PROGRAM_ADDRESS3,
|
|
12962
13226
|
fetchAllMaybeMint as fetchAllMaybeMint17,
|
|
12963
|
-
findAssociatedTokenPda as
|
|
13227
|
+
findAssociatedTokenPda as findAssociatedTokenPda25,
|
|
12964
13228
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS15
|
|
12965
13229
|
} from "@solana-program/token-2022";
|
|
12966
13230
|
import assert17 from "assert";
|
|
@@ -13098,47 +13362,47 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
13098
13362
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
13099
13363
|
const orcaPositionAddress = (await getPositionAddress15(positionMint.address))[0];
|
|
13100
13364
|
const orcaOracleAddress = (await getOracleAddress6(whirlpool.address))[0];
|
|
13101
|
-
const tunaPositionAta = (await
|
|
13365
|
+
const tunaPositionAta = (await findAssociatedTokenPda25({
|
|
13102
13366
|
owner: tunaPositionAddress,
|
|
13103
13367
|
mint: positionMint.address,
|
|
13104
13368
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS15
|
|
13105
13369
|
}))[0];
|
|
13106
|
-
const tunaPositionOwnerAtaA = (await
|
|
13370
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda25({
|
|
13107
13371
|
owner: authority.address,
|
|
13108
13372
|
mint: mintA.address,
|
|
13109
13373
|
tokenProgram: mintA.programAddress
|
|
13110
13374
|
}))[0];
|
|
13111
|
-
const tunaPositionOwnerAtaB = (await
|
|
13375
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda25({
|
|
13112
13376
|
owner: authority.address,
|
|
13113
13377
|
mint: mintB.address,
|
|
13114
13378
|
tokenProgram: mintB.programAddress
|
|
13115
13379
|
}))[0];
|
|
13116
|
-
const tunaPositionAtaA = (await
|
|
13380
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda25({
|
|
13117
13381
|
owner: tunaPositionAddress,
|
|
13118
13382
|
mint: mintA.address,
|
|
13119
13383
|
tokenProgram: mintA.programAddress
|
|
13120
13384
|
}))[0];
|
|
13121
|
-
const tunaPositionAtaB = (await
|
|
13385
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda25({
|
|
13122
13386
|
owner: tunaPositionAddress,
|
|
13123
13387
|
mint: mintB.address,
|
|
13124
13388
|
tokenProgram: mintB.programAddress
|
|
13125
13389
|
}))[0];
|
|
13126
|
-
const vaultAAta = (await
|
|
13390
|
+
const vaultAAta = (await findAssociatedTokenPda25({
|
|
13127
13391
|
owner: vaultA.address,
|
|
13128
13392
|
mint: mintA.address,
|
|
13129
13393
|
tokenProgram: mintA.programAddress
|
|
13130
13394
|
}))[0];
|
|
13131
|
-
const vaultBAta = (await
|
|
13395
|
+
const vaultBAta = (await findAssociatedTokenPda25({
|
|
13132
13396
|
owner: vaultB.address,
|
|
13133
13397
|
mint: mintB.address,
|
|
13134
13398
|
tokenProgram: mintB.programAddress
|
|
13135
13399
|
}))[0];
|
|
13136
|
-
const feeRecipientAtaA = (await
|
|
13400
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda25({
|
|
13137
13401
|
owner: tunaConfig.data.feeRecipient,
|
|
13138
13402
|
mint: mintA.address,
|
|
13139
13403
|
tokenProgram: mintA.programAddress
|
|
13140
13404
|
}))[0];
|
|
13141
|
-
const feeRecipientAtaB = (await
|
|
13405
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda25({
|
|
13142
13406
|
owner: tunaConfig.data.feeRecipient,
|
|
13143
13407
|
mint: mintB.address,
|
|
13144
13408
|
tokenProgram: mintB.programAddress
|
|
@@ -13194,7 +13458,7 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
13194
13458
|
orcaPosition: orcaPositionAddress,
|
|
13195
13459
|
tokenProgramA: mintA.programAddress,
|
|
13196
13460
|
tokenProgramB: mintB.programAddress,
|
|
13197
|
-
memoProgram:
|
|
13461
|
+
memoProgram: MEMO_PROGRAM_ADDRESS16,
|
|
13198
13462
|
metadataUpdateAuth: WP_NFT_UPDATE_AUTH,
|
|
13199
13463
|
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ADDRESS3,
|
|
13200
13464
|
token2022Program: TOKEN_2022_PROGRAM_ADDRESS15,
|
|
@@ -13223,11 +13487,11 @@ import {
|
|
|
13223
13487
|
lamports as lamports2
|
|
13224
13488
|
} from "@solana/kit";
|
|
13225
13489
|
import { fetchSysvarRent as fetchSysvarRent2 } from "@solana/sysvars";
|
|
13226
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
13490
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS17 } from "@solana-program/memo";
|
|
13227
13491
|
import {
|
|
13228
13492
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS as ASSOCIATED_TOKEN_PROGRAM_ADDRESS4,
|
|
13229
13493
|
fetchAllMaybeMint as fetchAllMaybeMint18,
|
|
13230
|
-
findAssociatedTokenPda as
|
|
13494
|
+
findAssociatedTokenPda as findAssociatedTokenPda26,
|
|
13231
13495
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS16
|
|
13232
13496
|
} from "@solana-program/token-2022";
|
|
13233
13497
|
import assert18 from "assert";
|
|
@@ -13351,47 +13615,47 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
13351
13615
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
13352
13616
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
13353
13617
|
const fusionPositionAddress = (await getPositionAddress16(positionMint.address))[0];
|
|
13354
|
-
const tunaPositionAta = (await
|
|
13618
|
+
const tunaPositionAta = (await findAssociatedTokenPda26({
|
|
13355
13619
|
owner: tunaPositionAddress,
|
|
13356
13620
|
mint: positionMint.address,
|
|
13357
13621
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS16
|
|
13358
13622
|
}))[0];
|
|
13359
|
-
const tunaPositionOwnerAtaA = (await
|
|
13623
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda26({
|
|
13360
13624
|
owner: authority.address,
|
|
13361
13625
|
mint: mintA.address,
|
|
13362
13626
|
tokenProgram: mintA.programAddress
|
|
13363
13627
|
}))[0];
|
|
13364
|
-
const tunaPositionOwnerAtaB = (await
|
|
13628
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda26({
|
|
13365
13629
|
owner: authority.address,
|
|
13366
13630
|
mint: mintB.address,
|
|
13367
13631
|
tokenProgram: mintB.programAddress
|
|
13368
13632
|
}))[0];
|
|
13369
|
-
const tunaPositionAtaA = (await
|
|
13633
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda26({
|
|
13370
13634
|
owner: tunaPositionAddress,
|
|
13371
13635
|
mint: mintA.address,
|
|
13372
13636
|
tokenProgram: mintA.programAddress
|
|
13373
13637
|
}))[0];
|
|
13374
|
-
const tunaPositionAtaB = (await
|
|
13638
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda26({
|
|
13375
13639
|
owner: tunaPositionAddress,
|
|
13376
13640
|
mint: mintB.address,
|
|
13377
13641
|
tokenProgram: mintB.programAddress
|
|
13378
13642
|
}))[0];
|
|
13379
|
-
const vaultAAta = (await
|
|
13643
|
+
const vaultAAta = (await findAssociatedTokenPda26({
|
|
13380
13644
|
owner: vaultA.address,
|
|
13381
13645
|
mint: mintA.address,
|
|
13382
13646
|
tokenProgram: mintA.programAddress
|
|
13383
13647
|
}))[0];
|
|
13384
|
-
const vaultBAta = (await
|
|
13648
|
+
const vaultBAta = (await findAssociatedTokenPda26({
|
|
13385
13649
|
owner: vaultB.address,
|
|
13386
13650
|
mint: mintB.address,
|
|
13387
13651
|
tokenProgram: mintB.programAddress
|
|
13388
13652
|
}))[0];
|
|
13389
|
-
const feeRecipientAtaA = (await
|
|
13653
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda26({
|
|
13390
13654
|
owner: tunaConfig.data.feeRecipient,
|
|
13391
13655
|
mint: mintA.address,
|
|
13392
13656
|
tokenProgram: mintA.programAddress
|
|
13393
13657
|
}))[0];
|
|
13394
|
-
const feeRecipientAtaB = (await
|
|
13658
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda26({
|
|
13395
13659
|
owner: tunaConfig.data.feeRecipient,
|
|
13396
13660
|
mint: mintB.address,
|
|
13397
13661
|
tokenProgram: mintB.programAddress
|
|
@@ -13445,7 +13709,7 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
13445
13709
|
fusionPosition: fusionPositionAddress,
|
|
13446
13710
|
tokenProgramA: mintA.programAddress,
|
|
13447
13711
|
tokenProgramB: mintB.programAddress,
|
|
13448
|
-
memoProgram:
|
|
13712
|
+
memoProgram: MEMO_PROGRAM_ADDRESS17,
|
|
13449
13713
|
metadataUpdateAuth: FP_NFT_UPDATE_AUTH2,
|
|
13450
13714
|
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ADDRESS4,
|
|
13451
13715
|
token2022Program: TOKEN_2022_PROGRAM_ADDRESS16,
|
|
@@ -13466,7 +13730,7 @@ import {
|
|
|
13466
13730
|
import {
|
|
13467
13731
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS as ASSOCIATED_TOKEN_PROGRAM_ADDRESS5,
|
|
13468
13732
|
fetchAllMaybeMint as fetchAllMaybeMint19,
|
|
13469
|
-
findAssociatedTokenPda as
|
|
13733
|
+
findAssociatedTokenPda as findAssociatedTokenPda27
|
|
13470
13734
|
} from "@solana-program/token-2022";
|
|
13471
13735
|
import assert19 from "assert";
|
|
13472
13736
|
async function openTunaSpotPositionInstructions(rpc, authority, poolAddress, args) {
|
|
@@ -13488,12 +13752,12 @@ async function openTunaSpotPositionInstructions(rpc, authority, poolAddress, arg
|
|
|
13488
13752
|
}
|
|
13489
13753
|
async function openTunaSpotPositionInstruction(authority, mintA, mintB, poolAddress, args) {
|
|
13490
13754
|
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
13491
|
-
const tunaPositionAtaA = (await
|
|
13755
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda27({
|
|
13492
13756
|
owner: tunaPositionAddress,
|
|
13493
13757
|
mint: mintA.address,
|
|
13494
13758
|
tokenProgram: mintA.programAddress
|
|
13495
13759
|
}))[0];
|
|
13496
|
-
const tunaPositionAtaB = (await
|
|
13760
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda27({
|
|
13497
13761
|
owner: tunaPositionAddress,
|
|
13498
13762
|
mint: mintB.address,
|
|
13499
13763
|
tokenProgram: mintB.programAddress
|
|
@@ -13528,10 +13792,10 @@ import {
|
|
|
13528
13792
|
AccountRole as AccountRole17,
|
|
13529
13793
|
assertAccountsExist as assertAccountsExist9
|
|
13530
13794
|
} from "@solana/kit";
|
|
13531
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
13795
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS18 } from "@solana-program/memo";
|
|
13532
13796
|
import {
|
|
13533
13797
|
fetchAllMaybeMint as fetchAllMaybeMint20,
|
|
13534
|
-
findAssociatedTokenPda as
|
|
13798
|
+
findAssociatedTokenPda as findAssociatedTokenPda28,
|
|
13535
13799
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS17
|
|
13536
13800
|
} from "@solana-program/token-2022";
|
|
13537
13801
|
import assert20 from "assert";
|
|
@@ -13621,37 +13885,37 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
13621
13885
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
13622
13886
|
const orcaPositionAddress = (await getPositionAddress17(positionMint))[0];
|
|
13623
13887
|
const orcaOracleAddress = (await getOracleAddress7(whirlpool.address))[0];
|
|
13624
|
-
const tunaPositionAta = (await
|
|
13888
|
+
const tunaPositionAta = (await findAssociatedTokenPda28({
|
|
13625
13889
|
owner: tunaPosition.address,
|
|
13626
13890
|
mint: positionMint,
|
|
13627
13891
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS17
|
|
13628
13892
|
}))[0];
|
|
13629
|
-
const tunaPositionOwnerAtaA = (await
|
|
13893
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda28({
|
|
13630
13894
|
owner: authority.address,
|
|
13631
13895
|
mint: mintA.address,
|
|
13632
13896
|
tokenProgram: mintA.programAddress
|
|
13633
13897
|
}))[0];
|
|
13634
|
-
const tunaPositionOwnerAtaB = (await
|
|
13898
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda28({
|
|
13635
13899
|
owner: authority.address,
|
|
13636
13900
|
mint: mintB.address,
|
|
13637
13901
|
tokenProgram: mintB.programAddress
|
|
13638
13902
|
}))[0];
|
|
13639
|
-
const tunaPositionAtaA = (await
|
|
13903
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda28({
|
|
13640
13904
|
owner: tunaPosition.address,
|
|
13641
13905
|
mint: mintA.address,
|
|
13642
13906
|
tokenProgram: mintA.programAddress
|
|
13643
13907
|
}))[0];
|
|
13644
|
-
const tunaPositionAtaB = (await
|
|
13908
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda28({
|
|
13645
13909
|
owner: tunaPosition.address,
|
|
13646
13910
|
mint: mintB.address,
|
|
13647
13911
|
tokenProgram: mintB.programAddress
|
|
13648
13912
|
}))[0];
|
|
13649
|
-
const vaultAAta = (await
|
|
13913
|
+
const vaultAAta = (await findAssociatedTokenPda28({
|
|
13650
13914
|
owner: vaultA.address,
|
|
13651
13915
|
mint: mintA.address,
|
|
13652
13916
|
tokenProgram: mintA.programAddress
|
|
13653
13917
|
}))[0];
|
|
13654
|
-
const vaultBAta = (await
|
|
13918
|
+
const vaultBAta = (await findAssociatedTokenPda28({
|
|
13655
13919
|
owner: vaultB.address,
|
|
13656
13920
|
mint: mintB.address,
|
|
13657
13921
|
tokenProgram: mintB.programAddress
|
|
@@ -13681,7 +13945,7 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
13681
13945
|
const rewardInfo = whirlpool.data.rewardInfos[rewardIndex];
|
|
13682
13946
|
const rewardMint = rewardMints.find((mint) => mint.address == rewardInfo.mint);
|
|
13683
13947
|
assert20(rewardMint, "Reward mint not found in the provided reward mint accounts");
|
|
13684
|
-
const ownerAta = await
|
|
13948
|
+
const ownerAta = await findAssociatedTokenPda28({
|
|
13685
13949
|
owner: authority.address,
|
|
13686
13950
|
mint: rewardMint.address,
|
|
13687
13951
|
tokenProgram: rewardMint.programAddress
|
|
@@ -13727,7 +13991,7 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
13727
13991
|
whirlpoolProgram: WHIRLPOOL_PROGRAM_ADDRESS12,
|
|
13728
13992
|
tokenProgramA: mintA.programAddress,
|
|
13729
13993
|
tokenProgramB: mintB.programAddress,
|
|
13730
|
-
memoProgram:
|
|
13994
|
+
memoProgram: MEMO_PROGRAM_ADDRESS18,
|
|
13731
13995
|
...args,
|
|
13732
13996
|
remainingAccountsInfo
|
|
13733
13997
|
});
|
|
@@ -13744,10 +14008,10 @@ import {
|
|
|
13744
14008
|
import {
|
|
13745
14009
|
AccountRole as AccountRole18
|
|
13746
14010
|
} from "@solana/kit";
|
|
13747
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
14011
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS19 } from "@solana-program/memo";
|
|
13748
14012
|
import {
|
|
13749
14013
|
fetchAllMaybeMint as fetchAllMaybeMint21,
|
|
13750
|
-
findAssociatedTokenPda as
|
|
14014
|
+
findAssociatedTokenPda as findAssociatedTokenPda29,
|
|
13751
14015
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS18
|
|
13752
14016
|
} from "@solana-program/token-2022";
|
|
13753
14017
|
import assert21 from "assert";
|
|
@@ -13803,37 +14067,37 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13803
14067
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
13804
14068
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
13805
14069
|
const fusionPositionAddress = (await getPositionAddress18(positionMint))[0];
|
|
13806
|
-
const tunaPositionAta = (await
|
|
14070
|
+
const tunaPositionAta = (await findAssociatedTokenPda29({
|
|
13807
14071
|
owner: tunaPosition.address,
|
|
13808
14072
|
mint: positionMint,
|
|
13809
14073
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS18
|
|
13810
14074
|
}))[0];
|
|
13811
|
-
const tunaPositionOwnerAtaA = (await
|
|
14075
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda29({
|
|
13812
14076
|
owner: authority.address,
|
|
13813
14077
|
mint: mintA.address,
|
|
13814
14078
|
tokenProgram: mintA.programAddress
|
|
13815
14079
|
}))[0];
|
|
13816
|
-
const tunaPositionOwnerAtaB = (await
|
|
14080
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda29({
|
|
13817
14081
|
owner: authority.address,
|
|
13818
14082
|
mint: mintB.address,
|
|
13819
14083
|
tokenProgram: mintB.programAddress
|
|
13820
14084
|
}))[0];
|
|
13821
|
-
const tunaPositionAtaA = (await
|
|
14085
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda29({
|
|
13822
14086
|
owner: tunaPosition.address,
|
|
13823
14087
|
mint: mintA.address,
|
|
13824
14088
|
tokenProgram: mintA.programAddress
|
|
13825
14089
|
}))[0];
|
|
13826
|
-
const tunaPositionAtaB = (await
|
|
14090
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda29({
|
|
13827
14091
|
owner: tunaPosition.address,
|
|
13828
14092
|
mint: mintB.address,
|
|
13829
14093
|
tokenProgram: mintB.programAddress
|
|
13830
14094
|
}))[0];
|
|
13831
|
-
const vaultAAta = (await
|
|
14095
|
+
const vaultAAta = (await findAssociatedTokenPda29({
|
|
13832
14096
|
owner: vaultA.address,
|
|
13833
14097
|
mint: mintA.address,
|
|
13834
14098
|
tokenProgram: mintA.programAddress
|
|
13835
14099
|
}))[0];
|
|
13836
|
-
const vaultBAta = (await
|
|
14100
|
+
const vaultBAta = (await findAssociatedTokenPda29({
|
|
13837
14101
|
owner: vaultB.address,
|
|
13838
14102
|
mint: mintB.address,
|
|
13839
14103
|
tokenProgram: mintB.programAddress
|
|
@@ -13890,7 +14154,7 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13890
14154
|
fusionammProgram: FUSIONAMM_PROGRAM_ADDRESS12,
|
|
13891
14155
|
tokenProgramA: mintA.programAddress,
|
|
13892
14156
|
tokenProgramB: mintB.programAddress,
|
|
13893
|
-
memoProgram:
|
|
14157
|
+
memoProgram: MEMO_PROGRAM_ADDRESS19,
|
|
13894
14158
|
...args,
|
|
13895
14159
|
remainingAccountsInfo
|
|
13896
14160
|
});
|
|
@@ -13899,19 +14163,19 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13899
14163
|
}
|
|
13900
14164
|
|
|
13901
14165
|
// src/txbuilder/repayBadDebt.ts
|
|
13902
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
13903
|
-
import { fetchMaybeMint as fetchMaybeMint2, findAssociatedTokenPda as
|
|
14166
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS20 } from "@solana-program/memo";
|
|
14167
|
+
import { fetchMaybeMint as fetchMaybeMint2, findAssociatedTokenPda as findAssociatedTokenPda30 } from "@solana-program/token-2022";
|
|
13904
14168
|
async function repayBadDebtInstruction(rpc, authority, mintAddress, funds, shares) {
|
|
13905
14169
|
const mint = await fetchMaybeMint2(rpc, mintAddress);
|
|
13906
14170
|
if (!mint.exists) throw new Error("Mint account not found");
|
|
13907
14171
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
13908
14172
|
const vault = (await getLendingVaultAddress(mint.address))[0];
|
|
13909
|
-
const vaultAta = (await
|
|
14173
|
+
const vaultAta = (await findAssociatedTokenPda30({
|
|
13910
14174
|
owner: vault,
|
|
13911
14175
|
mint: mint.address,
|
|
13912
14176
|
tokenProgram: mint.programAddress
|
|
13913
14177
|
}))[0];
|
|
13914
|
-
const authorityAta = (await
|
|
14178
|
+
const authorityAta = (await findAssociatedTokenPda30({
|
|
13915
14179
|
owner: authority.address,
|
|
13916
14180
|
mint: mint.address,
|
|
13917
14181
|
tokenProgram: mint.programAddress
|
|
@@ -13924,7 +14188,7 @@ async function repayBadDebtInstruction(rpc, authority, mintAddress, funds, share
|
|
|
13924
14188
|
tunaConfig,
|
|
13925
14189
|
vault,
|
|
13926
14190
|
tokenProgram: mint.programAddress,
|
|
13927
|
-
memoProgram:
|
|
14191
|
+
memoProgram: MEMO_PROGRAM_ADDRESS20,
|
|
13928
14192
|
funds,
|
|
13929
14193
|
shares
|
|
13930
14194
|
});
|
|
@@ -13956,7 +14220,7 @@ async function setTunaSpotPositionLimitOrdersInstruction(authority, poolAddress,
|
|
|
13956
14220
|
}
|
|
13957
14221
|
|
|
13958
14222
|
// src/txbuilder/resetTunaSpotPosition.ts
|
|
13959
|
-
import { fetchAllMaybeMint as fetchAllMaybeMint22, findAssociatedTokenPda as
|
|
14223
|
+
import { fetchAllMaybeMint as fetchAllMaybeMint22, findAssociatedTokenPda as findAssociatedTokenPda31 } from "@solana-program/token-2022";
|
|
13960
14224
|
import assert22 from "assert";
|
|
13961
14225
|
async function resetTunaSpotPositionInstruction(rpc, authority, poolAddress, args) {
|
|
13962
14226
|
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
@@ -13964,12 +14228,12 @@ async function resetTunaSpotPositionInstruction(rpc, authority, poolAddress, arg
|
|
|
13964
14228
|
const [mintA, mintB] = await fetchAllMaybeMint22(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
13965
14229
|
assert22(mintA.exists, "Token A not found");
|
|
13966
14230
|
assert22(mintB.exists, "Token B not found");
|
|
13967
|
-
const tunaPositionAtaA = (await
|
|
14231
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda31({
|
|
13968
14232
|
owner: tunaPositionAddress,
|
|
13969
14233
|
mint: mintA.address,
|
|
13970
14234
|
tokenProgram: mintA.programAddress
|
|
13971
14235
|
}))[0];
|
|
13972
|
-
const tunaPositionAtaB = (await
|
|
14236
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda31({
|
|
13973
14237
|
owner: tunaPositionAddress,
|
|
13974
14238
|
mint: mintB.address,
|
|
13975
14239
|
tokenProgram: mintB.programAddress
|
|
@@ -14010,8 +14274,8 @@ async function updateVaultInstruction(authority, mint, args) {
|
|
|
14010
14274
|
}
|
|
14011
14275
|
|
|
14012
14276
|
// src/txbuilder/withdraw.ts
|
|
14013
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
14014
|
-
import { fetchMaybeMint as fetchMaybeMint3, findAssociatedTokenPda as
|
|
14277
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS21 } from "@solana-program/memo";
|
|
14278
|
+
import { fetchMaybeMint as fetchMaybeMint3, findAssociatedTokenPda as findAssociatedTokenPda32 } from "@solana-program/token-2022";
|
|
14015
14279
|
async function withdrawInstructions(rpc, authority, mintAddress, funds, shares) {
|
|
14016
14280
|
const instructions = [];
|
|
14017
14281
|
const mint = await fetchMaybeMint3(rpc, mintAddress);
|
|
@@ -14033,12 +14297,12 @@ async function withdrawInstruction(authority, mint, funds, shares) {
|
|
|
14033
14297
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
14034
14298
|
const lendingPosition = (await getLendingPositionAddress(authority.address, mint.address))[0];
|
|
14035
14299
|
const vault = (await getLendingVaultAddress(mint.address))[0];
|
|
14036
|
-
const vaultAta = (await
|
|
14300
|
+
const vaultAta = (await findAssociatedTokenPda32({
|
|
14037
14301
|
owner: vault,
|
|
14038
14302
|
mint: mint.address,
|
|
14039
14303
|
tokenProgram: mint.programAddress
|
|
14040
14304
|
}))[0];
|
|
14041
|
-
const authorityAta = (await
|
|
14305
|
+
const authorityAta = (await findAssociatedTokenPda32({
|
|
14042
14306
|
owner: authority.address,
|
|
14043
14307
|
mint: mint.address,
|
|
14044
14308
|
tokenProgram: mint.programAddress
|
|
@@ -14052,7 +14316,7 @@ async function withdrawInstruction(authority, mint, funds, shares) {
|
|
|
14052
14316
|
vault,
|
|
14053
14317
|
vaultAta,
|
|
14054
14318
|
tokenProgram: mint.programAddress,
|
|
14055
|
-
memoProgram:
|
|
14319
|
+
memoProgram: MEMO_PROGRAM_ADDRESS21,
|
|
14056
14320
|
funds,
|
|
14057
14321
|
shares
|
|
14058
14322
|
});
|
|
@@ -14065,13 +14329,13 @@ import {
|
|
|
14065
14329
|
address as address3
|
|
14066
14330
|
} from "@solana/kit";
|
|
14067
14331
|
import { fetchAddressLookupTable, getExtendLookupTableInstruction as getExtendLookupTableInstruction2 } from "@solana-program/address-lookup-table";
|
|
14068
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
14332
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS22 } from "@solana-program/memo";
|
|
14069
14333
|
import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system";
|
|
14070
14334
|
import { TOKEN_PROGRAM_ADDRESS as TOKEN_PROGRAM_ADDRESS2 } from "@solana-program/token";
|
|
14071
14335
|
import {
|
|
14072
14336
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS as ASSOCIATED_TOKEN_PROGRAM_ADDRESS6,
|
|
14073
14337
|
fetchMint,
|
|
14074
|
-
findAssociatedTokenPda as
|
|
14338
|
+
findAssociatedTokenPda as findAssociatedTokenPda33,
|
|
14075
14339
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS19
|
|
14076
14340
|
} from "@solana-program/token-2022";
|
|
14077
14341
|
async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
@@ -14082,12 +14346,12 @@ async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
|
14082
14346
|
const pool = marketMaker == 0 /* Orca */ ? await fetchWhirlpool3(rpc, poolAddress) : await fetchFusionPool3(rpc, poolAddress);
|
|
14083
14347
|
const mintA = await fetchMint(rpc, pool.data.tokenMintA);
|
|
14084
14348
|
const mintB = await fetchMint(rpc, pool.data.tokenMintB);
|
|
14085
|
-
const feeRecipientAtaA = (await
|
|
14349
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda33({
|
|
14086
14350
|
owner: tunaConfig.data.feeRecipient,
|
|
14087
14351
|
mint: mintA.address,
|
|
14088
14352
|
tokenProgram: mintA.programAddress
|
|
14089
14353
|
}))[0];
|
|
14090
|
-
const feeRecipientAtaB = (await
|
|
14354
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda33({
|
|
14091
14355
|
owner: tunaConfig.data.feeRecipient,
|
|
14092
14356
|
mint: mintB.address,
|
|
14093
14357
|
tokenProgram: mintB.programAddress
|
|
@@ -14096,12 +14360,12 @@ async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
|
14096
14360
|
(await getLendingVaultAddress(mintA.address))[0],
|
|
14097
14361
|
(await getLendingVaultAddress(mintB.address))[0]
|
|
14098
14362
|
]);
|
|
14099
|
-
const vaultAAta = (await
|
|
14363
|
+
const vaultAAta = (await findAssociatedTokenPda33({
|
|
14100
14364
|
owner: vaultA.address,
|
|
14101
14365
|
mint: mintA.address,
|
|
14102
14366
|
tokenProgram: mintA.programAddress
|
|
14103
14367
|
}))[0];
|
|
14104
|
-
const vaultBAta = (await
|
|
14368
|
+
const vaultBAta = (await findAssociatedTokenPda33({
|
|
14105
14369
|
owner: vaultB.address,
|
|
14106
14370
|
mint: mintB.address,
|
|
14107
14371
|
tokenProgram: mintB.programAddress
|
|
@@ -14113,7 +14377,7 @@ async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
|
14113
14377
|
TOKEN_PROGRAM_ADDRESS2,
|
|
14114
14378
|
TOKEN_2022_PROGRAM_ADDRESS19,
|
|
14115
14379
|
NATIVE_MINT,
|
|
14116
|
-
|
|
14380
|
+
MEMO_PROGRAM_ADDRESS22,
|
|
14117
14381
|
tunaConfigAddress,
|
|
14118
14382
|
marketAddress,
|
|
14119
14383
|
mintA.address,
|
|
@@ -14168,8 +14432,8 @@ async function extendAddressLookupTableForMarketInstructions(rpc, poolAddress, m
|
|
|
14168
14432
|
}
|
|
14169
14433
|
|
|
14170
14434
|
// src/txbuilder/repayTunaLpPositionDebt.ts
|
|
14171
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
14172
|
-
import { fetchAllMaybeMint as fetchAllMaybeMint23, findAssociatedTokenPda as
|
|
14435
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS23 } from "@solana-program/memo";
|
|
14436
|
+
import { fetchAllMaybeMint as fetchAllMaybeMint23, findAssociatedTokenPda as findAssociatedTokenPda34 } from "@solana-program/token-2022";
|
|
14173
14437
|
import assert23 from "assert";
|
|
14174
14438
|
async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint, collateralA, collateralB, createInstructions, cleanupInstructions) {
|
|
14175
14439
|
const instructions = [];
|
|
@@ -14214,34 +14478,34 @@ async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint,
|
|
|
14214
14478
|
}
|
|
14215
14479
|
async function repayTunaLpPositionDebtInstruction(authority, positionMint, mintA, mintB, marketAddress, collateralA, collateralB) {
|
|
14216
14480
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint))[0];
|
|
14217
|
-
const tunaPositionOwnerAtaA = (await
|
|
14481
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda34({
|
|
14218
14482
|
owner: authority.address,
|
|
14219
14483
|
mint: mintA.address,
|
|
14220
14484
|
tokenProgram: mintA.programAddress
|
|
14221
14485
|
}))[0];
|
|
14222
|
-
const tunaPositionOwnerAtaB = (await
|
|
14486
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda34({
|
|
14223
14487
|
owner: authority.address,
|
|
14224
14488
|
mint: mintB.address,
|
|
14225
14489
|
tokenProgram: mintB.programAddress
|
|
14226
14490
|
}))[0];
|
|
14227
|
-
const tunaPositionAtaA = (await
|
|
14491
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda34({
|
|
14228
14492
|
owner: tunaPositionAddress,
|
|
14229
14493
|
mint: mintA.address,
|
|
14230
14494
|
tokenProgram: mintA.programAddress
|
|
14231
14495
|
}))[0];
|
|
14232
|
-
const tunaPositionAtaB = (await
|
|
14496
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda34({
|
|
14233
14497
|
owner: tunaPositionAddress,
|
|
14234
14498
|
mint: mintB.address,
|
|
14235
14499
|
tokenProgram: mintB.programAddress
|
|
14236
14500
|
}))[0];
|
|
14237
14501
|
const vaultAAddress = (await getLendingVaultAddress(mintA.address))[0];
|
|
14238
|
-
const vaultAAta = (await
|
|
14502
|
+
const vaultAAta = (await findAssociatedTokenPda34({
|
|
14239
14503
|
owner: vaultAAddress,
|
|
14240
14504
|
mint: mintA.address,
|
|
14241
14505
|
tokenProgram: mintA.programAddress
|
|
14242
14506
|
}))[0];
|
|
14243
14507
|
const vaultBAddress = (await getLendingVaultAddress(mintB.address))[0];
|
|
14244
|
-
const vaultBAta = (await
|
|
14508
|
+
const vaultBAta = (await findAssociatedTokenPda34({
|
|
14245
14509
|
owner: vaultBAddress,
|
|
14246
14510
|
mint: mintB.address,
|
|
14247
14511
|
tokenProgram: mintB.programAddress
|
|
@@ -14249,7 +14513,7 @@ async function repayTunaLpPositionDebtInstruction(authority, positionMint, mintA
|
|
|
14249
14513
|
return getRepayTunaLpPositionDebtInstruction({
|
|
14250
14514
|
authority,
|
|
14251
14515
|
market: marketAddress,
|
|
14252
|
-
memoProgram:
|
|
14516
|
+
memoProgram: MEMO_PROGRAM_ADDRESS23,
|
|
14253
14517
|
mintA: mintA.address,
|
|
14254
14518
|
mintB: mintB.address,
|
|
14255
14519
|
tokenProgramA: mintA.programAddress,
|
|
@@ -14283,10 +14547,10 @@ import {
|
|
|
14283
14547
|
lamports as lamports3
|
|
14284
14548
|
} from "@solana/kit";
|
|
14285
14549
|
import { fetchSysvarRent as fetchSysvarRent3 } from "@solana/sysvars";
|
|
14286
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
14550
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS24 } from "@solana-program/memo";
|
|
14287
14551
|
import {
|
|
14288
14552
|
fetchAllMaybeMint as fetchAllMaybeMint24,
|
|
14289
|
-
findAssociatedTokenPda as
|
|
14553
|
+
findAssociatedTokenPda as findAssociatedTokenPda35,
|
|
14290
14554
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS20
|
|
14291
14555
|
} from "@solana-program/token-2022";
|
|
14292
14556
|
import assert24 from "assert";
|
|
@@ -14376,27 +14640,27 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
14376
14640
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
14377
14641
|
const orcaPositionAddress = (await getPositionAddress19(positionMint))[0];
|
|
14378
14642
|
const orcaOracleAddress = (await getOracleAddress9(whirlpool.address))[0];
|
|
14379
|
-
const tunaPositionAta = (await
|
|
14643
|
+
const tunaPositionAta = (await findAssociatedTokenPda35({
|
|
14380
14644
|
owner: tunaPosition.address,
|
|
14381
14645
|
mint: positionMint,
|
|
14382
14646
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS20
|
|
14383
14647
|
}))[0];
|
|
14384
|
-
const tunaPositionAtaA = (await
|
|
14648
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda35({
|
|
14385
14649
|
owner: tunaPosition.address,
|
|
14386
14650
|
mint: mintA.address,
|
|
14387
14651
|
tokenProgram: mintA.programAddress
|
|
14388
14652
|
}))[0];
|
|
14389
|
-
const tunaPositionAtaB = (await
|
|
14653
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda35({
|
|
14390
14654
|
owner: tunaPosition.address,
|
|
14391
14655
|
mint: mintB.address,
|
|
14392
14656
|
tokenProgram: mintB.programAddress
|
|
14393
14657
|
}))[0];
|
|
14394
|
-
const feeRecipientAtaA = (await
|
|
14658
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda35({
|
|
14395
14659
|
owner: tunaConfig.data.feeRecipient,
|
|
14396
14660
|
mint: mintA.address,
|
|
14397
14661
|
tokenProgram: mintA.programAddress
|
|
14398
14662
|
}))[0];
|
|
14399
|
-
const feeRecipientAtaB = (await
|
|
14663
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda35({
|
|
14400
14664
|
owner: tunaConfig.data.feeRecipient,
|
|
14401
14665
|
mint: mintB.address,
|
|
14402
14666
|
tokenProgram: mintB.programAddress
|
|
@@ -14458,7 +14722,7 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
14458
14722
|
whirlpoolProgram: WHIRLPOOL_PROGRAM_ADDRESS14,
|
|
14459
14723
|
tokenProgramA: mintA.programAddress,
|
|
14460
14724
|
tokenProgramB: mintB.programAddress,
|
|
14461
|
-
memoProgram:
|
|
14725
|
+
memoProgram: MEMO_PROGRAM_ADDRESS24,
|
|
14462
14726
|
remainingAccountsInfo
|
|
14463
14727
|
});
|
|
14464
14728
|
ix.accounts.push(...remainingAccounts);
|
|
@@ -14479,10 +14743,10 @@ import {
|
|
|
14479
14743
|
lamports as lamports4
|
|
14480
14744
|
} from "@solana/kit";
|
|
14481
14745
|
import { fetchSysvarRent as fetchSysvarRent4 } from "@solana/sysvars";
|
|
14482
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
14746
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS25 } from "@solana-program/memo";
|
|
14483
14747
|
import {
|
|
14484
14748
|
fetchAllMaybeMint as fetchAllMaybeMint25,
|
|
14485
|
-
findAssociatedTokenPda as
|
|
14749
|
+
findAssociatedTokenPda as findAssociatedTokenPda36,
|
|
14486
14750
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS21
|
|
14487
14751
|
} from "@solana-program/token-2022";
|
|
14488
14752
|
import assert25 from "assert";
|
|
@@ -14567,27 +14831,27 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
14567
14831
|
const positionMint = tunaPosition.data.positionMint;
|
|
14568
14832
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
14569
14833
|
const fusionPositionAddress = (await getPositionAddress20(positionMint))[0];
|
|
14570
|
-
const tunaPositionAta = (await
|
|
14834
|
+
const tunaPositionAta = (await findAssociatedTokenPda36({
|
|
14571
14835
|
owner: tunaPosition.address,
|
|
14572
14836
|
mint: positionMint,
|
|
14573
14837
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS21
|
|
14574
14838
|
}))[0];
|
|
14575
|
-
const tunaPositionAtaA = (await
|
|
14839
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda36({
|
|
14576
14840
|
owner: tunaPosition.address,
|
|
14577
14841
|
mint: mintA.address,
|
|
14578
14842
|
tokenProgram: mintA.programAddress
|
|
14579
14843
|
}))[0];
|
|
14580
|
-
const tunaPositionAtaB = (await
|
|
14844
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda36({
|
|
14581
14845
|
owner: tunaPosition.address,
|
|
14582
14846
|
mint: mintB.address,
|
|
14583
14847
|
tokenProgram: mintB.programAddress
|
|
14584
14848
|
}))[0];
|
|
14585
|
-
const feeRecipientAtaA = (await
|
|
14849
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda36({
|
|
14586
14850
|
owner: tunaConfig.data.feeRecipient,
|
|
14587
14851
|
mint: mintA.address,
|
|
14588
14852
|
tokenProgram: mintA.programAddress
|
|
14589
14853
|
}))[0];
|
|
14590
|
-
const feeRecipientAtaB = (await
|
|
14854
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda36({
|
|
14591
14855
|
owner: tunaConfig.data.feeRecipient,
|
|
14592
14856
|
mint: mintB.address,
|
|
14593
14857
|
tokenProgram: mintB.programAddress
|
|
@@ -14647,7 +14911,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
14647
14911
|
fusionammProgram: FUSIONAMM_PROGRAM_ADDRESS14,
|
|
14648
14912
|
tokenProgramA: mintA.programAddress,
|
|
14649
14913
|
tokenProgramB: mintB.programAddress,
|
|
14650
|
-
memoProgram:
|
|
14914
|
+
memoProgram: MEMO_PROGRAM_ADDRESS25,
|
|
14651
14915
|
remainingAccountsInfo
|
|
14652
14916
|
});
|
|
14653
14917
|
ix.accounts.push(...remainingAccounts);
|
|
@@ -14732,6 +14996,8 @@ export {
|
|
|
14732
14996
|
TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED,
|
|
14733
14997
|
TUNA_ERROR__BAD_DEBT,
|
|
14734
14998
|
TUNA_ERROR__INCORRECT_POSITION_DIRECTION,
|
|
14999
|
+
TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT,
|
|
15000
|
+
TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT,
|
|
14735
15001
|
TUNA_ERROR__INSUFFICIENT_LIQUIDITY,
|
|
14736
15002
|
TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT,
|
|
14737
15003
|
TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE,
|
|
@@ -14811,6 +15077,7 @@ export {
|
|
|
14811
15077
|
TunaPositionState,
|
|
14812
15078
|
UNLIMITED_SUPPLY_LIMIT,
|
|
14813
15079
|
UPDATE_MARKET_DISCRIMINATOR,
|
|
15080
|
+
UPDATE_MARKET_VAULTS_DISCRIMINATOR,
|
|
14814
15081
|
UPDATE_VAULT_DISCRIMINATOR,
|
|
14815
15082
|
VAULT_DISCRIMINATOR,
|
|
14816
15083
|
WITHDRAW_DISCRIMINATOR,
|
|
@@ -15170,6 +15437,11 @@ export {
|
|
|
15170
15437
|
getUpdateMarketInstructionDataCodec,
|
|
15171
15438
|
getUpdateMarketInstructionDataDecoder,
|
|
15172
15439
|
getUpdateMarketInstructionDataEncoder,
|
|
15440
|
+
getUpdateMarketVaultsDiscriminatorBytes,
|
|
15441
|
+
getUpdateMarketVaultsInstruction,
|
|
15442
|
+
getUpdateMarketVaultsInstructionDataCodec,
|
|
15443
|
+
getUpdateMarketVaultsInstructionDataDecoder,
|
|
15444
|
+
getUpdateMarketVaultsInstructionDataEncoder,
|
|
15173
15445
|
getUpdateVaultDiscriminatorBytes,
|
|
15174
15446
|
getUpdateVaultInstruction,
|
|
15175
15447
|
getUpdateVaultInstructionDataCodec,
|
|
@@ -15200,6 +15472,8 @@ export {
|
|
|
15200
15472
|
liquidateTunaLpPositionOrcaInstructions,
|
|
15201
15473
|
liquidateTunaSpotPositionFusionInstruction,
|
|
15202
15474
|
liquidateTunaSpotPositionFusionInstructions,
|
|
15475
|
+
liquidateTunaSpotPositionJupiterInstruction,
|
|
15476
|
+
liquidateTunaSpotPositionJupiterInstructions,
|
|
15203
15477
|
liquidateTunaSpotPositionOrcaInstruction,
|
|
15204
15478
|
liquidateTunaSpotPositionOrcaInstructions,
|
|
15205
15479
|
modifyTunaSpotPositionFusionInstruction,
|
|
@@ -15267,6 +15541,7 @@ export {
|
|
|
15267
15541
|
parseSetTunaLpPositionRebalanceThresholdInstruction,
|
|
15268
15542
|
parseSetTunaSpotPositionLimitOrdersInstruction,
|
|
15269
15543
|
parseUpdateMarketInstruction,
|
|
15544
|
+
parseUpdateMarketVaultsInstruction,
|
|
15270
15545
|
parseUpdateVaultInstruction,
|
|
15271
15546
|
parseWithdrawInstruction,
|
|
15272
15547
|
rebalanceTunaLpPositionFusionInstruction,
|