@crypticdot/defituna-client 3.0.4 → 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 +79 -104
- package/dist/index.d.ts +79 -104
- package/dist/index.js +65 -131
- package/dist/index.mjs +66 -132
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -688,7 +688,6 @@ function getTunaSpotPositionEncoder() {
|
|
|
688
688
|
["pool", getAddressEncoder5()],
|
|
689
689
|
["mintA", getAddressEncoder5()],
|
|
690
690
|
["mintB", getAddressEncoder5()],
|
|
691
|
-
["positionMint", getAddressEncoder5()],
|
|
692
691
|
["marketMaker", getMarketMakerEncoder()],
|
|
693
692
|
["positionToken", getPoolTokenEncoder()],
|
|
694
693
|
["collateralToken", getPoolTokenEncoder()],
|
|
@@ -714,7 +713,6 @@ function getTunaSpotPositionDecoder() {
|
|
|
714
713
|
["pool", getAddressDecoder5()],
|
|
715
714
|
["mintA", getAddressDecoder5()],
|
|
716
715
|
["mintB", getAddressDecoder5()],
|
|
717
|
-
["positionMint", getAddressDecoder5()],
|
|
718
716
|
["marketMaker", getMarketMakerDecoder()],
|
|
719
717
|
["positionToken", getPoolTokenDecoder()],
|
|
720
718
|
["collateralToken", getPoolTokenDecoder()],
|
|
@@ -766,7 +764,7 @@ async function fetchAllMaybeTunaSpotPosition(rpc, addresses, config) {
|
|
|
766
764
|
);
|
|
767
765
|
}
|
|
768
766
|
function getTunaSpotPositionSize() {
|
|
769
|
-
return
|
|
767
|
+
return 347;
|
|
770
768
|
}
|
|
771
769
|
|
|
772
770
|
// src/generated/accounts/vault.ts
|
|
@@ -6560,10 +6558,6 @@ function getOpenAndIncreaseTunaSpotPositionFusionInstruction(input, config) {
|
|
|
6560
6558
|
vaultAAta: { value: input.vaultAAta ?? null, isWritable: true },
|
|
6561
6559
|
vaultBAta: { value: input.vaultBAta ?? null, isWritable: true },
|
|
6562
6560
|
tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
|
|
6563
|
-
tunaPositionMint: {
|
|
6564
|
-
value: input.tunaPositionMint ?? null,
|
|
6565
|
-
isWritable: false
|
|
6566
|
-
},
|
|
6567
6561
|
tunaPositionAtaA: {
|
|
6568
6562
|
value: input.tunaPositionAtaA ?? null,
|
|
6569
6563
|
isWritable: true
|
|
@@ -6628,7 +6622,6 @@ function getOpenAndIncreaseTunaSpotPositionFusionInstruction(input, config) {
|
|
|
6628
6622
|
getAccountMeta(accounts.vaultAAta),
|
|
6629
6623
|
getAccountMeta(accounts.vaultBAta),
|
|
6630
6624
|
getAccountMeta(accounts.tunaPosition),
|
|
6631
|
-
getAccountMeta(accounts.tunaPositionMint),
|
|
6632
6625
|
getAccountMeta(accounts.tunaPositionAtaA),
|
|
6633
6626
|
getAccountMeta(accounts.tunaPositionAtaB),
|
|
6634
6627
|
getAccountMeta(accounts.tunaPositionOwnerAtaA),
|
|
@@ -6651,7 +6644,7 @@ function getOpenAndIncreaseTunaSpotPositionFusionInstruction(input, config) {
|
|
|
6651
6644
|
return instruction;
|
|
6652
6645
|
}
|
|
6653
6646
|
function parseOpenAndIncreaseTunaSpotPositionFusionInstruction(instruction) {
|
|
6654
|
-
if (instruction.accounts.length <
|
|
6647
|
+
if (instruction.accounts.length < 25) {
|
|
6655
6648
|
throw new Error("Not enough accounts");
|
|
6656
6649
|
}
|
|
6657
6650
|
let accountIndex = 0;
|
|
@@ -6679,7 +6672,6 @@ function parseOpenAndIncreaseTunaSpotPositionFusionInstruction(instruction) {
|
|
|
6679
6672
|
vaultAAta: getNextAccount(),
|
|
6680
6673
|
vaultBAta: getNextAccount(),
|
|
6681
6674
|
tunaPosition: getNextAccount(),
|
|
6682
|
-
tunaPositionMint: getNextAccount(),
|
|
6683
6675
|
tunaPositionAtaA: getNextAccount(),
|
|
6684
6676
|
tunaPositionAtaB: getNextAccount(),
|
|
6685
6677
|
tunaPositionOwnerAtaA: getNextOptionalAccount(),
|
|
@@ -6778,10 +6770,6 @@ function getOpenAndIncreaseTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
6778
6770
|
vaultAAta: { value: input.vaultAAta ?? null, isWritable: true },
|
|
6779
6771
|
vaultBAta: { value: input.vaultBAta ?? null, isWritable: true },
|
|
6780
6772
|
tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
|
|
6781
|
-
tunaPositionMint: {
|
|
6782
|
-
value: input.tunaPositionMint ?? null,
|
|
6783
|
-
isWritable: false
|
|
6784
|
-
},
|
|
6785
6773
|
tunaPositionAtaA: {
|
|
6786
6774
|
value: input.tunaPositionAtaA ?? null,
|
|
6787
6775
|
isWritable: true
|
|
@@ -6846,7 +6834,6 @@ function getOpenAndIncreaseTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
6846
6834
|
getAccountMeta(accounts.vaultAAta),
|
|
6847
6835
|
getAccountMeta(accounts.vaultBAta),
|
|
6848
6836
|
getAccountMeta(accounts.tunaPosition),
|
|
6849
|
-
getAccountMeta(accounts.tunaPositionMint),
|
|
6850
6837
|
getAccountMeta(accounts.tunaPositionAtaA),
|
|
6851
6838
|
getAccountMeta(accounts.tunaPositionAtaB),
|
|
6852
6839
|
getAccountMeta(accounts.tunaPositionOwnerAtaA),
|
|
@@ -6869,7 +6856,7 @@ function getOpenAndIncreaseTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
6869
6856
|
return instruction;
|
|
6870
6857
|
}
|
|
6871
6858
|
function parseOpenAndIncreaseTunaSpotPositionOrcaInstruction(instruction) {
|
|
6872
|
-
if (instruction.accounts.length <
|
|
6859
|
+
if (instruction.accounts.length < 25) {
|
|
6873
6860
|
throw new Error("Not enough accounts");
|
|
6874
6861
|
}
|
|
6875
6862
|
let accountIndex = 0;
|
|
@@ -6897,7 +6884,6 @@ function parseOpenAndIncreaseTunaSpotPositionOrcaInstruction(instruction) {
|
|
|
6897
6884
|
vaultAAta: getNextAccount(),
|
|
6898
6885
|
vaultBAta: getNextAccount(),
|
|
6899
6886
|
tunaPosition: getNextAccount(),
|
|
6900
|
-
tunaPositionMint: getNextAccount(),
|
|
6901
6887
|
tunaPositionAtaA: getNextAccount(),
|
|
6902
6888
|
tunaPositionAtaB: getNextAccount(),
|
|
6903
6889
|
tunaPositionOwnerAtaA: getNextOptionalAccount(),
|
|
@@ -7448,10 +7434,6 @@ function getOpenTunaSpotPositionFusionInstruction(input, config) {
|
|
|
7448
7434
|
tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
|
|
7449
7435
|
tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
|
|
7450
7436
|
tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
|
|
7451
|
-
tunaPositionMint: {
|
|
7452
|
-
value: input.tunaPositionMint ?? null,
|
|
7453
|
-
isWritable: false
|
|
7454
|
-
},
|
|
7455
7437
|
tunaPositionAtaA: {
|
|
7456
7438
|
value: input.tunaPositionAtaA ?? null,
|
|
7457
7439
|
isWritable: true
|
|
@@ -7481,7 +7463,6 @@ function getOpenTunaSpotPositionFusionInstruction(input, config) {
|
|
|
7481
7463
|
getAccountMeta(accounts.tokenProgramA),
|
|
7482
7464
|
getAccountMeta(accounts.tokenProgramB),
|
|
7483
7465
|
getAccountMeta(accounts.tunaPosition),
|
|
7484
|
-
getAccountMeta(accounts.tunaPositionMint),
|
|
7485
7466
|
getAccountMeta(accounts.tunaPositionAtaA),
|
|
7486
7467
|
getAccountMeta(accounts.tunaPositionAtaB),
|
|
7487
7468
|
getAccountMeta(accounts.fusionPool),
|
|
@@ -7496,7 +7477,7 @@ function getOpenTunaSpotPositionFusionInstruction(input, config) {
|
|
|
7496
7477
|
return instruction;
|
|
7497
7478
|
}
|
|
7498
7479
|
function parseOpenTunaSpotPositionFusionInstruction(instruction) {
|
|
7499
|
-
if (instruction.accounts.length <
|
|
7480
|
+
if (instruction.accounts.length < 11) {
|
|
7500
7481
|
throw new Error("Not enough accounts");
|
|
7501
7482
|
}
|
|
7502
7483
|
let accountIndex = 0;
|
|
@@ -7514,7 +7495,6 @@ function parseOpenTunaSpotPositionFusionInstruction(instruction) {
|
|
|
7514
7495
|
tokenProgramA: getNextAccount(),
|
|
7515
7496
|
tokenProgramB: getNextAccount(),
|
|
7516
7497
|
tunaPosition: getNextAccount(),
|
|
7517
|
-
tunaPositionMint: getNextAccount(),
|
|
7518
7498
|
tunaPositionAtaA: getNextAccount(),
|
|
7519
7499
|
tunaPositionAtaB: getNextAccount(),
|
|
7520
7500
|
fusionPool: getNextAccount(),
|
|
@@ -7598,10 +7578,6 @@ function getOpenTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
7598
7578
|
tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
|
|
7599
7579
|
tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
|
|
7600
7580
|
tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
|
|
7601
|
-
tunaPositionMint: {
|
|
7602
|
-
value: input.tunaPositionMint ?? null,
|
|
7603
|
-
isWritable: false
|
|
7604
|
-
},
|
|
7605
7581
|
tunaPositionAtaA: {
|
|
7606
7582
|
value: input.tunaPositionAtaA ?? null,
|
|
7607
7583
|
isWritable: true
|
|
@@ -7631,7 +7607,6 @@ function getOpenTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
7631
7607
|
getAccountMeta(accounts.tokenProgramA),
|
|
7632
7608
|
getAccountMeta(accounts.tokenProgramB),
|
|
7633
7609
|
getAccountMeta(accounts.tunaPosition),
|
|
7634
|
-
getAccountMeta(accounts.tunaPositionMint),
|
|
7635
7610
|
getAccountMeta(accounts.tunaPositionAtaA),
|
|
7636
7611
|
getAccountMeta(accounts.tunaPositionAtaB),
|
|
7637
7612
|
getAccountMeta(accounts.whirlpool),
|
|
@@ -7646,7 +7621,7 @@ function getOpenTunaSpotPositionOrcaInstruction(input, config) {
|
|
|
7646
7621
|
return instruction;
|
|
7647
7622
|
}
|
|
7648
7623
|
function parseOpenTunaSpotPositionOrcaInstruction(instruction) {
|
|
7649
|
-
if (instruction.accounts.length <
|
|
7624
|
+
if (instruction.accounts.length < 11) {
|
|
7650
7625
|
throw new Error("Not enough accounts");
|
|
7651
7626
|
}
|
|
7652
7627
|
let accountIndex = 0;
|
|
@@ -7664,7 +7639,6 @@ function parseOpenTunaSpotPositionOrcaInstruction(instruction) {
|
|
|
7664
7639
|
tokenProgramA: getNextAccount(),
|
|
7665
7640
|
tokenProgramB: getNextAccount(),
|
|
7666
7641
|
tunaPosition: getNextAccount(),
|
|
7667
|
-
tunaPositionMint: getNextAccount(),
|
|
7668
7642
|
tunaPositionAtaA: getNextAccount(),
|
|
7669
7643
|
tunaPositionAtaB: getNextAccount(),
|
|
7670
7644
|
whirlpool: getNextAccount(),
|
|
@@ -9897,10 +9871,10 @@ async function getLendingVaultAddress(mint) {
|
|
|
9897
9871
|
seeds: ["vault", getAddressEncoder16().encode(mint)]
|
|
9898
9872
|
});
|
|
9899
9873
|
}
|
|
9900
|
-
async function getLendingPositionAddress(
|
|
9874
|
+
async function getLendingPositionAddress(authority, mint) {
|
|
9901
9875
|
return await getProgramDerivedAddress({
|
|
9902
9876
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9903
|
-
seeds: ["lending_position", getAddressEncoder16().encode(
|
|
9877
|
+
seeds: ["lending_position", getAddressEncoder16().encode(authority), getAddressEncoder16().encode(mint)]
|
|
9904
9878
|
});
|
|
9905
9879
|
}
|
|
9906
9880
|
async function getTunaLpPositionAddress(positionMint) {
|
|
@@ -9909,10 +9883,10 @@ async function getTunaLpPositionAddress(positionMint) {
|
|
|
9909
9883
|
seeds: ["tuna_position", getAddressEncoder16().encode(positionMint)]
|
|
9910
9884
|
});
|
|
9911
9885
|
}
|
|
9912
|
-
async function getTunaSpotPositionAddress(
|
|
9886
|
+
async function getTunaSpotPositionAddress(authority, pool) {
|
|
9913
9887
|
return await getProgramDerivedAddress({
|
|
9914
9888
|
programAddress: TUNA_PROGRAM_ADDRESS,
|
|
9915
|
-
seeds: ["tuna_spot_position", getAddressEncoder16().encode(
|
|
9889
|
+
seeds: ["tuna_spot_position", getAddressEncoder16().encode(authority), getAddressEncoder16().encode(pool)]
|
|
9916
9890
|
});
|
|
9917
9891
|
}
|
|
9918
9892
|
async function getPythPriceUpdateAccountAddress(shardId, priceFeedId) {
|
|
@@ -10072,15 +10046,6 @@ function tunaSpotPositionMintBFilter(address4) {
|
|
|
10072
10046
|
}
|
|
10073
10047
|
};
|
|
10074
10048
|
}
|
|
10075
|
-
function tunaSpotPositionMintFilter(address4) {
|
|
10076
|
-
return {
|
|
10077
|
-
memcmp: {
|
|
10078
|
-
offset: 139n,
|
|
10079
|
-
bytes: getBase58Decoder2().decode(getAddressEncoder18().encode(address4)),
|
|
10080
|
-
encoding: "base58"
|
|
10081
|
-
}
|
|
10082
|
-
};
|
|
10083
|
-
}
|
|
10084
10049
|
async function fetchAllTunaSpotPositionWithFilter(rpc, ...filters) {
|
|
10085
10050
|
const discriminator = getBase58Decoder2().decode(TUNA_SPOT_POSITION_DISCRIMINATOR);
|
|
10086
10051
|
const discriminatorFilter = {
|
|
@@ -10321,7 +10286,7 @@ async function createAddressLookupTableInstructions(authority, addresses, recent
|
|
|
10321
10286
|
return { instructions: [createInstruction, extendInstruction], lookupTableAddress: pda[0] };
|
|
10322
10287
|
}
|
|
10323
10288
|
|
|
10324
|
-
// src/utils/
|
|
10289
|
+
// src/utils/lpPositionMath.ts
|
|
10325
10290
|
import {
|
|
10326
10291
|
positionRatioX64,
|
|
10327
10292
|
tickIndexToSqrtPrice,
|
|
@@ -10331,8 +10296,7 @@ import {
|
|
|
10331
10296
|
tryGetTokenAFromLiquidity,
|
|
10332
10297
|
tryGetTokenBFromLiquidity
|
|
10333
10298
|
} from "@crypticdot/fusionamm-core";
|
|
10334
|
-
|
|
10335
|
-
function getLiquidityIncreaseQuote(args) {
|
|
10299
|
+
function getIncreaseLpPositionQuote(args) {
|
|
10336
10300
|
const { protocolFeeRate, protocolFeeRateOnCollateral, swapFeeRate, sqrtPrice, tickLowerIndex, tickUpperIndex } = args;
|
|
10337
10301
|
let { collateralA, collateralB, borrowA, borrowB } = args;
|
|
10338
10302
|
if (tickLowerIndex > tickUpperIndex) {
|
|
@@ -10344,7 +10308,7 @@ function getLiquidityIncreaseQuote(args) {
|
|
|
10344
10308
|
if (args.collateralA == COMPUTED_AMOUNT && args.collateralB == COMPUTED_AMOUNT) {
|
|
10345
10309
|
throw new Error("Both collateral amounts can't be set to COMPUTED_AMOUNT");
|
|
10346
10310
|
}
|
|
10347
|
-
const maxAmountSlippage =
|
|
10311
|
+
const maxAmountSlippage = BigInt(args.maxAmountSlippage);
|
|
10348
10312
|
let maxCollateralA = BigInt(collateralA);
|
|
10349
10313
|
let maxCollateralB = BigInt(collateralB);
|
|
10350
10314
|
const lowerSqrtPrice = tickIndexToSqrtPrice(tickLowerIndex);
|
|
@@ -10473,7 +10437,7 @@ async function increaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
|
|
|
10473
10437
|
const [mintA, mintB] = await fetchAllMaybeMint(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
10474
10438
|
assert(mintA.exists, "Token A not found");
|
|
10475
10439
|
assert(mintB.exists, "Token B not found");
|
|
10476
|
-
const increaseAmounts =
|
|
10440
|
+
const increaseAmounts = getIncreaseLpPositionQuote({
|
|
10477
10441
|
collateralA: BigInt(args.collateralA),
|
|
10478
10442
|
collateralB: BigInt(args.collateralB),
|
|
10479
10443
|
borrowA: BigInt(args.borrowA),
|
|
@@ -10717,7 +10681,7 @@ async function increaseTunaLpPositionFusionInstructions(rpc, authority, position
|
|
|
10717
10681
|
const [mintA, mintB] = await fetchAllMaybeMint2(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
10718
10682
|
assert2(mintA.exists, "Token A not found");
|
|
10719
10683
|
assert2(mintB.exists, "Token B not found");
|
|
10720
|
-
const increaseAmounts =
|
|
10684
|
+
const increaseAmounts = getIncreaseLpPositionQuote({
|
|
10721
10685
|
collateralA: BigInt(args.collateralA),
|
|
10722
10686
|
collateralB: BigInt(args.collateralB),
|
|
10723
10687
|
borrowA: BigInt(args.borrowA),
|
|
@@ -11888,8 +11852,9 @@ import {
|
|
|
11888
11852
|
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS8 } from "@solana-program/memo";
|
|
11889
11853
|
import { fetchAllMaybeMint as fetchAllMaybeMint11, findAssociatedTokenPda as findAssociatedTokenPda13 } from "@solana-program/token-2022";
|
|
11890
11854
|
import assert11 from "assert";
|
|
11891
|
-
async function closeActiveTunaSpotPositionFusionInstructions(rpc, authority,
|
|
11892
|
-
const
|
|
11855
|
+
async function closeActiveTunaSpotPositionFusionInstructions(rpc, authority, fusionPoolAddress, args, createInstructions, cleanupInstructions) {
|
|
11856
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, fusionPoolAddress))[0];
|
|
11857
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
11893
11858
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
11894
11859
|
const fusionPool = await fetchMaybeFusionPool6(rpc, tunaPosition.data.pool);
|
|
11895
11860
|
if (!fusionPool.exists) throw new Error("FusionPool account not found");
|
|
@@ -12017,8 +11982,9 @@ import {
|
|
|
12017
11982
|
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS9 } from "@solana-program/memo";
|
|
12018
11983
|
import { fetchAllMaybeMint as fetchAllMaybeMint12, findAssociatedTokenPda as findAssociatedTokenPda14 } from "@solana-program/token-2022";
|
|
12019
11984
|
import assert12 from "assert";
|
|
12020
|
-
async function closeActiveTunaSpotPositionOrcaInstructions(rpc, authority,
|
|
12021
|
-
const
|
|
11985
|
+
async function closeActiveTunaSpotPositionOrcaInstructions(rpc, authority, whirlpoolAddress, args, createInstructions, cleanupInstructions) {
|
|
11986
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, whirlpoolAddress))[0];
|
|
11987
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
12022
11988
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
12023
11989
|
const whirlpool = await fetchMaybeWhirlpool6(rpc, tunaPosition.data.pool);
|
|
12024
11990
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
@@ -12145,11 +12111,12 @@ import {
|
|
|
12145
12111
|
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS10 } from "@solana-program/memo";
|
|
12146
12112
|
import { fetchAllMaybeMint as fetchAllMaybeMint13, findAssociatedTokenPda as findAssociatedTokenPda15 } from "@solana-program/token-2022";
|
|
12147
12113
|
import assert13 from "assert";
|
|
12148
|
-
async function increaseTunaSpotPositionOrcaInstructions(rpc, authority,
|
|
12114
|
+
async function increaseTunaSpotPositionOrcaInstructions(rpc, authority, whirlpoolAddress, args, createInstructions, cleanupInstructions) {
|
|
12149
12115
|
const instructions = [];
|
|
12150
12116
|
if (!createInstructions) createInstructions = instructions;
|
|
12151
12117
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
12152
|
-
const
|
|
12118
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, whirlpoolAddress))[0];
|
|
12119
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
12153
12120
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
12154
12121
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
12155
12122
|
const whirlpool = await fetchWhirlpool(rpc, tunaPosition.data.pool);
|
|
@@ -12302,11 +12269,12 @@ import {
|
|
|
12302
12269
|
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS11 } from "@solana-program/memo";
|
|
12303
12270
|
import { fetchAllMaybeMint as fetchAllMaybeMint14, findAssociatedTokenPda as findAssociatedTokenPda16 } from "@solana-program/token-2022";
|
|
12304
12271
|
import assert14 from "assert";
|
|
12305
|
-
async function increaseTunaSpotPositionFusionInstructions(rpc, authority,
|
|
12272
|
+
async function increaseTunaSpotPositionFusionInstructions(rpc, authority, fusionPoolAddress, args, createInstructions, cleanupInstructions) {
|
|
12306
12273
|
const instructions = [];
|
|
12307
12274
|
if (!createInstructions) createInstructions = instructions;
|
|
12308
12275
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
12309
|
-
const
|
|
12276
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, fusionPoolAddress))[0];
|
|
12277
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
12310
12278
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
12311
12279
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
12312
12280
|
const fusionPool = await fetchFusionPool(rpc, tunaPosition.data.pool);
|
|
@@ -12456,11 +12424,12 @@ import {
|
|
|
12456
12424
|
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS12 } from "@solana-program/memo";
|
|
12457
12425
|
import { fetchAllMaybeMint as fetchAllMaybeMint15, fetchAllToken, findAssociatedTokenPda as findAssociatedTokenPda17 } from "@solana-program/token-2022";
|
|
12458
12426
|
import assert15 from "assert";
|
|
12459
|
-
async function decreaseTunaSpotPositionOrcaInstructions(rpc, authority,
|
|
12427
|
+
async function decreaseTunaSpotPositionOrcaInstructions(rpc, authority, whirlpoolAddress, args, createInstructions, cleanupInstructions) {
|
|
12460
12428
|
const instructions = [];
|
|
12461
12429
|
if (!createInstructions) createInstructions = instructions;
|
|
12462
12430
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
12463
|
-
const
|
|
12431
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, whirlpoolAddress))[0];
|
|
12432
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
12464
12433
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
12465
12434
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
12466
12435
|
const whirlpool = await fetchWhirlpool2(rpc, tunaPosition.data.pool);
|
|
@@ -12611,11 +12580,12 @@ import {
|
|
|
12611
12580
|
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS13 } from "@solana-program/memo";
|
|
12612
12581
|
import { fetchAllMaybeMint as fetchAllMaybeMint16, fetchAllToken as fetchAllToken2, findAssociatedTokenPda as findAssociatedTokenPda18 } from "@solana-program/token-2022";
|
|
12613
12582
|
import assert16 from "assert";
|
|
12614
|
-
async function decreaseTunaSpotPositionFusionInstructions(rpc, authority,
|
|
12583
|
+
async function decreaseTunaSpotPositionFusionInstructions(rpc, authority, fusionPoolAddress, args, createInstructions, cleanupInstructions) {
|
|
12615
12584
|
const instructions = [];
|
|
12616
12585
|
if (!createInstructions) createInstructions = instructions;
|
|
12617
12586
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
12618
|
-
const
|
|
12587
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, fusionPoolAddress))[0];
|
|
12588
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
12619
12589
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
12620
12590
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
12621
12591
|
const fusionPool = await fetchFusionPool2(rpc, tunaPosition.data.pool);
|
|
@@ -12758,17 +12728,18 @@ async function decreaseTunaSpotPositionFusionInstruction(authority, tunaPosition
|
|
|
12758
12728
|
// src/txbuilder/closeTunaSpotPosition.ts
|
|
12759
12729
|
import { fetchAllMaybeMint as fetchAllMaybeMint17, findAssociatedTokenPda as findAssociatedTokenPda19 } from "@solana-program/token-2022";
|
|
12760
12730
|
import assert17 from "assert";
|
|
12761
|
-
async function closeTunaSpotPositionInstructions(rpc, authority,
|
|
12762
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
12763
|
-
const tunaPosition = await
|
|
12731
|
+
async function closeTunaSpotPositionInstructions(rpc, authority, poolAddress) {
|
|
12732
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
12733
|
+
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
12734
|
+
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
12764
12735
|
const [mintA, mintB] = await fetchAllMaybeMint17(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
12765
12736
|
assert17(mintA.exists, "Token A account not found");
|
|
12766
12737
|
assert17(mintB.exists, "Token B account not found");
|
|
12767
|
-
const ix = await closeTunaSpotPositionInstruction(authority,
|
|
12738
|
+
const ix = await closeTunaSpotPositionInstruction(authority, poolAddress, mintA, mintB);
|
|
12768
12739
|
return [ix];
|
|
12769
12740
|
}
|
|
12770
|
-
async function closeTunaSpotPositionInstruction(authority,
|
|
12771
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
12741
|
+
async function closeTunaSpotPositionInstruction(authority, poolAddress, mintA, mintB) {
|
|
12742
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
12772
12743
|
const tunaPositionAtaA = (await findAssociatedTokenPda19({
|
|
12773
12744
|
owner: tunaPositionAddress,
|
|
12774
12745
|
mint: mintA.address,
|
|
@@ -13138,7 +13109,7 @@ async function liquidateTunaSpotPositionFusionInstructions(authority, tunaPositi
|
|
|
13138
13109
|
instructions.push(...createFeeRecipientAtaInstructions.init);
|
|
13139
13110
|
const ix = await liquidateTunaSpotPositionFusionInstruction(
|
|
13140
13111
|
authority,
|
|
13141
|
-
tunaPosition.
|
|
13112
|
+
tunaPosition.address,
|
|
13142
13113
|
tunaConfig,
|
|
13143
13114
|
mintA,
|
|
13144
13115
|
mintB,
|
|
@@ -13150,8 +13121,7 @@ async function liquidateTunaSpotPositionFusionInstructions(authority, tunaPositi
|
|
|
13150
13121
|
instructions.push(ix);
|
|
13151
13122
|
return instructions;
|
|
13152
13123
|
}
|
|
13153
|
-
async function liquidateTunaSpotPositionFusionInstruction(authority,
|
|
13154
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(positionMint))[0];
|
|
13124
|
+
async function liquidateTunaSpotPositionFusionInstruction(authority, tunaPositionAddress, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool, withdrawPercent) {
|
|
13155
13125
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
13156
13126
|
const tunaPositionAtaA = (await findAssociatedTokenPda23({
|
|
13157
13127
|
owner: tunaPositionAddress,
|
|
@@ -13247,7 +13217,7 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
13247
13217
|
instructions.push(...createFeeRecipientAtaInstructions.init);
|
|
13248
13218
|
const ix = await liquidateTunaSpotPositionOrcaInstruction(
|
|
13249
13219
|
authority,
|
|
13250
|
-
tunaPosition.
|
|
13220
|
+
tunaPosition.address,
|
|
13251
13221
|
tunaConfig,
|
|
13252
13222
|
mintA,
|
|
13253
13223
|
mintB,
|
|
@@ -13259,8 +13229,7 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
13259
13229
|
instructions.push(ix);
|
|
13260
13230
|
return instructions;
|
|
13261
13231
|
}
|
|
13262
|
-
async function liquidateTunaSpotPositionOrcaInstruction(authority,
|
|
13263
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(positionMint))[0];
|
|
13232
|
+
async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPositionAddress, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, withdrawPercent) {
|
|
13264
13233
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
13265
13234
|
const orcaOracleAddress = (await getOracleAddress7(whirlpool.address))[0];
|
|
13266
13235
|
const tunaPositionAtaA = (await findAssociatedTokenPda24({
|
|
@@ -13508,7 +13477,7 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
|
|
|
13508
13477
|
(await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
|
|
13509
13478
|
(await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
|
|
13510
13479
|
]);
|
|
13511
|
-
const increaseAmounts =
|
|
13480
|
+
const increaseAmounts = getIncreaseLpPositionQuote({
|
|
13512
13481
|
collateralA: BigInt(args.collateralA),
|
|
13513
13482
|
collateralB: BigInt(args.collateralB),
|
|
13514
13483
|
borrowA: BigInt(args.borrowA),
|
|
@@ -13764,7 +13733,7 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
|
|
|
13764
13733
|
(await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
|
|
13765
13734
|
(await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
|
|
13766
13735
|
]);
|
|
13767
|
-
const increaseAmounts =
|
|
13736
|
+
const increaseAmounts = getIncreaseLpPositionQuote({
|
|
13768
13737
|
collateralA: BigInt(args.collateralA),
|
|
13769
13738
|
collateralB: BigInt(args.collateralB),
|
|
13770
13739
|
borrowA: BigInt(args.borrowA),
|
|
@@ -13973,8 +13942,7 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
13973
13942
|
// src/txbuilder/openAndIncreaseTunaSpotPositionFusion.ts
|
|
13974
13943
|
import { fetchMaybeFusionPool as fetchMaybeFusionPool9, FUSIONAMM_PROGRAM_ADDRESS as FUSIONAMM_PROGRAM_ADDRESS13 } from "@crypticdot/fusionamm-client";
|
|
13975
13944
|
import {
|
|
13976
|
-
AccountRole as AccountRole20
|
|
13977
|
-
generateKeyPairSigner as generateKeyPairSigner3
|
|
13945
|
+
AccountRole as AccountRole20
|
|
13978
13946
|
} from "@solana/kit";
|
|
13979
13947
|
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS20 } from "@solana-program/memo";
|
|
13980
13948
|
import {
|
|
@@ -13987,7 +13955,6 @@ async function openAndIncreaseTunaSpotPositionFusionInstructions(rpc, authority,
|
|
|
13987
13955
|
const instructions = [];
|
|
13988
13956
|
if (!createInstructions) createInstructions = instructions;
|
|
13989
13957
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
13990
|
-
const positionMint = await generateKeyPairSigner3();
|
|
13991
13958
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
13992
13959
|
const fusionPool = await fetchMaybeFusionPool9(rpc, fusionPoolAddress);
|
|
13993
13960
|
if (!fusionPool.exists) throw new Error("FusionPool account not found");
|
|
@@ -14026,7 +13993,6 @@ async function openAndIncreaseTunaSpotPositionFusionInstructions(rpc, authority,
|
|
|
14026
13993
|
createInstructions.push(...createFeeRecipientAtaBInstructions.init);
|
|
14027
13994
|
const ix = await openAndIncreaseTunaSpotPositionFusionInstruction(
|
|
14028
13995
|
authority,
|
|
14029
|
-
positionMint,
|
|
14030
13996
|
tunaConfig,
|
|
14031
13997
|
mintA,
|
|
14032
13998
|
mintB,
|
|
@@ -14037,13 +14003,10 @@ async function openAndIncreaseTunaSpotPositionFusionInstructions(rpc, authority,
|
|
|
14037
14003
|
);
|
|
14038
14004
|
instructions.push(ix);
|
|
14039
14005
|
cleanupInstructions.push(...createUserAtaInstructions.cleanup);
|
|
14040
|
-
return
|
|
14041
|
-
instructions,
|
|
14042
|
-
positionMint: positionMint.address
|
|
14043
|
-
};
|
|
14006
|
+
return instructions;
|
|
14044
14007
|
}
|
|
14045
|
-
async function openAndIncreaseTunaSpotPositionFusionInstruction(authority,
|
|
14046
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
14008
|
+
async function openAndIncreaseTunaSpotPositionFusionInstruction(authority, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool, args) {
|
|
14009
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, fusionPool.address))[0];
|
|
14047
14010
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
14048
14011
|
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda29({
|
|
14049
14012
|
owner: authority.address,
|
|
@@ -14117,7 +14080,6 @@ async function openAndIncreaseTunaSpotPositionFusionInstruction(authority, posit
|
|
|
14117
14080
|
vaultB: vaultB.address,
|
|
14118
14081
|
vaultBAta,
|
|
14119
14082
|
tunaPosition: tunaPositionAddress,
|
|
14120
|
-
tunaPositionMint: positionMint,
|
|
14121
14083
|
tunaPositionAtaA,
|
|
14122
14084
|
tunaPositionAtaB,
|
|
14123
14085
|
tunaPositionOwnerAtaA: args.collateralToken == 0 /* A */ ? tunaPositionOwnerAtaA : void 0,
|
|
@@ -14142,8 +14104,7 @@ import {
|
|
|
14142
14104
|
WHIRLPOOL_PROGRAM_ADDRESS as WHIRLPOOL_PROGRAM_ADDRESS13
|
|
14143
14105
|
} from "@orca-so/whirlpools-client";
|
|
14144
14106
|
import {
|
|
14145
|
-
AccountRole as AccountRole21
|
|
14146
|
-
generateKeyPairSigner as generateKeyPairSigner4
|
|
14107
|
+
AccountRole as AccountRole21
|
|
14147
14108
|
} from "@solana/kit";
|
|
14148
14109
|
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS21 } from "@solana-program/memo";
|
|
14149
14110
|
import {
|
|
@@ -14156,7 +14117,6 @@ async function openAndIncreaseTunaSpotPositionOrcaInstructions(rpc, authority, w
|
|
|
14156
14117
|
const instructions = [];
|
|
14157
14118
|
if (!createInstructions) createInstructions = instructions;
|
|
14158
14119
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
14159
|
-
const positionMint = await generateKeyPairSigner4();
|
|
14160
14120
|
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
14161
14121
|
const whirlpool = await fetchMaybeWhirlpool9(rpc, whirlpoolAddress);
|
|
14162
14122
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
@@ -14195,7 +14155,6 @@ async function openAndIncreaseTunaSpotPositionOrcaInstructions(rpc, authority, w
|
|
|
14195
14155
|
createInstructions.push(...createFeeRecipientAtaBInstructions.init);
|
|
14196
14156
|
const ix = await openAndIncreaseTunaSpotPositionOrcaInstruction(
|
|
14197
14157
|
authority,
|
|
14198
|
-
positionMint,
|
|
14199
14158
|
tunaConfig,
|
|
14200
14159
|
mintA,
|
|
14201
14160
|
mintB,
|
|
@@ -14206,13 +14165,10 @@ async function openAndIncreaseTunaSpotPositionOrcaInstructions(rpc, authority, w
|
|
|
14206
14165
|
);
|
|
14207
14166
|
instructions.push(ix);
|
|
14208
14167
|
cleanupInstructions.push(...createUserAtaInstructions.cleanup);
|
|
14209
|
-
return
|
|
14210
|
-
instructions,
|
|
14211
|
-
positionMint: positionMint.address
|
|
14212
|
-
};
|
|
14168
|
+
return instructions;
|
|
14213
14169
|
}
|
|
14214
|
-
async function openAndIncreaseTunaSpotPositionOrcaInstruction(authority,
|
|
14215
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
14170
|
+
async function openAndIncreaseTunaSpotPositionOrcaInstruction(authority, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, args) {
|
|
14171
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, whirlpool.address))[0];
|
|
14216
14172
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
14217
14173
|
const orcaOracleAddress = (await getOracleAddress9(whirlpool.address))[0];
|
|
14218
14174
|
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda30({
|
|
@@ -14289,7 +14245,6 @@ async function openAndIncreaseTunaSpotPositionOrcaInstruction(authority, positio
|
|
|
14289
14245
|
vaultB: vaultB.address,
|
|
14290
14246
|
vaultBAta,
|
|
14291
14247
|
tunaPosition: tunaPositionAddress,
|
|
14292
|
-
tunaPositionMint: positionMint,
|
|
14293
14248
|
tunaPositionAtaA,
|
|
14294
14249
|
tunaPositionAtaB,
|
|
14295
14250
|
tunaPositionOwnerAtaA: args.collateralToken == 0 /* A */ ? tunaPositionOwnerAtaA : void 0,
|
|
@@ -14315,24 +14270,17 @@ import {
|
|
|
14315
14270
|
findAssociatedTokenPda as findAssociatedTokenPda31
|
|
14316
14271
|
} from "@solana-program/token-2022";
|
|
14317
14272
|
import assert24 from "assert";
|
|
14318
|
-
async function openTunaSpotPositionFusionInstructions(rpc, authority,
|
|
14273
|
+
async function openTunaSpotPositionFusionInstructions(rpc, authority, fusionPoolAddress, args) {
|
|
14319
14274
|
const fusionPool = await fetchMaybeFusionPool10(rpc, fusionPoolAddress);
|
|
14320
14275
|
if (!fusionPool.exists) throw new Error("FusionPool account not found");
|
|
14321
14276
|
const [mintA, mintB] = await fetchAllMaybeMint24(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
14322
14277
|
assert24(mintA.exists, "Token A account not found");
|
|
14323
14278
|
assert24(mintB.exists, "Token B account not found");
|
|
14324
|
-
const ix = await openTunaSpotPositionFusionInstruction(
|
|
14325
|
-
authority,
|
|
14326
|
-
positionMint,
|
|
14327
|
-
mintA,
|
|
14328
|
-
mintB,
|
|
14329
|
-
fusionPoolAddress,
|
|
14330
|
-
args
|
|
14331
|
-
);
|
|
14279
|
+
const ix = await openTunaSpotPositionFusionInstruction(authority, mintA, mintB, fusionPoolAddress, args);
|
|
14332
14280
|
return [ix];
|
|
14333
14281
|
}
|
|
14334
|
-
async function openTunaSpotPositionFusionInstruction(authority,
|
|
14335
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
14282
|
+
async function openTunaSpotPositionFusionInstruction(authority, mintA, mintB, fusionPoolAddress, args) {
|
|
14283
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, fusionPoolAddress))[0];
|
|
14336
14284
|
const tunaPositionAtaA = (await findAssociatedTokenPda31({
|
|
14337
14285
|
owner: tunaPositionAddress,
|
|
14338
14286
|
mint: mintA.address,
|
|
@@ -14350,7 +14298,6 @@ async function openTunaSpotPositionFusionInstruction(authority, positionMint, mi
|
|
|
14350
14298
|
tokenProgramA: mintA.programAddress,
|
|
14351
14299
|
tokenProgramB: mintB.programAddress,
|
|
14352
14300
|
tunaPosition: tunaPositionAddress,
|
|
14353
|
-
tunaPositionMint: positionMint,
|
|
14354
14301
|
tunaPositionAtaA,
|
|
14355
14302
|
tunaPositionAtaB,
|
|
14356
14303
|
fusionPool: fusionPoolAddress,
|
|
@@ -14367,17 +14314,17 @@ import {
|
|
|
14367
14314
|
findAssociatedTokenPda as findAssociatedTokenPda32
|
|
14368
14315
|
} from "@solana-program/token-2022";
|
|
14369
14316
|
import assert25 from "assert";
|
|
14370
|
-
async function openTunaSpotPositionOrcaInstructions(rpc, authority,
|
|
14317
|
+
async function openTunaSpotPositionOrcaInstructions(rpc, authority, whirlpoolAddress, args) {
|
|
14371
14318
|
const whirlpool = await fetchMaybeWhirlpool10(rpc, whirlpoolAddress);
|
|
14372
14319
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
14373
14320
|
const [mintA, mintB] = await fetchAllMaybeMint25(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
14374
14321
|
assert25(mintA.exists, "Token A account not found");
|
|
14375
14322
|
assert25(mintB.exists, "Token B account not found");
|
|
14376
|
-
const ix = await openTunaSpotPositionOrcaInstruction(authority,
|
|
14323
|
+
const ix = await openTunaSpotPositionOrcaInstruction(authority, mintA, mintB, whirlpoolAddress, args);
|
|
14377
14324
|
return [ix];
|
|
14378
14325
|
}
|
|
14379
|
-
async function openTunaSpotPositionOrcaInstruction(authority,
|
|
14380
|
-
const tunaPositionAddress = (await getTunaSpotPositionAddress(
|
|
14326
|
+
async function openTunaSpotPositionOrcaInstruction(authority, mintA, mintB, whirlpoolAddress, args) {
|
|
14327
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, whirlpoolAddress))[0];
|
|
14381
14328
|
const tunaPositionAtaA = (await findAssociatedTokenPda32({
|
|
14382
14329
|
owner: tunaPositionAddress,
|
|
14383
14330
|
mint: mintA.address,
|
|
@@ -14395,7 +14342,6 @@ async function openTunaSpotPositionOrcaInstruction(authority, positionMint, mint
|
|
|
14395
14342
|
tokenProgramA: mintA.programAddress,
|
|
14396
14343
|
tokenProgramB: mintB.programAddress,
|
|
14397
14344
|
tunaPosition: tunaPositionAddress,
|
|
14398
|
-
tunaPositionMint: positionMint,
|
|
14399
14345
|
tunaPositionAtaA,
|
|
14400
14346
|
tunaPositionAtaB,
|
|
14401
14347
|
whirlpool: whirlpoolAddress,
|
|
@@ -14837,13 +14783,8 @@ async function setTunaLpPositionLimitOrdersInstruction(authority, args, position
|
|
|
14837
14783
|
}
|
|
14838
14784
|
|
|
14839
14785
|
// src/txbuilder/setTunaSpotPositionLimitOrders.ts
|
|
14840
|
-
async function setTunaSpotPositionLimitOrdersInstruction(authority,
|
|
14841
|
-
|
|
14842
|
-
if (positionMint === void 0) {
|
|
14843
|
-
throw new Error("At least one of 'positionMint' or 'tunaPositionAddress' must be provided.");
|
|
14844
|
-
}
|
|
14845
|
-
tunaPositionAddress = (await getTunaSpotPositionAddress(positionMint))[0];
|
|
14846
|
-
}
|
|
14786
|
+
async function setTunaSpotPositionLimitOrdersInstruction(authority, poolAddress, args) {
|
|
14787
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
14847
14788
|
return getSetTunaSpotPositionLimitOrdersInstruction({
|
|
14848
14789
|
...args,
|
|
14849
14790
|
authority,
|
|
@@ -14854,13 +14795,8 @@ async function setTunaSpotPositionLimitOrdersInstruction(authority, args, positi
|
|
|
14854
14795
|
// src/txbuilder/resetTunaSpotPosition.ts
|
|
14855
14796
|
import { fetchAllMaybeMint as fetchAllMaybeMint28, findAssociatedTokenPda as findAssociatedTokenPda36 } from "@solana-program/token-2022";
|
|
14856
14797
|
import assert28 from "assert";
|
|
14857
|
-
async function resetTunaSpotPositionInstruction(rpc, authority,
|
|
14858
|
-
|
|
14859
|
-
if (positionMint === void 0) {
|
|
14860
|
-
throw new Error("At least one of 'positionMint' or 'tunaPositionAddress' must be provided.");
|
|
14861
|
-
}
|
|
14862
|
-
tunaPositionAddress = (await getTunaSpotPositionAddress(positionMint))[0];
|
|
14863
|
-
}
|
|
14798
|
+
async function resetTunaSpotPositionInstruction(rpc, authority, poolAddress, args) {
|
|
14799
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
14864
14800
|
const tunaPosition = await fetchTunaSpotPosition(rpc, tunaPositionAddress);
|
|
14865
14801
|
const [mintA, mintB] = await fetchAllMaybeMint28(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
14866
14802
|
assert28(mintA.exists, "Token A not found");
|
|
@@ -15561,7 +15497,6 @@ export {
|
|
|
15561
15497
|
DECREASE_TUNA_SPOT_POSITION_FUSION_DISCRIMINATOR,
|
|
15562
15498
|
DECREASE_TUNA_SPOT_POSITION_ORCA_DISCRIMINATOR,
|
|
15563
15499
|
DEFAULT_ADDRESS,
|
|
15564
|
-
DEFAULT_MAX_AMOUNT_SLIPPAGE,
|
|
15565
15500
|
DEFAULT_MAX_SWAP_SLIPPAGE,
|
|
15566
15501
|
DEFAULT_PUSH_ORACLE_PROGRAM_ID,
|
|
15567
15502
|
DEPOSIT_DISCRIMINATOR,
|
|
@@ -15861,6 +15796,7 @@ export {
|
|
|
15861
15796
|
getDepositInstructionDataCodec,
|
|
15862
15797
|
getDepositInstructionDataDecoder,
|
|
15863
15798
|
getDepositInstructionDataEncoder,
|
|
15799
|
+
getIncreaseLpPositionQuote,
|
|
15864
15800
|
getIncreaseTunaLpPositionFusionDiscriminatorBytes,
|
|
15865
15801
|
getIncreaseTunaLpPositionFusionInstruction,
|
|
15866
15802
|
getIncreaseTunaLpPositionFusionInstructionDataCodec,
|
|
@@ -15908,7 +15844,6 @@ export {
|
|
|
15908
15844
|
getLiquidateTunaSpotPositionOrcaInstructionDataCodec,
|
|
15909
15845
|
getLiquidateTunaSpotPositionOrcaInstructionDataDecoder,
|
|
15910
15846
|
getLiquidateTunaSpotPositionOrcaInstructionDataEncoder,
|
|
15911
|
-
getLiquidityIncreaseQuote,
|
|
15912
15847
|
getMarketAddress,
|
|
15913
15848
|
getMarketCodec,
|
|
15914
15849
|
getMarketDecoder,
|
|
@@ -16211,7 +16146,6 @@ export {
|
|
|
16211
16146
|
tunaSpotPositionAuthorityFilter,
|
|
16212
16147
|
tunaSpotPositionMintAFilter,
|
|
16213
16148
|
tunaSpotPositionMintBFilter,
|
|
16214
|
-
tunaSpotPositionMintFilter,
|
|
16215
16149
|
tunaSpotPositionPoolFilter,
|
|
16216
16150
|
updateMarketInstruction,
|
|
16217
16151
|
updateVaultInstruction,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crypticdot/defituna-client",
|
|
3
3
|
"description": "Typescript client to interact with DefiTuna's on-chain program.",
|
|
4
|
-
"version": "3.0
|
|
4
|
+
"version": "3.1.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"rimraf": "^6.0.1",
|
|
52
52
|
"vitest": "^3.1.1",
|
|
53
53
|
"solana-bankrun": "^0.4.0",
|
|
54
|
-
"@crypticdot/defituna-program": "3.0
|
|
54
|
+
"@crypticdot/defituna-program": "3.1.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "node ./codama.mjs && tsup src/index.ts --format cjs,esm --dts",
|