@crypticdot/defituna-client 3.0.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +81 -104
- package/dist/index.d.ts +81 -104
- package/dist/index.js +149 -192
- package/dist/index.mjs +117 -162
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -49,8 +49,8 @@ __export(index_exports, {
|
|
|
49
49
|
DECREASE_TUNA_SPOT_POSITION_FUSION_DISCRIMINATOR: () => DECREASE_TUNA_SPOT_POSITION_FUSION_DISCRIMINATOR,
|
|
50
50
|
DECREASE_TUNA_SPOT_POSITION_ORCA_DISCRIMINATOR: () => DECREASE_TUNA_SPOT_POSITION_ORCA_DISCRIMINATOR,
|
|
51
51
|
DEFAULT_ADDRESS: () => DEFAULT_ADDRESS,
|
|
52
|
-
DEFAULT_MAX_AMOUNT_SLIPPAGE: () => DEFAULT_MAX_AMOUNT_SLIPPAGE,
|
|
53
52
|
DEFAULT_MAX_SWAP_SLIPPAGE: () => DEFAULT_MAX_SWAP_SLIPPAGE,
|
|
53
|
+
DEFAULT_PUSH_ORACLE_PROGRAM_ID: () => DEFAULT_PUSH_ORACLE_PROGRAM_ID,
|
|
54
54
|
DEPOSIT_DISCRIMINATOR: () => DEPOSIT_DISCRIMINATOR,
|
|
55
55
|
FusionUtils: () => FusionUtils,
|
|
56
56
|
HUNDRED_PERCENT: () => HUNDRED_PERCENT,
|
|
@@ -348,6 +348,7 @@ __export(index_exports, {
|
|
|
348
348
|
getDepositInstructionDataCodec: () => getDepositInstructionDataCodec,
|
|
349
349
|
getDepositInstructionDataDecoder: () => getDepositInstructionDataDecoder,
|
|
350
350
|
getDepositInstructionDataEncoder: () => getDepositInstructionDataEncoder,
|
|
351
|
+
getIncreaseLpPositionQuote: () => getIncreaseLpPositionQuote,
|
|
351
352
|
getIncreaseTunaLpPositionFusionDiscriminatorBytes: () => getIncreaseTunaLpPositionFusionDiscriminatorBytes,
|
|
352
353
|
getIncreaseTunaLpPositionFusionInstruction: () => getIncreaseTunaLpPositionFusionInstruction,
|
|
353
354
|
getIncreaseTunaLpPositionFusionInstructionDataCodec: () => getIncreaseTunaLpPositionFusionInstructionDataCodec,
|
|
@@ -395,7 +396,6 @@ __export(index_exports, {
|
|
|
395
396
|
getLiquidateTunaSpotPositionOrcaInstructionDataCodec: () => getLiquidateTunaSpotPositionOrcaInstructionDataCodec,
|
|
396
397
|
getLiquidateTunaSpotPositionOrcaInstructionDataDecoder: () => getLiquidateTunaSpotPositionOrcaInstructionDataDecoder,
|
|
397
398
|
getLiquidateTunaSpotPositionOrcaInstructionDataEncoder: () => getLiquidateTunaSpotPositionOrcaInstructionDataEncoder,
|
|
398
|
-
getLiquidityIncreaseQuote: () => getLiquidityIncreaseQuote,
|
|
399
399
|
getMarketAddress: () => getMarketAddress,
|
|
400
400
|
getMarketCodec: () => getMarketCodec,
|
|
401
401
|
getMarketDecoder: () => getMarketDecoder,
|
|
@@ -453,6 +453,7 @@ __export(index_exports, {
|
|
|
453
453
|
getPoolTokenCodec: () => getPoolTokenCodec,
|
|
454
454
|
getPoolTokenDecoder: () => getPoolTokenDecoder,
|
|
455
455
|
getPoolTokenEncoder: () => getPoolTokenEncoder,
|
|
456
|
+
getPythPriceUpdateAccountAddress: () => getPythPriceUpdateAccountAddress,
|
|
456
457
|
getRebalanceTunaLpPositionFusionDiscriminatorBytes: () => getRebalanceTunaLpPositionFusionDiscriminatorBytes,
|
|
457
458
|
getRebalanceTunaLpPositionFusionInstruction: () => getRebalanceTunaLpPositionFusionInstruction,
|
|
458
459
|
getRebalanceTunaLpPositionFusionInstructionDataCodec: () => getRebalanceTunaLpPositionFusionInstructionDataCodec,
|
|
@@ -697,7 +698,6 @@ __export(index_exports, {
|
|
|
697
698
|
tunaSpotPositionAuthorityFilter: () => tunaSpotPositionAuthorityFilter,
|
|
698
699
|
tunaSpotPositionMintAFilter: () => tunaSpotPositionMintAFilter,
|
|
699
700
|
tunaSpotPositionMintBFilter: () => tunaSpotPositionMintBFilter,
|
|
700
|
-
tunaSpotPositionMintFilter: () => tunaSpotPositionMintFilter,
|
|
701
701
|
tunaSpotPositionPoolFilter: () => tunaSpotPositionPoolFilter,
|
|
702
702
|
updateMarketInstruction: () => updateMarketInstruction,
|
|
703
703
|
updateVaultInstruction: () => updateVaultInstruction,
|
|
@@ -1248,7 +1248,6 @@ function getTunaSpotPositionEncoder() {
|
|
|
1248
1248
|
["pool", (0, import_kit11.getAddressEncoder)()],
|
|
1249
1249
|
["mintA", (0, import_kit11.getAddressEncoder)()],
|
|
1250
1250
|
["mintB", (0, import_kit11.getAddressEncoder)()],
|
|
1251
|
-
["positionMint", (0, import_kit11.getAddressEncoder)()],
|
|
1252
1251
|
["marketMaker", getMarketMakerEncoder()],
|
|
1253
1252
|
["positionToken", getPoolTokenEncoder()],
|
|
1254
1253
|
["collateralToken", getPoolTokenEncoder()],
|
|
@@ -1274,7 +1273,6 @@ function getTunaSpotPositionDecoder() {
|
|
|
1274
1273
|
["pool", (0, import_kit11.getAddressDecoder)()],
|
|
1275
1274
|
["mintA", (0, import_kit11.getAddressDecoder)()],
|
|
1276
1275
|
["mintB", (0, import_kit11.getAddressDecoder)()],
|
|
1277
|
-
["positionMint", (0, import_kit11.getAddressDecoder)()],
|
|
1278
1276
|
["marketMaker", getMarketMakerDecoder()],
|
|
1279
1277
|
["positionToken", getPoolTokenDecoder()],
|
|
1280
1278
|
["collateralToken", getPoolTokenDecoder()],
|
|
@@ -1326,7 +1324,7 @@ async function fetchAllMaybeTunaSpotPosition(rpc, addresses, config) {
|
|
|
1326
1324
|
);
|
|
1327
1325
|
}
|
|
1328
1326
|
function getTunaSpotPositionSize() {
|
|
1329
|
-
return
|
|
1327
|
+
return 347;
|
|
1330
1328
|
}
|
|
1331
1329
|
|
|
1332
1330
|
// src/generated/accounts/vault.ts
|
|
@@ -6736,10 +6734,6 @@ function getOpenAndIncreaseTunaSpotPositionFusionInstruction(input, config) {
|
|
|
6736
6734
|
vaultAAta: { value: input.vaultAAta ?? null, isWritable: true },
|
|
6737
6735
|
vaultBAta: { value: input.vaultBAta ?? null, isWritable: true },
|
|
6738
6736
|
tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
|
|
6739
|
-
tunaPositionMint: {
|
|
6740
|
-
value: input.tunaPositionMint ?? null,
|
|
6741
|
-
isWritable: false
|
|
6742
|
-
},
|
|
6743
6737
|
tunaPositionAtaA: {
|
|
6744
6738
|
value: input.tunaPositionAtaA ?? null,
|
|
6745
6739
|
isWritable: true
|
|
@@ -6804,7 +6798,6 @@ function getOpenAndIncreaseTunaSpotPositionFusionInstruction(input, config) {
|
|
|
6804
6798
|
getAccountMeta(accounts.vaultAAta),
|
|
6805
6799
|
getAccountMeta(accounts.vaultBAta),
|
|
6806
6800
|
getAccountMeta(accounts.tunaPosition),
|
|
6807
|
-
getAccountMeta(accounts.tunaPositionMint),
|
|
6808
6801
|
getAccountMeta(accounts.tunaPositionAtaA),
|
|
6809
6802
|
getAccountMeta(accounts.tunaPositionAtaB),
|
|
6810
6803
|
getAccountMeta(accounts.tunaPositionOwnerAtaA),
|
|
@@ -6827,7 +6820,7 @@ function getOpenAndIncreaseTunaSpotPositionFusionInstruction(input, config) {
|
|
|
6827
6820
|
return instruction;
|
|
6828
6821
|
}
|
|
6829
6822
|
function parseOpenAndIncreaseTunaSpotPositionFusionInstruction(instruction) {
|
|
6830
|
-
if (instruction.accounts.length <
|
|
6823
|
+
if (instruction.accounts.length < 25) {
|
|
6831
6824
|
throw new Error("Not enough accounts");
|
|
6832
6825
|
}
|
|
6833
6826
|
let accountIndex = 0;
|
|
@@ -6855,7 +6848,6 @@ function parseOpenAndIncreaseTunaSpotPositionFusionInstruction(instruction) {
|
|
|
6855
6848
|
vaultAAta: getNextAccount(),
|
|
6856
6849
|
vaultBAta: getNextAccount(),
|
|
6857
6850
|
tunaPosition: getNextAccount(),
|
|
6858
|
-
tunaPositionMint: getNextAccount(),
|
|
6859
6851
|
tunaPositionAtaA: getNextAccount(),
|
|
6860
6852
|
tunaPositionAtaB: getNextAccount(),
|
|
6861
6853
|
tunaPositionOwnerAtaA: getNextOptionalAccount(),
|
|
@@ -6939,10 +6931,6 @@ function getOpenAndIncreaseTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
6939
6931
|
vaultAAta: { value: input.vaultAAta ?? null, isWritable: true },
|
|
6940
6932
|
vaultBAta: { value: input.vaultBAta ?? null, isWritable: true },
|
|
6941
6933
|
tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
|
|
6942
|
-
tunaPositionMint: {
|
|
6943
|
-
value: input.tunaPositionMint ?? null,
|
|
6944
|
-
isWritable: false
|
|
6945
|
-
},
|
|
6946
6934
|
tunaPositionAtaA: {
|
|
6947
6935
|
value: input.tunaPositionAtaA ?? null,
|
|
6948
6936
|
isWritable: true
|
|
@@ -7007,7 +6995,6 @@ function getOpenAndIncreaseTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
7007
6995
|
getAccountMeta(accounts.vaultAAta),
|
|
7008
6996
|
getAccountMeta(accounts.vaultBAta),
|
|
7009
6997
|
getAccountMeta(accounts.tunaPosition),
|
|
7010
|
-
getAccountMeta(accounts.tunaPositionMint),
|
|
7011
6998
|
getAccountMeta(accounts.tunaPositionAtaA),
|
|
7012
6999
|
getAccountMeta(accounts.tunaPositionAtaB),
|
|
7013
7000
|
getAccountMeta(accounts.tunaPositionOwnerAtaA),
|
|
@@ -7030,7 +7017,7 @@ function getOpenAndIncreaseTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
7030
7017
|
return instruction;
|
|
7031
7018
|
}
|
|
7032
7019
|
function parseOpenAndIncreaseTunaSpotPositionOrcaInstruction(instruction) {
|
|
7033
|
-
if (instruction.accounts.length <
|
|
7020
|
+
if (instruction.accounts.length < 25) {
|
|
7034
7021
|
throw new Error("Not enough accounts");
|
|
7035
7022
|
}
|
|
7036
7023
|
let accountIndex = 0;
|
|
@@ -7058,7 +7045,6 @@ function parseOpenAndIncreaseTunaSpotPositionOrcaInstruction(instruction) {
|
|
|
7058
7045
|
vaultAAta: getNextAccount(),
|
|
7059
7046
|
vaultBAta: getNextAccount(),
|
|
7060
7047
|
tunaPosition: getNextAccount(),
|
|
7061
|
-
tunaPositionMint: getNextAccount(),
|
|
7062
7048
|
tunaPositionAtaA: getNextAccount(),
|
|
7063
7049
|
tunaPositionAtaB: getNextAccount(),
|
|
7064
7050
|
tunaPositionOwnerAtaA: getNextOptionalAccount(),
|
|
@@ -7557,10 +7543,6 @@ function getOpenTunaSpotPositionFusionInstruction(input, config) {
|
|
|
7557
7543
|
tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
|
|
7558
7544
|
tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
|
|
7559
7545
|
tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
|
|
7560
|
-
tunaPositionMint: {
|
|
7561
|
-
value: input.tunaPositionMint ?? null,
|
|
7562
|
-
isWritable: false
|
|
7563
|
-
},
|
|
7564
7546
|
tunaPositionAtaA: {
|
|
7565
7547
|
value: input.tunaPositionAtaA ?? null,
|
|
7566
7548
|
isWritable: true
|
|
@@ -7590,7 +7572,6 @@ function getOpenTunaSpotPositionFusionInstruction(input, config) {
|
|
|
7590
7572
|
getAccountMeta(accounts.tokenProgramA),
|
|
7591
7573
|
getAccountMeta(accounts.tokenProgramB),
|
|
7592
7574
|
getAccountMeta(accounts.tunaPosition),
|
|
7593
|
-
getAccountMeta(accounts.tunaPositionMint),
|
|
7594
7575
|
getAccountMeta(accounts.tunaPositionAtaA),
|
|
7595
7576
|
getAccountMeta(accounts.tunaPositionAtaB),
|
|
7596
7577
|
getAccountMeta(accounts.fusionPool),
|
|
@@ -7605,7 +7586,7 @@ function getOpenTunaSpotPositionFusionInstruction(input, config) {
|
|
|
7605
7586
|
return instruction;
|
|
7606
7587
|
}
|
|
7607
7588
|
function parseOpenTunaSpotPositionFusionInstruction(instruction) {
|
|
7608
|
-
if (instruction.accounts.length <
|
|
7589
|
+
if (instruction.accounts.length < 11) {
|
|
7609
7590
|
throw new Error("Not enough accounts");
|
|
7610
7591
|
}
|
|
7611
7592
|
let accountIndex = 0;
|
|
@@ -7623,7 +7604,6 @@ function parseOpenTunaSpotPositionFusionInstruction(instruction) {
|
|
|
7623
7604
|
tokenProgramA: getNextAccount(),
|
|
7624
7605
|
tokenProgramB: getNextAccount(),
|
|
7625
7606
|
tunaPosition: getNextAccount(),
|
|
7626
|
-
tunaPositionMint: getNextAccount(),
|
|
7627
7607
|
tunaPositionAtaA: getNextAccount(),
|
|
7628
7608
|
tunaPositionAtaB: getNextAccount(),
|
|
7629
7609
|
fusionPool: getNextAccount(),
|
|
@@ -7694,10 +7674,6 @@ function getOpenTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
7694
7674
|
tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
|
|
7695
7675
|
tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
|
|
7696
7676
|
tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
|
|
7697
|
-
tunaPositionMint: {
|
|
7698
|
-
value: input.tunaPositionMint ?? null,
|
|
7699
|
-
isWritable: false
|
|
7700
|
-
},
|
|
7701
7677
|
tunaPositionAtaA: {
|
|
7702
7678
|
value: input.tunaPositionAtaA ?? null,
|
|
7703
7679
|
isWritable: true
|
|
@@ -7727,7 +7703,6 @@ function getOpenTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
7727
7703
|
getAccountMeta(accounts.tokenProgramA),
|
|
7728
7704
|
getAccountMeta(accounts.tokenProgramB),
|
|
7729
7705
|
getAccountMeta(accounts.tunaPosition),
|
|
7730
|
-
getAccountMeta(accounts.tunaPositionMint),
|
|
7731
7706
|
getAccountMeta(accounts.tunaPositionAtaA),
|
|
7732
7707
|
getAccountMeta(accounts.tunaPositionAtaB),
|
|
7733
7708
|
getAccountMeta(accounts.whirlpool),
|
|
@@ -7742,7 +7717,7 @@ function getOpenTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
7742
7717
|
return instruction;
|
|
7743
7718
|
}
|
|
7744
7719
|
function parseOpenTunaSpotPositionOrcaInstruction(instruction) {
|
|
7745
|
-
if (instruction.accounts.length <
|
|
7720
|
+
if (instruction.accounts.length < 11) {
|
|
7746
7721
|
throw new Error("Not enough accounts");
|
|
7747
7722
|
}
|
|
7748
7723
|
let accountIndex = 0;
|
|
@@ -7760,7 +7735,6 @@ function parseOpenTunaSpotPositionOrcaInstruction(instruction) {
|
|
|
7760
7735
|
tokenProgramA: getNextAccount(),
|
|
7761
7736
|
tokenProgramB: getNextAccount(),
|
|
7762
7737
|
tunaPosition: getNextAccount(),
|
|
7763
|
-
tunaPositionMint: getNextAccount(),
|
|
7764
7738
|
tunaPositionAtaA: getNextAccount(),
|
|
7765
7739
|
tunaPositionAtaB: getNextAccount(),
|
|
7766
7740
|
whirlpool: getNextAccount(),
|
|
@@ -9717,55 +9691,102 @@ function parseWithdrawInstruction(instruction) {
|
|
|
9717
9691
|
}
|
|
9718
9692
|
|
|
9719
9693
|
// src/pda.ts
|
|
9694
|
+
var import_kit72 = require("@solana/kit");
|
|
9695
|
+
|
|
9696
|
+
// src/consts.ts
|
|
9720
9697
|
var import_kit71 = require("@solana/kit");
|
|
9698
|
+
var DEFAULT_ADDRESS = (0, import_kit71.address)("11111111111111111111111111111111");
|
|
9699
|
+
var HUNDRED_PERCENT = 1e6;
|
|
9700
|
+
var LEVERAGE_ONE = HUNDRED_PERCENT;
|
|
9701
|
+
var MAX_LEVERAGE = 11 * LEVERAGE_ONE;
|
|
9702
|
+
var MAX_PROTOCOL_FEE = HUNDRED_PERCENT / 100;
|
|
9703
|
+
var MAX_LIQUIDATION_FEE = HUNDRED_PERCENT / 5;
|
|
9704
|
+
var MAX_LIMIT_ORDER_EXECUTION_FEE = HUNDRED_PERCENT / 100;
|
|
9705
|
+
var DEFAULT_MAX_SWAP_SLIPPAGE = HUNDRED_PERCENT / 50;
|
|
9706
|
+
var MAX_LIQUIDATION_THRESHOLD = HUNDRED_PERCENT * 95 / 100;
|
|
9707
|
+
var NO_LOWER_LIMIT_ORDER = -2147483648;
|
|
9708
|
+
var NO_UPPER_LIMIT_ORDER = 2147483647;
|
|
9709
|
+
var COMPUTED_AMOUNT = 18446744073709551615n;
|
|
9710
|
+
var UNLIMITED_SUPPLY_LIMIT = 18446744073709551615n;
|
|
9711
|
+
var TUNA_POSITION_FLAGS_LOWER_LIMIT_ORDER_SWAP_TO_TOKEN_A = 1;
|
|
9712
|
+
var TUNA_POSITION_FLAGS_LOWER_LIMIT_ORDER_SWAP_TO_TOKEN_B = 1 << 1;
|
|
9713
|
+
var TUNA_POSITION_FLAGS_UPPER_LIMIT_ORDER_SWAP_TO_TOKEN_A = 1 << 2;
|
|
9714
|
+
var TUNA_POSITION_FLAGS_UPPER_LIMIT_ORDER_SWAP_TO_TOKEN_B = 1 << 3;
|
|
9715
|
+
var TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD = 1 << 4;
|
|
9716
|
+
var TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD_WITH_LEVERAGE = 1 << 5;
|
|
9717
|
+
var TUNA_POSITION_FLAGS_ALLOW_REBALANCING = 1 << 6;
|
|
9718
|
+
var WP_NFT_UPDATE_AUTH = (0, import_kit71.address)("3axbTs2z5GBy6usVbNVoqEgZMng3vZvMnAoX29BFfwhr");
|
|
9719
|
+
var DEFAULT_PUSH_ORACLE_PROGRAM_ID = (0, import_kit71.address)("pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT");
|
|
9720
|
+
var MIN_SQRT_PRICE = 4295048016n;
|
|
9721
|
+
var MAX_SQRT_PRICE = 79226673515401279992447579055n;
|
|
9722
|
+
|
|
9723
|
+
// src/pda.ts
|
|
9721
9724
|
async function getTunaConfigAddress() {
|
|
9722
|
-
return await (0,
|
|
9725
|
+
return await (0, import_kit72.getProgramDerivedAddress)({
|
|
9723
9726
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9724
9727
|
seeds: ["tuna_config"]
|
|
9725
9728
|
});
|
|
9726
9729
|
}
|
|
9727
9730
|
async function getMarketAddress(pool) {
|
|
9728
|
-
return await (0,
|
|
9731
|
+
return await (0, import_kit72.getProgramDerivedAddress)({
|
|
9729
9732
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9730
|
-
seeds: ["market", (0,
|
|
9733
|
+
seeds: ["market", (0, import_kit72.getAddressEncoder)().encode(pool)]
|
|
9731
9734
|
});
|
|
9732
9735
|
}
|
|
9733
9736
|
async function getLendingVaultAddress(mint) {
|
|
9734
|
-
return await (0,
|
|
9737
|
+
return await (0, import_kit72.getProgramDerivedAddress)({
|
|
9735
9738
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9736
|
-
seeds: ["vault", (0,
|
|
9739
|
+
seeds: ["vault", (0, import_kit72.getAddressEncoder)().encode(mint)]
|
|
9737
9740
|
});
|
|
9738
9741
|
}
|
|
9739
|
-
async function getLendingPositionAddress(
|
|
9740
|
-
return await (0,
|
|
9742
|
+
async function getLendingPositionAddress(authority, mint) {
|
|
9743
|
+
return await (0, import_kit72.getProgramDerivedAddress)({
|
|
9741
9744
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9742
|
-
seeds: ["lending_position", (0,
|
|
9745
|
+
seeds: ["lending_position", (0, import_kit72.getAddressEncoder)().encode(authority), (0, import_kit72.getAddressEncoder)().encode(mint)]
|
|
9743
9746
|
});
|
|
9744
9747
|
}
|
|
9745
9748
|
async function getTunaLpPositionAddress(positionMint) {
|
|
9746
|
-
return await (0,
|
|
9749
|
+
return await (0, import_kit72.getProgramDerivedAddress)({
|
|
9747
9750
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9748
|
-
seeds: ["tuna_position", (0,
|
|
9751
|
+
seeds: ["tuna_position", (0, import_kit72.getAddressEncoder)().encode(positionMint)]
|
|
9749
9752
|
});
|
|
9750
9753
|
}
|
|
9751
|
-
async function getTunaSpotPositionAddress(
|
|
9752
|
-
return await (0,
|
|
9754
|
+
async function getTunaSpotPositionAddress(authority, pool) {
|
|
9755
|
+
return await (0, import_kit72.getProgramDerivedAddress)({
|
|
9753
9756
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9754
|
-
seeds: ["tuna_spot_position", (0,
|
|
9757
|
+
seeds: ["tuna_spot_position", (0, import_kit72.getAddressEncoder)().encode(authority), (0, import_kit72.getAddressEncoder)().encode(pool)]
|
|
9758
|
+
});
|
|
9759
|
+
}
|
|
9760
|
+
async function getPythPriceUpdateAccountAddress(shardId, priceFeedId) {
|
|
9761
|
+
if (typeof priceFeedId == "string") {
|
|
9762
|
+
if (priceFeedId.startsWith("0x")) {
|
|
9763
|
+
priceFeedId = Buffer.from(priceFeedId.slice(2), "hex");
|
|
9764
|
+
} else {
|
|
9765
|
+
priceFeedId = Buffer.from(priceFeedId, "hex");
|
|
9766
|
+
}
|
|
9767
|
+
}
|
|
9768
|
+
if (priceFeedId.length != 32) {
|
|
9769
|
+
throw new Error("Feed ID should be 32 bytes long");
|
|
9770
|
+
}
|
|
9771
|
+
const shardBuffer = Buffer.alloc(2);
|
|
9772
|
+
shardBuffer.writeUint16LE(shardId, 0);
|
|
9773
|
+
return await (0, import_kit72.getProgramDerivedAddress)({
|
|
9774
|
+
programAddress: DEFAULT_PUSH_ORACLE_PROGRAM_ID,
|
|
9775
|
+
seeds: [shardBuffer, priceFeedId]
|
|
9755
9776
|
});
|
|
9756
9777
|
}
|
|
9757
9778
|
|
|
9758
9779
|
// src/gpa/tunaLpPosition.ts
|
|
9759
|
-
var
|
|
9780
|
+
var import_kit74 = require("@solana/kit");
|
|
9760
9781
|
|
|
9761
9782
|
// src/gpa/utils.ts
|
|
9762
|
-
var
|
|
9783
|
+
var import_kit73 = require("@solana/kit");
|
|
9763
9784
|
async function fetchDecodedProgramAccounts(rpc, programAddress, filters, decoder) {
|
|
9764
9785
|
const accountInfos = await rpc.getProgramAccounts(programAddress, {
|
|
9765
9786
|
encoding: "base64",
|
|
9766
9787
|
filters
|
|
9767
9788
|
}).send();
|
|
9768
|
-
const encoder = (0,
|
|
9789
|
+
const encoder = (0, import_kit73.getBase64Encoder)();
|
|
9769
9790
|
const datas = accountInfos.map((x) => encoder.encode(x.account.data[0]));
|
|
9770
9791
|
const decoded = datas.map((x) => decoder.decode(x));
|
|
9771
9792
|
return decoded.map((data, i) => ({
|
|
@@ -9781,7 +9802,7 @@ function tunaLpPositionAuthorityFilter(address4) {
|
|
|
9781
9802
|
return {
|
|
9782
9803
|
memcmp: {
|
|
9783
9804
|
offset: 11n,
|
|
9784
|
-
bytes: (0,
|
|
9805
|
+
bytes: (0, import_kit74.getBase58Decoder)().decode((0, import_kit74.getAddressEncoder)().encode(address4)),
|
|
9785
9806
|
encoding: "base58"
|
|
9786
9807
|
}
|
|
9787
9808
|
};
|
|
@@ -9790,7 +9811,7 @@ function tunaLpPositionPoolFilter(address4) {
|
|
|
9790
9811
|
return {
|
|
9791
9812
|
memcmp: {
|
|
9792
9813
|
offset: 43n,
|
|
9793
|
-
bytes: (0,
|
|
9814
|
+
bytes: (0, import_kit74.getBase58Decoder)().decode((0, import_kit74.getAddressEncoder)().encode(address4)),
|
|
9794
9815
|
encoding: "base58"
|
|
9795
9816
|
}
|
|
9796
9817
|
};
|
|
@@ -9799,7 +9820,7 @@ function tunaLpPositionMintAFilter(address4) {
|
|
|
9799
9820
|
return {
|
|
9800
9821
|
memcmp: {
|
|
9801
9822
|
offset: 75n,
|
|
9802
|
-
bytes: (0,
|
|
9823
|
+
bytes: (0, import_kit74.getBase58Decoder)().decode((0, import_kit74.getAddressEncoder)().encode(address4)),
|
|
9803
9824
|
encoding: "base58"
|
|
9804
9825
|
}
|
|
9805
9826
|
};
|
|
@@ -9808,7 +9829,7 @@ function tunaLpPositionMintBFilter(address4) {
|
|
|
9808
9829
|
return {
|
|
9809
9830
|
memcmp: {
|
|
9810
9831
|
offset: 107n,
|
|
9811
|
-
bytes: (0,
|
|
9832
|
+
bytes: (0, import_kit74.getBase58Decoder)().decode((0, import_kit74.getAddressEncoder)().encode(address4)),
|
|
9812
9833
|
encoding: "base58"
|
|
9813
9834
|
}
|
|
9814
9835
|
};
|
|
@@ -9817,7 +9838,7 @@ function tunaLpPositionMintFilter(address4) {
|
|
|
9817
9838
|
return {
|
|
9818
9839
|
memcmp: {
|
|
9819
9840
|
offset: 139n,
|
|
9820
|
-
bytes: (0,
|
|
9841
|
+
bytes: (0, import_kit74.getBase58Decoder)().decode((0, import_kit74.getAddressEncoder)().encode(address4)),
|
|
9821
9842
|
encoding: "base58"
|
|
9822
9843
|
}
|
|
9823
9844
|
};
|
|
@@ -9826,13 +9847,13 @@ function tunaLpPositionMarketMakerFilter(marketMaker) {
|
|
|
9826
9847
|
return {
|
|
9827
9848
|
memcmp: {
|
|
9828
9849
|
offset: 277n,
|
|
9829
|
-
bytes: (0,
|
|
9850
|
+
bytes: (0, import_kit74.getBase58Decoder)().decode((0, import_kit74.getI8Encoder)().encode(marketMaker)),
|
|
9830
9851
|
encoding: "base58"
|
|
9831
9852
|
}
|
|
9832
9853
|
};
|
|
9833
9854
|
}
|
|
9834
9855
|
async function fetchAllTunaLpPositionWithFilter(rpc, ...filters) {
|
|
9835
|
-
const discriminator = (0,
|
|
9856
|
+
const discriminator = (0, import_kit74.getBase58Decoder)().decode(TUNA_LP_POSITION_DISCRIMINATOR);
|
|
9836
9857
|
const discriminatorFilter = {
|
|
9837
9858
|
memcmp: {
|
|
9838
9859
|
offset: 0n,
|
|
@@ -9849,12 +9870,12 @@ async function fetchAllTunaLpPositionWithFilter(rpc, ...filters) {
|
|
|
9849
9870
|
}
|
|
9850
9871
|
|
|
9851
9872
|
// src/gpa/tunaSpotPosition.ts
|
|
9852
|
-
var
|
|
9873
|
+
var import_kit75 = require("@solana/kit");
|
|
9853
9874
|
function tunaSpotPositionAuthorityFilter(address4) {
|
|
9854
9875
|
return {
|
|
9855
9876
|
memcmp: {
|
|
9856
9877
|
offset: 11n,
|
|
9857
|
-
bytes: (0,
|
|
9878
|
+
bytes: (0, import_kit75.getBase58Decoder)().decode((0, import_kit75.getAddressEncoder)().encode(address4)),
|
|
9858
9879
|
encoding: "base58"
|
|
9859
9880
|
}
|
|
9860
9881
|
};
|
|
@@ -9863,7 +9884,7 @@ function tunaSpotPositionPoolFilter(address4) {
|
|
|
9863
9884
|
return {
|
|
9864
9885
|
memcmp: {
|
|
9865
9886
|
offset: 43n,
|
|
9866
|
-
bytes: (0,
|
|
9887
|
+
bytes: (0, import_kit75.getBase58Decoder)().decode((0, import_kit75.getAddressEncoder)().encode(address4)),
|
|
9867
9888
|
encoding: "base58"
|
|
9868
9889
|
}
|
|
9869
9890
|
};
|
|
@@ -9872,7 +9893,7 @@ function tunaSpotPositionMintAFilter(address4) {
|
|
|
9872
9893
|
return {
|
|
9873
9894
|
memcmp: {
|
|
9874
9895
|
offset: 75n,
|
|
9875
|
-
bytes: (0,
|
|
9896
|
+
bytes: (0, import_kit75.getBase58Decoder)().decode((0, import_kit75.getAddressEncoder)().encode(address4)),
|
|
9876
9897
|
encoding: "base58"
|
|
9877
9898
|
}
|
|
9878
9899
|
};
|
|
@@ -9881,22 +9902,13 @@ function tunaSpotPositionMintBFilter(address4) {
|
|
|
9881
9902
|
return {
|
|
9882
9903
|
memcmp: {
|
|
9883
9904
|
offset: 107n,
|
|
9884
|
-
bytes: (0,
|
|
9885
|
-
encoding: "base58"
|
|
9886
|
-
}
|
|
9887
|
-
};
|
|
9888
|
-
}
|
|
9889
|
-
function tunaSpotPositionMintFilter(address4) {
|
|
9890
|
-
return {
|
|
9891
|
-
memcmp: {
|
|
9892
|
-
offset: 139n,
|
|
9893
|
-
bytes: (0, import_kit74.getBase58Decoder)().decode((0, import_kit74.getAddressEncoder)().encode(address4)),
|
|
9905
|
+
bytes: (0, import_kit75.getBase58Decoder)().decode((0, import_kit75.getAddressEncoder)().encode(address4)),
|
|
9894
9906
|
encoding: "base58"
|
|
9895
9907
|
}
|
|
9896
9908
|
};
|
|
9897
9909
|
}
|
|
9898
9910
|
async function fetchAllTunaSpotPositionWithFilter(rpc, ...filters) {
|
|
9899
|
-
const discriminator = (0,
|
|
9911
|
+
const discriminator = (0, import_kit75.getBase58Decoder)().decode(TUNA_SPOT_POSITION_DISCRIMINATOR);
|
|
9900
9912
|
const discriminatorFilter = {
|
|
9901
9913
|
memcmp: {
|
|
9902
9914
|
offset: 0n,
|
|
@@ -9913,12 +9925,12 @@ async function fetchAllTunaSpotPositionWithFilter(rpc, ...filters) {
|
|
|
9913
9925
|
}
|
|
9914
9926
|
|
|
9915
9927
|
// src/gpa/lendingPosition.ts
|
|
9916
|
-
var
|
|
9928
|
+
var import_kit76 = require("@solana/kit");
|
|
9917
9929
|
function lendingPositionAuthorityFilter(address4) {
|
|
9918
9930
|
return {
|
|
9919
9931
|
memcmp: {
|
|
9920
9932
|
offset: 11n,
|
|
9921
|
-
bytes: (0,
|
|
9933
|
+
bytes: (0, import_kit76.getBase58Decoder)().decode((0, import_kit76.getAddressEncoder)().encode(address4)),
|
|
9922
9934
|
encoding: "base58"
|
|
9923
9935
|
}
|
|
9924
9936
|
};
|
|
@@ -9927,13 +9939,13 @@ function lendingPositionMintFilter(address4) {
|
|
|
9927
9939
|
return {
|
|
9928
9940
|
memcmp: {
|
|
9929
9941
|
offset: 43n,
|
|
9930
|
-
bytes: (0,
|
|
9942
|
+
bytes: (0, import_kit76.getBase58Decoder)().decode((0, import_kit76.getAddressEncoder)().encode(address4)),
|
|
9931
9943
|
encoding: "base58"
|
|
9932
9944
|
}
|
|
9933
9945
|
};
|
|
9934
9946
|
}
|
|
9935
9947
|
async function fetchAllLendingPositionWithFilter(rpc, ...filters) {
|
|
9936
|
-
const discriminator = (0,
|
|
9948
|
+
const discriminator = (0, import_kit76.getBase58Decoder)().decode(LENDING_POSITION_DISCRIMINATOR);
|
|
9937
9949
|
const discriminatorFilter = {
|
|
9938
9950
|
memcmp: {
|
|
9939
9951
|
offset: 0n,
|
|
@@ -9950,9 +9962,9 @@ async function fetchAllLendingPositionWithFilter(rpc, ...filters) {
|
|
|
9950
9962
|
}
|
|
9951
9963
|
|
|
9952
9964
|
// src/gpa/market.ts
|
|
9953
|
-
var
|
|
9965
|
+
var import_kit77 = require("@solana/kit");
|
|
9954
9966
|
async function fetchAllMarketWithFilter(rpc, ...filters) {
|
|
9955
|
-
const discriminator = (0,
|
|
9967
|
+
const discriminator = (0, import_kit77.getBase58Decoder)().decode(MARKET_DISCRIMINATOR);
|
|
9956
9968
|
const discriminatorFilter = {
|
|
9957
9969
|
memcmp: {
|
|
9958
9970
|
offset: 0n,
|
|
@@ -10045,11 +10057,11 @@ var FusionUtils = class {
|
|
|
10045
10057
|
};
|
|
10046
10058
|
|
|
10047
10059
|
// src/utils/token.ts
|
|
10048
|
-
var
|
|
10060
|
+
var import_kit78 = require("@solana/kit");
|
|
10049
10061
|
var import_system = require("@solana-program/system");
|
|
10050
10062
|
var import_token = require("@solana-program/token");
|
|
10051
10063
|
var import_token_2022 = require("@solana-program/token-2022");
|
|
10052
|
-
var NATIVE_MINT = (0,
|
|
10064
|
+
var NATIVE_MINT = (0, import_kit78.address)("So11111111111111111111111111111111111111112");
|
|
10053
10065
|
async function getCreateAtaInstruction(mint, owner, payer, tokenProgram = import_token.TOKEN_PROGRAM_ADDRESS) {
|
|
10054
10066
|
const ata = (await (0, import_token.findAssociatedTokenPda)({
|
|
10055
10067
|
mint,
|
|
@@ -10112,38 +10124,9 @@ async function createAddressLookupTableInstructions(authority, addresses, recent
|
|
|
10112
10124
|
return { instructions: [createInstruction, extendInstruction], lookupTableAddress: pda[0] };
|
|
10113
10125
|
}
|
|
10114
10126
|
|
|
10115
|
-
// src/utils/
|
|
10127
|
+
// src/utils/lpPositionMath.ts
|
|
10116
10128
|
var import_fusionamm_core3 = require("@crypticdot/fusionamm-core");
|
|
10117
|
-
|
|
10118
|
-
// src/consts.ts
|
|
10119
|
-
var import_kit78 = require("@solana/kit");
|
|
10120
|
-
var DEFAULT_ADDRESS = (0, import_kit78.address)("11111111111111111111111111111111");
|
|
10121
|
-
var HUNDRED_PERCENT = 1e6;
|
|
10122
|
-
var LEVERAGE_ONE = HUNDRED_PERCENT;
|
|
10123
|
-
var MAX_LEVERAGE = 11 * LEVERAGE_ONE;
|
|
10124
|
-
var MAX_PROTOCOL_FEE = HUNDRED_PERCENT / 100;
|
|
10125
|
-
var MAX_LIQUIDATION_FEE = HUNDRED_PERCENT / 5;
|
|
10126
|
-
var MAX_LIMIT_ORDER_EXECUTION_FEE = HUNDRED_PERCENT / 100;
|
|
10127
|
-
var DEFAULT_MAX_SWAP_SLIPPAGE = HUNDRED_PERCENT / 50;
|
|
10128
|
-
var MAX_LIQUIDATION_THRESHOLD = HUNDRED_PERCENT * 95 / 100;
|
|
10129
|
-
var NO_LOWER_LIMIT_ORDER = -2147483648;
|
|
10130
|
-
var NO_UPPER_LIMIT_ORDER = 2147483647;
|
|
10131
|
-
var COMPUTED_AMOUNT = 18446744073709551615n;
|
|
10132
|
-
var UNLIMITED_SUPPLY_LIMIT = 18446744073709551615n;
|
|
10133
|
-
var TUNA_POSITION_FLAGS_LOWER_LIMIT_ORDER_SWAP_TO_TOKEN_A = 1;
|
|
10134
|
-
var TUNA_POSITION_FLAGS_LOWER_LIMIT_ORDER_SWAP_TO_TOKEN_B = 1 << 1;
|
|
10135
|
-
var TUNA_POSITION_FLAGS_UPPER_LIMIT_ORDER_SWAP_TO_TOKEN_A = 1 << 2;
|
|
10136
|
-
var TUNA_POSITION_FLAGS_UPPER_LIMIT_ORDER_SWAP_TO_TOKEN_B = 1 << 3;
|
|
10137
|
-
var TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD = 1 << 4;
|
|
10138
|
-
var TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD_WITH_LEVERAGE = 1 << 5;
|
|
10139
|
-
var TUNA_POSITION_FLAGS_ALLOW_REBALANCING = 1 << 6;
|
|
10140
|
-
var WP_NFT_UPDATE_AUTH = (0, import_kit78.address)("3axbTs2z5GBy6usVbNVoqEgZMng3vZvMnAoX29BFfwhr");
|
|
10141
|
-
var MIN_SQRT_PRICE = 4295048016n;
|
|
10142
|
-
var MAX_SQRT_PRICE = 79226673515401279992447579055n;
|
|
10143
|
-
|
|
10144
|
-
// src/utils/positionMath.ts
|
|
10145
|
-
var DEFAULT_MAX_AMOUNT_SLIPPAGE = HUNDRED_PERCENT / 2;
|
|
10146
|
-
function getLiquidityIncreaseQuote(args) {
|
|
10129
|
+
function getIncreaseLpPositionQuote(args) {
|
|
10147
10130
|
const { protocolFeeRate, protocolFeeRateOnCollateral, swapFeeRate, sqrtPrice, tickLowerIndex, tickUpperIndex } = args;
|
|
10148
10131
|
let { collateralA, collateralB, borrowA, borrowB } = args;
|
|
10149
10132
|
if (tickLowerIndex > tickUpperIndex) {
|
|
@@ -10155,7 +10138,7 @@ function getLiquidityIncreaseQuote(args) {
|
|
|
10155
10138
|
if (args.collateralA == COMPUTED_AMOUNT && args.collateralB == COMPUTED_AMOUNT) {
|
|
10156
10139
|
throw new Error("Both collateral amounts can't be set to COMPUTED_AMOUNT");
|
|
10157
10140
|
}
|
|
10158
|
-
const maxAmountSlippage =
|
|
10141
|
+
const maxAmountSlippage = BigInt(args.maxAmountSlippage);
|
|
10159
10142
|
let maxCollateralA = BigInt(collateralA);
|
|
10160
10143
|
let maxCollateralB = BigInt(collateralB);
|
|
10161
10144
|
const lowerSqrtPrice = (0, import_fusionamm_core3.tickIndexToSqrtPrice)(tickLowerIndex);
|
|
@@ -10271,7 +10254,7 @@ async function increaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
|
|
|
10271
10254
|
const [mintA, mintB] = await (0, import_token_20222.fetchAllMaybeMint)(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
10272
10255
|
(0, import_assert.default)(mintA.exists, "Token A not found");
|
|
10273
10256
|
(0, import_assert.default)(mintB.exists, "Token B not found");
|
|
10274
|
-
const increaseAmounts =
|
|
10257
|
+
const increaseAmounts = getIncreaseLpPositionQuote({
|
|
10275
10258
|
collateralA: BigInt(args.collateralA),
|
|
10276
10259
|
collateralB: BigInt(args.collateralB),
|
|
10277
10260
|
borrowA: BigInt(args.borrowA),
|
|
@@ -10502,7 +10485,7 @@ async function increaseTunaLpPositionFusionInstructions(rpc, authority, position
|
|
|
10502
10485
|
const [mintA, mintB] = await (0, import_token_20223.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
10503
10486
|
(0, import_assert2.default)(mintA.exists, "Token A not found");
|
|
10504
10487
|
(0, import_assert2.default)(mintB.exists, "Token B not found");
|
|
10505
|
-
const increaseAmounts =
|
|
10488
|
+
const increaseAmounts = getIncreaseLpPositionQuote({
|
|
10506
10489
|
collateralA: BigInt(args.collateralA),
|
|
10507
10490
|
collateralB: BigInt(args.collateralB),
|
|
10508
10491
|
borrowA: BigInt(args.borrowA),
|
|
@@ -11616,8 +11599,9 @@ var import_kit86 = require("@solana/kit");
|
|
|
11616
11599
|
var import_memo8 = require("@solana-program/memo");
|
|
11617
11600
|
var import_token_202213 = require("@solana-program/token-2022");
|
|
11618
11601
|
var import_assert11 = __toESM(require("assert"));
|
|
11619
|
-
async function closeActiveTunaSpotPositionFusionInstructions(rpc, authority,
|
|
11620
|
-
const
|
|
11602
|
+
async function closeActiveTunaSpotPositionFusionInstructions(rpc, authority, fusionPoolAddress, args, createInstructions, cleanupInstructions) {
|
|
11603
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, fusionPoolAddress))[0];
|
|
11604
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
11621
11605
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
11622
11606
|
const fusionPool = await (0, import_fusionamm_client7.fetchMaybeFusionPool)(rpc, tunaPosition.data.pool);
|
|
11623
11607
|
if (!fusionPool.exists) throw new Error("FusionPool account not found");
|
|
@@ -11739,8 +11723,9 @@ var import_kit87 = require("@solana/kit");
|
|
|
11739
11723
|
var import_memo9 = require("@solana-program/memo");
|
|
11740
11724
|
var import_token_202214 = require("@solana-program/token-2022");
|
|
11741
11725
|
var import_assert12 = __toESM(require("assert"));
|
|
11742
|
-
async function closeActiveTunaSpotPositionOrcaInstructions(rpc, authority,
|
|
11743
|
-
const
|
|
11726
|
+
async function closeActiveTunaSpotPositionOrcaInstructions(rpc, authority, whirlpoolAddress, args, createInstructions, cleanupInstructions) {
|
|
11727
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, whirlpoolAddress))[0];
|
|
11728
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
11744
11729
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
11745
11730
|
const whirlpool = await (0, import_whirlpools_client7.fetchMaybeWhirlpool)(rpc, tunaPosition.data.pool);
|
|
11746
11731
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
@@ -11865,11 +11850,12 @@ var import_kit88 = require("@solana/kit");
|
|
|
11865
11850
|
var import_memo10 = require("@solana-program/memo");
|
|
11866
11851
|
var import_token_202215 = require("@solana-program/token-2022");
|
|
11867
11852
|
var import_assert13 = __toESM(require("assert"));
|
|
11868
|
-
async function increaseTunaSpotPositionOrcaInstructions(rpc, authority,
|
|
11853
|
+
async function increaseTunaSpotPositionOrcaInstructions(rpc, authority, whirlpoolAddress, args, createInstructions, cleanupInstructions) {
|
|
11869
11854
|
const instructions = [];
|
|
11870
11855
|
if (!createInstructions) createInstructions = instructions;
|
|
11871
11856
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
11872
|
-
const
|
|
11857
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, whirlpoolAddress))[0];
|
|
11858
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
11873
11859
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
11874
11860
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
11875
11861
|
const whirlpool = await (0, import_whirlpools_client8.fetchWhirlpool)(rpc, tunaPosition.data.pool);
|
|
@@ -12020,11 +12006,12 @@ var import_kit89 = require("@solana/kit");
|
|
|
12020
12006
|
var import_memo11 = require("@solana-program/memo");
|
|
12021
12007
|
var import_token_202216 = require("@solana-program/token-2022");
|
|
12022
12008
|
var import_assert14 = __toESM(require("assert"));
|
|
12023
|
-
async function increaseTunaSpotPositionFusionInstructions(rpc, authority,
|
|
12009
|
+
async function increaseTunaSpotPositionFusionInstructions(rpc, authority, fusionPoolAddress, args, createInstructions, cleanupInstructions) {
|
|
12024
12010
|
const instructions = [];
|
|
12025
12011
|
if (!createInstructions) createInstructions = instructions;
|
|
12026
12012
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
12027
|
-
const
|
|
12013
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, fusionPoolAddress))[0];
|
|
12014
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
12028
12015
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
12029
12016
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
12030
12017
|
const fusionPool = await (0, import_fusionamm_client8.fetchFusionPool)(rpc, tunaPosition.data.pool);
|
|
@@ -12172,11 +12159,12 @@ var import_kit90 = require("@solana/kit");
|
|
|
12172
12159
|
var import_memo12 = require("@solana-program/memo");
|
|
12173
12160
|
var import_token_202217 = require("@solana-program/token-2022");
|
|
12174
12161
|
var import_assert15 = __toESM(require("assert"));
|
|
12175
|
-
async function decreaseTunaSpotPositionOrcaInstructions(rpc, authority,
|
|
12162
|
+
async function decreaseTunaSpotPositionOrcaInstructions(rpc, authority, whirlpoolAddress, args, createInstructions, cleanupInstructions) {
|
|
12176
12163
|
const instructions = [];
|
|
12177
12164
|
if (!createInstructions) createInstructions = instructions;
|
|
12178
12165
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
12179
|
-
const
|
|
12166
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, whirlpoolAddress))[0];
|
|
12167
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
12180
12168
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
12181
12169
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
12182
12170
|
const whirlpool = await (0, import_whirlpools_client9.fetchWhirlpool)(rpc, tunaPosition.data.pool);
|
|
@@ -12325,11 +12313,12 @@ var import_kit91 = require("@solana/kit");
|
|
|
12325
12313
|
var import_memo13 = require("@solana-program/memo");
|
|
12326
12314
|
var import_token_202218 = require("@solana-program/token-2022");
|
|
12327
12315
|
var import_assert16 = __toESM(require("assert"));
|
|
12328
|
-
async function decreaseTunaSpotPositionFusionInstructions(rpc, authority,
|
|
12316
|
+
async function decreaseTunaSpotPositionFusionInstructions(rpc, authority, fusionPoolAddress, args, createInstructions, cleanupInstructions) {
|
|
12329
12317
|
const instructions = [];
|
|
12330
12318
|
if (!createInstructions) createInstructions = instructions;
|
|
12331
12319
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
12332
|
-
const
|
|
12320
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, fusionPoolAddress))[0];
|
|
12321
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
12333
12322
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
12334
12323
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
12335
12324
|
const fusionPool = await (0, import_fusionamm_client9.fetchFusionPool)(rpc, tunaPosition.data.pool);
|
|
@@ -12472,17 +12461,18 @@ async function decreaseTunaSpotPositionFusionInstruction(authority, tunaPosition
|
|
|
12472
12461
|
// src/txbuilder/closeTunaSpotPosition.ts
|
|
12473
12462
|
var import_token_202219 = require("@solana-program/token-2022");
|
|
12474
12463
|
var import_assert17 = __toESM(require("assert"));
|
|
12475
|
-
async function closeTunaSpotPositionInstructions(rpc, authority,
|
|
12476
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
12477
|
-
const tunaPosition = await
|
|
12464
|
+
async function closeTunaSpotPositionInstructions(rpc, authority, poolAddress) {
|
|
12465
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
12466
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
12467
|
+
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
12478
12468
|
const [mintA, mintB] = await (0, import_token_202219.fetchAllMaybeMint)(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
12479
12469
|
(0, import_assert17.default)(mintA.exists, "Token A account not found");
|
|
12480
12470
|
(0, import_assert17.default)(mintB.exists, "Token B account not found");
|
|
12481
|
-
const ix = await closeTunaSpotPositionInstruction(authority,
|
|
12471
|
+
const ix = await closeTunaSpotPositionInstruction(authority, poolAddress, mintA, mintB);
|
|
12482
12472
|
return [ix];
|
|
12483
12473
|
}
|
|
12484
|
-
async function closeTunaSpotPositionInstruction(authority,
|
|
12485
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
12474
|
+
async function closeTunaSpotPositionInstruction(authority, poolAddress, mintA, mintB) {
|
|
12475
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
12486
12476
|
const tunaPositionAtaA = (await (0, import_token_202219.findAssociatedTokenPda)({
|
|
12487
12477
|
owner: tunaPositionAddress,
|
|
12488
12478
|
mint: mintA.address,
|
|
@@ -12852,7 +12842,7 @@ async function liquidateTunaSpotPositionFusionInstructions(authority, tunaPositi
|
|
|
12852
12842
|
instructions.push(...createFeeRecipientAtaInstructions.init);
|
|
12853
12843
|
const ix = await liquidateTunaSpotPositionFusionInstruction(
|
|
12854
12844
|
authority,
|
|
12855
|
-
tunaPosition.
|
|
12845
|
+
tunaPosition.address,
|
|
12856
12846
|
tunaConfig,
|
|
12857
12847
|
mintA,
|
|
12858
12848
|
mintB,
|
|
@@ -12864,8 +12854,7 @@ async function liquidateTunaSpotPositionFusionInstructions(authority, tunaPositi
|
|
|
12864
12854
|
instructions.push(ix);
|
|
12865
12855
|
return instructions;
|
|
12866
12856
|
}
|
|
12867
|
-
async function liquidateTunaSpotPositionFusionInstruction(authority,
|
|
12868
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(positionMint))[0];
|
|
12857
|
+
async function liquidateTunaSpotPositionFusionInstruction(authority, tunaPositionAddress, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool, withdrawPercent) {
|
|
12869
12858
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
12870
12859
|
const tunaPositionAtaA = (await (0, import_token_202223.findAssociatedTokenPda)({
|
|
12871
12860
|
owner: tunaPositionAddress,
|
|
@@ -12961,7 +12950,7 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
12961
12950
|
instructions.push(...createFeeRecipientAtaInstructions.init);
|
|
12962
12951
|
const ix = await liquidateTunaSpotPositionOrcaInstruction(
|
|
12963
12952
|
authority,
|
|
12964
|
-
tunaPosition.
|
|
12953
|
+
tunaPosition.address,
|
|
12965
12954
|
tunaConfig,
|
|
12966
12955
|
mintA,
|
|
12967
12956
|
mintB,
|
|
@@ -12973,8 +12962,7 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
12973
12962
|
instructions.push(ix);
|
|
12974
12963
|
return instructions;
|
|
12975
12964
|
}
|
|
12976
|
-
async function liquidateTunaSpotPositionOrcaInstruction(authority,
|
|
12977
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(positionMint))[0];
|
|
12965
|
+
async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPositionAddress, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, withdrawPercent) {
|
|
12978
12966
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12979
12967
|
const orcaOracleAddress = (await (0, import_whirlpools_client11.getOracleAddress)(whirlpool.address))[0];
|
|
12980
12968
|
const tunaPositionAtaA = (await (0, import_token_202224.findAssociatedTokenPda)({
|
|
@@ -13194,7 +13182,7 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
|
|
|
13194
13182
|
(await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
|
|
13195
13183
|
(await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
|
|
13196
13184
|
]);
|
|
13197
|
-
const increaseAmounts =
|
|
13185
|
+
const increaseAmounts = getIncreaseLpPositionQuote({
|
|
13198
13186
|
collateralA: BigInt(args.collateralA),
|
|
13199
13187
|
collateralB: BigInt(args.collateralB),
|
|
13200
13188
|
borrowA: BigInt(args.borrowA),
|
|
@@ -13432,7 +13420,7 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
|
|
|
13432
13420
|
(await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
|
|
13433
13421
|
(await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
|
|
13434
13422
|
]);
|
|
13435
|
-
const increaseAmounts =
|
|
13423
|
+
const increaseAmounts = getIncreaseLpPositionQuote({
|
|
13436
13424
|
collateralA: BigInt(args.collateralA),
|
|
13437
13425
|
collateralB: BigInt(args.collateralB),
|
|
13438
13426
|
borrowA: BigInt(args.borrowA),
|
|
@@ -13648,7 +13636,6 @@ async function openAndIncreaseTunaSpotPositionFusionInstructions(rpc, authority,
|
|
|
13648
13636
|
const instructions = [];
|
|
13649
13637
|
if (!createInstructions) createInstructions = instructions;
|
|
13650
13638
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
13651
|
-
const positionMint = await (0, import_kit98.generateKeyPairSigner)();
|
|
13652
13639
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
13653
13640
|
const fusionPool = await (0, import_fusionamm_client15.fetchMaybeFusionPool)(rpc, fusionPoolAddress);
|
|
13654
13641
|
if (!fusionPool.exists) throw new Error("FusionPool account not found");
|
|
@@ -13687,7 +13674,6 @@ async function openAndIncreaseTunaSpotPositionFusionInstructions(rpc, authority,
|
|
|
13687
13674
|
createInstructions.push(...createFeeRecipientAtaBInstructions.init);
|
|
13688
13675
|
const ix = await openAndIncreaseTunaSpotPositionFusionInstruction(
|
|
13689
13676
|
authority,
|
|
13690
|
-
positionMint,
|
|
13691
13677
|
tunaConfig,
|
|
13692
13678
|
mintA,
|
|
13693
13679
|
mintB,
|
|
@@ -13698,13 +13684,10 @@ async function openAndIncreaseTunaSpotPositionFusionInstructions(rpc, authority,
|
|
|
13698
13684
|
);
|
|
13699
13685
|
instructions.push(ix);
|
|
13700
13686
|
cleanupInstructions.push(...createUserAtaInstructions.cleanup);
|
|
13701
|
-
return
|
|
13702
|
-
instructions,
|
|
13703
|
-
positionMint: positionMint.address
|
|
13704
|
-
};
|
|
13687
|
+
return instructions;
|
|
13705
13688
|
}
|
|
13706
|
-
async function openAndIncreaseTunaSpotPositionFusionInstruction(authority,
|
|
13707
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
13689
|
+
async function openAndIncreaseTunaSpotPositionFusionInstruction(authority, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool, args) {
|
|
13690
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, fusionPool.address))[0];
|
|
13708
13691
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
13709
13692
|
const tunaPositionOwnerAtaA = (await (0, import_token_202229.findAssociatedTokenPda)({
|
|
13710
13693
|
owner: authority.address,
|
|
@@ -13778,7 +13761,6 @@ async function openAndIncreaseTunaSpotPositionFusionInstruction(authority, posit
|
|
|
13778
13761
|
vaultB: vaultB.address,
|
|
13779
13762
|
vaultBAta,
|
|
13780
13763
|
tunaPosition: tunaPositionAddress,
|
|
13781
|
-
tunaPositionMint: positionMint,
|
|
13782
13764
|
tunaPositionAtaA,
|
|
13783
13765
|
tunaPositionAtaB,
|
|
13784
13766
|
tunaPositionOwnerAtaA: args.collateralToken == 0 /* A */ ? tunaPositionOwnerAtaA : void 0,
|
|
@@ -13806,7 +13788,6 @@ async function openAndIncreaseTunaSpotPositionOrcaInstructions(rpc, authority, w
|
|
|
13806
13788
|
const instructions = [];
|
|
13807
13789
|
if (!createInstructions) createInstructions = instructions;
|
|
13808
13790
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
13809
|
-
const positionMint = await (0, import_kit99.generateKeyPairSigner)();
|
|
13810
13791
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
13811
13792
|
const whirlpool = await (0, import_whirlpools_client14.fetchMaybeWhirlpool)(rpc, whirlpoolAddress);
|
|
13812
13793
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
@@ -13845,7 +13826,6 @@ async function openAndIncreaseTunaSpotPositionOrcaInstructions(rpc, authority, w
|
|
|
13845
13826
|
createInstructions.push(...createFeeRecipientAtaBInstructions.init);
|
|
13846
13827
|
const ix = await openAndIncreaseTunaSpotPositionOrcaInstruction(
|
|
13847
13828
|
authority,
|
|
13848
|
-
positionMint,
|
|
13849
13829
|
tunaConfig,
|
|
13850
13830
|
mintA,
|
|
13851
13831
|
mintB,
|
|
@@ -13856,13 +13836,10 @@ async function openAndIncreaseTunaSpotPositionOrcaInstructions(rpc, authority, w
|
|
|
13856
13836
|
);
|
|
13857
13837
|
instructions.push(ix);
|
|
13858
13838
|
cleanupInstructions.push(...createUserAtaInstructions.cleanup);
|
|
13859
|
-
return
|
|
13860
|
-
instructions,
|
|
13861
|
-
positionMint: positionMint.address
|
|
13862
|
-
};
|
|
13839
|
+
return instructions;
|
|
13863
13840
|
}
|
|
13864
|
-
async function openAndIncreaseTunaSpotPositionOrcaInstruction(authority,
|
|
13865
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
13841
|
+
async function openAndIncreaseTunaSpotPositionOrcaInstruction(authority, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, args) {
|
|
13842
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, whirlpool.address))[0];
|
|
13866
13843
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
13867
13844
|
const orcaOracleAddress = (await (0, import_whirlpools_client14.getOracleAddress)(whirlpool.address))[0];
|
|
13868
13845
|
const tunaPositionOwnerAtaA = (await (0, import_token_202230.findAssociatedTokenPda)({
|
|
@@ -13939,7 +13916,6 @@ async function openAndIncreaseTunaSpotPositionOrcaInstruction(authority, positio
|
|
|
13939
13916
|
vaultB: vaultB.address,
|
|
13940
13917
|
vaultBAta,
|
|
13941
13918
|
tunaPosition: tunaPositionAddress,
|
|
13942
|
-
tunaPositionMint: positionMint,
|
|
13943
13919
|
tunaPositionAtaA,
|
|
13944
13920
|
tunaPositionAtaB,
|
|
13945
13921
|
tunaPositionOwnerAtaA: args.collateralToken == 0 /* A */ ? tunaPositionOwnerAtaA : void 0,
|
|
@@ -13961,24 +13937,17 @@ async function openAndIncreaseTunaSpotPositionOrcaInstruction(authority, positio
|
|
|
13961
13937
|
var import_fusionamm_client16 = require("@crypticdot/fusionamm-client");
|
|
13962
13938
|
var import_token_202231 = require("@solana-program/token-2022");
|
|
13963
13939
|
var import_assert24 = __toESM(require("assert"));
|
|
13964
|
-
async function openTunaSpotPositionFusionInstructions(rpc, authority,
|
|
13940
|
+
async function openTunaSpotPositionFusionInstructions(rpc, authority, fusionPoolAddress, args) {
|
|
13965
13941
|
const fusionPool = await (0, import_fusionamm_client16.fetchMaybeFusionPool)(rpc, fusionPoolAddress);
|
|
13966
13942
|
if (!fusionPool.exists) throw new Error("FusionPool account not found");
|
|
13967
13943
|
const [mintA, mintB] = await (0, import_token_202231.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
13968
13944
|
(0, import_assert24.default)(mintA.exists, "Token A account not found");
|
|
13969
13945
|
(0, import_assert24.default)(mintB.exists, "Token B account not found");
|
|
13970
|
-
const ix = await openTunaSpotPositionFusionInstruction(
|
|
13971
|
-
authority,
|
|
13972
|
-
positionMint,
|
|
13973
|
-
mintA,
|
|
13974
|
-
mintB,
|
|
13975
|
-
fusionPoolAddress,
|
|
13976
|
-
args
|
|
13977
|
-
);
|
|
13946
|
+
const ix = await openTunaSpotPositionFusionInstruction(authority, mintA, mintB, fusionPoolAddress, args);
|
|
13978
13947
|
return [ix];
|
|
13979
13948
|
}
|
|
13980
|
-
async function openTunaSpotPositionFusionInstruction(authority,
|
|
13981
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
13949
|
+
async function openTunaSpotPositionFusionInstruction(authority, mintA, mintB, fusionPoolAddress, args) {
|
|
13950
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, fusionPoolAddress))[0];
|
|
13982
13951
|
const tunaPositionAtaA = (await (0, import_token_202231.findAssociatedTokenPda)({
|
|
13983
13952
|
owner: tunaPositionAddress,
|
|
13984
13953
|
mint: mintA.address,
|
|
@@ -13996,7 +13965,6 @@ async function openTunaSpotPositionFusionInstruction(authority, positionMint, mi
|
|
|
13996
13965
|
tokenProgramA: mintA.programAddress,
|
|
13997
13966
|
tokenProgramB: mintB.programAddress,
|
|
13998
13967
|
tunaPosition: tunaPositionAddress,
|
|
13999
|
-
tunaPositionMint: positionMint,
|
|
14000
13968
|
tunaPositionAtaA,
|
|
14001
13969
|
tunaPositionAtaB,
|
|
14002
13970
|
fusionPool: fusionPoolAddress,
|
|
@@ -14009,17 +13977,17 @@ async function openTunaSpotPositionFusionInstruction(authority, positionMint, mi
|
|
|
14009
13977
|
var import_whirlpools_client15 = require("@orca-so/whirlpools-client");
|
|
14010
13978
|
var import_token_202232 = require("@solana-program/token-2022");
|
|
14011
13979
|
var import_assert25 = __toESM(require("assert"));
|
|
14012
|
-
async function openTunaSpotPositionOrcaInstructions(rpc, authority,
|
|
13980
|
+
async function openTunaSpotPositionOrcaInstructions(rpc, authority, whirlpoolAddress, args) {
|
|
14013
13981
|
const whirlpool = await (0, import_whirlpools_client15.fetchMaybeWhirlpool)(rpc, whirlpoolAddress);
|
|
14014
13982
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
14015
13983
|
const [mintA, mintB] = await (0, import_token_202232.fetchAllMaybeMint)(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
14016
13984
|
(0, import_assert25.default)(mintA.exists, "Token A account not found");
|
|
14017
13985
|
(0, import_assert25.default)(mintB.exists, "Token B account not found");
|
|
14018
|
-
const ix = await openTunaSpotPositionOrcaInstruction(authority,
|
|
13986
|
+
const ix = await openTunaSpotPositionOrcaInstruction(authority, mintA, mintB, whirlpoolAddress, args);
|
|
14019
13987
|
return [ix];
|
|
14020
13988
|
}
|
|
14021
|
-
async function openTunaSpotPositionOrcaInstruction(authority,
|
|
14022
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
13989
|
+
async function openTunaSpotPositionOrcaInstruction(authority, mintA, mintB, whirlpoolAddress, args) {
|
|
13990
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, whirlpoolAddress))[0];
|
|
14023
13991
|
const tunaPositionAtaA = (await (0, import_token_202232.findAssociatedTokenPda)({
|
|
14024
13992
|
owner: tunaPositionAddress,
|
|
14025
13993
|
mint: mintA.address,
|
|
@@ -14037,7 +14005,6 @@ async function openTunaSpotPositionOrcaInstruction(authority, positionMint, mint
|
|
|
14037
14005
|
tokenProgramA: mintA.programAddress,
|
|
14038
14006
|
tokenProgramB: mintB.programAddress,
|
|
14039
14007
|
tunaPosition: tunaPositionAddress,
|
|
14040
|
-
tunaPositionMint: positionMint,
|
|
14041
14008
|
tunaPositionAtaA,
|
|
14042
14009
|
tunaPositionAtaB,
|
|
14043
14010
|
whirlpool: whirlpoolAddress,
|
|
@@ -14454,13 +14421,8 @@ async function setTunaLpPositionLimitOrdersInstruction(authority, args, position
|
|
|
14454
14421
|
}
|
|
14455
14422
|
|
|
14456
14423
|
// src/txbuilder/setTunaSpotPositionLimitOrders.ts
|
|
14457
|
-
async function setTunaSpotPositionLimitOrdersInstruction(authority,
|
|
14458
|
-
|
|
14459
|
-
if (positionMint === void 0) {
|
|
14460
|
-
throw new Error("At least one of 'positionMint' or 'tunaPositionAddress' must be provided.");
|
|
14461
|
-
}
|
|
14462
|
-
tunaPositionAddress = (await getTunaSpotPositionAddress(positionMint))[0];
|
|
14463
|
-
}
|
|
14424
|
+
async function setTunaSpotPositionLimitOrdersInstruction(authority, poolAddress, args) {
|
|
14425
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
14464
14426
|
return getSetTunaSpotPositionLimitOrdersInstruction({
|
|
14465
14427
|
...args,
|
|
14466
14428
|
authority,
|
|
@@ -14471,13 +14433,8 @@ async function setTunaSpotPositionLimitOrdersInstruction(authority, args, positi
|
|
|
14471
14433
|
// src/txbuilder/resetTunaSpotPosition.ts
|
|
14472
14434
|
var import_token_202236 = require("@solana-program/token-2022");
|
|
14473
14435
|
var import_assert28 = __toESM(require("assert"));
|
|
14474
|
-
async function resetTunaSpotPositionInstruction(rpc, authority,
|
|
14475
|
-
|
|
14476
|
-
if (positionMint === void 0) {
|
|
14477
|
-
throw new Error("At least one of 'positionMint' or 'tunaPositionAddress' must be provided.");
|
|
14478
|
-
}
|
|
14479
|
-
tunaPositionAddress = (await getTunaSpotPositionAddress(positionMint))[0];
|
|
14480
|
-
}
|
|
14436
|
+
async function resetTunaSpotPositionInstruction(rpc, authority, poolAddress, args) {
|
|
14437
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
14481
14438
|
const tunaPosition = await fetchTunaSpotPosition(rpc, tunaPositionAddress);
|
|
14482
14439
|
const [mintA, mintB] = await (0, import_token_202236.fetchAllMaybeMint)(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
14483
14440
|
(0, import_assert28.default)(mintA.exists, "Token A not found");
|
|
@@ -15143,8 +15100,8 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
15143
15100
|
DECREASE_TUNA_SPOT_POSITION_FUSION_DISCRIMINATOR,
|
|
15144
15101
|
DECREASE_TUNA_SPOT_POSITION_ORCA_DISCRIMINATOR,
|
|
15145
15102
|
DEFAULT_ADDRESS,
|
|
15146
|
-
DEFAULT_MAX_AMOUNT_SLIPPAGE,
|
|
15147
15103
|
DEFAULT_MAX_SWAP_SLIPPAGE,
|
|
15104
|
+
DEFAULT_PUSH_ORACLE_PROGRAM_ID,
|
|
15148
15105
|
DEPOSIT_DISCRIMINATOR,
|
|
15149
15106
|
FusionUtils,
|
|
15150
15107
|
HUNDRED_PERCENT,
|
|
@@ -15442,6 +15399,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
15442
15399
|
getDepositInstructionDataCodec,
|
|
15443
15400
|
getDepositInstructionDataDecoder,
|
|
15444
15401
|
getDepositInstructionDataEncoder,
|
|
15402
|
+
getIncreaseLpPositionQuote,
|
|
15445
15403
|
getIncreaseTunaLpPositionFusionDiscriminatorBytes,
|
|
15446
15404
|
getIncreaseTunaLpPositionFusionInstruction,
|
|
15447
15405
|
getIncreaseTunaLpPositionFusionInstructionDataCodec,
|
|
@@ -15489,7 +15447,6 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
15489
15447
|
getLiquidateTunaSpotPositionOrcaInstructionDataCodec,
|
|
15490
15448
|
getLiquidateTunaSpotPositionOrcaInstructionDataDecoder,
|
|
15491
15449
|
getLiquidateTunaSpotPositionOrcaInstructionDataEncoder,
|
|
15492
|
-
getLiquidityIncreaseQuote,
|
|
15493
15450
|
getMarketAddress,
|
|
15494
15451
|
getMarketCodec,
|
|
15495
15452
|
getMarketDecoder,
|
|
@@ -15547,6 +15504,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
15547
15504
|
getPoolTokenCodec,
|
|
15548
15505
|
getPoolTokenDecoder,
|
|
15549
15506
|
getPoolTokenEncoder,
|
|
15507
|
+
getPythPriceUpdateAccountAddress,
|
|
15550
15508
|
getRebalanceTunaLpPositionFusionDiscriminatorBytes,
|
|
15551
15509
|
getRebalanceTunaLpPositionFusionInstruction,
|
|
15552
15510
|
getRebalanceTunaLpPositionFusionInstructionDataCodec,
|
|
@@ -15791,7 +15749,6 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
15791
15749
|
tunaSpotPositionAuthorityFilter,
|
|
15792
15750
|
tunaSpotPositionMintAFilter,
|
|
15793
15751
|
tunaSpotPositionMintBFilter,
|
|
15794
|
-
tunaSpotPositionMintFilter,
|
|
15795
15752
|
tunaSpotPositionPoolFilter,
|
|
15796
15753
|
updateMarketInstruction,
|
|
15797
15754
|
updateVaultInstruction,
|