@crypticdot/defituna-client 3.3.1 → 3.3.2
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 +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +888 -465
- package/dist/index.mjs +1149 -359
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -10830,23 +10830,29 @@ async function modifyTunaSpotPositionOrcaInstructions(rpc, authority, poolAddres
|
|
|
10830
10830
|
(await getLendingVaultAddress(pool.data.tokenMintA))[0],
|
|
10831
10831
|
(await getLendingVaultAddress(pool.data.tokenMintB))[0]
|
|
10832
10832
|
]);
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10833
|
+
let hasDirectlyTransferredTokensA = false;
|
|
10834
|
+
let hasDirectlyTransferredTokensB = false;
|
|
10835
|
+
if (tunaPosition.exists) {
|
|
10836
|
+
const tunaPositionAtaAAddress = (await findAssociatedTokenPda13({
|
|
10837
|
+
owner: tunaPositionAddress,
|
|
10838
|
+
mint: mintA.address,
|
|
10839
|
+
tokenProgram: mintA.programAddress
|
|
10840
|
+
}))[0];
|
|
10841
|
+
const tunaPositionAtaBAddress = (await findAssociatedTokenPda13({
|
|
10842
|
+
owner: tunaPositionAddress,
|
|
10843
|
+
mint: mintB.address,
|
|
10844
|
+
tokenProgram: mintB.programAddress
|
|
10845
|
+
}))[0];
|
|
10846
|
+
const [tunaPositionAtaA, tunaPositionAtaB] = await fetchAllToken(rpc, [
|
|
10847
|
+
tunaPositionAtaAAddress,
|
|
10848
|
+
tunaPositionAtaBAddress
|
|
10849
|
+
]);
|
|
10850
|
+
hasDirectlyTransferredTokensA = tunaPositionAtaA.data.amount > (tunaPosition.data.positionToken == 0 /* A */ ? tunaPosition.data.amount : 0n);
|
|
10851
|
+
hasDirectlyTransferredTokensB = tunaPositionAtaB.data.amount > (tunaPosition.data.positionToken == 1 /* B */ ? tunaPosition.data.amount : 0n);
|
|
10852
|
+
}
|
|
10853
|
+
const createUserAtaAInstructions = collateralToken == 0 /* A */ || hasDirectlyTransferredTokensA ? await getCreateAtaInstructions(rpc, authority, mintA.address, authority.address, mintA.programAddress) : void 0;
|
|
10848
10854
|
if (createUserAtaAInstructions) createInstructions.push(...createUserAtaAInstructions.init);
|
|
10849
|
-
const createUserAtaBInstructions = collateralToken == 1 /* B */ ||
|
|
10855
|
+
const createUserAtaBInstructions = collateralToken == 1 /* B */ || hasDirectlyTransferredTokensB ? await getCreateAtaInstructions(rpc, authority, mintB.address, authority.address, mintB.programAddress) : void 0;
|
|
10850
10856
|
if (createUserAtaBInstructions) createInstructions.push(...createUserAtaBInstructions.init);
|
|
10851
10857
|
const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
|
|
10852
10858
|
rpc,
|
|
@@ -11003,23 +11009,29 @@ async function modifyTunaSpotPositionFusionInstructions(rpc, authority, poolAddr
|
|
|
11003
11009
|
(await getLendingVaultAddress(pool.data.tokenMintA))[0],
|
|
11004
11010
|
(await getLendingVaultAddress(pool.data.tokenMintB))[0]
|
|
11005
11011
|
]);
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11012
|
+
let hasDirectlyTransferredTokensA = false;
|
|
11013
|
+
let hasDirectlyTransferredTokensB = false;
|
|
11014
|
+
if (tunaPosition.exists) {
|
|
11015
|
+
const tunaPositionAtaAAddress = (await findAssociatedTokenPda14({
|
|
11016
|
+
owner: tunaPositionAddress,
|
|
11017
|
+
mint: mintA.address,
|
|
11018
|
+
tokenProgram: mintA.programAddress
|
|
11019
|
+
}))[0];
|
|
11020
|
+
const tunaPositionAtaBAddress = (await findAssociatedTokenPda14({
|
|
11021
|
+
owner: tunaPositionAddress,
|
|
11022
|
+
mint: mintB.address,
|
|
11023
|
+
tokenProgram: mintB.programAddress
|
|
11024
|
+
}))[0];
|
|
11025
|
+
const [tunaPositionAtaA, tunaPositionAtaB] = await fetchAllToken2(rpc, [
|
|
11026
|
+
tunaPositionAtaAAddress,
|
|
11027
|
+
tunaPositionAtaBAddress
|
|
11028
|
+
]);
|
|
11029
|
+
hasDirectlyTransferredTokensA = tunaPositionAtaA.data.amount > (tunaPosition.data.positionToken == 0 /* A */ ? tunaPosition.data.amount : 0n);
|
|
11030
|
+
hasDirectlyTransferredTokensB = tunaPositionAtaB.data.amount > (tunaPosition.data.positionToken == 1 /* B */ ? tunaPosition.data.amount : 0n);
|
|
11031
|
+
}
|
|
11032
|
+
const createUserAtaAInstructions = collateralToken == 0 /* A */ || hasDirectlyTransferredTokensA ? await getCreateAtaInstructions(rpc, authority, mintA.address, authority.address, mintA.programAddress) : void 0;
|
|
11021
11033
|
if (createUserAtaAInstructions) createInstructions.push(...createUserAtaAInstructions.init);
|
|
11022
|
-
const createUserAtaBInstructions = collateralToken == 1 /* B */ ||
|
|
11034
|
+
const createUserAtaBInstructions = collateralToken == 1 /* B */ || hasDirectlyTransferredTokensB ? await getCreateAtaInstructions(rpc, authority, mintB.address, authority.address, mintB.programAddress) : void 0;
|
|
11023
11035
|
if (createUserAtaBInstructions) createInstructions.push(...createUserAtaBInstructions.init);
|
|
11024
11036
|
const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
|
|
11025
11037
|
rpc,
|
|
@@ -11145,27 +11157,803 @@ async function modifyTunaSpotPositionFusionInstruction(authority, tunaConfig, mi
|
|
|
11145
11157
|
return ix;
|
|
11146
11158
|
}
|
|
11147
11159
|
|
|
11148
|
-
// src/txbuilder/
|
|
11160
|
+
// src/txbuilder/modifyTunaSpotPositionJupiter.ts
|
|
11161
|
+
import { fetchFusionPool as fetchFusionPool2 } from "@crypticdot/fusionamm-client";
|
|
11162
|
+
|
|
11163
|
+
// ../../node_modules/.pnpm/@crypticdot+jupiter-solana-client@1.0.0_fastestsmallesttextencoderdecoder@1.0.22_typesc_c15ee540b6a974c893a6f86bc9defff2/node_modules/@crypticdot/jupiter-solana-client/dist/index.mjs
|
|
11164
|
+
import {
|
|
11165
|
+
assertAccountExists as assertAccountExists7,
|
|
11166
|
+
assertAccountsExist as assertAccountsExist8,
|
|
11167
|
+
combineCodec as combineCodec62,
|
|
11168
|
+
decodeAccount as decodeAccount7,
|
|
11169
|
+
fetchEncodedAccount as fetchEncodedAccount7,
|
|
11170
|
+
fetchEncodedAccounts as fetchEncodedAccounts7,
|
|
11171
|
+
fixDecoderSize as fixDecoderSize56,
|
|
11172
|
+
fixEncoderSize as fixEncoderSize57,
|
|
11173
|
+
getAddressDecoder as getAddressDecoder16,
|
|
11174
|
+
getAddressEncoder as getAddressEncoder20,
|
|
11175
|
+
getBytesDecoder as getBytesDecoder56,
|
|
11176
|
+
getBytesEncoder as getBytesEncoder57,
|
|
11177
|
+
getStructDecoder as getStructDecoder58,
|
|
11178
|
+
getStructEncoder as getStructEncoder58,
|
|
11179
|
+
getU64Decoder as getU64Decoder23,
|
|
11180
|
+
getU64Encoder as getU64Encoder23,
|
|
11181
|
+
transformEncoder as transformEncoder56
|
|
11182
|
+
} from "@solana/kit";
|
|
11183
|
+
import {
|
|
11184
|
+
isProgramError as isProgramError2
|
|
11185
|
+
} from "@solana/kit";
|
|
11186
|
+
import {
|
|
11187
|
+
containsBytes as containsBytes2,
|
|
11188
|
+
fixEncoderSize as fixEncoderSize210,
|
|
11189
|
+
getBytesEncoder as getBytesEncoder210
|
|
11190
|
+
} from "@solana/kit";
|
|
11191
|
+
import {
|
|
11192
|
+
combineCodec as combineCodec210,
|
|
11193
|
+
fixDecoderSize as fixDecoderSize210,
|
|
11194
|
+
fixEncoderSize as fixEncoderSize310,
|
|
11195
|
+
getBytesDecoder as getBytesDecoder210,
|
|
11196
|
+
getBytesEncoder as getBytesEncoder310,
|
|
11197
|
+
getStructDecoder as getStructDecoder210,
|
|
11198
|
+
getStructEncoder as getStructEncoder210,
|
|
11199
|
+
getU8Decoder as getU8Decoder6,
|
|
11200
|
+
getU8Encoder as getU8Encoder6,
|
|
11201
|
+
transformEncoder as transformEncoder210
|
|
11202
|
+
} from "@solana/kit";
|
|
11203
|
+
import {
|
|
11204
|
+
AccountRole as AccountRole10,
|
|
11205
|
+
isProgramDerivedAddress as isProgramDerivedAddress2,
|
|
11206
|
+
isTransactionSigner as kitIsTransactionSigner2,
|
|
11207
|
+
upgradeRoleToSigner as upgradeRoleToSigner2
|
|
11208
|
+
} from "@solana/kit";
|
|
11209
|
+
import {
|
|
11210
|
+
combineCodec as combineCodec310,
|
|
11211
|
+
fixDecoderSize as fixDecoderSize310,
|
|
11212
|
+
fixEncoderSize as fixEncoderSize410,
|
|
11213
|
+
getAddressEncoder as getAddressEncoder22,
|
|
11214
|
+
getBytesDecoder as getBytesDecoder310,
|
|
11215
|
+
getBytesEncoder as getBytesEncoder410,
|
|
11216
|
+
getProgramDerivedAddress as getProgramDerivedAddress2,
|
|
11217
|
+
getStructDecoder as getStructDecoder310,
|
|
11218
|
+
getStructEncoder as getStructEncoder310,
|
|
11219
|
+
getU8Decoder as getU8Decoder22,
|
|
11220
|
+
getU8Encoder as getU8Encoder22,
|
|
11221
|
+
transformEncoder as transformEncoder310
|
|
11222
|
+
} from "@solana/kit";
|
|
11223
|
+
import {
|
|
11224
|
+
combineCodec as combineCodec410,
|
|
11225
|
+
fixDecoderSize as fixDecoderSize410,
|
|
11226
|
+
fixEncoderSize as fixEncoderSize58,
|
|
11227
|
+
getBooleanDecoder as getBooleanDecoder9,
|
|
11228
|
+
getBooleanEncoder as getBooleanEncoder9,
|
|
11229
|
+
getBytesDecoder as getBytesDecoder410,
|
|
11230
|
+
getBytesEncoder as getBytesEncoder58,
|
|
11231
|
+
getStructDecoder as getStructDecoder410,
|
|
11232
|
+
getStructEncoder as getStructEncoder410,
|
|
11233
|
+
getU8Decoder as getU8Decoder32,
|
|
11234
|
+
getU8Encoder as getU8Encoder32,
|
|
11235
|
+
transformEncoder as transformEncoder410
|
|
11236
|
+
} from "@solana/kit";
|
|
11237
|
+
import {
|
|
11238
|
+
combineCodec as combineCodec510,
|
|
11239
|
+
fixDecoderSize as fixDecoderSize57,
|
|
11240
|
+
fixEncoderSize as fixEncoderSize62,
|
|
11241
|
+
getAddressEncoder as getAddressEncoder32,
|
|
11242
|
+
getBytesDecoder as getBytesDecoder57,
|
|
11243
|
+
getBytesEncoder as getBytesEncoder62,
|
|
11244
|
+
getProgramDerivedAddress as getProgramDerivedAddress22,
|
|
11245
|
+
getStructDecoder as getStructDecoder59,
|
|
11246
|
+
getStructEncoder as getStructEncoder59,
|
|
11247
|
+
transformEncoder as transformEncoder57
|
|
11248
|
+
} from "@solana/kit";
|
|
11249
|
+
import {
|
|
11250
|
+
combineCodec as combineCodec63,
|
|
11251
|
+
fixDecoderSize as fixDecoderSize62,
|
|
11252
|
+
fixEncoderSize as fixEncoderSize72,
|
|
11253
|
+
getAddressEncoder as getAddressEncoder42,
|
|
11254
|
+
getBytesDecoder as getBytesDecoder62,
|
|
11255
|
+
getBytesEncoder as getBytesEncoder72,
|
|
11256
|
+
getProgramDerivedAddress as getProgramDerivedAddress3,
|
|
11257
|
+
getStructDecoder as getStructDecoder62,
|
|
11258
|
+
getStructEncoder as getStructEncoder62,
|
|
11259
|
+
getU8Decoder as getU8Decoder42,
|
|
11260
|
+
getU8Encoder as getU8Encoder42,
|
|
11261
|
+
transformEncoder as transformEncoder62
|
|
11262
|
+
} from "@solana/kit";
|
|
11263
|
+
import {
|
|
11264
|
+
combineCodec as combineCodec72,
|
|
11265
|
+
fixDecoderSize as fixDecoderSize72,
|
|
11266
|
+
fixEncoderSize as fixEncoderSize82,
|
|
11267
|
+
getBytesDecoder as getBytesDecoder72,
|
|
11268
|
+
getBytesEncoder as getBytesEncoder82,
|
|
11269
|
+
getStructDecoder as getStructDecoder72,
|
|
11270
|
+
getStructEncoder as getStructEncoder72,
|
|
11271
|
+
getU8Decoder as getU8Decoder52,
|
|
11272
|
+
getU8Encoder as getU8Encoder52,
|
|
11273
|
+
transformEncoder as transformEncoder72
|
|
11274
|
+
} from "@solana/kit";
|
|
11275
|
+
import {
|
|
11276
|
+
combineCodec as combineCodec82,
|
|
11277
|
+
fixDecoderSize as fixDecoderSize82,
|
|
11278
|
+
fixEncoderSize as fixEncoderSize92,
|
|
11279
|
+
getBytesDecoder as getBytesDecoder82,
|
|
11280
|
+
getBytesEncoder as getBytesEncoder92,
|
|
11281
|
+
getStructDecoder as getStructDecoder82,
|
|
11282
|
+
getStructEncoder as getStructEncoder82,
|
|
11283
|
+
transformEncoder as transformEncoder82
|
|
11284
|
+
} from "@solana/kit";
|
|
11285
|
+
import {
|
|
11286
|
+
combineCodec as combineCodec212,
|
|
11287
|
+
fixDecoderSize as fixDecoderSize92,
|
|
11288
|
+
fixEncoderSize as fixEncoderSize102,
|
|
11289
|
+
getArrayDecoder as getArrayDecoder3,
|
|
11290
|
+
getArrayEncoder as getArrayEncoder3,
|
|
11291
|
+
getBytesDecoder as getBytesDecoder92,
|
|
11292
|
+
getBytesEncoder as getBytesEncoder102,
|
|
11293
|
+
getStructDecoder as getStructDecoder182,
|
|
11294
|
+
getStructEncoder as getStructEncoder182,
|
|
11295
|
+
getU16Decoder as getU16Decoder22,
|
|
11296
|
+
getU16Encoder as getU16Encoder22,
|
|
11297
|
+
getU64Decoder as getU64Decoder52,
|
|
11298
|
+
getU64Encoder as getU64Encoder52,
|
|
11299
|
+
getU8Decoder as getU8Decoder11,
|
|
11300
|
+
getU8Encoder as getU8Encoder11,
|
|
11301
|
+
transformEncoder as transformEncoder92
|
|
11302
|
+
} from "@solana/kit";
|
|
11303
|
+
import {
|
|
11304
|
+
combineCodec as combineCodec92,
|
|
11305
|
+
getEnumDecoder as getEnumDecoder5,
|
|
11306
|
+
getEnumEncoder as getEnumEncoder5
|
|
11307
|
+
} from "@solana/kit";
|
|
11308
|
+
import {
|
|
11309
|
+
combineCodec as combineCodec102,
|
|
11310
|
+
getEnumDecoder as getEnumDecoder22,
|
|
11311
|
+
getEnumEncoder as getEnumEncoder22
|
|
11312
|
+
} from "@solana/kit";
|
|
11313
|
+
import {
|
|
11314
|
+
combineCodec as combineCodec112,
|
|
11315
|
+
getArrayDecoder as getArrayDecoder2,
|
|
11316
|
+
getArrayEncoder as getArrayEncoder2,
|
|
11317
|
+
getStructDecoder as getStructDecoder92,
|
|
11318
|
+
getStructEncoder as getStructEncoder92
|
|
11319
|
+
} from "@solana/kit";
|
|
11320
|
+
import {
|
|
11321
|
+
combineCodec as combineCodec122,
|
|
11322
|
+
getStructDecoder as getStructDecoder102,
|
|
11323
|
+
getStructEncoder as getStructEncoder102,
|
|
11324
|
+
getU8Decoder as getU8Decoder62,
|
|
11325
|
+
getU8Encoder as getU8Encoder62
|
|
11326
|
+
} from "@solana/kit";
|
|
11327
|
+
import {
|
|
11328
|
+
combineCodec as combineCodec132,
|
|
11329
|
+
getAddressDecoder as getAddressDecoder22,
|
|
11330
|
+
getAddressEncoder as getAddressEncoder52,
|
|
11331
|
+
getStructDecoder as getStructDecoder112,
|
|
11332
|
+
getStructEncoder as getStructEncoder112,
|
|
11333
|
+
getU64Decoder as getU64Decoder24,
|
|
11334
|
+
getU64Encoder as getU64Encoder24
|
|
11335
|
+
} from "@solana/kit";
|
|
11336
|
+
import {
|
|
11337
|
+
combineCodec as combineCodec142,
|
|
11338
|
+
getArrayDecoder as getArrayDecoder22,
|
|
11339
|
+
getArrayEncoder as getArrayEncoder22,
|
|
11340
|
+
getStructDecoder as getStructDecoder122,
|
|
11341
|
+
getStructEncoder as getStructEncoder122
|
|
11342
|
+
} from "@solana/kit";
|
|
11343
|
+
import {
|
|
11344
|
+
combineCodec as combineCodec152,
|
|
11345
|
+
getStructDecoder as getStructDecoder132,
|
|
11346
|
+
getStructEncoder as getStructEncoder132,
|
|
11347
|
+
getU8Decoder as getU8Decoder7,
|
|
11348
|
+
getU8Encoder as getU8Encoder7
|
|
11349
|
+
} from "@solana/kit";
|
|
11350
|
+
import {
|
|
11351
|
+
combineCodec as combineCodec162,
|
|
11352
|
+
getStructDecoder as getStructDecoder142,
|
|
11353
|
+
getStructEncoder as getStructEncoder142,
|
|
11354
|
+
getU8Decoder as getU8Decoder8,
|
|
11355
|
+
getU8Encoder as getU8Encoder8
|
|
11356
|
+
} from "@solana/kit";
|
|
11357
|
+
import {
|
|
11358
|
+
combineCodec as combineCodec172,
|
|
11359
|
+
getStructDecoder as getStructDecoder152,
|
|
11360
|
+
getStructEncoder as getStructEncoder152,
|
|
11361
|
+
getU16Decoder as getU16Decoder9,
|
|
11362
|
+
getU16Encoder as getU16Encoder9,
|
|
11363
|
+
getU8Decoder as getU8Decoder9,
|
|
11364
|
+
getU8Encoder as getU8Encoder9
|
|
11365
|
+
} from "@solana/kit";
|
|
11366
|
+
import {
|
|
11367
|
+
combineCodec as combineCodec182,
|
|
11368
|
+
getEnumDecoder as getEnumDecoder32,
|
|
11369
|
+
getEnumEncoder as getEnumEncoder32
|
|
11370
|
+
} from "@solana/kit";
|
|
11371
|
+
import {
|
|
11372
|
+
combineCodec as combineCodec192,
|
|
11373
|
+
getBooleanDecoder as getBooleanDecoder22,
|
|
11374
|
+
getBooleanEncoder as getBooleanEncoder22,
|
|
11375
|
+
getDiscriminatedUnionDecoder,
|
|
11376
|
+
getDiscriminatedUnionEncoder,
|
|
11377
|
+
getOptionDecoder as getOptionDecoder3,
|
|
11378
|
+
getOptionEncoder as getOptionEncoder3,
|
|
11379
|
+
getStructDecoder as getStructDecoder162,
|
|
11380
|
+
getStructEncoder as getStructEncoder162,
|
|
11381
|
+
getU32Decoder as getU32Decoder27,
|
|
11382
|
+
getU32Encoder as getU32Encoder27,
|
|
11383
|
+
getU64Decoder as getU64Decoder32,
|
|
11384
|
+
getU64Encoder as getU64Encoder32,
|
|
11385
|
+
getU8Decoder as getU8Decoder10,
|
|
11386
|
+
getU8Encoder as getU8Encoder10,
|
|
11387
|
+
getUnitDecoder,
|
|
11388
|
+
getUnitEncoder
|
|
11389
|
+
} from "@solana/kit";
|
|
11390
|
+
import {
|
|
11391
|
+
combineCodec as combineCodec202,
|
|
11392
|
+
getAddressDecoder as getAddressDecoder32,
|
|
11393
|
+
getAddressEncoder as getAddressEncoder62,
|
|
11394
|
+
getStructDecoder as getStructDecoder172,
|
|
11395
|
+
getStructEncoder as getStructEncoder172,
|
|
11396
|
+
getU64Decoder as getU64Decoder42,
|
|
11397
|
+
getU64Encoder as getU64Encoder42
|
|
11398
|
+
} from "@solana/kit";
|
|
11399
|
+
import {
|
|
11400
|
+
combineCodec as combineCodec222,
|
|
11401
|
+
fixDecoderSize as fixDecoderSize102,
|
|
11402
|
+
fixEncoderSize as fixEncoderSize112,
|
|
11403
|
+
getArrayDecoder as getArrayDecoder4,
|
|
11404
|
+
getArrayEncoder as getArrayEncoder4,
|
|
11405
|
+
getBytesDecoder as getBytesDecoder102,
|
|
11406
|
+
getBytesEncoder as getBytesEncoder112,
|
|
11407
|
+
getStructDecoder as getStructDecoder192,
|
|
11408
|
+
getStructEncoder as getStructEncoder192,
|
|
11409
|
+
getU16Decoder as getU16Decoder32,
|
|
11410
|
+
getU16Encoder as getU16Encoder32,
|
|
11411
|
+
getU64Decoder as getU64Decoder62,
|
|
11412
|
+
getU64Encoder as getU64Encoder62,
|
|
11413
|
+
transformEncoder as transformEncoder102
|
|
11414
|
+
} from "@solana/kit";
|
|
11415
|
+
import {
|
|
11416
|
+
combineCodec as combineCodec232,
|
|
11417
|
+
fixDecoderSize as fixDecoderSize112,
|
|
11418
|
+
fixEncoderSize as fixEncoderSize122,
|
|
11419
|
+
getArrayDecoder as getArrayDecoder5,
|
|
11420
|
+
getArrayEncoder as getArrayEncoder5,
|
|
11421
|
+
getBytesDecoder as getBytesDecoder112,
|
|
11422
|
+
getBytesEncoder as getBytesEncoder122,
|
|
11423
|
+
getStructDecoder as getStructDecoder202,
|
|
11424
|
+
getStructEncoder as getStructEncoder202,
|
|
11425
|
+
getU16Decoder as getU16Decoder42,
|
|
11426
|
+
getU16Encoder as getU16Encoder42,
|
|
11427
|
+
getU64Decoder as getU64Decoder72,
|
|
11428
|
+
getU64Encoder as getU64Encoder72,
|
|
11429
|
+
getU8Decoder as getU8Decoder12,
|
|
11430
|
+
getU8Encoder as getU8Encoder12,
|
|
11431
|
+
transformEncoder as transformEncoder112
|
|
11432
|
+
} from "@solana/kit";
|
|
11433
|
+
import {
|
|
11434
|
+
combineCodec as combineCodec242,
|
|
11435
|
+
fixDecoderSize as fixDecoderSize122,
|
|
11436
|
+
fixEncoderSize as fixEncoderSize132,
|
|
11437
|
+
getArrayDecoder as getArrayDecoder6,
|
|
11438
|
+
getArrayEncoder as getArrayEncoder6,
|
|
11439
|
+
getBytesDecoder as getBytesDecoder122,
|
|
11440
|
+
getBytesEncoder as getBytesEncoder132,
|
|
11441
|
+
getStructDecoder as getStructDecoder212,
|
|
11442
|
+
getStructEncoder as getStructEncoder212,
|
|
11443
|
+
getU16Decoder as getU16Decoder52,
|
|
11444
|
+
getU16Encoder as getU16Encoder52,
|
|
11445
|
+
getU64Decoder as getU64Decoder82,
|
|
11446
|
+
getU64Encoder as getU64Encoder82,
|
|
11447
|
+
transformEncoder as transformEncoder122
|
|
11448
|
+
} from "@solana/kit";
|
|
11449
|
+
import {
|
|
11450
|
+
combineCodec as combineCodec252,
|
|
11451
|
+
fixDecoderSize as fixDecoderSize132,
|
|
11452
|
+
fixEncoderSize as fixEncoderSize142,
|
|
11453
|
+
getArrayDecoder as getArrayDecoder7,
|
|
11454
|
+
getArrayEncoder as getArrayEncoder7,
|
|
11455
|
+
getBytesDecoder as getBytesDecoder132,
|
|
11456
|
+
getBytesEncoder as getBytesEncoder142,
|
|
11457
|
+
getStructDecoder as getStructDecoder222,
|
|
11458
|
+
getStructEncoder as getStructEncoder222,
|
|
11459
|
+
getU16Decoder as getU16Decoder62,
|
|
11460
|
+
getU16Encoder as getU16Encoder62,
|
|
11461
|
+
getU64Decoder as getU64Decoder92,
|
|
11462
|
+
getU64Encoder as getU64Encoder92,
|
|
11463
|
+
getU8Decoder as getU8Decoder13,
|
|
11464
|
+
getU8Encoder as getU8Encoder13,
|
|
11465
|
+
transformEncoder as transformEncoder132
|
|
11466
|
+
} from "@solana/kit";
|
|
11467
|
+
import {
|
|
11468
|
+
combineCodec as combineCodec262,
|
|
11469
|
+
fixDecoderSize as fixDecoderSize142,
|
|
11470
|
+
fixEncoderSize as fixEncoderSize152,
|
|
11471
|
+
getBytesDecoder as getBytesDecoder142,
|
|
11472
|
+
getBytesEncoder as getBytesEncoder152,
|
|
11473
|
+
getStructDecoder as getStructDecoder232,
|
|
11474
|
+
getStructEncoder as getStructEncoder232,
|
|
11475
|
+
transformEncoder as transformEncoder142
|
|
11476
|
+
} from "@solana/kit";
|
|
11477
|
+
import {
|
|
11478
|
+
combineCodec as combineCodec272,
|
|
11479
|
+
fixDecoderSize as fixDecoderSize152,
|
|
11480
|
+
fixEncoderSize as fixEncoderSize162,
|
|
11481
|
+
getArrayDecoder as getArrayDecoder8,
|
|
11482
|
+
getArrayEncoder as getArrayEncoder8,
|
|
11483
|
+
getBytesDecoder as getBytesDecoder152,
|
|
11484
|
+
getBytesEncoder as getBytesEncoder162,
|
|
11485
|
+
getStructDecoder as getStructDecoder242,
|
|
11486
|
+
getStructEncoder as getStructEncoder242,
|
|
11487
|
+
getU16Decoder as getU16Decoder72,
|
|
11488
|
+
getU16Encoder as getU16Encoder72,
|
|
11489
|
+
getU64Decoder as getU64Decoder102,
|
|
11490
|
+
getU64Encoder as getU64Encoder102,
|
|
11491
|
+
getU8Decoder as getU8Decoder14,
|
|
11492
|
+
getU8Encoder as getU8Encoder14,
|
|
11493
|
+
transformEncoder as transformEncoder152
|
|
11494
|
+
} from "@solana/kit";
|
|
11495
|
+
import {
|
|
11496
|
+
combineCodec as combineCodec282,
|
|
11497
|
+
fixDecoderSize as fixDecoderSize162,
|
|
11498
|
+
fixEncoderSize as fixEncoderSize172,
|
|
11499
|
+
getArrayDecoder as getArrayDecoder9,
|
|
11500
|
+
getArrayEncoder as getArrayEncoder9,
|
|
11501
|
+
getBytesDecoder as getBytesDecoder162,
|
|
11502
|
+
getBytesEncoder as getBytesEncoder172,
|
|
11503
|
+
getStructDecoder as getStructDecoder252,
|
|
11504
|
+
getStructEncoder as getStructEncoder252,
|
|
11505
|
+
getU16Decoder as getU16Decoder82,
|
|
11506
|
+
getU16Encoder as getU16Encoder82,
|
|
11507
|
+
getU64Decoder as getU64Decoder112,
|
|
11508
|
+
getU64Encoder as getU64Encoder112,
|
|
11509
|
+
getU8Decoder as getU8Decoder15,
|
|
11510
|
+
getU8Encoder as getU8Encoder15,
|
|
11511
|
+
transformEncoder as transformEncoder162
|
|
11512
|
+
} from "@solana/kit";
|
|
11513
|
+
import {
|
|
11514
|
+
combineCodec as combineCodec292,
|
|
11515
|
+
fixDecoderSize as fixDecoderSize172,
|
|
11516
|
+
fixEncoderSize as fixEncoderSize182,
|
|
11517
|
+
getArrayDecoder as getArrayDecoder10,
|
|
11518
|
+
getArrayEncoder as getArrayEncoder10,
|
|
11519
|
+
getBytesDecoder as getBytesDecoder172,
|
|
11520
|
+
getBytesEncoder as getBytesEncoder182,
|
|
11521
|
+
getStructDecoder as getStructDecoder262,
|
|
11522
|
+
getStructEncoder as getStructEncoder262,
|
|
11523
|
+
getU16Decoder as getU16Decoder92,
|
|
11524
|
+
getU16Encoder as getU16Encoder92,
|
|
11525
|
+
getU64Decoder as getU64Decoder122,
|
|
11526
|
+
getU64Encoder as getU64Encoder122,
|
|
11527
|
+
getU8Decoder as getU8Decoder16,
|
|
11528
|
+
getU8Encoder as getU8Encoder16,
|
|
11529
|
+
transformEncoder as transformEncoder172
|
|
11530
|
+
} from "@solana/kit";
|
|
11531
|
+
import {
|
|
11532
|
+
combineCodec as combineCodec302,
|
|
11533
|
+
fixDecoderSize as fixDecoderSize182,
|
|
11534
|
+
fixEncoderSize as fixEncoderSize192,
|
|
11535
|
+
getArrayDecoder as getArrayDecoder11,
|
|
11536
|
+
getArrayEncoder as getArrayEncoder11,
|
|
11537
|
+
getBytesDecoder as getBytesDecoder182,
|
|
11538
|
+
getBytesEncoder as getBytesEncoder192,
|
|
11539
|
+
getStructDecoder as getStructDecoder272,
|
|
11540
|
+
getStructEncoder as getStructEncoder272,
|
|
11541
|
+
getU16Decoder as getU16Decoder10,
|
|
11542
|
+
getU16Encoder as getU16Encoder10,
|
|
11543
|
+
getU64Decoder as getU64Decoder132,
|
|
11544
|
+
getU64Encoder as getU64Encoder132,
|
|
11545
|
+
getU8Decoder as getU8Decoder17,
|
|
11546
|
+
getU8Encoder as getU8Encoder17,
|
|
11547
|
+
transformEncoder as transformEncoder182
|
|
11548
|
+
} from "@solana/kit";
|
|
11549
|
+
import {
|
|
11550
|
+
combineCodec as combineCodec312,
|
|
11551
|
+
fixDecoderSize as fixDecoderSize192,
|
|
11552
|
+
fixEncoderSize as fixEncoderSize202,
|
|
11553
|
+
getArrayDecoder as getArrayDecoder12,
|
|
11554
|
+
getArrayEncoder as getArrayEncoder12,
|
|
11555
|
+
getBytesDecoder as getBytesDecoder192,
|
|
11556
|
+
getBytesEncoder as getBytesEncoder202,
|
|
11557
|
+
getStructDecoder as getStructDecoder282,
|
|
11558
|
+
getStructEncoder as getStructEncoder282,
|
|
11559
|
+
getU16Decoder as getU16Decoder11,
|
|
11560
|
+
getU16Encoder as getU16Encoder11,
|
|
11561
|
+
getU64Decoder as getU64Decoder142,
|
|
11562
|
+
getU64Encoder as getU64Encoder142,
|
|
11563
|
+
getU8Decoder as getU8Decoder18,
|
|
11564
|
+
getU8Encoder as getU8Encoder18,
|
|
11565
|
+
transformEncoder as transformEncoder192
|
|
11566
|
+
} from "@solana/kit";
|
|
11567
|
+
var TOKEN_LEDGER_DISCRIMINATOR = new Uint8Array([
|
|
11568
|
+
156,
|
|
11569
|
+
247,
|
|
11570
|
+
9,
|
|
11571
|
+
188,
|
|
11572
|
+
54,
|
|
11573
|
+
108,
|
|
11574
|
+
85,
|
|
11575
|
+
77
|
|
11576
|
+
]);
|
|
11577
|
+
var JUPITER_PROGRAM_ADDRESS = "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4";
|
|
11578
|
+
var JUPITER_ERROR__EMPTY_ROUTE = 6e3;
|
|
11579
|
+
var JUPITER_ERROR__SLIPPAGE_TOLERANCE_EXCEEDED = 6001;
|
|
11580
|
+
var JUPITER_ERROR__INVALID_CALCULATION = 6002;
|
|
11581
|
+
var JUPITER_ERROR__MISSING_PLATFORM_FEE_ACCOUNT = 6003;
|
|
11582
|
+
var JUPITER_ERROR__INVALID_SLIPPAGE = 6004;
|
|
11583
|
+
var JUPITER_ERROR__NOT_ENOUGH_PERCENT = 6005;
|
|
11584
|
+
var JUPITER_ERROR__INVALID_INPUT_INDEX = 6006;
|
|
11585
|
+
var JUPITER_ERROR__INVALID_OUTPUT_INDEX = 6007;
|
|
11586
|
+
var JUPITER_ERROR__NOT_ENOUGH_ACCOUNT_KEYS = 6008;
|
|
11587
|
+
var JUPITER_ERROR__NON_ZERO_MINIMUM_OUT_AMOUNT_NOT_SUPPORTED = 6009;
|
|
11588
|
+
var JUPITER_ERROR__INVALID_ROUTE_PLAN = 6010;
|
|
11589
|
+
var JUPITER_ERROR__INVALID_REFERRAL_AUTHORITY = 6011;
|
|
11590
|
+
var JUPITER_ERROR__LEDGER_TOKEN_ACCOUNT_DOES_NOT_MATCH = 6012;
|
|
11591
|
+
var JUPITER_ERROR__INVALID_TOKEN_LEDGER = 6013;
|
|
11592
|
+
var JUPITER_ERROR__INCORRECT_TOKEN_PROGRAM_I_D = 6014;
|
|
11593
|
+
var JUPITER_ERROR__TOKEN_PROGRAM_NOT_PROVIDED = 6015;
|
|
11594
|
+
var JUPITER_ERROR__SWAP_NOT_SUPPORTED = 6016;
|
|
11595
|
+
var JUPITER_ERROR__EXACT_OUT_AMOUNT_NOT_MATCHED = 6017;
|
|
11596
|
+
var JUPITER_ERROR__SOURCE_AND_DESTINATION_MINT_CANNOT_BE_THE_SAME = 6018;
|
|
11597
|
+
var jupiterErrorMessages;
|
|
11598
|
+
if (process.env.NODE_ENV !== "production") {
|
|
11599
|
+
jupiterErrorMessages = {
|
|
11600
|
+
[JUPITER_ERROR__EMPTY_ROUTE]: `Empty route`,
|
|
11601
|
+
[JUPITER_ERROR__EXACT_OUT_AMOUNT_NOT_MATCHED]: `Exact out amount doesn't match`,
|
|
11602
|
+
[JUPITER_ERROR__INCORRECT_TOKEN_PROGRAM_I_D]: `Token program ID is invalid`,
|
|
11603
|
+
[JUPITER_ERROR__INVALID_CALCULATION]: `Invalid calculation`,
|
|
11604
|
+
[JUPITER_ERROR__INVALID_INPUT_INDEX]: `Token input index is invalid`,
|
|
11605
|
+
[JUPITER_ERROR__INVALID_OUTPUT_INDEX]: `Token output index is invalid`,
|
|
11606
|
+
[JUPITER_ERROR__INVALID_REFERRAL_AUTHORITY]: `Invalid referral authority`,
|
|
11607
|
+
[JUPITER_ERROR__INVALID_ROUTE_PLAN]: `Invalid route plan`,
|
|
11608
|
+
[JUPITER_ERROR__INVALID_SLIPPAGE]: `Invalid slippage`,
|
|
11609
|
+
[JUPITER_ERROR__INVALID_TOKEN_LEDGER]: `Invalid token ledger`,
|
|
11610
|
+
[JUPITER_ERROR__LEDGER_TOKEN_ACCOUNT_DOES_NOT_MATCH]: `Token account doesn't match the ledger`,
|
|
11611
|
+
[JUPITER_ERROR__MISSING_PLATFORM_FEE_ACCOUNT]: `Missing platform fee account`,
|
|
11612
|
+
[JUPITER_ERROR__NON_ZERO_MINIMUM_OUT_AMOUNT_NOT_SUPPORTED]: `Non zero minimum out amount not supported`,
|
|
11613
|
+
[JUPITER_ERROR__NOT_ENOUGH_ACCOUNT_KEYS]: `Not Enough Account keys`,
|
|
11614
|
+
[JUPITER_ERROR__NOT_ENOUGH_PERCENT]: `Not enough percent to 100`,
|
|
11615
|
+
[JUPITER_ERROR__SLIPPAGE_TOLERANCE_EXCEEDED]: `Slippage tolerance exceeded`,
|
|
11616
|
+
[JUPITER_ERROR__SOURCE_AND_DESTINATION_MINT_CANNOT_BE_THE_SAME]: `Source mint and destination mint cannot the same`,
|
|
11617
|
+
[JUPITER_ERROR__SWAP_NOT_SUPPORTED]: `Swap not supported`,
|
|
11618
|
+
[JUPITER_ERROR__TOKEN_PROGRAM_NOT_PROVIDED]: `Token program not provided`
|
|
11619
|
+
};
|
|
11620
|
+
}
|
|
11621
|
+
var CLAIM_DISCRIMINATOR = new Uint8Array([
|
|
11622
|
+
62,
|
|
11623
|
+
198,
|
|
11624
|
+
214,
|
|
11625
|
+
193,
|
|
11626
|
+
213,
|
|
11627
|
+
159,
|
|
11628
|
+
108,
|
|
11629
|
+
210
|
|
11630
|
+
]);
|
|
11631
|
+
var CLAIM_TOKEN_DISCRIMINATOR = new Uint8Array([
|
|
11632
|
+
116,
|
|
11633
|
+
206,
|
|
11634
|
+
27,
|
|
11635
|
+
191,
|
|
11636
|
+
166,
|
|
11637
|
+
19,
|
|
11638
|
+
0,
|
|
11639
|
+
73
|
|
11640
|
+
]);
|
|
11641
|
+
var CLOSE_TOKEN_DISCRIMINATOR = new Uint8Array([
|
|
11642
|
+
26,
|
|
11643
|
+
74,
|
|
11644
|
+
236,
|
|
11645
|
+
151,
|
|
11646
|
+
104,
|
|
11647
|
+
64,
|
|
11648
|
+
183,
|
|
11649
|
+
249
|
|
11650
|
+
]);
|
|
11651
|
+
var CREATE_OPEN_ORDERS_DISCRIMINATOR = new Uint8Array([
|
|
11652
|
+
229,
|
|
11653
|
+
194,
|
|
11654
|
+
212,
|
|
11655
|
+
172,
|
|
11656
|
+
8,
|
|
11657
|
+
10,
|
|
11658
|
+
134,
|
|
11659
|
+
147
|
|
11660
|
+
]);
|
|
11661
|
+
var CREATE_PROGRAM_OPEN_ORDERS_DISCRIMINATOR = new Uint8Array([
|
|
11662
|
+
28,
|
|
11663
|
+
226,
|
|
11664
|
+
32,
|
|
11665
|
+
148,
|
|
11666
|
+
188,
|
|
11667
|
+
136,
|
|
11668
|
+
113,
|
|
11669
|
+
171
|
|
11670
|
+
]);
|
|
11671
|
+
var CREATE_TOKEN_ACCOUNT_DISCRIMINATOR = new Uint8Array([
|
|
11672
|
+
147,
|
|
11673
|
+
241,
|
|
11674
|
+
123,
|
|
11675
|
+
100,
|
|
11676
|
+
244,
|
|
11677
|
+
132,
|
|
11678
|
+
174,
|
|
11679
|
+
118
|
|
11680
|
+
]);
|
|
11681
|
+
var CREATE_TOKEN_LEDGER_DISCRIMINATOR = new Uint8Array([
|
|
11682
|
+
232,
|
|
11683
|
+
242,
|
|
11684
|
+
197,
|
|
11685
|
+
253,
|
|
11686
|
+
240,
|
|
11687
|
+
143,
|
|
11688
|
+
129,
|
|
11689
|
+
52
|
|
11690
|
+
]);
|
|
11691
|
+
var EXACT_OUT_ROUTE_DISCRIMINATOR = new Uint8Array([
|
|
11692
|
+
208,
|
|
11693
|
+
51,
|
|
11694
|
+
239,
|
|
11695
|
+
151,
|
|
11696
|
+
123,
|
|
11697
|
+
43,
|
|
11698
|
+
237,
|
|
11699
|
+
92
|
|
11700
|
+
]);
|
|
11701
|
+
var EXACT_OUT_ROUTE_V2_DISCRIMINATOR = new Uint8Array([
|
|
11702
|
+
157,
|
|
11703
|
+
138,
|
|
11704
|
+
184,
|
|
11705
|
+
82,
|
|
11706
|
+
21,
|
|
11707
|
+
244,
|
|
11708
|
+
243,
|
|
11709
|
+
36
|
|
11710
|
+
]);
|
|
11711
|
+
var ROUTE_DISCRIMINATOR = new Uint8Array([
|
|
11712
|
+
229,
|
|
11713
|
+
23,
|
|
11714
|
+
203,
|
|
11715
|
+
151,
|
|
11716
|
+
122,
|
|
11717
|
+
227,
|
|
11718
|
+
173,
|
|
11719
|
+
42
|
|
11720
|
+
]);
|
|
11721
|
+
var ROUTE_V2_DISCRIMINATOR = new Uint8Array([
|
|
11722
|
+
187,
|
|
11723
|
+
100,
|
|
11724
|
+
250,
|
|
11725
|
+
204,
|
|
11726
|
+
49,
|
|
11727
|
+
196,
|
|
11728
|
+
175,
|
|
11729
|
+
20
|
|
11730
|
+
]);
|
|
11731
|
+
var ROUTE_WITH_TOKEN_LEDGER_DISCRIMINATOR = new Uint8Array([
|
|
11732
|
+
150,
|
|
11733
|
+
86,
|
|
11734
|
+
71,
|
|
11735
|
+
116,
|
|
11736
|
+
167,
|
|
11737
|
+
93,
|
|
11738
|
+
14,
|
|
11739
|
+
104
|
|
11740
|
+
]);
|
|
11741
|
+
var SET_TOKEN_LEDGER_DISCRIMINATOR = new Uint8Array([
|
|
11742
|
+
228,
|
|
11743
|
+
85,
|
|
11744
|
+
185,
|
|
11745
|
+
112,
|
|
11746
|
+
78,
|
|
11747
|
+
79,
|
|
11748
|
+
77,
|
|
11749
|
+
2
|
|
11750
|
+
]);
|
|
11751
|
+
var SHARED_ACCOUNTS_EXACT_OUT_ROUTE_DISCRIMINATOR = new Uint8Array([
|
|
11752
|
+
176,
|
|
11753
|
+
209,
|
|
11754
|
+
105,
|
|
11755
|
+
168,
|
|
11756
|
+
154,
|
|
11757
|
+
125,
|
|
11758
|
+
69,
|
|
11759
|
+
62
|
|
11760
|
+
]);
|
|
11761
|
+
var SHARED_ACCOUNTS_EXACT_OUT_ROUTE_V2_DISCRIMINATOR = new Uint8Array([
|
|
11762
|
+
53,
|
|
11763
|
+
96,
|
|
11764
|
+
229,
|
|
11765
|
+
202,
|
|
11766
|
+
216,
|
|
11767
|
+
187,
|
|
11768
|
+
250,
|
|
11769
|
+
24
|
|
11770
|
+
]);
|
|
11771
|
+
var SHARED_ACCOUNTS_ROUTE_DISCRIMINATOR = new Uint8Array([
|
|
11772
|
+
193,
|
|
11773
|
+
32,
|
|
11774
|
+
155,
|
|
11775
|
+
51,
|
|
11776
|
+
65,
|
|
11777
|
+
214,
|
|
11778
|
+
156,
|
|
11779
|
+
129
|
|
11780
|
+
]);
|
|
11781
|
+
var SHARED_ACCOUNTS_ROUTE_V2_DISCRIMINATOR = new Uint8Array([
|
|
11782
|
+
209,
|
|
11783
|
+
152,
|
|
11784
|
+
83,
|
|
11785
|
+
147,
|
|
11786
|
+
124,
|
|
11787
|
+
254,
|
|
11788
|
+
216,
|
|
11789
|
+
233
|
|
11790
|
+
]);
|
|
11791
|
+
var SHARED_ACCOUNTS_ROUTE_WITH_TOKEN_LEDGER_DISCRIMINATOR = new Uint8Array([230, 121, 143, 80, 119, 159, 106, 170]);
|
|
11792
|
+
|
|
11793
|
+
// src/txbuilder/modifyTunaSpotPositionJupiter.ts
|
|
11794
|
+
import { fetchWhirlpool as fetchWhirlpool2 } from "@orca-so/whirlpools-client";
|
|
11795
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS10 } from "@solana-program/memo";
|
|
11149
11796
|
import { fetchAllMaybeMint as fetchAllMaybeMint13, findAssociatedTokenPda as findAssociatedTokenPda15 } from "@solana-program/token-2022";
|
|
11150
11797
|
import assert13 from "assert";
|
|
11798
|
+
async function modifyTunaSpotPositionJupiterInstructions(rpc, authority, poolAddress, remainingAccounts, args, createInstructions, cleanupInstructions) {
|
|
11799
|
+
const instructions = [];
|
|
11800
|
+
if (!createInstructions) createInstructions = instructions;
|
|
11801
|
+
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
11802
|
+
const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
|
|
11803
|
+
const marketAddress = (await getMarketAddress(poolAddress))[0];
|
|
11804
|
+
const market = await fetchMarket(rpc, marketAddress);
|
|
11805
|
+
const pool = market.data.marketMaker == 1 /* Fusion */ ? await fetchFusionPool2(rpc, poolAddress) : await fetchWhirlpool2(rpc, poolAddress);
|
|
11806
|
+
const [mintA, mintB] = await fetchAllMaybeMint13(rpc, [pool.data.tokenMintA, pool.data.tokenMintB]);
|
|
11807
|
+
assert13(mintA.exists, "Token A account not found");
|
|
11808
|
+
assert13(mintB.exists, "Token B account not found");
|
|
11809
|
+
const [vaultA, vaultB] = await fetchAllVault(rpc, [
|
|
11810
|
+
(await getLendingVaultAddress(mintA.address))[0],
|
|
11811
|
+
(await getLendingVaultAddress(mintB.address))[0]
|
|
11812
|
+
]);
|
|
11813
|
+
const createUserAtaAInstructions = await getCreateAtaInstructions(
|
|
11814
|
+
rpc,
|
|
11815
|
+
authority,
|
|
11816
|
+
mintA.address,
|
|
11817
|
+
authority.address,
|
|
11818
|
+
mintA.programAddress
|
|
11819
|
+
);
|
|
11820
|
+
createInstructions.push(...createUserAtaAInstructions.init);
|
|
11821
|
+
const createUserAtaBInstructions = await getCreateAtaInstructions(
|
|
11822
|
+
rpc,
|
|
11823
|
+
authority,
|
|
11824
|
+
mintB.address,
|
|
11825
|
+
authority.address,
|
|
11826
|
+
mintB.programAddress
|
|
11827
|
+
);
|
|
11828
|
+
createInstructions.push(...createUserAtaBInstructions.init);
|
|
11829
|
+
const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
|
|
11830
|
+
rpc,
|
|
11831
|
+
authority,
|
|
11832
|
+
mintA.address,
|
|
11833
|
+
tunaConfig.data.feeRecipient,
|
|
11834
|
+
mintA.programAddress
|
|
11835
|
+
);
|
|
11836
|
+
createInstructions.push(...createFeeRecipientAtaAInstructions.init);
|
|
11837
|
+
const createFeeRecipientAtaBInstructions = await getCreateAtaInstructions(
|
|
11838
|
+
rpc,
|
|
11839
|
+
authority,
|
|
11840
|
+
mintB.address,
|
|
11841
|
+
tunaConfig.data.feeRecipient,
|
|
11842
|
+
mintB.programAddress
|
|
11843
|
+
);
|
|
11844
|
+
createInstructions.push(...createFeeRecipientAtaBInstructions.init);
|
|
11845
|
+
const ix = await modifyTunaSpotPositionJupiterInstruction(
|
|
11846
|
+
authority,
|
|
11847
|
+
tunaConfig,
|
|
11848
|
+
mintA,
|
|
11849
|
+
mintB,
|
|
11850
|
+
vaultA,
|
|
11851
|
+
vaultB,
|
|
11852
|
+
poolAddress,
|
|
11853
|
+
remainingAccounts,
|
|
11854
|
+
{ ...args }
|
|
11855
|
+
);
|
|
11856
|
+
instructions.push(ix);
|
|
11857
|
+
if (createUserAtaAInstructions) cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
|
|
11858
|
+
if (createUserAtaBInstructions) cleanupInstructions.push(...createUserAtaBInstructions.cleanup);
|
|
11859
|
+
return instructions;
|
|
11860
|
+
}
|
|
11861
|
+
async function modifyTunaSpotPositionJupiterInstruction(authority, tunaConfig, mintA, mintB, vaultA, vaultB, poolAddress, remainingAccounts, args) {
|
|
11862
|
+
const marketAddress = (await getMarketAddress(poolAddress))[0];
|
|
11863
|
+
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
11864
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda15({
|
|
11865
|
+
owner: authority.address,
|
|
11866
|
+
mint: mintA.address,
|
|
11867
|
+
tokenProgram: mintA.programAddress
|
|
11868
|
+
}))[0];
|
|
11869
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda15({
|
|
11870
|
+
owner: authority.address,
|
|
11871
|
+
mint: mintB.address,
|
|
11872
|
+
tokenProgram: mintB.programAddress
|
|
11873
|
+
}))[0];
|
|
11874
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda15({
|
|
11875
|
+
owner: tunaConfig.data.feeRecipient,
|
|
11876
|
+
mint: mintA.address,
|
|
11877
|
+
tokenProgram: mintA.programAddress
|
|
11878
|
+
}))[0];
|
|
11879
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda15({
|
|
11880
|
+
owner: tunaConfig.data.feeRecipient,
|
|
11881
|
+
mint: mintB.address,
|
|
11882
|
+
tokenProgram: mintB.programAddress
|
|
11883
|
+
}))[0];
|
|
11884
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda15({
|
|
11885
|
+
owner: tunaPositionAddress,
|
|
11886
|
+
mint: mintA.address,
|
|
11887
|
+
tokenProgram: mintA.programAddress
|
|
11888
|
+
}))[0];
|
|
11889
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda15({
|
|
11890
|
+
owner: tunaPositionAddress,
|
|
11891
|
+
mint: mintB.address,
|
|
11892
|
+
tokenProgram: mintB.programAddress
|
|
11893
|
+
}))[0];
|
|
11894
|
+
const vaultAAta = (await findAssociatedTokenPda15({
|
|
11895
|
+
owner: vaultA.address,
|
|
11896
|
+
mint: mintA.address,
|
|
11897
|
+
tokenProgram: mintA.programAddress
|
|
11898
|
+
}))[0];
|
|
11899
|
+
const vaultBAta = (await findAssociatedTokenPda15({
|
|
11900
|
+
owner: vaultB.address,
|
|
11901
|
+
mint: mintB.address,
|
|
11902
|
+
tokenProgram: mintB.programAddress
|
|
11903
|
+
}))[0];
|
|
11904
|
+
const ix = getModifyTunaSpotPositionJupiterInstruction({
|
|
11905
|
+
authority,
|
|
11906
|
+
tunaConfig: tunaConfig.address,
|
|
11907
|
+
mintA: mintA.address,
|
|
11908
|
+
mintB: mintB.address,
|
|
11909
|
+
tokenProgramA: mintA.programAddress,
|
|
11910
|
+
tokenProgramB: mintB.programAddress,
|
|
11911
|
+
market: marketAddress,
|
|
11912
|
+
pythOraclePriceFeedA: vaultA.data.pythOraclePriceUpdate,
|
|
11913
|
+
pythOraclePriceFeedB: vaultB.data.pythOraclePriceUpdate,
|
|
11914
|
+
vaultA: vaultA.address,
|
|
11915
|
+
vaultAAta,
|
|
11916
|
+
vaultB: vaultB.address,
|
|
11917
|
+
vaultBAta,
|
|
11918
|
+
tunaPosition: tunaPositionAddress,
|
|
11919
|
+
tunaPositionAtaA,
|
|
11920
|
+
tunaPositionAtaB,
|
|
11921
|
+
tunaPositionOwnerAtaA,
|
|
11922
|
+
tunaPositionOwnerAtaB,
|
|
11923
|
+
feeRecipientAtaA,
|
|
11924
|
+
feeRecipientAtaB,
|
|
11925
|
+
pool: poolAddress,
|
|
11926
|
+
jupiterProgram: JUPITER_PROGRAM_ADDRESS,
|
|
11927
|
+
jupiterEventAuthority: JUPITER_EVENT_AUTHORITY,
|
|
11928
|
+
jupiterProgramAuthority: JUPITER_PROGRAM_AUTHORITY,
|
|
11929
|
+
memoProgram: MEMO_PROGRAM_ADDRESS10,
|
|
11930
|
+
...args
|
|
11931
|
+
});
|
|
11932
|
+
ix.accounts.push(...remainingAccounts);
|
|
11933
|
+
return ix;
|
|
11934
|
+
}
|
|
11935
|
+
|
|
11936
|
+
// src/txbuilder/closeTunaSpotPosition.ts
|
|
11937
|
+
import { fetchAllMaybeMint as fetchAllMaybeMint14, findAssociatedTokenPda as findAssociatedTokenPda16 } from "@solana-program/token-2022";
|
|
11938
|
+
import assert14 from "assert";
|
|
11151
11939
|
async function closeTunaSpotPositionInstructions(rpc, authority, poolAddress) {
|
|
11152
11940
|
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
11153
11941
|
const tunaPosition = await fetchMaybeTunaSpotPosition(rpc, tunaPositionAddress);
|
|
11154
11942
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
11155
|
-
const [mintA, mintB] = await
|
|
11156
|
-
|
|
11157
|
-
|
|
11943
|
+
const [mintA, mintB] = await fetchAllMaybeMint14(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
11944
|
+
assert14(mintA.exists, "Token A account not found");
|
|
11945
|
+
assert14(mintB.exists, "Token B account not found");
|
|
11158
11946
|
const ix = await closeTunaSpotPositionInstruction(authority, poolAddress, mintA, mintB);
|
|
11159
11947
|
return [ix];
|
|
11160
11948
|
}
|
|
11161
11949
|
async function closeTunaSpotPositionInstruction(authority, poolAddress, mintA, mintB) {
|
|
11162
11950
|
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
11163
|
-
const tunaPositionAtaA = (await
|
|
11951
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda16({
|
|
11164
11952
|
owner: tunaPositionAddress,
|
|
11165
11953
|
mint: mintA.address,
|
|
11166
11954
|
tokenProgram: mintA.programAddress
|
|
11167
11955
|
}))[0];
|
|
11168
|
-
const tunaPositionAtaB = (await
|
|
11956
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda16({
|
|
11169
11957
|
owner: tunaPositionAddress,
|
|
11170
11958
|
mint: mintB.address,
|
|
11171
11959
|
tokenProgram: mintB.programAddress
|
|
@@ -11209,11 +11997,11 @@ async function createTunaConfigInstruction(authority, ownerAuthority, adminAutho
|
|
|
11209
11997
|
}
|
|
11210
11998
|
|
|
11211
11999
|
// src/txbuilder/createVault.ts
|
|
11212
|
-
import { findAssociatedTokenPda as
|
|
12000
|
+
import { findAssociatedTokenPda as findAssociatedTokenPda17 } from "@solana-program/token-2022";
|
|
11213
12001
|
async function createVaultInstructions(authority, mint, args) {
|
|
11214
12002
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
11215
12003
|
const vault = (await getLendingVaultAddress(mint.address))[0];
|
|
11216
|
-
const vaultAta = (await
|
|
12004
|
+
const vaultAta = (await findAssociatedTokenPda17({
|
|
11217
12005
|
owner: vault,
|
|
11218
12006
|
mint: mint.address,
|
|
11219
12007
|
tokenProgram: mint.programAddress
|
|
@@ -11234,9 +12022,9 @@ async function createVaultInstructions(authority, mint, args) {
|
|
|
11234
12022
|
|
|
11235
12023
|
// src/txbuilder/liquidateTunaLpPositionOrca.ts
|
|
11236
12024
|
import { getOracleAddress as getOracleAddress4, getPositionAddress as getPositionAddress11, WHIRLPOOL_PROGRAM_ADDRESS as WHIRLPOOL_PROGRAM_ADDRESS7 } from "@orca-so/whirlpools-client";
|
|
11237
|
-
import { AccountRole as
|
|
11238
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
11239
|
-
import { findAssociatedTokenPda as
|
|
12025
|
+
import { AccountRole as AccountRole11 } from "@solana/kit";
|
|
12026
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS11 } from "@solana-program/memo";
|
|
12027
|
+
import { findAssociatedTokenPda as findAssociatedTokenPda18, TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS11 } from "@solana-program/token-2022";
|
|
11240
12028
|
async function liquidateTunaLpPositionOrcaInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, decreasePercent) {
|
|
11241
12029
|
const instructions = [];
|
|
11242
12030
|
const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
|
|
@@ -11276,37 +12064,37 @@ async function liquidateTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
11276
12064
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
11277
12065
|
const orcaPositionAddress = (await getPositionAddress11(positionMint))[0];
|
|
11278
12066
|
const orcaOracleAddress = (await getOracleAddress4(whirlpool.address))[0];
|
|
11279
|
-
const tunaPositionAta = (await
|
|
12067
|
+
const tunaPositionAta = (await findAssociatedTokenPda18({
|
|
11280
12068
|
owner: tunaPosition.address,
|
|
11281
12069
|
mint: positionMint,
|
|
11282
12070
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS11
|
|
11283
12071
|
}))[0];
|
|
11284
|
-
const tunaPositionAtaA = (await
|
|
12072
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda18({
|
|
11285
12073
|
owner: tunaPosition.address,
|
|
11286
12074
|
mint: mintA.address,
|
|
11287
12075
|
tokenProgram: mintA.programAddress
|
|
11288
12076
|
}))[0];
|
|
11289
|
-
const tunaPositionAtaB = (await
|
|
12077
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda18({
|
|
11290
12078
|
owner: tunaPosition.address,
|
|
11291
12079
|
mint: mintB.address,
|
|
11292
12080
|
tokenProgram: mintB.programAddress
|
|
11293
12081
|
}))[0];
|
|
11294
|
-
const vaultAAta = (await
|
|
12082
|
+
const vaultAAta = (await findAssociatedTokenPda18({
|
|
11295
12083
|
owner: vaultA.address,
|
|
11296
12084
|
mint: mintA.address,
|
|
11297
12085
|
tokenProgram: mintA.programAddress
|
|
11298
12086
|
}))[0];
|
|
11299
|
-
const vaultBAta = (await
|
|
12087
|
+
const vaultBAta = (await findAssociatedTokenPda18({
|
|
11300
12088
|
owner: vaultB.address,
|
|
11301
12089
|
mint: mintB.address,
|
|
11302
12090
|
tokenProgram: mintB.programAddress
|
|
11303
12091
|
}))[0];
|
|
11304
|
-
const feeRecipientAtaA = (await
|
|
12092
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda18({
|
|
11305
12093
|
owner: tunaConfig.data.feeRecipient,
|
|
11306
12094
|
mint: mintA.address,
|
|
11307
12095
|
tokenProgram: mintA.programAddress
|
|
11308
12096
|
}))[0];
|
|
11309
|
-
const feeRecipientAtaB = (await
|
|
12097
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda18({
|
|
11310
12098
|
owner: tunaConfig.data.feeRecipient,
|
|
11311
12099
|
mint: mintB.address,
|
|
11312
12100
|
tokenProgram: mintB.programAddress
|
|
@@ -11321,16 +12109,16 @@ async function liquidateTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
11321
12109
|
tunaPosition.data.tickUpperIndex
|
|
11322
12110
|
);
|
|
11323
12111
|
const remainingAccounts = [
|
|
11324
|
-
{ address: swapTickArrays[0], role:
|
|
11325
|
-
{ address: swapTickArrays[1], role:
|
|
11326
|
-
{ address: swapTickArrays[2], role:
|
|
11327
|
-
{ address: swapTickArrays[3], role:
|
|
11328
|
-
{ address: swapTickArrays[4], role:
|
|
11329
|
-
{ address: lowerTickArrayAddress, role:
|
|
11330
|
-
{ address: upperTickArrayAddress, role:
|
|
11331
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
11332
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
11333
|
-
{ address: orcaOracleAddress, role:
|
|
12112
|
+
{ address: swapTickArrays[0], role: AccountRole11.WRITABLE },
|
|
12113
|
+
{ address: swapTickArrays[1], role: AccountRole11.WRITABLE },
|
|
12114
|
+
{ address: swapTickArrays[2], role: AccountRole11.WRITABLE },
|
|
12115
|
+
{ address: swapTickArrays[3], role: AccountRole11.WRITABLE },
|
|
12116
|
+
{ address: swapTickArrays[4], role: AccountRole11.WRITABLE },
|
|
12117
|
+
{ address: lowerTickArrayAddress, role: AccountRole11.WRITABLE },
|
|
12118
|
+
{ address: upperTickArrayAddress, role: AccountRole11.WRITABLE },
|
|
12119
|
+
{ address: whirlpool.data.tokenVaultA, role: AccountRole11.WRITABLE },
|
|
12120
|
+
{ address: whirlpool.data.tokenVaultB, role: AccountRole11.WRITABLE },
|
|
12121
|
+
{ address: orcaOracleAddress, role: AccountRole11.WRITABLE }
|
|
11334
12122
|
];
|
|
11335
12123
|
const remainingAccountsInfo = {
|
|
11336
12124
|
slices: [
|
|
@@ -11365,7 +12153,7 @@ async function liquidateTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
11365
12153
|
whirlpoolProgram: WHIRLPOOL_PROGRAM_ADDRESS7,
|
|
11366
12154
|
tokenProgramA: mintA.programAddress,
|
|
11367
12155
|
tokenProgramB: mintB.programAddress,
|
|
11368
|
-
memoProgram:
|
|
12156
|
+
memoProgram: MEMO_PROGRAM_ADDRESS11,
|
|
11369
12157
|
decreasePercent,
|
|
11370
12158
|
remainingAccountsInfo
|
|
11371
12159
|
});
|
|
@@ -11375,9 +12163,9 @@ async function liquidateTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
11375
12163
|
|
|
11376
12164
|
// src/txbuilder/liquidateTunaLpPositionFusion.ts
|
|
11377
12165
|
import { FUSIONAMM_PROGRAM_ADDRESS as FUSIONAMM_PROGRAM_ADDRESS7, getPositionAddress as getPositionAddress12 } from "@crypticdot/fusionamm-client";
|
|
11378
|
-
import { AccountRole as
|
|
11379
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
11380
|
-
import { findAssociatedTokenPda as
|
|
12166
|
+
import { AccountRole as AccountRole12 } from "@solana/kit";
|
|
12167
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS12 } from "@solana-program/memo";
|
|
12168
|
+
import { findAssociatedTokenPda as findAssociatedTokenPda19, TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS12 } from "@solana-program/token-2022";
|
|
11381
12169
|
async function liquidateTunaLpPositionFusionInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, decreasePercent) {
|
|
11382
12170
|
const instructions = [];
|
|
11383
12171
|
const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
|
|
@@ -11416,37 +12204,37 @@ async function liquidateTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
11416
12204
|
const positionMint = tunaPosition.data.positionMint;
|
|
11417
12205
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
11418
12206
|
const fusionPositionAddress = (await getPositionAddress12(positionMint))[0];
|
|
11419
|
-
const tunaPositionAta = (await
|
|
12207
|
+
const tunaPositionAta = (await findAssociatedTokenPda19({
|
|
11420
12208
|
owner: tunaPosition.address,
|
|
11421
12209
|
mint: positionMint,
|
|
11422
12210
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS12
|
|
11423
12211
|
}))[0];
|
|
11424
|
-
const tunaPositionAtaA = (await
|
|
12212
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda19({
|
|
11425
12213
|
owner: tunaPosition.address,
|
|
11426
12214
|
mint: mintA.address,
|
|
11427
12215
|
tokenProgram: mintA.programAddress
|
|
11428
12216
|
}))[0];
|
|
11429
|
-
const tunaPositionAtaB = (await
|
|
12217
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda19({
|
|
11430
12218
|
owner: tunaPosition.address,
|
|
11431
12219
|
mint: mintB.address,
|
|
11432
12220
|
tokenProgram: mintB.programAddress
|
|
11433
12221
|
}))[0];
|
|
11434
|
-
const vaultAAta = (await
|
|
12222
|
+
const vaultAAta = (await findAssociatedTokenPda19({
|
|
11435
12223
|
owner: vaultA.address,
|
|
11436
12224
|
mint: mintA.address,
|
|
11437
12225
|
tokenProgram: mintA.programAddress
|
|
11438
12226
|
}))[0];
|
|
11439
|
-
const vaultBAta = (await
|
|
12227
|
+
const vaultBAta = (await findAssociatedTokenPda19({
|
|
11440
12228
|
owner: vaultB.address,
|
|
11441
12229
|
mint: mintB.address,
|
|
11442
12230
|
tokenProgram: mintB.programAddress
|
|
11443
12231
|
}))[0];
|
|
11444
|
-
const feeRecipientAtaA = (await
|
|
12232
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda19({
|
|
11445
12233
|
owner: tunaConfig.data.feeRecipient,
|
|
11446
12234
|
mint: mintA.address,
|
|
11447
12235
|
tokenProgram: mintA.programAddress
|
|
11448
12236
|
}))[0];
|
|
11449
|
-
const feeRecipientAtaB = (await
|
|
12237
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda19({
|
|
11450
12238
|
owner: tunaConfig.data.feeRecipient,
|
|
11451
12239
|
mint: mintB.address,
|
|
11452
12240
|
tokenProgram: mintB.programAddress
|
|
@@ -11461,15 +12249,15 @@ async function liquidateTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
11461
12249
|
tunaPosition.data.tickUpperIndex
|
|
11462
12250
|
);
|
|
11463
12251
|
const remainingAccounts = [
|
|
11464
|
-
{ address: swapTickArrays[0], role:
|
|
11465
|
-
{ address: swapTickArrays[1], role:
|
|
11466
|
-
{ address: swapTickArrays[2], role:
|
|
11467
|
-
{ address: swapTickArrays[3], role:
|
|
11468
|
-
{ address: swapTickArrays[4], role:
|
|
11469
|
-
{ address: lowerTickArrayAddress, role:
|
|
11470
|
-
{ address: upperTickArrayAddress, role:
|
|
11471
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
11472
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
12252
|
+
{ address: swapTickArrays[0], role: AccountRole12.WRITABLE },
|
|
12253
|
+
{ address: swapTickArrays[1], role: AccountRole12.WRITABLE },
|
|
12254
|
+
{ address: swapTickArrays[2], role: AccountRole12.WRITABLE },
|
|
12255
|
+
{ address: swapTickArrays[3], role: AccountRole12.WRITABLE },
|
|
12256
|
+
{ address: swapTickArrays[4], role: AccountRole12.WRITABLE },
|
|
12257
|
+
{ address: lowerTickArrayAddress, role: AccountRole12.WRITABLE },
|
|
12258
|
+
{ address: upperTickArrayAddress, role: AccountRole12.WRITABLE },
|
|
12259
|
+
{ address: fusionPool.data.tokenVaultA, role: AccountRole12.WRITABLE },
|
|
12260
|
+
{ address: fusionPool.data.tokenVaultB, role: AccountRole12.WRITABLE }
|
|
11473
12261
|
];
|
|
11474
12262
|
const remainingAccountsInfo = {
|
|
11475
12263
|
slices: [
|
|
@@ -11503,7 +12291,7 @@ async function liquidateTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
11503
12291
|
fusionammProgram: FUSIONAMM_PROGRAM_ADDRESS7,
|
|
11504
12292
|
tokenProgramA: mintA.programAddress,
|
|
11505
12293
|
tokenProgramB: mintB.programAddress,
|
|
11506
|
-
memoProgram:
|
|
12294
|
+
memoProgram: MEMO_PROGRAM_ADDRESS12,
|
|
11507
12295
|
decreasePercent,
|
|
11508
12296
|
remainingAccountsInfo
|
|
11509
12297
|
});
|
|
@@ -11513,9 +12301,9 @@ async function liquidateTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
11513
12301
|
|
|
11514
12302
|
// src/txbuilder/liquidateTunaSpotPositionFusion.ts
|
|
11515
12303
|
import { FUSIONAMM_PROGRAM_ADDRESS as FUSIONAMM_PROGRAM_ADDRESS8 } from "@crypticdot/fusionamm-client";
|
|
11516
|
-
import { AccountRole as
|
|
11517
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
11518
|
-
import { findAssociatedTokenPda as
|
|
12304
|
+
import { AccountRole as AccountRole13 } from "@solana/kit";
|
|
12305
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS13 } from "@solana-program/memo";
|
|
12306
|
+
import { findAssociatedTokenPda as findAssociatedTokenPda20 } from "@solana-program/token-2022";
|
|
11519
12307
|
async function liquidateTunaSpotPositionFusionInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool, createTunaPositionOwnerAta, decreasePercent) {
|
|
11520
12308
|
const instructions = [];
|
|
11521
12309
|
if (createTunaPositionOwnerAta) {
|
|
@@ -11563,55 +12351,55 @@ async function liquidateTunaSpotPositionFusionInstructions(authority, tunaPositi
|
|
|
11563
12351
|
}
|
|
11564
12352
|
async function liquidateTunaSpotPositionFusionInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool, decreasePercent) {
|
|
11565
12353
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
11566
|
-
const tunaPositionOwnerAtaA = (await
|
|
12354
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda20({
|
|
11567
12355
|
owner: tunaPosition.data.authority,
|
|
11568
12356
|
mint: mintA.address,
|
|
11569
12357
|
tokenProgram: mintA.programAddress
|
|
11570
12358
|
}))[0];
|
|
11571
|
-
const tunaPositionOwnerAtaB = (await
|
|
12359
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda20({
|
|
11572
12360
|
owner: tunaPosition.data.authority,
|
|
11573
12361
|
mint: mintB.address,
|
|
11574
12362
|
tokenProgram: mintB.programAddress
|
|
11575
12363
|
}))[0];
|
|
11576
|
-
const tunaPositionAtaA = (await
|
|
12364
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda20({
|
|
11577
12365
|
owner: tunaPosition.address,
|
|
11578
12366
|
mint: mintA.address,
|
|
11579
12367
|
tokenProgram: mintA.programAddress
|
|
11580
12368
|
}))[0];
|
|
11581
|
-
const tunaPositionAtaB = (await
|
|
12369
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda20({
|
|
11582
12370
|
owner: tunaPosition.address,
|
|
11583
12371
|
mint: mintB.address,
|
|
11584
12372
|
tokenProgram: mintB.programAddress
|
|
11585
12373
|
}))[0];
|
|
11586
|
-
const feeRecipientAtaA = (await
|
|
12374
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda20({
|
|
11587
12375
|
owner: tunaConfig.data.feeRecipient,
|
|
11588
12376
|
mint: mintA.address,
|
|
11589
12377
|
tokenProgram: mintA.programAddress
|
|
11590
12378
|
}))[0];
|
|
11591
|
-
const feeRecipientAtaB = (await
|
|
12379
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda20({
|
|
11592
12380
|
owner: tunaConfig.data.feeRecipient,
|
|
11593
12381
|
mint: mintB.address,
|
|
11594
12382
|
tokenProgram: mintB.programAddress
|
|
11595
12383
|
}))[0];
|
|
11596
|
-
const vaultAAta = (await
|
|
12384
|
+
const vaultAAta = (await findAssociatedTokenPda20({
|
|
11597
12385
|
owner: vaultA.address,
|
|
11598
12386
|
mint: mintA.address,
|
|
11599
12387
|
tokenProgram: mintA.programAddress
|
|
11600
12388
|
}))[0];
|
|
11601
|
-
const vaultBAta = (await
|
|
12389
|
+
const vaultBAta = (await findAssociatedTokenPda20({
|
|
11602
12390
|
owner: vaultB.address,
|
|
11603
12391
|
mint: mintB.address,
|
|
11604
12392
|
tokenProgram: mintB.programAddress
|
|
11605
12393
|
}))[0];
|
|
11606
12394
|
const swapTickArrays = await FusionUtils.getSwapTickArrayAddresses(fusionPool);
|
|
11607
12395
|
const remainingAccounts = [
|
|
11608
|
-
{ address: swapTickArrays[0], role:
|
|
11609
|
-
{ address: swapTickArrays[1], role:
|
|
11610
|
-
{ address: swapTickArrays[2], role:
|
|
11611
|
-
{ address: swapTickArrays[3], role:
|
|
11612
|
-
{ address: swapTickArrays[4], role:
|
|
11613
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
11614
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
12396
|
+
{ address: swapTickArrays[0], role: AccountRole13.WRITABLE },
|
|
12397
|
+
{ address: swapTickArrays[1], role: AccountRole13.WRITABLE },
|
|
12398
|
+
{ address: swapTickArrays[2], role: AccountRole13.WRITABLE },
|
|
12399
|
+
{ address: swapTickArrays[3], role: AccountRole13.WRITABLE },
|
|
12400
|
+
{ address: swapTickArrays[4], role: AccountRole13.WRITABLE },
|
|
12401
|
+
{ address: fusionPool.data.tokenVaultA, role: AccountRole13.WRITABLE },
|
|
12402
|
+
{ address: fusionPool.data.tokenVaultB, role: AccountRole13.WRITABLE }
|
|
11615
12403
|
];
|
|
11616
12404
|
const remainingAccountsInfo = {
|
|
11617
12405
|
slices: [
|
|
@@ -11644,7 +12432,7 @@ async function liquidateTunaSpotPositionFusionInstruction(authority, tunaPositio
|
|
|
11644
12432
|
feeRecipientAtaB,
|
|
11645
12433
|
fusionPool: fusionPool.address,
|
|
11646
12434
|
fusionammProgram: FUSIONAMM_PROGRAM_ADDRESS8,
|
|
11647
|
-
memoProgram:
|
|
12435
|
+
memoProgram: MEMO_PROGRAM_ADDRESS13,
|
|
11648
12436
|
decreasePercent,
|
|
11649
12437
|
remainingAccountsInfo
|
|
11650
12438
|
});
|
|
@@ -11654,9 +12442,9 @@ async function liquidateTunaSpotPositionFusionInstruction(authority, tunaPositio
|
|
|
11654
12442
|
|
|
11655
12443
|
// src/txbuilder/liquidateTunaSpotPositionOrca.ts
|
|
11656
12444
|
import { getOracleAddress as getOracleAddress5, WHIRLPOOL_PROGRAM_ADDRESS as WHIRLPOOL_PROGRAM_ADDRESS8 } from "@orca-so/whirlpools-client";
|
|
11657
|
-
import { AccountRole as
|
|
11658
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
11659
|
-
import { findAssociatedTokenPda as
|
|
12445
|
+
import { AccountRole as AccountRole14 } from "@solana/kit";
|
|
12446
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS14 } from "@solana-program/memo";
|
|
12447
|
+
import { findAssociatedTokenPda as findAssociatedTokenPda21 } from "@solana-program/token-2022";
|
|
11660
12448
|
async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, createTunaPositionOwnerAta, decreasePercent) {
|
|
11661
12449
|
const instructions = [];
|
|
11662
12450
|
if (createTunaPositionOwnerAta) {
|
|
@@ -11705,56 +12493,56 @@ async function liquidateTunaSpotPositionOrcaInstructions(authority, tunaPosition
|
|
|
11705
12493
|
async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool, decreasePercent) {
|
|
11706
12494
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
11707
12495
|
const orcaOracleAddress = (await getOracleAddress5(whirlpool.address))[0];
|
|
11708
|
-
const tunaPositionOwnerAtaA = (await
|
|
12496
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda21({
|
|
11709
12497
|
owner: tunaPosition.data.authority,
|
|
11710
12498
|
mint: mintA.address,
|
|
11711
12499
|
tokenProgram: mintA.programAddress
|
|
11712
12500
|
}))[0];
|
|
11713
|
-
const tunaPositionOwnerAtaB = (await
|
|
12501
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda21({
|
|
11714
12502
|
owner: tunaPosition.data.authority,
|
|
11715
12503
|
mint: mintB.address,
|
|
11716
12504
|
tokenProgram: mintB.programAddress
|
|
11717
12505
|
}))[0];
|
|
11718
|
-
const tunaPositionAtaA = (await
|
|
12506
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda21({
|
|
11719
12507
|
owner: tunaPosition.address,
|
|
11720
12508
|
mint: mintA.address,
|
|
11721
12509
|
tokenProgram: mintA.programAddress
|
|
11722
12510
|
}))[0];
|
|
11723
|
-
const tunaPositionAtaB = (await
|
|
12511
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda21({
|
|
11724
12512
|
owner: tunaPosition.address,
|
|
11725
12513
|
mint: mintB.address,
|
|
11726
12514
|
tokenProgram: mintB.programAddress
|
|
11727
12515
|
}))[0];
|
|
11728
|
-
const feeRecipientAtaA = (await
|
|
12516
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda21({
|
|
11729
12517
|
owner: tunaConfig.data.feeRecipient,
|
|
11730
12518
|
mint: mintA.address,
|
|
11731
12519
|
tokenProgram: mintA.programAddress
|
|
11732
12520
|
}))[0];
|
|
11733
|
-
const feeRecipientAtaB = (await
|
|
12521
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda21({
|
|
11734
12522
|
owner: tunaConfig.data.feeRecipient,
|
|
11735
12523
|
mint: mintB.address,
|
|
11736
12524
|
tokenProgram: mintB.programAddress
|
|
11737
12525
|
}))[0];
|
|
11738
|
-
const vaultAAta = (await
|
|
12526
|
+
const vaultAAta = (await findAssociatedTokenPda21({
|
|
11739
12527
|
owner: vaultA.address,
|
|
11740
12528
|
mint: mintA.address,
|
|
11741
12529
|
tokenProgram: mintA.programAddress
|
|
11742
12530
|
}))[0];
|
|
11743
|
-
const vaultBAta = (await
|
|
12531
|
+
const vaultBAta = (await findAssociatedTokenPda21({
|
|
11744
12532
|
owner: vaultB.address,
|
|
11745
12533
|
mint: mintB.address,
|
|
11746
12534
|
tokenProgram: mintB.programAddress
|
|
11747
12535
|
}))[0];
|
|
11748
12536
|
const swapTickArrays = await OrcaUtils.getSwapTickArrayAddresses(whirlpool);
|
|
11749
12537
|
const remainingAccounts = [
|
|
11750
|
-
{ address: swapTickArrays[0], role:
|
|
11751
|
-
{ address: swapTickArrays[1], role:
|
|
11752
|
-
{ address: swapTickArrays[2], role:
|
|
11753
|
-
{ address: swapTickArrays[3], role:
|
|
11754
|
-
{ address: swapTickArrays[4], role:
|
|
11755
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
11756
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
11757
|
-
{ address: orcaOracleAddress, role:
|
|
12538
|
+
{ address: swapTickArrays[0], role: AccountRole14.WRITABLE },
|
|
12539
|
+
{ address: swapTickArrays[1], role: AccountRole14.WRITABLE },
|
|
12540
|
+
{ address: swapTickArrays[2], role: AccountRole14.WRITABLE },
|
|
12541
|
+
{ address: swapTickArrays[3], role: AccountRole14.WRITABLE },
|
|
12542
|
+
{ address: swapTickArrays[4], role: AccountRole14.WRITABLE },
|
|
12543
|
+
{ address: whirlpool.data.tokenVaultA, role: AccountRole14.WRITABLE },
|
|
12544
|
+
{ address: whirlpool.data.tokenVaultB, role: AccountRole14.WRITABLE },
|
|
12545
|
+
{ address: orcaOracleAddress, role: AccountRole14.WRITABLE }
|
|
11758
12546
|
];
|
|
11759
12547
|
const remainingAccountsInfo = {
|
|
11760
12548
|
slices: [
|
|
@@ -11788,7 +12576,7 @@ async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition,
|
|
|
11788
12576
|
feeRecipientAtaB,
|
|
11789
12577
|
whirlpool: whirlpool.address,
|
|
11790
12578
|
whirlpoolProgram: WHIRLPOOL_PROGRAM_ADDRESS8,
|
|
11791
|
-
memoProgram:
|
|
12579
|
+
memoProgram: MEMO_PROGRAM_ADDRESS14,
|
|
11792
12580
|
decreasePercent,
|
|
11793
12581
|
remainingAccountsInfo
|
|
11794
12582
|
});
|
|
@@ -11800,31 +12588,31 @@ async function liquidateTunaSpotPositionOrcaInstruction(authority, tunaPosition,
|
|
|
11800
12588
|
import { fetchMaybeWhirlpool as fetchMaybeWhirlpool6, getPositionAddress as getPositionAddress13, WHIRLPOOL_PROGRAM_ADDRESS as WHIRLPOOL_PROGRAM_ADDRESS9 } from "@orca-so/whirlpools-client";
|
|
11801
12589
|
import {
|
|
11802
12590
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
|
|
11803
|
-
fetchAllMaybeMint as
|
|
11804
|
-
findAssociatedTokenPda as
|
|
12591
|
+
fetchAllMaybeMint as fetchAllMaybeMint15,
|
|
12592
|
+
findAssociatedTokenPda as findAssociatedTokenPda22,
|
|
11805
12593
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS13
|
|
11806
12594
|
} from "@solana-program/token-2022";
|
|
11807
|
-
import
|
|
12595
|
+
import assert15 from "assert";
|
|
11808
12596
|
async function openTunaLpPositionOrcaInstruction(rpc, authority, positionMint, whirlpoolAddress, args) {
|
|
11809
12597
|
const whirlpool = await fetchMaybeWhirlpool6(rpc, whirlpoolAddress);
|
|
11810
12598
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
11811
|
-
const [mintA, mintB] = await
|
|
11812
|
-
|
|
11813
|
-
|
|
12599
|
+
const [mintA, mintB] = await fetchAllMaybeMint15(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
12600
|
+
assert15(mintA.exists, "Token A account not found");
|
|
12601
|
+
assert15(mintB.exists, "Token B account not found");
|
|
11814
12602
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
11815
12603
|
const orcaPositionAddress = (await getPositionAddress13(positionMint.address))[0];
|
|
11816
12604
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
11817
|
-
const tunaPositionAta = (await
|
|
12605
|
+
const tunaPositionAta = (await findAssociatedTokenPda22({
|
|
11818
12606
|
owner: tunaPositionAddress,
|
|
11819
12607
|
mint: positionMint.address,
|
|
11820
12608
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS13
|
|
11821
12609
|
}))[0];
|
|
11822
|
-
const tunaPositionAtaA = (await
|
|
12610
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda22({
|
|
11823
12611
|
owner: tunaPositionAddress,
|
|
11824
12612
|
mint: mintA.address,
|
|
11825
12613
|
tokenProgram: mintA.programAddress
|
|
11826
12614
|
}))[0];
|
|
11827
|
-
const tunaPositionAtaB = (await
|
|
12615
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda22({
|
|
11828
12616
|
owner: tunaPositionAddress,
|
|
11829
12617
|
mint: mintB.address,
|
|
11830
12618
|
tokenProgram: mintB.programAddress
|
|
@@ -11856,31 +12644,31 @@ import { fetchMaybeFusionPool as fetchMaybeFusionPool6, FUSIONAMM_PROGRAM_ADDRES
|
|
|
11856
12644
|
import { FP_NFT_UPDATE_AUTH } from "@crypticdot/fusionamm-client";
|
|
11857
12645
|
import {
|
|
11858
12646
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS as ASSOCIATED_TOKEN_PROGRAM_ADDRESS2,
|
|
11859
|
-
fetchAllMaybeMint as
|
|
11860
|
-
findAssociatedTokenPda as
|
|
12647
|
+
fetchAllMaybeMint as fetchAllMaybeMint16,
|
|
12648
|
+
findAssociatedTokenPda as findAssociatedTokenPda23,
|
|
11861
12649
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS14
|
|
11862
12650
|
} from "@solana-program/token-2022";
|
|
11863
|
-
import
|
|
12651
|
+
import assert16 from "assert";
|
|
11864
12652
|
async function openTunaLpPositionFusionInstruction(rpc, authority, positionMint, fusionPoolAddress, args) {
|
|
11865
12653
|
const fusionPool = await fetchMaybeFusionPool6(rpc, fusionPoolAddress);
|
|
11866
|
-
if (!fusionPool.exists) throw new Error("Whirlpool account not found");
|
|
11867
|
-
const [mintA, mintB] = await
|
|
11868
|
-
|
|
11869
|
-
|
|
12654
|
+
if (!fusionPool.exists) throw new Error("Whirlpool account not found");
|
|
12655
|
+
const [mintA, mintB] = await fetchAllMaybeMint16(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
12656
|
+
assert16(mintA.exists, "Token A account not found");
|
|
12657
|
+
assert16(mintB.exists, "Token B account not found");
|
|
11870
12658
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
11871
12659
|
const fusionPositionAddress = (await getPositionAddress14(positionMint.address))[0];
|
|
11872
12660
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
11873
|
-
const tunaPositionAta = (await
|
|
12661
|
+
const tunaPositionAta = (await findAssociatedTokenPda23({
|
|
11874
12662
|
owner: tunaPositionAddress,
|
|
11875
12663
|
mint: positionMint.address,
|
|
11876
12664
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS14
|
|
11877
12665
|
}))[0];
|
|
11878
|
-
const tunaPositionAtaA = (await
|
|
12666
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda23({
|
|
11879
12667
|
owner: tunaPositionAddress,
|
|
11880
12668
|
mint: mintA.address,
|
|
11881
12669
|
tokenProgram: mintA.programAddress
|
|
11882
12670
|
}))[0];
|
|
11883
|
-
const tunaPositionAtaB = (await
|
|
12671
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda23({
|
|
11884
12672
|
owner: tunaPositionAddress,
|
|
11885
12673
|
mint: mintB.address,
|
|
11886
12674
|
tokenProgram: mintB.programAddress
|
|
@@ -11920,19 +12708,19 @@ import {
|
|
|
11920
12708
|
} from "@orca-so/whirlpools-client";
|
|
11921
12709
|
import { getTickArrayStartTickIndex as getTickArrayStartTickIndex6 } from "@orca-so/whirlpools-core";
|
|
11922
12710
|
import {
|
|
11923
|
-
AccountRole as
|
|
12711
|
+
AccountRole as AccountRole15,
|
|
11924
12712
|
generateKeyPairSigner,
|
|
11925
12713
|
lamports
|
|
11926
12714
|
} from "@solana/kit";
|
|
11927
12715
|
import { fetchSysvarRent } from "@solana/sysvars";
|
|
11928
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
12716
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS15 } from "@solana-program/memo";
|
|
11929
12717
|
import {
|
|
11930
12718
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS as ASSOCIATED_TOKEN_PROGRAM_ADDRESS3,
|
|
11931
|
-
fetchAllMaybeMint as
|
|
11932
|
-
findAssociatedTokenPda as
|
|
12719
|
+
fetchAllMaybeMint as fetchAllMaybeMint17,
|
|
12720
|
+
findAssociatedTokenPda as findAssociatedTokenPda24,
|
|
11933
12721
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS15
|
|
11934
12722
|
} from "@solana-program/token-2022";
|
|
11935
|
-
import
|
|
12723
|
+
import assert17 from "assert";
|
|
11936
12724
|
|
|
11937
12725
|
// src/utils/sysvar.ts
|
|
11938
12726
|
var ACCOUNT_STORAGE_OVERHEAD = 128;
|
|
@@ -11956,9 +12744,9 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
|
|
|
11956
12744
|
if (!whirlpool.exists) throw new Error("Whirlpool account not found");
|
|
11957
12745
|
const marketAddress = (await getMarketAddress(whirlpoolAddress))[0];
|
|
11958
12746
|
const market = await fetchMarket(rpc, marketAddress);
|
|
11959
|
-
const [mintA, mintB] = await
|
|
11960
|
-
|
|
11961
|
-
|
|
12747
|
+
const [mintA, mintB] = await fetchAllMaybeMint17(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
12748
|
+
assert17(mintA.exists, "Token A account not found");
|
|
12749
|
+
assert17(mintB.exists, "Token B account not found");
|
|
11962
12750
|
const [vaultA, vaultB] = await fetchAllVault(rpc, [
|
|
11963
12751
|
(await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
|
|
11964
12752
|
(await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
|
|
@@ -12067,47 +12855,47 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
12067
12855
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12068
12856
|
const orcaPositionAddress = (await getPositionAddress15(positionMint.address))[0];
|
|
12069
12857
|
const orcaOracleAddress = (await getOracleAddress6(whirlpool.address))[0];
|
|
12070
|
-
const tunaPositionAta = (await
|
|
12858
|
+
const tunaPositionAta = (await findAssociatedTokenPda24({
|
|
12071
12859
|
owner: tunaPositionAddress,
|
|
12072
12860
|
mint: positionMint.address,
|
|
12073
12861
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS15
|
|
12074
12862
|
}))[0];
|
|
12075
|
-
const tunaPositionOwnerAtaA = (await
|
|
12863
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda24({
|
|
12076
12864
|
owner: authority.address,
|
|
12077
12865
|
mint: mintA.address,
|
|
12078
12866
|
tokenProgram: mintA.programAddress
|
|
12079
12867
|
}))[0];
|
|
12080
|
-
const tunaPositionOwnerAtaB = (await
|
|
12868
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda24({
|
|
12081
12869
|
owner: authority.address,
|
|
12082
12870
|
mint: mintB.address,
|
|
12083
12871
|
tokenProgram: mintB.programAddress
|
|
12084
12872
|
}))[0];
|
|
12085
|
-
const tunaPositionAtaA = (await
|
|
12873
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda24({
|
|
12086
12874
|
owner: tunaPositionAddress,
|
|
12087
12875
|
mint: mintA.address,
|
|
12088
12876
|
tokenProgram: mintA.programAddress
|
|
12089
12877
|
}))[0];
|
|
12090
|
-
const tunaPositionAtaB = (await
|
|
12878
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda24({
|
|
12091
12879
|
owner: tunaPositionAddress,
|
|
12092
12880
|
mint: mintB.address,
|
|
12093
12881
|
tokenProgram: mintB.programAddress
|
|
12094
12882
|
}))[0];
|
|
12095
|
-
const vaultAAta = (await
|
|
12883
|
+
const vaultAAta = (await findAssociatedTokenPda24({
|
|
12096
12884
|
owner: vaultA.address,
|
|
12097
12885
|
mint: mintA.address,
|
|
12098
12886
|
tokenProgram: mintA.programAddress
|
|
12099
12887
|
}))[0];
|
|
12100
|
-
const vaultBAta = (await
|
|
12888
|
+
const vaultBAta = (await findAssociatedTokenPda24({
|
|
12101
12889
|
owner: vaultB.address,
|
|
12102
12890
|
mint: mintB.address,
|
|
12103
12891
|
tokenProgram: mintB.programAddress
|
|
12104
12892
|
}))[0];
|
|
12105
|
-
const feeRecipientAtaA = (await
|
|
12893
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda24({
|
|
12106
12894
|
owner: tunaConfig.data.feeRecipient,
|
|
12107
12895
|
mint: mintA.address,
|
|
12108
12896
|
tokenProgram: mintA.programAddress
|
|
12109
12897
|
}))[0];
|
|
12110
|
-
const feeRecipientAtaB = (await
|
|
12898
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda24({
|
|
12111
12899
|
owner: tunaConfig.data.feeRecipient,
|
|
12112
12900
|
mint: mintB.address,
|
|
12113
12901
|
tokenProgram: mintB.programAddress
|
|
@@ -12116,16 +12904,16 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
12116
12904
|
const lowerTickArrayAddress = await OrcaUtils.getTickArrayAddressFromTickIndex(whirlpool, args.tickLowerIndex);
|
|
12117
12905
|
const upperTickArrayAddress = await OrcaUtils.getTickArrayAddressFromTickIndex(whirlpool, args.tickUpperIndex);
|
|
12118
12906
|
const remainingAccounts = [
|
|
12119
|
-
{ address: swapTickArrays[0], role:
|
|
12120
|
-
{ address: swapTickArrays[1], role:
|
|
12121
|
-
{ address: swapTickArrays[2], role:
|
|
12122
|
-
{ address: swapTickArrays[3], role:
|
|
12123
|
-
{ address: swapTickArrays[4], role:
|
|
12124
|
-
{ address: lowerTickArrayAddress, role:
|
|
12125
|
-
{ address: upperTickArrayAddress, role:
|
|
12126
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
12127
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
12128
|
-
{ address: orcaOracleAddress, role:
|
|
12907
|
+
{ address: swapTickArrays[0], role: AccountRole15.WRITABLE },
|
|
12908
|
+
{ address: swapTickArrays[1], role: AccountRole15.WRITABLE },
|
|
12909
|
+
{ address: swapTickArrays[2], role: AccountRole15.WRITABLE },
|
|
12910
|
+
{ address: swapTickArrays[3], role: AccountRole15.WRITABLE },
|
|
12911
|
+
{ address: swapTickArrays[4], role: AccountRole15.WRITABLE },
|
|
12912
|
+
{ address: lowerTickArrayAddress, role: AccountRole15.WRITABLE },
|
|
12913
|
+
{ address: upperTickArrayAddress, role: AccountRole15.WRITABLE },
|
|
12914
|
+
{ address: whirlpool.data.tokenVaultA, role: AccountRole15.WRITABLE },
|
|
12915
|
+
{ address: whirlpool.data.tokenVaultB, role: AccountRole15.WRITABLE },
|
|
12916
|
+
{ address: orcaOracleAddress, role: AccountRole15.WRITABLE }
|
|
12129
12917
|
];
|
|
12130
12918
|
const remainingAccountsInfo = {
|
|
12131
12919
|
slices: [
|
|
@@ -12163,7 +12951,7 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
|
|
|
12163
12951
|
orcaPosition: orcaPositionAddress,
|
|
12164
12952
|
tokenProgramA: mintA.programAddress,
|
|
12165
12953
|
tokenProgramB: mintB.programAddress,
|
|
12166
|
-
memoProgram:
|
|
12954
|
+
memoProgram: MEMO_PROGRAM_ADDRESS15,
|
|
12167
12955
|
metadataUpdateAuth: WP_NFT_UPDATE_AUTH,
|
|
12168
12956
|
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ADDRESS3,
|
|
12169
12957
|
token2022Program: TOKEN_2022_PROGRAM_ADDRESS15,
|
|
@@ -12187,19 +12975,19 @@ import {
|
|
|
12187
12975
|
} from "@crypticdot/fusionamm-client";
|
|
12188
12976
|
import { getTickArrayStartTickIndex as getTickArrayStartTickIndex7 } from "@crypticdot/fusionamm-core";
|
|
12189
12977
|
import {
|
|
12190
|
-
AccountRole as
|
|
12978
|
+
AccountRole as AccountRole16,
|
|
12191
12979
|
generateKeyPairSigner as generateKeyPairSigner2,
|
|
12192
12980
|
lamports as lamports2
|
|
12193
12981
|
} from "@solana/kit";
|
|
12194
12982
|
import { fetchSysvarRent as fetchSysvarRent2 } from "@solana/sysvars";
|
|
12195
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
12983
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS16 } from "@solana-program/memo";
|
|
12196
12984
|
import {
|
|
12197
12985
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS as ASSOCIATED_TOKEN_PROGRAM_ADDRESS4,
|
|
12198
|
-
fetchAllMaybeMint as
|
|
12199
|
-
findAssociatedTokenPda as
|
|
12986
|
+
fetchAllMaybeMint as fetchAllMaybeMint18,
|
|
12987
|
+
findAssociatedTokenPda as findAssociatedTokenPda25,
|
|
12200
12988
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS16
|
|
12201
12989
|
} from "@solana-program/token-2022";
|
|
12202
|
-
import
|
|
12990
|
+
import assert18 from "assert";
|
|
12203
12991
|
async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, fusionPoolAddress, args, createInstructions, cleanupInstructions) {
|
|
12204
12992
|
const instructions = [];
|
|
12205
12993
|
if (!createInstructions) createInstructions = instructions;
|
|
@@ -12212,9 +13000,9 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
|
|
|
12212
13000
|
if (!fusionPool.exists) throw new Error("FusionPool account not found");
|
|
12213
13001
|
const marketAddress = (await getMarketAddress(fusionPoolAddress))[0];
|
|
12214
13002
|
const market = await fetchMarket(rpc, marketAddress);
|
|
12215
|
-
const [mintA, mintB] = await
|
|
12216
|
-
|
|
12217
|
-
|
|
13003
|
+
const [mintA, mintB] = await fetchAllMaybeMint18(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
13004
|
+
assert18(mintA.exists, "Token A account not found");
|
|
13005
|
+
assert18(mintB.exists, "Token B account not found");
|
|
12218
13006
|
const [vaultA, vaultB] = await fetchAllVault(rpc, [
|
|
12219
13007
|
(await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
|
|
12220
13008
|
(await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
|
|
@@ -12320,47 +13108,47 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
12320
13108
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint.address))[0];
|
|
12321
13109
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
12322
13110
|
const fusionPositionAddress = (await getPositionAddress16(positionMint.address))[0];
|
|
12323
|
-
const tunaPositionAta = (await
|
|
13111
|
+
const tunaPositionAta = (await findAssociatedTokenPda25({
|
|
12324
13112
|
owner: tunaPositionAddress,
|
|
12325
13113
|
mint: positionMint.address,
|
|
12326
13114
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS16
|
|
12327
13115
|
}))[0];
|
|
12328
|
-
const tunaPositionOwnerAtaA = (await
|
|
13116
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda25({
|
|
12329
13117
|
owner: authority.address,
|
|
12330
13118
|
mint: mintA.address,
|
|
12331
13119
|
tokenProgram: mintA.programAddress
|
|
12332
13120
|
}))[0];
|
|
12333
|
-
const tunaPositionOwnerAtaB = (await
|
|
13121
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda25({
|
|
12334
13122
|
owner: authority.address,
|
|
12335
13123
|
mint: mintB.address,
|
|
12336
13124
|
tokenProgram: mintB.programAddress
|
|
12337
13125
|
}))[0];
|
|
12338
|
-
const tunaPositionAtaA = (await
|
|
13126
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda25({
|
|
12339
13127
|
owner: tunaPositionAddress,
|
|
12340
13128
|
mint: mintA.address,
|
|
12341
13129
|
tokenProgram: mintA.programAddress
|
|
12342
13130
|
}))[0];
|
|
12343
|
-
const tunaPositionAtaB = (await
|
|
13131
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda25({
|
|
12344
13132
|
owner: tunaPositionAddress,
|
|
12345
13133
|
mint: mintB.address,
|
|
12346
13134
|
tokenProgram: mintB.programAddress
|
|
12347
13135
|
}))[0];
|
|
12348
|
-
const vaultAAta = (await
|
|
13136
|
+
const vaultAAta = (await findAssociatedTokenPda25({
|
|
12349
13137
|
owner: vaultA.address,
|
|
12350
13138
|
mint: mintA.address,
|
|
12351
13139
|
tokenProgram: mintA.programAddress
|
|
12352
13140
|
}))[0];
|
|
12353
|
-
const vaultBAta = (await
|
|
13141
|
+
const vaultBAta = (await findAssociatedTokenPda25({
|
|
12354
13142
|
owner: vaultB.address,
|
|
12355
13143
|
mint: mintB.address,
|
|
12356
13144
|
tokenProgram: mintB.programAddress
|
|
12357
13145
|
}))[0];
|
|
12358
|
-
const feeRecipientAtaA = (await
|
|
13146
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda25({
|
|
12359
13147
|
owner: tunaConfig.data.feeRecipient,
|
|
12360
13148
|
mint: mintA.address,
|
|
12361
13149
|
tokenProgram: mintA.programAddress
|
|
12362
13150
|
}))[0];
|
|
12363
|
-
const feeRecipientAtaB = (await
|
|
13151
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda25({
|
|
12364
13152
|
owner: tunaConfig.data.feeRecipient,
|
|
12365
13153
|
mint: mintB.address,
|
|
12366
13154
|
tokenProgram: mintB.programAddress
|
|
@@ -12369,15 +13157,15 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
12369
13157
|
const lowerTickArrayAddress = await FusionUtils.getTickArrayAddressFromTickIndex(fusionPool, args.tickLowerIndex);
|
|
12370
13158
|
const upperTickArrayAddress = await FusionUtils.getTickArrayAddressFromTickIndex(fusionPool, args.tickUpperIndex);
|
|
12371
13159
|
const remainingAccounts = [
|
|
12372
|
-
{ address: swapTickArrays[0], role:
|
|
12373
|
-
{ address: swapTickArrays[1], role:
|
|
12374
|
-
{ address: swapTickArrays[2], role:
|
|
12375
|
-
{ address: swapTickArrays[3], role:
|
|
12376
|
-
{ address: swapTickArrays[4], role:
|
|
12377
|
-
{ address: lowerTickArrayAddress, role:
|
|
12378
|
-
{ address: upperTickArrayAddress, role:
|
|
12379
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
12380
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
13160
|
+
{ address: swapTickArrays[0], role: AccountRole16.WRITABLE },
|
|
13161
|
+
{ address: swapTickArrays[1], role: AccountRole16.WRITABLE },
|
|
13162
|
+
{ address: swapTickArrays[2], role: AccountRole16.WRITABLE },
|
|
13163
|
+
{ address: swapTickArrays[3], role: AccountRole16.WRITABLE },
|
|
13164
|
+
{ address: swapTickArrays[4], role: AccountRole16.WRITABLE },
|
|
13165
|
+
{ address: lowerTickArrayAddress, role: AccountRole16.WRITABLE },
|
|
13166
|
+
{ address: upperTickArrayAddress, role: AccountRole16.WRITABLE },
|
|
13167
|
+
{ address: fusionPool.data.tokenVaultA, role: AccountRole16.WRITABLE },
|
|
13168
|
+
{ address: fusionPool.data.tokenVaultB, role: AccountRole16.WRITABLE }
|
|
12381
13169
|
];
|
|
12382
13170
|
const remainingAccountsInfo = {
|
|
12383
13171
|
slices: [
|
|
@@ -12414,7 +13202,7 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
12414
13202
|
fusionPosition: fusionPositionAddress,
|
|
12415
13203
|
tokenProgramA: mintA.programAddress,
|
|
12416
13204
|
tokenProgramB: mintB.programAddress,
|
|
12417
|
-
memoProgram:
|
|
13205
|
+
memoProgram: MEMO_PROGRAM_ADDRESS16,
|
|
12418
13206
|
metadataUpdateAuth: FP_NFT_UPDATE_AUTH2,
|
|
12419
13207
|
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ADDRESS4,
|
|
12420
13208
|
token2022Program: TOKEN_2022_PROGRAM_ADDRESS16,
|
|
@@ -12429,40 +13217,40 @@ async function openAndIncreaseTunaLpPositionFusionInstruction(authority, positio
|
|
|
12429
13217
|
import { FUSIONAMM_PROGRAM_ADDRESS as FUSIONAMM_PROGRAM_ADDRESS11, getFusionPoolDecoder } from "@crypticdot/fusionamm-client";
|
|
12430
13218
|
import { getWhirlpoolDecoder, WHIRLPOOL_PROGRAM_ADDRESS as WHIRLPOOL_PROGRAM_ADDRESS11 } from "@orca-so/whirlpools-client";
|
|
12431
13219
|
import {
|
|
12432
|
-
decodeAccount as
|
|
12433
|
-
fetchEncodedAccount as
|
|
13220
|
+
decodeAccount as decodeAccount8,
|
|
13221
|
+
fetchEncodedAccount as fetchEncodedAccount8
|
|
12434
13222
|
} from "@solana/kit";
|
|
12435
13223
|
import {
|
|
12436
13224
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS as ASSOCIATED_TOKEN_PROGRAM_ADDRESS5,
|
|
12437
|
-
fetchAllMaybeMint as
|
|
12438
|
-
findAssociatedTokenPda as
|
|
13225
|
+
fetchAllMaybeMint as fetchAllMaybeMint19,
|
|
13226
|
+
findAssociatedTokenPda as findAssociatedTokenPda26
|
|
12439
13227
|
} from "@solana-program/token-2022";
|
|
12440
|
-
import
|
|
13228
|
+
import assert19 from "assert";
|
|
12441
13229
|
async function openTunaSpotPositionInstructions(rpc, authority, poolAddress, args) {
|
|
12442
|
-
const poolAccount = await
|
|
12443
|
-
|
|
13230
|
+
const poolAccount = await fetchEncodedAccount8(rpc, poolAddress);
|
|
13231
|
+
assert19(poolAccount.exists, "Pool account not found");
|
|
12444
13232
|
let pool;
|
|
12445
13233
|
if (poolAccount.programAddress == FUSIONAMM_PROGRAM_ADDRESS11) {
|
|
12446
|
-
pool =
|
|
13234
|
+
pool = decodeAccount8(poolAccount, getFusionPoolDecoder());
|
|
12447
13235
|
} else if (poolAccount.programAddress == WHIRLPOOL_PROGRAM_ADDRESS11) {
|
|
12448
|
-
pool =
|
|
13236
|
+
pool = decodeAccount8(poolAccount, getWhirlpoolDecoder());
|
|
12449
13237
|
} else {
|
|
12450
13238
|
throw new Error("Incorrect Fusion or Orca pool account");
|
|
12451
13239
|
}
|
|
12452
|
-
const [mintA, mintB] = await
|
|
12453
|
-
|
|
12454
|
-
|
|
13240
|
+
const [mintA, mintB] = await fetchAllMaybeMint19(rpc, [pool.data.tokenMintA, pool.data.tokenMintB]);
|
|
13241
|
+
assert19(mintA.exists, "Token A account not found");
|
|
13242
|
+
assert19(mintB.exists, "Token B account not found");
|
|
12455
13243
|
const ix = await openTunaSpotPositionInstruction(authority, mintA, mintB, poolAddress, args);
|
|
12456
13244
|
return [ix];
|
|
12457
13245
|
}
|
|
12458
13246
|
async function openTunaSpotPositionInstruction(authority, mintA, mintB, poolAddress, args) {
|
|
12459
13247
|
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
12460
|
-
const tunaPositionAtaA = (await
|
|
13248
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda26({
|
|
12461
13249
|
owner: tunaPositionAddress,
|
|
12462
13250
|
mint: mintA.address,
|
|
12463
13251
|
tokenProgram: mintA.programAddress
|
|
12464
13252
|
}))[0];
|
|
12465
|
-
const tunaPositionAtaB = (await
|
|
13253
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda26({
|
|
12466
13254
|
owner: tunaPositionAddress,
|
|
12467
13255
|
mint: mintB.address,
|
|
12468
13256
|
tokenProgram: mintB.programAddress
|
|
@@ -12494,16 +13282,16 @@ import {
|
|
|
12494
13282
|
} from "@orca-so/whirlpools-client";
|
|
12495
13283
|
import { collectRewardsQuote as collectRewardsQuote2, getTickArrayStartTickIndex as getTickArrayStartTickIndex8, getTickIndexInArray as getTickIndexInArray2 } from "@orca-so/whirlpools-core";
|
|
12496
13284
|
import {
|
|
12497
|
-
AccountRole as
|
|
12498
|
-
assertAccountsExist as
|
|
13285
|
+
AccountRole as AccountRole17,
|
|
13286
|
+
assertAccountsExist as assertAccountsExist9
|
|
12499
13287
|
} from "@solana/kit";
|
|
12500
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
13288
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS17 } from "@solana-program/memo";
|
|
12501
13289
|
import {
|
|
12502
|
-
fetchAllMaybeMint as
|
|
12503
|
-
findAssociatedTokenPda as
|
|
13290
|
+
fetchAllMaybeMint as fetchAllMaybeMint20,
|
|
13291
|
+
findAssociatedTokenPda as findAssociatedTokenPda27,
|
|
12504
13292
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS17
|
|
12505
13293
|
} from "@solana-program/token-2022";
|
|
12506
|
-
import
|
|
13294
|
+
import assert20 from "assert";
|
|
12507
13295
|
async function decreaseTunaLpPositionOrcaInstructions(rpc, authority, positionMint, args, createInstructions, cleanupInstructions) {
|
|
12508
13296
|
const tunaPosition = await fetchMaybeTunaLpPosition(rpc, (await getTunaLpPositionAddress(positionMint))[0]);
|
|
12509
13297
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
@@ -12514,15 +13302,15 @@ async function decreaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
|
|
|
12514
13302
|
(await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
|
|
12515
13303
|
(await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
|
|
12516
13304
|
]);
|
|
12517
|
-
const [mintA, mintB, ...rewardMints] = await
|
|
13305
|
+
const [mintA, mintB, ...rewardMints] = await fetchAllMaybeMint20(rpc, [
|
|
12518
13306
|
whirlpool.data.tokenMintA,
|
|
12519
13307
|
whirlpool.data.tokenMintB,
|
|
12520
13308
|
...whirlpool.data.rewardInfos.map((x) => x.mint).filter((x) => x !== DEFAULT_ADDRESS)
|
|
12521
13309
|
]);
|
|
12522
13310
|
const allMints = [mintA, mintB, ...rewardMints];
|
|
12523
|
-
|
|
12524
|
-
|
|
12525
|
-
|
|
13311
|
+
assert20(mintA.exists, "Token A account not found");
|
|
13312
|
+
assert20(mintB.exists, "Token B account not found");
|
|
13313
|
+
assertAccountsExist9(rewardMints);
|
|
12526
13314
|
const lowerTickArrayStartIndex = getTickArrayStartTickIndex8(
|
|
12527
13315
|
tunaPosition.data.tickLowerIndex,
|
|
12528
13316
|
whirlpool.data.tickSpacing
|
|
@@ -12562,7 +13350,7 @@ async function decreaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
|
|
|
12562
13350
|
}
|
|
12563
13351
|
for (const mintAddress of requiredMints) {
|
|
12564
13352
|
const mint = allMints.find((mint2) => mint2.address == mintAddress);
|
|
12565
|
-
|
|
13353
|
+
assert20(mint && mint.exists);
|
|
12566
13354
|
const ixs = await getCreateAtaInstructions(rpc, authority, mint.address, authority.address, mint.programAddress);
|
|
12567
13355
|
createInstructions.push(...ixs.init);
|
|
12568
13356
|
internalCleanupInstructions.push(...ixs.cleanup);
|
|
@@ -12590,37 +13378,37 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
12590
13378
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
12591
13379
|
const orcaPositionAddress = (await getPositionAddress17(positionMint))[0];
|
|
12592
13380
|
const orcaOracleAddress = (await getOracleAddress7(whirlpool.address))[0];
|
|
12593
|
-
const tunaPositionAta = (await
|
|
13381
|
+
const tunaPositionAta = (await findAssociatedTokenPda27({
|
|
12594
13382
|
owner: tunaPosition.address,
|
|
12595
13383
|
mint: positionMint,
|
|
12596
13384
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS17
|
|
12597
13385
|
}))[0];
|
|
12598
|
-
const tunaPositionOwnerAtaA = (await
|
|
13386
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda27({
|
|
12599
13387
|
owner: authority.address,
|
|
12600
13388
|
mint: mintA.address,
|
|
12601
13389
|
tokenProgram: mintA.programAddress
|
|
12602
13390
|
}))[0];
|
|
12603
|
-
const tunaPositionOwnerAtaB = (await
|
|
13391
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda27({
|
|
12604
13392
|
owner: authority.address,
|
|
12605
13393
|
mint: mintB.address,
|
|
12606
13394
|
tokenProgram: mintB.programAddress
|
|
12607
13395
|
}))[0];
|
|
12608
|
-
const tunaPositionAtaA = (await
|
|
13396
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda27({
|
|
12609
13397
|
owner: tunaPosition.address,
|
|
12610
13398
|
mint: mintA.address,
|
|
12611
13399
|
tokenProgram: mintA.programAddress
|
|
12612
13400
|
}))[0];
|
|
12613
|
-
const tunaPositionAtaB = (await
|
|
13401
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda27({
|
|
12614
13402
|
owner: tunaPosition.address,
|
|
12615
13403
|
mint: mintB.address,
|
|
12616
13404
|
tokenProgram: mintB.programAddress
|
|
12617
13405
|
}))[0];
|
|
12618
|
-
const vaultAAta = (await
|
|
13406
|
+
const vaultAAta = (await findAssociatedTokenPda27({
|
|
12619
13407
|
owner: vaultA.address,
|
|
12620
13408
|
mint: mintA.address,
|
|
12621
13409
|
tokenProgram: mintA.programAddress
|
|
12622
13410
|
}))[0];
|
|
12623
|
-
const vaultBAta = (await
|
|
13411
|
+
const vaultBAta = (await findAssociatedTokenPda27({
|
|
12624
13412
|
owner: vaultB.address,
|
|
12625
13413
|
mint: mintB.address,
|
|
12626
13414
|
tokenProgram: mintB.programAddress
|
|
@@ -12635,30 +13423,30 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
12635
13423
|
tunaPosition.data.tickUpperIndex
|
|
12636
13424
|
);
|
|
12637
13425
|
const remainingAccounts = [
|
|
12638
|
-
{ address: swapTickArrays[0], role:
|
|
12639
|
-
{ address: swapTickArrays[1], role:
|
|
12640
|
-
{ address: swapTickArrays[2], role:
|
|
12641
|
-
{ address: swapTickArrays[3], role:
|
|
12642
|
-
{ address: swapTickArrays[4], role:
|
|
12643
|
-
{ address: lowerTickArrayAddress, role:
|
|
12644
|
-
{ address: upperTickArrayAddress, role:
|
|
12645
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
12646
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
12647
|
-
{ address: orcaOracleAddress, role:
|
|
13426
|
+
{ address: swapTickArrays[0], role: AccountRole17.WRITABLE },
|
|
13427
|
+
{ address: swapTickArrays[1], role: AccountRole17.WRITABLE },
|
|
13428
|
+
{ address: swapTickArrays[2], role: AccountRole17.WRITABLE },
|
|
13429
|
+
{ address: swapTickArrays[3], role: AccountRole17.WRITABLE },
|
|
13430
|
+
{ address: swapTickArrays[4], role: AccountRole17.WRITABLE },
|
|
13431
|
+
{ address: lowerTickArrayAddress, role: AccountRole17.WRITABLE },
|
|
13432
|
+
{ address: upperTickArrayAddress, role: AccountRole17.WRITABLE },
|
|
13433
|
+
{ address: whirlpool.data.tokenVaultA, role: AccountRole17.WRITABLE },
|
|
13434
|
+
{ address: whirlpool.data.tokenVaultB, role: AccountRole17.WRITABLE },
|
|
13435
|
+
{ address: orcaOracleAddress, role: AccountRole17.WRITABLE }
|
|
12648
13436
|
];
|
|
12649
13437
|
for (const rewardIndex of rewardIndicesToClaim) {
|
|
12650
13438
|
const rewardInfo = whirlpool.data.rewardInfos[rewardIndex];
|
|
12651
13439
|
const rewardMint = rewardMints.find((mint) => mint.address == rewardInfo.mint);
|
|
12652
|
-
|
|
12653
|
-
const ownerAta = await
|
|
13440
|
+
assert20(rewardMint, "Reward mint not found in the provided reward mint accounts");
|
|
13441
|
+
const ownerAta = await findAssociatedTokenPda27({
|
|
12654
13442
|
owner: authority.address,
|
|
12655
13443
|
mint: rewardMint.address,
|
|
12656
13444
|
tokenProgram: rewardMint.programAddress
|
|
12657
13445
|
});
|
|
12658
|
-
remainingAccounts.push({ address: rewardMint.address, role:
|
|
12659
|
-
remainingAccounts.push({ address: rewardMint.programAddress, role:
|
|
12660
|
-
remainingAccounts.push({ address: ownerAta[0], role:
|
|
12661
|
-
remainingAccounts.push({ address: rewardInfo.vault, role:
|
|
13446
|
+
remainingAccounts.push({ address: rewardMint.address, role: AccountRole17.READONLY });
|
|
13447
|
+
remainingAccounts.push({ address: rewardMint.programAddress, role: AccountRole17.READONLY });
|
|
13448
|
+
remainingAccounts.push({ address: ownerAta[0], role: AccountRole17.WRITABLE });
|
|
13449
|
+
remainingAccounts.push({ address: rewardInfo.vault, role: AccountRole17.WRITABLE });
|
|
12662
13450
|
}
|
|
12663
13451
|
const remainingAccountsInfo = {
|
|
12664
13452
|
slices: [
|
|
@@ -12696,7 +13484,7 @@ async function decreaseTunaLpPositionOrcaInstruction(authority, tunaPosition, mi
|
|
|
12696
13484
|
whirlpoolProgram: WHIRLPOOL_PROGRAM_ADDRESS12,
|
|
12697
13485
|
tokenProgramA: mintA.programAddress,
|
|
12698
13486
|
tokenProgramB: mintB.programAddress,
|
|
12699
|
-
memoProgram:
|
|
13487
|
+
memoProgram: MEMO_PROGRAM_ADDRESS17,
|
|
12700
13488
|
...args,
|
|
12701
13489
|
remainingAccountsInfo
|
|
12702
13490
|
});
|
|
@@ -12711,15 +13499,15 @@ import {
|
|
|
12711
13499
|
getPositionAddress as getPositionAddress18
|
|
12712
13500
|
} from "@crypticdot/fusionamm-client";
|
|
12713
13501
|
import {
|
|
12714
|
-
AccountRole as
|
|
13502
|
+
AccountRole as AccountRole18
|
|
12715
13503
|
} from "@solana/kit";
|
|
12716
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
13504
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS18 } from "@solana-program/memo";
|
|
12717
13505
|
import {
|
|
12718
|
-
fetchAllMaybeMint as
|
|
12719
|
-
findAssociatedTokenPda as
|
|
13506
|
+
fetchAllMaybeMint as fetchAllMaybeMint21,
|
|
13507
|
+
findAssociatedTokenPda as findAssociatedTokenPda28,
|
|
12720
13508
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS18
|
|
12721
13509
|
} from "@solana-program/token-2022";
|
|
12722
|
-
import
|
|
13510
|
+
import assert21 from "assert";
|
|
12723
13511
|
async function decreaseTunaLpPositionFusionInstructions(rpc, authority, positionMint, args, createInstructions, cleanupInstructions) {
|
|
12724
13512
|
const tunaPosition = await fetchMaybeTunaLpPosition(rpc, (await getTunaLpPositionAddress(positionMint))[0]);
|
|
12725
13513
|
if (!tunaPosition.exists) throw new Error("Tuna position account not found");
|
|
@@ -12729,9 +13517,9 @@ async function decreaseTunaLpPositionFusionInstructions(rpc, authority, position
|
|
|
12729
13517
|
(await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
|
|
12730
13518
|
(await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
|
|
12731
13519
|
]);
|
|
12732
|
-
const [mintA, mintB] = await
|
|
12733
|
-
|
|
12734
|
-
|
|
13520
|
+
const [mintA, mintB] = await fetchAllMaybeMint21(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
13521
|
+
assert21(mintA.exists, "Token A account not found");
|
|
13522
|
+
assert21(mintB.exists, "Token B account not found");
|
|
12735
13523
|
const instructions = [];
|
|
12736
13524
|
if (!createInstructions) createInstructions = instructions;
|
|
12737
13525
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
@@ -12772,37 +13560,37 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
12772
13560
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
12773
13561
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
12774
13562
|
const fusionPositionAddress = (await getPositionAddress18(positionMint))[0];
|
|
12775
|
-
const tunaPositionAta = (await
|
|
13563
|
+
const tunaPositionAta = (await findAssociatedTokenPda28({
|
|
12776
13564
|
owner: tunaPosition.address,
|
|
12777
13565
|
mint: positionMint,
|
|
12778
13566
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS18
|
|
12779
13567
|
}))[0];
|
|
12780
|
-
const tunaPositionOwnerAtaA = (await
|
|
13568
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda28({
|
|
12781
13569
|
owner: authority.address,
|
|
12782
13570
|
mint: mintA.address,
|
|
12783
13571
|
tokenProgram: mintA.programAddress
|
|
12784
13572
|
}))[0];
|
|
12785
|
-
const tunaPositionOwnerAtaB = (await
|
|
13573
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda28({
|
|
12786
13574
|
owner: authority.address,
|
|
12787
13575
|
mint: mintB.address,
|
|
12788
13576
|
tokenProgram: mintB.programAddress
|
|
12789
13577
|
}))[0];
|
|
12790
|
-
const tunaPositionAtaA = (await
|
|
13578
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda28({
|
|
12791
13579
|
owner: tunaPosition.address,
|
|
12792
13580
|
mint: mintA.address,
|
|
12793
13581
|
tokenProgram: mintA.programAddress
|
|
12794
13582
|
}))[0];
|
|
12795
|
-
const tunaPositionAtaB = (await
|
|
13583
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda28({
|
|
12796
13584
|
owner: tunaPosition.address,
|
|
12797
13585
|
mint: mintB.address,
|
|
12798
13586
|
tokenProgram: mintB.programAddress
|
|
12799
13587
|
}))[0];
|
|
12800
|
-
const vaultAAta = (await
|
|
13588
|
+
const vaultAAta = (await findAssociatedTokenPda28({
|
|
12801
13589
|
owner: vaultA.address,
|
|
12802
13590
|
mint: mintA.address,
|
|
12803
13591
|
tokenProgram: mintA.programAddress
|
|
12804
13592
|
}))[0];
|
|
12805
|
-
const vaultBAta = (await
|
|
13593
|
+
const vaultBAta = (await findAssociatedTokenPda28({
|
|
12806
13594
|
owner: vaultB.address,
|
|
12807
13595
|
mint: mintB.address,
|
|
12808
13596
|
tokenProgram: mintB.programAddress
|
|
@@ -12817,15 +13605,15 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
12817
13605
|
tunaPosition.data.tickUpperIndex
|
|
12818
13606
|
);
|
|
12819
13607
|
const remainingAccounts = [
|
|
12820
|
-
{ address: swapTickArrays[0], role:
|
|
12821
|
-
{ address: swapTickArrays[1], role:
|
|
12822
|
-
{ address: swapTickArrays[2], role:
|
|
12823
|
-
{ address: swapTickArrays[3], role:
|
|
12824
|
-
{ address: swapTickArrays[4], role:
|
|
12825
|
-
{ address: lowerTickArrayAddress, role:
|
|
12826
|
-
{ address: upperTickArrayAddress, role:
|
|
12827
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
12828
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
13608
|
+
{ address: swapTickArrays[0], role: AccountRole18.WRITABLE },
|
|
13609
|
+
{ address: swapTickArrays[1], role: AccountRole18.WRITABLE },
|
|
13610
|
+
{ address: swapTickArrays[2], role: AccountRole18.WRITABLE },
|
|
13611
|
+
{ address: swapTickArrays[3], role: AccountRole18.WRITABLE },
|
|
13612
|
+
{ address: swapTickArrays[4], role: AccountRole18.WRITABLE },
|
|
13613
|
+
{ address: lowerTickArrayAddress, role: AccountRole18.WRITABLE },
|
|
13614
|
+
{ address: upperTickArrayAddress, role: AccountRole18.WRITABLE },
|
|
13615
|
+
{ address: fusionPool.data.tokenVaultA, role: AccountRole18.WRITABLE },
|
|
13616
|
+
{ address: fusionPool.data.tokenVaultB, role: AccountRole18.WRITABLE }
|
|
12829
13617
|
];
|
|
12830
13618
|
const remainingAccountsInfo = {
|
|
12831
13619
|
slices: [
|
|
@@ -12859,7 +13647,7 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
12859
13647
|
fusionammProgram: FUSIONAMM_PROGRAM_ADDRESS12,
|
|
12860
13648
|
tokenProgramA: mintA.programAddress,
|
|
12861
13649
|
tokenProgramB: mintB.programAddress,
|
|
12862
|
-
memoProgram:
|
|
13650
|
+
memoProgram: MEMO_PROGRAM_ADDRESS18,
|
|
12863
13651
|
...args,
|
|
12864
13652
|
remainingAccountsInfo
|
|
12865
13653
|
});
|
|
@@ -12868,19 +13656,19 @@ async function decreaseTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
12868
13656
|
}
|
|
12869
13657
|
|
|
12870
13658
|
// src/txbuilder/repayBadDebt.ts
|
|
12871
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
12872
|
-
import { fetchMaybeMint as fetchMaybeMint2, findAssociatedTokenPda as
|
|
13659
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS19 } from "@solana-program/memo";
|
|
13660
|
+
import { fetchMaybeMint as fetchMaybeMint2, findAssociatedTokenPda as findAssociatedTokenPda29 } from "@solana-program/token-2022";
|
|
12873
13661
|
async function repayBadDebtInstruction(rpc, authority, mintAddress, funds, shares) {
|
|
12874
13662
|
const mint = await fetchMaybeMint2(rpc, mintAddress);
|
|
12875
13663
|
if (!mint.exists) throw new Error("Mint account not found");
|
|
12876
13664
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
12877
13665
|
const vault = (await getLendingVaultAddress(mint.address))[0];
|
|
12878
|
-
const vaultAta = (await
|
|
13666
|
+
const vaultAta = (await findAssociatedTokenPda29({
|
|
12879
13667
|
owner: vault,
|
|
12880
13668
|
mint: mint.address,
|
|
12881
13669
|
tokenProgram: mint.programAddress
|
|
12882
13670
|
}))[0];
|
|
12883
|
-
const authorityAta = (await
|
|
13671
|
+
const authorityAta = (await findAssociatedTokenPda29({
|
|
12884
13672
|
owner: authority.address,
|
|
12885
13673
|
mint: mint.address,
|
|
12886
13674
|
tokenProgram: mint.programAddress
|
|
@@ -12893,7 +13681,7 @@ async function repayBadDebtInstruction(rpc, authority, mintAddress, funds, share
|
|
|
12893
13681
|
tunaConfig,
|
|
12894
13682
|
vault,
|
|
12895
13683
|
tokenProgram: mint.programAddress,
|
|
12896
|
-
memoProgram:
|
|
13684
|
+
memoProgram: MEMO_PROGRAM_ADDRESS19,
|
|
12897
13685
|
funds,
|
|
12898
13686
|
shares
|
|
12899
13687
|
});
|
|
@@ -12925,20 +13713,20 @@ async function setTunaSpotPositionLimitOrdersInstruction(authority, poolAddress,
|
|
|
12925
13713
|
}
|
|
12926
13714
|
|
|
12927
13715
|
// src/txbuilder/resetTunaSpotPosition.ts
|
|
12928
|
-
import { fetchAllMaybeMint as
|
|
12929
|
-
import
|
|
13716
|
+
import { fetchAllMaybeMint as fetchAllMaybeMint22, findAssociatedTokenPda as findAssociatedTokenPda30 } from "@solana-program/token-2022";
|
|
13717
|
+
import assert22 from "assert";
|
|
12930
13718
|
async function resetTunaSpotPositionInstruction(rpc, authority, poolAddress, args) {
|
|
12931
13719
|
const tunaPositionAddress = (await getTunaSpotPositionAddress(authority.address, poolAddress))[0];
|
|
12932
13720
|
const tunaPosition = await fetchTunaSpotPosition(rpc, tunaPositionAddress);
|
|
12933
|
-
const [mintA, mintB] = await
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
const tunaPositionAtaA = (await
|
|
13721
|
+
const [mintA, mintB] = await fetchAllMaybeMint22(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
13722
|
+
assert22(mintA.exists, "Token A not found");
|
|
13723
|
+
assert22(mintB.exists, "Token B not found");
|
|
13724
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda30({
|
|
12937
13725
|
owner: tunaPositionAddress,
|
|
12938
13726
|
mint: mintA.address,
|
|
12939
13727
|
tokenProgram: mintA.programAddress
|
|
12940
13728
|
}))[0];
|
|
12941
|
-
const tunaPositionAtaB = (await
|
|
13729
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda30({
|
|
12942
13730
|
owner: tunaPositionAddress,
|
|
12943
13731
|
mint: mintB.address,
|
|
12944
13732
|
tokenProgram: mintB.programAddress
|
|
@@ -12979,8 +13767,8 @@ async function updateVaultInstruction(authority, mint, args) {
|
|
|
12979
13767
|
}
|
|
12980
13768
|
|
|
12981
13769
|
// src/txbuilder/withdraw.ts
|
|
12982
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
12983
|
-
import { fetchMaybeMint as fetchMaybeMint3, findAssociatedTokenPda as
|
|
13770
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS20 } from "@solana-program/memo";
|
|
13771
|
+
import { fetchMaybeMint as fetchMaybeMint3, findAssociatedTokenPda as findAssociatedTokenPda31 } from "@solana-program/token-2022";
|
|
12984
13772
|
async function withdrawInstructions(rpc, authority, mintAddress, funds, shares) {
|
|
12985
13773
|
const instructions = [];
|
|
12986
13774
|
const mint = await fetchMaybeMint3(rpc, mintAddress);
|
|
@@ -13002,12 +13790,12 @@ async function withdrawInstruction(authority, mint, funds, shares) {
|
|
|
13002
13790
|
const tunaConfig = (await getTunaConfigAddress())[0];
|
|
13003
13791
|
const lendingPosition = (await getLendingPositionAddress(authority.address, mint.address))[0];
|
|
13004
13792
|
const vault = (await getLendingVaultAddress(mint.address))[0];
|
|
13005
|
-
const vaultAta = (await
|
|
13793
|
+
const vaultAta = (await findAssociatedTokenPda31({
|
|
13006
13794
|
owner: vault,
|
|
13007
13795
|
mint: mint.address,
|
|
13008
13796
|
tokenProgram: mint.programAddress
|
|
13009
13797
|
}))[0];
|
|
13010
|
-
const authorityAta = (await
|
|
13798
|
+
const authorityAta = (await findAssociatedTokenPda31({
|
|
13011
13799
|
owner: authority.address,
|
|
13012
13800
|
mint: mint.address,
|
|
13013
13801
|
tokenProgram: mint.programAddress
|
|
@@ -13021,26 +13809,26 @@ async function withdrawInstruction(authority, mint, funds, shares) {
|
|
|
13021
13809
|
vault,
|
|
13022
13810
|
vaultAta,
|
|
13023
13811
|
tokenProgram: mint.programAddress,
|
|
13024
|
-
memoProgram:
|
|
13812
|
+
memoProgram: MEMO_PROGRAM_ADDRESS20,
|
|
13025
13813
|
funds,
|
|
13026
13814
|
shares
|
|
13027
13815
|
});
|
|
13028
13816
|
}
|
|
13029
13817
|
|
|
13030
13818
|
// src/txbuilder/createMarketLookupTable.ts
|
|
13031
|
-
import { fetchFusionPool as
|
|
13032
|
-
import { fetchWhirlpool as
|
|
13819
|
+
import { fetchFusionPool as fetchFusionPool3, FP_NFT_UPDATE_AUTH as FP_NFT_UPDATE_AUTH3, FUSIONAMM_PROGRAM_ADDRESS as FUSIONAMM_PROGRAM_ADDRESS13 } from "@crypticdot/fusionamm-client";
|
|
13820
|
+
import { fetchWhirlpool as fetchWhirlpool3, getOracleAddress as getOracleAddress8, WHIRLPOOL_PROGRAM_ADDRESS as WHIRLPOOL_PROGRAM_ADDRESS13 } from "@orca-so/whirlpools-client";
|
|
13033
13821
|
import {
|
|
13034
13822
|
address as address3
|
|
13035
13823
|
} from "@solana/kit";
|
|
13036
13824
|
import { fetchAddressLookupTable, getExtendLookupTableInstruction as getExtendLookupTableInstruction2 } from "@solana-program/address-lookup-table";
|
|
13037
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
13825
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS21 } from "@solana-program/memo";
|
|
13038
13826
|
import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system";
|
|
13039
13827
|
import { TOKEN_PROGRAM_ADDRESS as TOKEN_PROGRAM_ADDRESS2 } from "@solana-program/token";
|
|
13040
13828
|
import {
|
|
13041
13829
|
ASSOCIATED_TOKEN_PROGRAM_ADDRESS as ASSOCIATED_TOKEN_PROGRAM_ADDRESS6,
|
|
13042
13830
|
fetchMint,
|
|
13043
|
-
findAssociatedTokenPda as
|
|
13831
|
+
findAssociatedTokenPda as findAssociatedTokenPda32,
|
|
13044
13832
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS19
|
|
13045
13833
|
} from "@solana-program/token-2022";
|
|
13046
13834
|
async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
@@ -13048,15 +13836,15 @@ async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
|
13048
13836
|
const marketAddress = (await getMarketAddress(poolAddress))[0];
|
|
13049
13837
|
const orcaOracleAddress = (await getOracleAddress8(poolAddress))[0];
|
|
13050
13838
|
const tunaConfig = await fetchTunaConfig(rpc, tunaConfigAddress);
|
|
13051
|
-
const pool = marketMaker == 0 /* Orca */ ? await
|
|
13839
|
+
const pool = marketMaker == 0 /* Orca */ ? await fetchWhirlpool3(rpc, poolAddress) : await fetchFusionPool3(rpc, poolAddress);
|
|
13052
13840
|
const mintA = await fetchMint(rpc, pool.data.tokenMintA);
|
|
13053
13841
|
const mintB = await fetchMint(rpc, pool.data.tokenMintB);
|
|
13054
|
-
const feeRecipientAtaA = (await
|
|
13842
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda32({
|
|
13055
13843
|
owner: tunaConfig.data.feeRecipient,
|
|
13056
13844
|
mint: mintA.address,
|
|
13057
13845
|
tokenProgram: mintA.programAddress
|
|
13058
13846
|
}))[0];
|
|
13059
|
-
const feeRecipientAtaB = (await
|
|
13847
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda32({
|
|
13060
13848
|
owner: tunaConfig.data.feeRecipient,
|
|
13061
13849
|
mint: mintB.address,
|
|
13062
13850
|
tokenProgram: mintB.programAddress
|
|
@@ -13065,12 +13853,12 @@ async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
|
13065
13853
|
(await getLendingVaultAddress(mintA.address))[0],
|
|
13066
13854
|
(await getLendingVaultAddress(mintB.address))[0]
|
|
13067
13855
|
]);
|
|
13068
|
-
const vaultAAta = (await
|
|
13856
|
+
const vaultAAta = (await findAssociatedTokenPda32({
|
|
13069
13857
|
owner: vaultA.address,
|
|
13070
13858
|
mint: mintA.address,
|
|
13071
13859
|
tokenProgram: mintA.programAddress
|
|
13072
13860
|
}))[0];
|
|
13073
|
-
const vaultBAta = (await
|
|
13861
|
+
const vaultBAta = (await findAssociatedTokenPda32({
|
|
13074
13862
|
owner: vaultB.address,
|
|
13075
13863
|
mint: mintB.address,
|
|
13076
13864
|
tokenProgram: mintB.programAddress
|
|
@@ -13082,7 +13870,7 @@ async function getAddressesForMarketLookupTable(rpc, poolAddress, marketMaker) {
|
|
|
13082
13870
|
TOKEN_PROGRAM_ADDRESS2,
|
|
13083
13871
|
TOKEN_2022_PROGRAM_ADDRESS19,
|
|
13084
13872
|
NATIVE_MINT,
|
|
13085
|
-
|
|
13873
|
+
MEMO_PROGRAM_ADDRESS21,
|
|
13086
13874
|
tunaConfigAddress,
|
|
13087
13875
|
marketAddress,
|
|
13088
13876
|
mintA.address,
|
|
@@ -13137,17 +13925,17 @@ async function extendAddressLookupTableForMarketInstructions(rpc, poolAddress, m
|
|
|
13137
13925
|
}
|
|
13138
13926
|
|
|
13139
13927
|
// src/txbuilder/repayTunaLpPositionDebt.ts
|
|
13140
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
13141
|
-
import { fetchAllMaybeMint as
|
|
13142
|
-
import
|
|
13928
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS22 } from "@solana-program/memo";
|
|
13929
|
+
import { fetchAllMaybeMint as fetchAllMaybeMint23, findAssociatedTokenPda as findAssociatedTokenPda33 } from "@solana-program/token-2022";
|
|
13930
|
+
import assert23 from "assert";
|
|
13143
13931
|
async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint, collateralA, collateralB, createInstructions, cleanupInstructions) {
|
|
13144
13932
|
const instructions = [];
|
|
13145
13933
|
if (!createInstructions) createInstructions = instructions;
|
|
13146
13934
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
13147
13935
|
const tunaPosition = await fetchTunaLpPosition(rpc, (await getTunaLpPositionAddress(positionMint))[0]);
|
|
13148
|
-
const [mintA, mintB] = await
|
|
13149
|
-
|
|
13150
|
-
|
|
13936
|
+
const [mintA, mintB] = await fetchAllMaybeMint23(rpc, [tunaPosition.data.mintA, tunaPosition.data.mintB]);
|
|
13937
|
+
assert23(mintA.exists, "Token A not found");
|
|
13938
|
+
assert23(mintB.exists, "Token B not found");
|
|
13151
13939
|
const marketAddress = (await getMarketAddress(tunaPosition.data.pool))[0];
|
|
13152
13940
|
const createUserAtaAInstructions = await getCreateAtaInstructions(
|
|
13153
13941
|
rpc,
|
|
@@ -13183,34 +13971,34 @@ async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint,
|
|
|
13183
13971
|
}
|
|
13184
13972
|
async function repayTunaLpPositionDebtInstruction(authority, positionMint, mintA, mintB, marketAddress, collateralA, collateralB) {
|
|
13185
13973
|
const tunaPositionAddress = (await getTunaLpPositionAddress(positionMint))[0];
|
|
13186
|
-
const tunaPositionOwnerAtaA = (await
|
|
13974
|
+
const tunaPositionOwnerAtaA = (await findAssociatedTokenPda33({
|
|
13187
13975
|
owner: authority.address,
|
|
13188
13976
|
mint: mintA.address,
|
|
13189
13977
|
tokenProgram: mintA.programAddress
|
|
13190
13978
|
}))[0];
|
|
13191
|
-
const tunaPositionOwnerAtaB = (await
|
|
13979
|
+
const tunaPositionOwnerAtaB = (await findAssociatedTokenPda33({
|
|
13192
13980
|
owner: authority.address,
|
|
13193
13981
|
mint: mintB.address,
|
|
13194
13982
|
tokenProgram: mintB.programAddress
|
|
13195
13983
|
}))[0];
|
|
13196
|
-
const tunaPositionAtaA = (await
|
|
13984
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda33({
|
|
13197
13985
|
owner: tunaPositionAddress,
|
|
13198
13986
|
mint: mintA.address,
|
|
13199
13987
|
tokenProgram: mintA.programAddress
|
|
13200
13988
|
}))[0];
|
|
13201
|
-
const tunaPositionAtaB = (await
|
|
13989
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda33({
|
|
13202
13990
|
owner: tunaPositionAddress,
|
|
13203
13991
|
mint: mintB.address,
|
|
13204
13992
|
tokenProgram: mintB.programAddress
|
|
13205
13993
|
}))[0];
|
|
13206
13994
|
const vaultAAddress = (await getLendingVaultAddress(mintA.address))[0];
|
|
13207
|
-
const vaultAAta = (await
|
|
13995
|
+
const vaultAAta = (await findAssociatedTokenPda33({
|
|
13208
13996
|
owner: vaultAAddress,
|
|
13209
13997
|
mint: mintA.address,
|
|
13210
13998
|
tokenProgram: mintA.programAddress
|
|
13211
13999
|
}))[0];
|
|
13212
14000
|
const vaultBAddress = (await getLendingVaultAddress(mintB.address))[0];
|
|
13213
|
-
const vaultBAta = (await
|
|
14001
|
+
const vaultBAta = (await findAssociatedTokenPda33({
|
|
13214
14002
|
owner: vaultBAddress,
|
|
13215
14003
|
mint: mintB.address,
|
|
13216
14004
|
tokenProgram: mintB.programAddress
|
|
@@ -13218,7 +14006,7 @@ async function repayTunaLpPositionDebtInstruction(authority, positionMint, mintA
|
|
|
13218
14006
|
return getRepayTunaLpPositionDebtInstruction({
|
|
13219
14007
|
authority,
|
|
13220
14008
|
market: marketAddress,
|
|
13221
|
-
memoProgram:
|
|
14009
|
+
memoProgram: MEMO_PROGRAM_ADDRESS22,
|
|
13222
14010
|
mintA: mintA.address,
|
|
13223
14011
|
mintB: mintB.address,
|
|
13224
14012
|
tokenProgramA: mintA.programAddress,
|
|
@@ -13248,17 +14036,17 @@ import {
|
|
|
13248
14036
|
WHIRLPOOL_PROGRAM_ADDRESS as WHIRLPOOL_PROGRAM_ADDRESS14
|
|
13249
14037
|
} from "@orca-so/whirlpools-client";
|
|
13250
14038
|
import {
|
|
13251
|
-
AccountRole as
|
|
14039
|
+
AccountRole as AccountRole19,
|
|
13252
14040
|
lamports as lamports3
|
|
13253
14041
|
} from "@solana/kit";
|
|
13254
14042
|
import { fetchSysvarRent as fetchSysvarRent3 } from "@solana/sysvars";
|
|
13255
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
14043
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS23 } from "@solana-program/memo";
|
|
13256
14044
|
import {
|
|
13257
|
-
fetchAllMaybeMint as
|
|
13258
|
-
findAssociatedTokenPda as
|
|
14045
|
+
fetchAllMaybeMint as fetchAllMaybeMint24,
|
|
14046
|
+
findAssociatedTokenPda as findAssociatedTokenPda34,
|
|
13259
14047
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS20
|
|
13260
14048
|
} from "@solana-program/token-2022";
|
|
13261
|
-
import
|
|
14049
|
+
import assert24 from "assert";
|
|
13262
14050
|
async function rebalanceTunaLpPositionOrcaInstructions(rpc, authority, positionMint, createInstructions, cleanupInstructions) {
|
|
13263
14051
|
const rent = await fetchSysvarRent3(rpc);
|
|
13264
14052
|
let nonRefundableRent = 0n;
|
|
@@ -13271,9 +14059,9 @@ async function rebalanceTunaLpPositionOrcaInstructions(rpc, authority, positionM
|
|
|
13271
14059
|
(await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
|
|
13272
14060
|
(await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
|
|
13273
14061
|
]);
|
|
13274
|
-
const [mintA, mintB] = await
|
|
13275
|
-
|
|
13276
|
-
|
|
14062
|
+
const [mintA, mintB] = await fetchAllMaybeMint24(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
|
|
14063
|
+
assert24(mintA.exists, "Token A account not found");
|
|
14064
|
+
assert24(mintB.exists, "Token B account not found");
|
|
13277
14065
|
const instructions = [];
|
|
13278
14066
|
if (!createInstructions) createInstructions = instructions;
|
|
13279
14067
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
@@ -13345,27 +14133,27 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
13345
14133
|
const marketAddress = (await getMarketAddress(whirlpool.address))[0];
|
|
13346
14134
|
const orcaPositionAddress = (await getPositionAddress19(positionMint))[0];
|
|
13347
14135
|
const orcaOracleAddress = (await getOracleAddress9(whirlpool.address))[0];
|
|
13348
|
-
const tunaPositionAta = (await
|
|
14136
|
+
const tunaPositionAta = (await findAssociatedTokenPda34({
|
|
13349
14137
|
owner: tunaPosition.address,
|
|
13350
14138
|
mint: positionMint,
|
|
13351
14139
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS20
|
|
13352
14140
|
}))[0];
|
|
13353
|
-
const tunaPositionAtaA = (await
|
|
14141
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda34({
|
|
13354
14142
|
owner: tunaPosition.address,
|
|
13355
14143
|
mint: mintA.address,
|
|
13356
14144
|
tokenProgram: mintA.programAddress
|
|
13357
14145
|
}))[0];
|
|
13358
|
-
const tunaPositionAtaB = (await
|
|
14146
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda34({
|
|
13359
14147
|
owner: tunaPosition.address,
|
|
13360
14148
|
mint: mintB.address,
|
|
13361
14149
|
tokenProgram: mintB.programAddress
|
|
13362
14150
|
}))[0];
|
|
13363
|
-
const feeRecipientAtaA = (await
|
|
14151
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda34({
|
|
13364
14152
|
owner: tunaConfig.data.feeRecipient,
|
|
13365
14153
|
mint: mintA.address,
|
|
13366
14154
|
tokenProgram: mintA.programAddress
|
|
13367
14155
|
}))[0];
|
|
13368
|
-
const feeRecipientAtaB = (await
|
|
14156
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda34({
|
|
13369
14157
|
owner: tunaConfig.data.feeRecipient,
|
|
13370
14158
|
mint: mintB.address,
|
|
13371
14159
|
tokenProgram: mintB.programAddress
|
|
@@ -13381,18 +14169,18 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
13381
14169
|
);
|
|
13382
14170
|
const secondaryTickArrays = await OrcaUtils.getTickArraysForRebalancedPosition(whirlpool, tunaPosition);
|
|
13383
14171
|
const remainingAccounts = [
|
|
13384
|
-
{ address: swapTickArrays[0], role:
|
|
13385
|
-
{ address: swapTickArrays[1], role:
|
|
13386
|
-
{ address: swapTickArrays[2], role:
|
|
13387
|
-
{ address: swapTickArrays[3], role:
|
|
13388
|
-
{ address: swapTickArrays[4], role:
|
|
13389
|
-
{ address: lowerTickArrayAddress, role:
|
|
13390
|
-
{ address: upperTickArrayAddress, role:
|
|
13391
|
-
{ address: secondaryTickArrays.lowerTickArrayAddress, role:
|
|
13392
|
-
{ address: secondaryTickArrays.upperTickArrayAddress, role:
|
|
13393
|
-
{ address: whirlpool.data.tokenVaultA, role:
|
|
13394
|
-
{ address: whirlpool.data.tokenVaultB, role:
|
|
13395
|
-
{ address: orcaOracleAddress, role:
|
|
14172
|
+
{ address: swapTickArrays[0], role: AccountRole19.WRITABLE },
|
|
14173
|
+
{ address: swapTickArrays[1], role: AccountRole19.WRITABLE },
|
|
14174
|
+
{ address: swapTickArrays[2], role: AccountRole19.WRITABLE },
|
|
14175
|
+
{ address: swapTickArrays[3], role: AccountRole19.WRITABLE },
|
|
14176
|
+
{ address: swapTickArrays[4], role: AccountRole19.WRITABLE },
|
|
14177
|
+
{ address: lowerTickArrayAddress, role: AccountRole19.WRITABLE },
|
|
14178
|
+
{ address: upperTickArrayAddress, role: AccountRole19.WRITABLE },
|
|
14179
|
+
{ address: secondaryTickArrays.lowerTickArrayAddress, role: AccountRole19.WRITABLE },
|
|
14180
|
+
{ address: secondaryTickArrays.upperTickArrayAddress, role: AccountRole19.WRITABLE },
|
|
14181
|
+
{ address: whirlpool.data.tokenVaultA, role: AccountRole19.WRITABLE },
|
|
14182
|
+
{ address: whirlpool.data.tokenVaultB, role: AccountRole19.WRITABLE },
|
|
14183
|
+
{ address: orcaOracleAddress, role: AccountRole19.WRITABLE }
|
|
13396
14184
|
];
|
|
13397
14185
|
const remainingAccountsInfo = {
|
|
13398
14186
|
slices: [
|
|
@@ -13427,7 +14215,7 @@ async function rebalanceTunaLpPositionOrcaInstruction(authority, tunaPosition, t
|
|
|
13427
14215
|
whirlpoolProgram: WHIRLPOOL_PROGRAM_ADDRESS14,
|
|
13428
14216
|
tokenProgramA: mintA.programAddress,
|
|
13429
14217
|
tokenProgramB: mintB.programAddress,
|
|
13430
|
-
memoProgram:
|
|
14218
|
+
memoProgram: MEMO_PROGRAM_ADDRESS23,
|
|
13431
14219
|
remainingAccountsInfo
|
|
13432
14220
|
});
|
|
13433
14221
|
ix.accounts.push(...remainingAccounts);
|
|
@@ -13444,17 +14232,17 @@ import {
|
|
|
13444
14232
|
getTickArraySize as getTickArraySize2
|
|
13445
14233
|
} from "@crypticdot/fusionamm-client";
|
|
13446
14234
|
import {
|
|
13447
|
-
AccountRole as
|
|
14235
|
+
AccountRole as AccountRole20,
|
|
13448
14236
|
lamports as lamports4
|
|
13449
14237
|
} from "@solana/kit";
|
|
13450
14238
|
import { fetchSysvarRent as fetchSysvarRent4 } from "@solana/sysvars";
|
|
13451
|
-
import { MEMO_PROGRAM_ADDRESS as
|
|
14239
|
+
import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS24 } from "@solana-program/memo";
|
|
13452
14240
|
import {
|
|
13453
|
-
fetchAllMaybeMint as
|
|
13454
|
-
findAssociatedTokenPda as
|
|
14241
|
+
fetchAllMaybeMint as fetchAllMaybeMint25,
|
|
14242
|
+
findAssociatedTokenPda as findAssociatedTokenPda35,
|
|
13455
14243
|
TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS21
|
|
13456
14244
|
} from "@solana-program/token-2022";
|
|
13457
|
-
import
|
|
14245
|
+
import assert25 from "assert";
|
|
13458
14246
|
async function rebalanceTunaLpPositionFusionInstructions(rpc, authority, positionMint, createInstructions, cleanupInstructions) {
|
|
13459
14247
|
const rent = await fetchSysvarRent4(rpc);
|
|
13460
14248
|
let nonRefundableRent = 0n;
|
|
@@ -13467,9 +14255,9 @@ async function rebalanceTunaLpPositionFusionInstructions(rpc, authority, positio
|
|
|
13467
14255
|
(await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
|
|
13468
14256
|
(await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
|
|
13469
14257
|
]);
|
|
13470
|
-
const [mintA, mintB] = await
|
|
13471
|
-
|
|
13472
|
-
|
|
14258
|
+
const [mintA, mintB] = await fetchAllMaybeMint25(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
|
|
14259
|
+
assert25(mintA.exists, "Token A account not found");
|
|
14260
|
+
assert25(mintB.exists, "Token B account not found");
|
|
13473
14261
|
const instructions = [];
|
|
13474
14262
|
if (!createInstructions) createInstructions = instructions;
|
|
13475
14263
|
if (!cleanupInstructions) cleanupInstructions = instructions;
|
|
@@ -13536,27 +14324,27 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13536
14324
|
const positionMint = tunaPosition.data.positionMint;
|
|
13537
14325
|
const marketAddress = (await getMarketAddress(fusionPool.address))[0];
|
|
13538
14326
|
const fusionPositionAddress = (await getPositionAddress20(positionMint))[0];
|
|
13539
|
-
const tunaPositionAta = (await
|
|
14327
|
+
const tunaPositionAta = (await findAssociatedTokenPda35({
|
|
13540
14328
|
owner: tunaPosition.address,
|
|
13541
14329
|
mint: positionMint,
|
|
13542
14330
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS21
|
|
13543
14331
|
}))[0];
|
|
13544
|
-
const tunaPositionAtaA = (await
|
|
14332
|
+
const tunaPositionAtaA = (await findAssociatedTokenPda35({
|
|
13545
14333
|
owner: tunaPosition.address,
|
|
13546
14334
|
mint: mintA.address,
|
|
13547
14335
|
tokenProgram: mintA.programAddress
|
|
13548
14336
|
}))[0];
|
|
13549
|
-
const tunaPositionAtaB = (await
|
|
14337
|
+
const tunaPositionAtaB = (await findAssociatedTokenPda35({
|
|
13550
14338
|
owner: tunaPosition.address,
|
|
13551
14339
|
mint: mintB.address,
|
|
13552
14340
|
tokenProgram: mintB.programAddress
|
|
13553
14341
|
}))[0];
|
|
13554
|
-
const feeRecipientAtaA = (await
|
|
14342
|
+
const feeRecipientAtaA = (await findAssociatedTokenPda35({
|
|
13555
14343
|
owner: tunaConfig.data.feeRecipient,
|
|
13556
14344
|
mint: mintA.address,
|
|
13557
14345
|
tokenProgram: mintA.programAddress
|
|
13558
14346
|
}))[0];
|
|
13559
|
-
const feeRecipientAtaB = (await
|
|
14347
|
+
const feeRecipientAtaB = (await findAssociatedTokenPda35({
|
|
13560
14348
|
owner: tunaConfig.data.feeRecipient,
|
|
13561
14349
|
mint: mintB.address,
|
|
13562
14350
|
tokenProgram: mintB.programAddress
|
|
@@ -13572,17 +14360,17 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13572
14360
|
);
|
|
13573
14361
|
const secondaryTickArrays = await FusionUtils.getTickArraysForRebalancedPosition(fusionPool, tunaPosition);
|
|
13574
14362
|
const remainingAccounts = [
|
|
13575
|
-
{ address: swapTickArrays[0], role:
|
|
13576
|
-
{ address: swapTickArrays[1], role:
|
|
13577
|
-
{ address: swapTickArrays[2], role:
|
|
13578
|
-
{ address: swapTickArrays[3], role:
|
|
13579
|
-
{ address: swapTickArrays[4], role:
|
|
13580
|
-
{ address: lowerTickArrayAddress, role:
|
|
13581
|
-
{ address: upperTickArrayAddress, role:
|
|
13582
|
-
{ address: secondaryTickArrays.lowerTickArrayAddress, role:
|
|
13583
|
-
{ address: secondaryTickArrays.upperTickArrayAddress, role:
|
|
13584
|
-
{ address: fusionPool.data.tokenVaultA, role:
|
|
13585
|
-
{ address: fusionPool.data.tokenVaultB, role:
|
|
14363
|
+
{ address: swapTickArrays[0], role: AccountRole20.WRITABLE },
|
|
14364
|
+
{ address: swapTickArrays[1], role: AccountRole20.WRITABLE },
|
|
14365
|
+
{ address: swapTickArrays[2], role: AccountRole20.WRITABLE },
|
|
14366
|
+
{ address: swapTickArrays[3], role: AccountRole20.WRITABLE },
|
|
14367
|
+
{ address: swapTickArrays[4], role: AccountRole20.WRITABLE },
|
|
14368
|
+
{ address: lowerTickArrayAddress, role: AccountRole20.WRITABLE },
|
|
14369
|
+
{ address: upperTickArrayAddress, role: AccountRole20.WRITABLE },
|
|
14370
|
+
{ address: secondaryTickArrays.lowerTickArrayAddress, role: AccountRole20.WRITABLE },
|
|
14371
|
+
{ address: secondaryTickArrays.upperTickArrayAddress, role: AccountRole20.WRITABLE },
|
|
14372
|
+
{ address: fusionPool.data.tokenVaultA, role: AccountRole20.WRITABLE },
|
|
14373
|
+
{ address: fusionPool.data.tokenVaultB, role: AccountRole20.WRITABLE }
|
|
13586
14374
|
];
|
|
13587
14375
|
const remainingAccountsInfo = {
|
|
13588
14376
|
slices: [
|
|
@@ -13616,7 +14404,7 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
|
|
|
13616
14404
|
fusionammProgram: FUSIONAMM_PROGRAM_ADDRESS14,
|
|
13617
14405
|
tokenProgramA: mintA.programAddress,
|
|
13618
14406
|
tokenProgramB: mintB.programAddress,
|
|
13619
|
-
memoProgram:
|
|
14407
|
+
memoProgram: MEMO_PROGRAM_ADDRESS24,
|
|
13620
14408
|
remainingAccountsInfo
|
|
13621
14409
|
});
|
|
13622
14410
|
ix.accounts.push(...remainingAccounts);
|
|
@@ -14167,6 +14955,8 @@ export {
|
|
|
14167
14955
|
liquidateTunaSpotPositionOrcaInstructions,
|
|
14168
14956
|
modifyTunaSpotPositionFusionInstruction,
|
|
14169
14957
|
modifyTunaSpotPositionFusionInstructions,
|
|
14958
|
+
modifyTunaSpotPositionJupiterInstruction,
|
|
14959
|
+
modifyTunaSpotPositionJupiterInstructions,
|
|
14170
14960
|
modifyTunaSpotPositionOrcaInstruction,
|
|
14171
14961
|
modifyTunaSpotPositionOrcaInstructions,
|
|
14172
14962
|
mulDiv,
|