@hawksightco/hawk-sdk 1.3.244 → 1.3.246
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.
|
@@ -5,11 +5,18 @@ import { RaydiumIncreaseLiquidity, RaydiumOpenPosition, RaydiumDecreaseLiquidity
|
|
|
5
5
|
import { GeneralUtility } from './GeneralUtility';
|
|
6
6
|
import { MultiTransaction } from './MultiTransaction';
|
|
7
7
|
import { SimpleIxGenerator } from './SimpleIxGenerator';
|
|
8
|
+
export declare const MAX_INIT_BIN_ARRAYS_PER_TRANSACTION = 4;
|
|
9
|
+
export declare const MAX_LIMIT_CLOSE_INIT_BIN_ARRAYS = 2;
|
|
10
|
+
export declare const MAX_INIT_EXTEND_INSTRUCTIONS_PER_TRANSACTION = 10;
|
|
8
11
|
export declare function getHybridChunkOffsets(positionLowerBinId: number, chunkLowerBinId: number, chunkUpperBinId: number): {
|
|
9
12
|
chunkLowerOffset: number;
|
|
10
13
|
chunkUpperOffset: number;
|
|
11
14
|
};
|
|
12
15
|
export declare function batchHybridChunkInstructionGroups(chunkInstructionGroups: LabeledInstruction[][], chunksPerTransaction?: number): LabeledInstruction[][];
|
|
16
|
+
export declare function batchLabeledInstructionGroups(instructions: LabeledInstruction[], instructionsPerTransaction: number): LabeledInstruction[][];
|
|
17
|
+
export declare function buildWideHybridRebuildInstructionGroups(initExtendIxs: LabeledInstruction[], fullRangeBinArrayInitIxs: LabeledInstruction[], chunkInstructionGroups: LabeledInstruction[][]): LabeledInstruction[][];
|
|
18
|
+
export declare function buildLimitCloseMainInstructions(initBinArrayIxs: web3.TransactionInstruction[], closeIx: web3.TransactionInstruction): web3.TransactionInstruction[];
|
|
19
|
+
export declare function stripComputeBudgetInstructions(instructions: web3.TransactionInstruction[]): web3.TransactionInstruction[];
|
|
13
20
|
export declare function getLastHybridAmountConsumerIndexes(entries: Array<{
|
|
14
21
|
amountX: BN;
|
|
15
22
|
amountY: BN;
|
|
@@ -316,6 +323,7 @@ export declare class Transactions {
|
|
|
316
323
|
* Reference: data/tvl/src/meteoraFunctions.ts:getBatchedFees
|
|
317
324
|
*/
|
|
318
325
|
private _computeClaimableFees;
|
|
326
|
+
private _createCompoundDestinationIxs;
|
|
319
327
|
/**
|
|
320
328
|
* Build raw instruction arrays for depositing liquidity to a large Meteora DLMM position
|
|
321
329
|
* using rebalanceLiquidityAutomation (automation variant).
|
|
@@ -539,7 +547,7 @@ export declare class Transactions {
|
|
|
539
547
|
private _calculateSweepBinRange;
|
|
540
548
|
/**
|
|
541
549
|
* Initialize bin arrays for a given bin range, skipping arrays that already exist.
|
|
542
|
-
*
|
|
550
|
+
* Explicitly checks account owners so generated init instructions only target missing arrays.
|
|
543
551
|
*/
|
|
544
552
|
private _initBinArraysForRange;
|
|
545
553
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../../src/classes/Transactions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,OAAO,CAAC;AAkBvB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,+BAA+B,EAC/B,kCAAkC,EAClC,cAAc,EACd,0BAA0B,EAC1B,eAAe,EACf,QAAQ,EACR,WAAW,EACX,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,2BAA2B,EAC3B,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EAEpB,gBAAgB,EAChB,wBAAwB,EACxB,+BAA+B,EAC/B,4BAA4B,EAC5B,iBAAiB,EAEjB,8BAA8B,EAE9B,4BAA4B,EAC5B,6BAA6B,EAC7B,iCAAiC,EAGjC,kBAAkB,EAClB,4BAA4B,EAC5B,+BAA+B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ACP,EAAE,WAAW,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAyG/E;;;;;;OAMG;IACG,wBAAwB,CAAC,EAC7B,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAkGzE,2CAA2C,CAAC,EAChD,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,+BAA+B,CAAC,GAAG,OAAO,CACvD,4BAA4B,EAAE,CAC/B;IA6bK,2CAA2C,CAAC,EAChD,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,+BAA+B,CAAC,GAAG,OAAO,CACvD,4BAA4B,EAAE,CAC/B;IA6TD;;;;;;;OAOG;IACH,OAAO,CAAC,uBAAuB;IA6B/B;;;OAGG;YACW,sBAAsB;IA8CpC;;;;OAIG;YACW,sBAAsB;IA0Z9B,6BAA6B,CAAC,EAClC,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,6BAA6B,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;CA6JrF;AAED,eAAO,MAAM,KAAK,cAA6B,CAAC"}
|
|
@@ -45,9 +45,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
45
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.txgen = exports.Transactions = void 0;
|
|
48
|
+
exports.txgen = exports.Transactions = exports.MAX_INIT_EXTEND_INSTRUCTIONS_PER_TRANSACTION = exports.MAX_LIMIT_CLOSE_INIT_BIN_ARRAYS = exports.MAX_INIT_BIN_ARRAYS_PER_TRANSACTION = void 0;
|
|
49
49
|
exports.getHybridChunkOffsets = getHybridChunkOffsets;
|
|
50
50
|
exports.batchHybridChunkInstructionGroups = batchHybridChunkInstructionGroups;
|
|
51
|
+
exports.batchLabeledInstructionGroups = batchLabeledInstructionGroups;
|
|
52
|
+
exports.buildWideHybridRebuildInstructionGroups = buildWideHybridRebuildInstructionGroups;
|
|
53
|
+
exports.buildLimitCloseMainInstructions = buildLimitCloseMainInstructions;
|
|
54
|
+
exports.stripComputeBudgetInstructions = stripComputeBudgetInstructions;
|
|
51
55
|
exports.getLastHybridAmountConsumerIndexes = getLastHybridAmountConsumerIndexes;
|
|
52
56
|
exports.buildHybridDepositAmountParams = buildHybridDepositAmountParams;
|
|
53
57
|
const errors_1 = require("../errors");
|
|
@@ -74,6 +78,9 @@ const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
|
74
78
|
const RaydiumIxGenerator_1 = require("../ixGenerator/RaydiumIxGenerator");
|
|
75
79
|
const RaydiumSDK_1 = require("./RaydiumSDK");
|
|
76
80
|
const types_3 = require("../types");
|
|
81
|
+
exports.MAX_INIT_BIN_ARRAYS_PER_TRANSACTION = 4;
|
|
82
|
+
exports.MAX_LIMIT_CLOSE_INIT_BIN_ARRAYS = 2;
|
|
83
|
+
exports.MAX_INIT_EXTEND_INSTRUCTIONS_PER_TRANSACTION = 10;
|
|
77
84
|
function getHybridChunkOffsets(positionLowerBinId, chunkLowerBinId, chunkUpperBinId) {
|
|
78
85
|
return {
|
|
79
86
|
chunkLowerOffset: chunkLowerBinId - positionLowerBinId,
|
|
@@ -121,6 +128,33 @@ function batchHybridChunkInstructionGroups(chunkInstructionGroups, chunksPerTran
|
|
|
121
128
|
}
|
|
122
129
|
return batchedGroups;
|
|
123
130
|
}
|
|
131
|
+
function batchLabeledInstructionGroups(instructions, instructionsPerTransaction) {
|
|
132
|
+
if (!Number.isInteger(instructionsPerTransaction) ||
|
|
133
|
+
instructionsPerTransaction <= 0) {
|
|
134
|
+
throw new Error('instructionsPerTransaction must be a positive integer');
|
|
135
|
+
}
|
|
136
|
+
const groups = [];
|
|
137
|
+
for (let i = 0; i < instructions.length; i += instructionsPerTransaction) {
|
|
138
|
+
groups.push(instructions.slice(i, i + instructionsPerTransaction));
|
|
139
|
+
}
|
|
140
|
+
return groups;
|
|
141
|
+
}
|
|
142
|
+
function buildWideHybridRebuildInstructionGroups(initExtendIxs, fullRangeBinArrayInitIxs, chunkInstructionGroups) {
|
|
143
|
+
return [
|
|
144
|
+
...batchLabeledInstructionGroups(initExtendIxs, exports.MAX_INIT_EXTEND_INSTRUCTIONS_PER_TRANSACTION),
|
|
145
|
+
...batchLabeledInstructionGroups(fullRangeBinArrayInitIxs, exports.MAX_INIT_BIN_ARRAYS_PER_TRANSACTION),
|
|
146
|
+
...chunkInstructionGroups,
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
function buildLimitCloseMainInstructions(initBinArrayIxs, closeIx) {
|
|
150
|
+
if (initBinArrayIxs.length > exports.MAX_LIMIT_CLOSE_INIT_BIN_ARRAYS) {
|
|
151
|
+
throw new Error(`Limit close requires ${initBinArrayIxs.length} bin-array initialization instructions; max supported in one transaction is ${exports.MAX_LIMIT_CLOSE_INIT_BIN_ARRAYS}. Multi-transaction limit close is required.`);
|
|
152
|
+
}
|
|
153
|
+
return [...initBinArrayIxs, closeIx];
|
|
154
|
+
}
|
|
155
|
+
function stripComputeBudgetInstructions(instructions) {
|
|
156
|
+
return instructions.filter(ix => !ix.programId.equals(web3.ComputeBudgetProgram.programId));
|
|
157
|
+
}
|
|
124
158
|
function findLastIndex(items, predicate) {
|
|
125
159
|
for (let i = items.length - 1; i >= 0; i--) {
|
|
126
160
|
if (predicate(items[i], i)) {
|
|
@@ -1191,7 +1225,7 @@ class Transactions {
|
|
|
1191
1225
|
*/
|
|
1192
1226
|
compoundAutomationIx(_a) {
|
|
1193
1227
|
return __awaiter(this, arguments, void 0, function* ({ connection, params, }) {
|
|
1194
|
-
var _b;
|
|
1228
|
+
var _b, _c;
|
|
1195
1229
|
try {
|
|
1196
1230
|
const program = yield meteora_1.MeteoraDLMM.program(connection);
|
|
1197
1231
|
const position = yield program.account.positionV2.fetch(params.position);
|
|
@@ -1206,19 +1240,75 @@ class Transactions {
|
|
|
1206
1240
|
if (userPosition === undefined) {
|
|
1207
1241
|
throw new Error(`Position: ${params.position} does not exist.`);
|
|
1208
1242
|
}
|
|
1243
|
+
const rewardPdaTokenType = (_b = params.pdaTokenType) !== null && _b !== void 0 ? _b : types_1.TokenType.STA;
|
|
1209
1244
|
// Validate position bin IDs
|
|
1210
1245
|
if (position.upperBinId === undefined ||
|
|
1211
1246
|
position.lowerBinId === undefined) {
|
|
1212
1247
|
throw new Error(`Position ${params.position} has invalid bin IDs: upper=${position.upperBinId}, lower=${position.lowerBinId}`);
|
|
1213
1248
|
}
|
|
1214
|
-
|
|
1215
|
-
const
|
|
1216
|
-
const
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1249
|
+
const lbPairState = dlmmPool.dlmm.lbPair;
|
|
1250
|
+
const tokenXMint = lbPairState.tokenXMint;
|
|
1251
|
+
const tokenYMint = lbPairState.tokenYMint;
|
|
1252
|
+
const rewardInfos = lbPairState.rewardInfos;
|
|
1253
|
+
const tokenProgramMap = yield (0, functions_1.getTokenProgramMapForMints)(connection, [
|
|
1254
|
+
tokenXMint,
|
|
1255
|
+
tokenYMint,
|
|
1256
|
+
]);
|
|
1257
|
+
const tokenXProgram = tokenProgramMap[tokenXMint.toString()];
|
|
1258
|
+
const tokenYProgram = tokenProgramMap[tokenYMint.toString()];
|
|
1259
|
+
const remainingAccountsInfo = yield (0, functions_1.fetchRemainingAccountsInfo)(connection, tokenXMint, tokenYMint, tokenXProgram, tokenYProgram);
|
|
1260
|
+
const rewardDestinations = [];
|
|
1261
|
+
const claimIxs = [
|
|
1262
|
+
yield this.ix.meteoraDlmm.claimFee2Automation(connection, {
|
|
1263
|
+
userWallet: params.userWallet,
|
|
1264
|
+
lbPair: position.lbPair,
|
|
1265
|
+
position: params.position,
|
|
1266
|
+
tokenMintX: tokenXMint,
|
|
1267
|
+
tokenMintY: tokenYMint,
|
|
1268
|
+
tokenProgramX: tokenXProgram,
|
|
1269
|
+
tokenProgramY: tokenYProgram,
|
|
1270
|
+
lowerBinId: position.lowerBinId,
|
|
1271
|
+
upperBinId: position.upperBinId,
|
|
1272
|
+
pdaTokenType: types_1.TokenType.ATA,
|
|
1273
|
+
remainingAccountsInfo,
|
|
1274
|
+
}),
|
|
1275
|
+
];
|
|
1276
|
+
for (let rewardIndex = 0; rewardIndex < 2; rewardIndex++) {
|
|
1277
|
+
const rewardInfo = rewardInfos[rewardIndex];
|
|
1278
|
+
if (!rewardInfo || rewardInfo.mint.equals(web3.PublicKey.default)) {
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
const rewardTokenProgramMap = yield (0, functions_1.getTokenProgramMapForMints)(connection, [rewardInfo.mint]);
|
|
1282
|
+
const rewardTokenProgram = rewardTokenProgramMap[rewardInfo.mint.toString()];
|
|
1283
|
+
const rewardRemainingAccountsInfo = yield (0, functions_1.fetchRemainingAccountsInfoForReward)(connection, rewardInfo.mint, rewardTokenProgram);
|
|
1284
|
+
rewardDestinations.push({
|
|
1285
|
+
mint: rewardInfo.mint,
|
|
1286
|
+
programId: rewardTokenProgram,
|
|
1287
|
+
});
|
|
1288
|
+
claimIxs.push(yield this.ix.meteoraDlmm.claimReward2Automation(connection, {
|
|
1289
|
+
userWallet: params.userWallet,
|
|
1290
|
+
lbPair: position.lbPair,
|
|
1291
|
+
position: params.position,
|
|
1292
|
+
rewardIndex,
|
|
1293
|
+
rewardMint: rewardInfo.mint,
|
|
1294
|
+
rewardVault: rewardInfo.vault,
|
|
1295
|
+
tokenProgram: rewardTokenProgram,
|
|
1296
|
+
lowerBinId: position.lowerBinId,
|
|
1297
|
+
upperBinId: position.upperBinId,
|
|
1298
|
+
pdaTokenType: rewardPdaTokenType,
|
|
1299
|
+
remainingAccountsInfo: rewardRemainingAccountsInfo,
|
|
1300
|
+
}));
|
|
1301
|
+
}
|
|
1302
|
+
const createDestinationIxs = yield this._createCompoundDestinationIxs({
|
|
1303
|
+
connection,
|
|
1304
|
+
userWallet: params.userWallet,
|
|
1305
|
+
tokenXMint,
|
|
1306
|
+
tokenYMint,
|
|
1307
|
+
tokenXProgram,
|
|
1308
|
+
tokenYProgram,
|
|
1309
|
+
rewardDestinations,
|
|
1310
|
+
rewardPdaTokenType,
|
|
1311
|
+
});
|
|
1222
1312
|
// Re-deposit fees (TODO: How to re-deposit reward tokens that is not X or Y token?)
|
|
1223
1313
|
// Get slippage amount that returns a 10 bin slippage (meteora defaults to 3 bins if not provided)
|
|
1224
1314
|
const binStep = yield dlmmPool.dlmm.lbPair.binStep;
|
|
@@ -1231,16 +1321,17 @@ class Transactions {
|
|
|
1231
1321
|
strategy: {
|
|
1232
1322
|
maxBinId: position.upperBinId,
|
|
1233
1323
|
minBinId: position.lowerBinId,
|
|
1234
|
-
strategyType: types_3.StrategyTypeMap[(
|
|
1324
|
+
strategyType: types_3.StrategyTypeMap[(_c = params.distribution) !== null && _c !== void 0 ? _c : 'SPOT-IMBALANCED'],
|
|
1235
1325
|
},
|
|
1236
1326
|
skipInputTokenCheck: true,
|
|
1237
1327
|
slippage: slippageAmount,
|
|
1328
|
+
pdaTokenType: types_1.TokenType.ATA,
|
|
1238
1329
|
}, hsToMeteora_1.meteoraToHawksightAutomationIxs);
|
|
1239
1330
|
const mainInstructions = [
|
|
1240
|
-
// Step 1: Initialize
|
|
1241
|
-
...
|
|
1242
|
-
// Step 2: Claim
|
|
1243
|
-
...
|
|
1331
|
+
// Step 1: Initialize fee/deposit ATAs and reward destination accounts
|
|
1332
|
+
...createDestinationIxs,
|
|
1333
|
+
// Step 2: Claim fees to ATA and rewards to the configured reward account type
|
|
1334
|
+
...claimIxs,
|
|
1244
1335
|
// Step 3: Re-deposit fees
|
|
1245
1336
|
...addLiquidityBuilder.mainIxs,
|
|
1246
1337
|
];
|
|
@@ -1612,7 +1703,7 @@ class Transactions {
|
|
|
1612
1703
|
*/
|
|
1613
1704
|
compoundFromLargePositionAutomationIx(_a) {
|
|
1614
1705
|
return __awaiter(this, arguments, void 0, function* ({ connection, params, }) {
|
|
1615
|
-
var _b, _c;
|
|
1706
|
+
var _b, _c, _d;
|
|
1616
1707
|
try {
|
|
1617
1708
|
// Fetch position data
|
|
1618
1709
|
const program = yield meteora_1.MeteoraDLMM.program(connection);
|
|
@@ -1624,6 +1715,7 @@ class Transactions {
|
|
|
1624
1715
|
const lowerBinId = positionData.lowerBinId;
|
|
1625
1716
|
const upperBinId = positionData.upperBinId;
|
|
1626
1717
|
const binCount = upperBinId - lowerBinId + 1;
|
|
1718
|
+
const rewardPdaTokenType = (_b = params.pdaTokenType) !== null && _b !== void 0 ? _b : types_1.TokenType.STA;
|
|
1627
1719
|
// For ≤70 bins, delegate to existing single-TX compoundAutomationIx
|
|
1628
1720
|
if (binCount <= 70) {
|
|
1629
1721
|
const singleResult = yield this.compoundAutomationIx({
|
|
@@ -1687,7 +1779,20 @@ class Transactions {
|
|
|
1687
1779
|
rewardRemainingAccountsInfo,
|
|
1688
1780
|
});
|
|
1689
1781
|
}
|
|
1690
|
-
|
|
1782
|
+
const createDestinationIxs = yield this._createCompoundDestinationIxs({
|
|
1783
|
+
connection,
|
|
1784
|
+
userWallet: params.userWallet,
|
|
1785
|
+
tokenXMint,
|
|
1786
|
+
tokenYMint,
|
|
1787
|
+
tokenXProgram,
|
|
1788
|
+
tokenYProgram,
|
|
1789
|
+
rewardDestinations: rewardIxBuilders.map(reward => ({
|
|
1790
|
+
mint: reward.rewardMint,
|
|
1791
|
+
programId: reward.rewardTokenProgram,
|
|
1792
|
+
})),
|
|
1793
|
+
rewardPdaTokenType,
|
|
1794
|
+
});
|
|
1795
|
+
// Build claim instructions per chunk: fees go to ATA for compound; rewards follow the configured reward account type.
|
|
1691
1796
|
const claimTxs = [];
|
|
1692
1797
|
for (const chunk of chunks) {
|
|
1693
1798
|
const instructions = [];
|
|
@@ -1716,7 +1821,7 @@ class Transactions {
|
|
|
1716
1821
|
tokenProgram: reward.rewardTokenProgram,
|
|
1717
1822
|
lowerBinId: chunk.lower,
|
|
1718
1823
|
upperBinId: chunk.upper,
|
|
1719
|
-
pdaTokenType:
|
|
1824
|
+
pdaTokenType: rewardPdaTokenType,
|
|
1720
1825
|
remainingAccountsInfo: reward.rewardRemainingAccountsInfo,
|
|
1721
1826
|
});
|
|
1722
1827
|
instructions.push(claimRewardIx);
|
|
@@ -1740,7 +1845,7 @@ class Transactions {
|
|
|
1740
1845
|
'BID-ASK-ONE-SIDE': liquidityStrategy_1.StrategyType.BID_ASK,
|
|
1741
1846
|
'BID-ASK-BALANCED': liquidityStrategy_1.StrategyType.BID_ASK,
|
|
1742
1847
|
};
|
|
1743
|
-
const strategyType = (
|
|
1848
|
+
const strategyType = (_d = distributionToStrategyType[(_c = params.distribution) !== null && _c !== void 0 ? _c : 'SPOT-IMBALANCED']) !== null && _d !== void 0 ? _d : liquidityStrategy_1.StrategyType.SPOT;
|
|
1744
1849
|
const { binId: activeId } = yield dlmmPool.dlmm.getActiveBin();
|
|
1745
1850
|
const depositTxs = yield this._meteoraDepositToLargePositionAutomation({
|
|
1746
1851
|
connection,
|
|
@@ -1763,6 +1868,7 @@ class Transactions {
|
|
|
1763
1868
|
// Phase 3: Assemble transactions
|
|
1764
1869
|
// =========================================================================
|
|
1765
1870
|
const assembled = [
|
|
1871
|
+
...(createDestinationIxs.length ? [createDestinationIxs] : []),
|
|
1766
1872
|
...claimTxs,
|
|
1767
1873
|
...depositTxs,
|
|
1768
1874
|
];
|
|
@@ -2736,6 +2842,72 @@ class Transactions {
|
|
|
2736
2842
|
};
|
|
2737
2843
|
});
|
|
2738
2844
|
}
|
|
2845
|
+
_createCompoundDestinationIxs(params) {
|
|
2846
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2847
|
+
const { connection, userWallet, tokenXMint, tokenYMint, tokenXProgram, tokenYProgram, rewardDestinations, rewardPdaTokenType, } = params;
|
|
2848
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet);
|
|
2849
|
+
const ixs = [];
|
|
2850
|
+
const feeDepositDestinations = [
|
|
2851
|
+
{ mint: tokenXMint, programId: tokenXProgram },
|
|
2852
|
+
{ mint: tokenYMint, programId: tokenYProgram },
|
|
2853
|
+
];
|
|
2854
|
+
const feeDepositAccounts = feeDepositDestinations.map(destination => (Object.assign(Object.assign({}, destination), { tokenAccount: (0, functions_1.generateAta)(userPda, destination.mint, destination.programId) })));
|
|
2855
|
+
const feeDepositAccountInfos = yield connection.getMultipleAccountsInfo(feeDepositAccounts.map(destination => destination.tokenAccount));
|
|
2856
|
+
const missingFeeDepositAccounts = feeDepositAccounts.filter((_, index) => feeDepositAccountInfos[index] === null);
|
|
2857
|
+
ixs.push(...(0, functions_1.createAtaIdempotentIxs)({
|
|
2858
|
+
accounts: missingFeeDepositAccounts.map(destination => ({
|
|
2859
|
+
owner: userPda,
|
|
2860
|
+
payer: addresses_1.HS_AUTHORITY,
|
|
2861
|
+
mint: destination.mint,
|
|
2862
|
+
programId: destination.programId,
|
|
2863
|
+
})),
|
|
2864
|
+
}));
|
|
2865
|
+
if (rewardDestinations.length === 0) {
|
|
2866
|
+
return ixs;
|
|
2867
|
+
}
|
|
2868
|
+
const rewardDestinationAccounts = rewardDestinations.map(destination => {
|
|
2869
|
+
let tokenAccount;
|
|
2870
|
+
if (rewardPdaTokenType === types_1.TokenType.STA) {
|
|
2871
|
+
tokenAccount = (0, functions_1.generateUserPdaStorageAccount)(userPda, destination.mint);
|
|
2872
|
+
}
|
|
2873
|
+
else if (rewardPdaTokenType === types_1.TokenType.LTA) {
|
|
2874
|
+
tokenAccount = (0, functions_1.generateLimitToken)(userPda, destination.mint);
|
|
2875
|
+
}
|
|
2876
|
+
else {
|
|
2877
|
+
tokenAccount = (0, functions_1.generateAta)(userPda, destination.mint, destination.programId);
|
|
2878
|
+
}
|
|
2879
|
+
return Object.assign(Object.assign({}, destination), { tokenAccount });
|
|
2880
|
+
});
|
|
2881
|
+
const rewardDestinationAccountInfos = yield connection.getMultipleAccountsInfo(rewardDestinationAccounts.map(destination => destination.tokenAccount));
|
|
2882
|
+
const missingRewardDestinations = rewardDestinationAccounts.filter((_, index) => rewardDestinationAccountInfos[index] === null);
|
|
2883
|
+
const missingRewardMints = missingRewardDestinations.map(destination => destination.mint);
|
|
2884
|
+
if (rewardPdaTokenType === types_1.TokenType.STA) {
|
|
2885
|
+
ixs.push(...(yield this.ix.iyfMain.initializeStorageTokenAccounts(connection, {
|
|
2886
|
+
userWallet,
|
|
2887
|
+
mints: missingRewardMints,
|
|
2888
|
+
})));
|
|
2889
|
+
}
|
|
2890
|
+
else if (rewardPdaTokenType === types_1.TokenType.LTA) {
|
|
2891
|
+
ixs.push(...(yield Promise.all(missingRewardMints.map(mint => this.ix.iyfMain.createLimitToken({
|
|
2892
|
+
connection,
|
|
2893
|
+
payer: addresses_1.HS_AUTHORITY,
|
|
2894
|
+
userWallet,
|
|
2895
|
+
mint,
|
|
2896
|
+
})))));
|
|
2897
|
+
}
|
|
2898
|
+
else {
|
|
2899
|
+
ixs.push(...(0, functions_1.createAtaIdempotentIxs)({
|
|
2900
|
+
accounts: missingRewardDestinations.map(destination => ({
|
|
2901
|
+
owner: userPda,
|
|
2902
|
+
payer: addresses_1.HS_AUTHORITY,
|
|
2903
|
+
mint: destination.mint,
|
|
2904
|
+
programId: destination.programId,
|
|
2905
|
+
})),
|
|
2906
|
+
}));
|
|
2907
|
+
}
|
|
2908
|
+
return ixs;
|
|
2909
|
+
});
|
|
2910
|
+
}
|
|
2739
2911
|
/**
|
|
2740
2912
|
* Build raw instruction arrays for depositing liquidity to a large Meteora DLMM position
|
|
2741
2913
|
* using rebalanceLiquidityAutomation (automation variant).
|
|
@@ -3361,10 +3533,8 @@ class Transactions {
|
|
|
3361
3533
|
ix: limitCloseAutomationIx,
|
|
3362
3534
|
});
|
|
3363
3535
|
}
|
|
3364
|
-
const
|
|
3365
|
-
|
|
3366
|
-
ix,
|
|
3367
|
-
];
|
|
3536
|
+
const initBinArrayIxs = yield this._initBinArraysForRange(connection, lbPair.pubkey, dlmmPool, position.lowerBinId, position.upperBinId);
|
|
3537
|
+
const mainInstructions = buildLimitCloseMainInstructions(initBinArrayIxs, ix);
|
|
3368
3538
|
return (0, functions_1.createTransactionMeta)({
|
|
3369
3539
|
payer: params.userWallet,
|
|
3370
3540
|
description: 'Automation IX: Meteora limit close instruction (Full withdraw and close on to specific bin id)',
|
|
@@ -3497,10 +3667,8 @@ class Transactions {
|
|
|
3497
3667
|
});
|
|
3498
3668
|
}));
|
|
3499
3669
|
}
|
|
3500
|
-
const
|
|
3501
|
-
|
|
3502
|
-
ix,
|
|
3503
|
-
];
|
|
3670
|
+
const initBinArrayIxs = yield this._initBinArraysForRange(connection, lbPair.pubkey, dlmmPool, position.lowerBinId, position.upperBinId);
|
|
3671
|
+
const mainInstructions = buildLimitCloseMainInstructions(initBinArrayIxs, ix);
|
|
3504
3672
|
return (0, functions_1.createTransactionMeta)({
|
|
3505
3673
|
payer: params.userWallet,
|
|
3506
3674
|
description: 'Automation IX: Meteora limit close instruction (Full withdraw and close on to specific bin id)',
|
|
@@ -6248,7 +6416,8 @@ class Transactions {
|
|
|
6248
6416
|
];
|
|
6249
6417
|
for (let i = 0; i < strategyResults.length; i++) {
|
|
6250
6418
|
const layerStrategy = strategyResults[i];
|
|
6251
|
-
if (layerStrategy.maxAmountX.isZero() &&
|
|
6419
|
+
if (layerStrategy.maxAmountX.isZero() &&
|
|
6420
|
+
layerStrategy.maxAmountY.isZero()) {
|
|
6252
6421
|
continue;
|
|
6253
6422
|
}
|
|
6254
6423
|
const singleLayer = {
|
|
@@ -6267,7 +6436,11 @@ class Transactions {
|
|
|
6267
6436
|
tokenYMint,
|
|
6268
6437
|
tokenXProgram,
|
|
6269
6438
|
tokenYProgram, layers: [singleLayer], checkRange: params.checkRange }, amountParams), { remainingAccountsInfo: baseRemainingAccountsInfo, pdaTokenType: types_1.TokenType.ATA, lowerBinId: newLowerBinId, upperBinId: newUpperBinId }));
|
|
6270
|
-
layeredDepositIxs.push({
|
|
6439
|
+
layeredDepositIxs.push({
|
|
6440
|
+
label: 'deposit_v2',
|
|
6441
|
+
class: CLASS,
|
|
6442
|
+
instruction: depositIx,
|
|
6443
|
+
});
|
|
6271
6444
|
}
|
|
6272
6445
|
if (layeredDepositIxs.length > 0) {
|
|
6273
6446
|
rebuildTxGroups.push(layeredDepositIxs);
|
|
@@ -6307,7 +6480,11 @@ class Transactions {
|
|
|
6307
6480
|
}
|
|
6308
6481
|
}
|
|
6309
6482
|
else {
|
|
6310
|
-
|
|
6483
|
+
const fullRangeBinArrayInitIxs = (yield this._initBinArraysForRange(connection, lbPair, dlmmPool, newLowerBinId, newUpperBinId)).map(ix => ({
|
|
6484
|
+
label: 'init_bin_array',
|
|
6485
|
+
class: CLASS,
|
|
6486
|
+
instruction: ix,
|
|
6487
|
+
}));
|
|
6311
6488
|
const strategyResults = (0, liquidityStrategy_1.distributionToHybridStrategy)({
|
|
6312
6489
|
hybridDistribution: layers,
|
|
6313
6490
|
amountX: effectiveAmountX,
|
|
@@ -6337,22 +6514,16 @@ class Transactions {
|
|
|
6337
6514
|
omitXAmount: i === lastXChunkIndex,
|
|
6338
6515
|
omitYAmount: i === lastYChunkIndex,
|
|
6339
6516
|
});
|
|
6340
|
-
const binArrayInitIxs = yield this._initBinArraysForRange(connection, lbPair, dlmmPool, chunk.lowerBinId, chunk.upperBinId);
|
|
6341
6517
|
const depositIx = yield this.ix.meteoraDlmm.addLiquidity2Automation(Object.assign(Object.assign({ connection, userWallet: params.userWallet, lbPair, position: params.newPosition, tokenXMint,
|
|
6342
6518
|
tokenYMint,
|
|
6343
6519
|
tokenXProgram,
|
|
6344
6520
|
tokenYProgram, layers: contractLayers, checkRange: params.checkRange }, amountParams), { chunkLowerOffset,
|
|
6345
6521
|
chunkUpperOffset, remainingAccountsInfo: baseRemainingAccountsInfo, pdaTokenType: types_1.TokenType.ATA, lowerBinId: chunk.lowerBinId, upperBinId: chunk.upperBinId }));
|
|
6346
6522
|
chunkInstructionGroups.push([
|
|
6347
|
-
...binArrayInitIxs.map(ix => ({
|
|
6348
|
-
label: 'init_bin_array',
|
|
6349
|
-
class: CLASS,
|
|
6350
|
-
instruction: ix,
|
|
6351
|
-
})),
|
|
6352
6523
|
{ label: 'deposit_v2', class: CLASS, instruction: depositIx },
|
|
6353
6524
|
]);
|
|
6354
6525
|
}
|
|
6355
|
-
rebuildTxGroups.push(...batchHybridChunkInstructionGroups(chunkInstructionGroups, CHUNKS_PER_TRANSACTION));
|
|
6526
|
+
rebuildTxGroups.push(...buildWideHybridRebuildInstructionGroups(initExtendIxs, fullRangeBinArrayInitIxs, batchHybridChunkInstructionGroups(chunkInstructionGroups, CHUNKS_PER_TRANSACTION)));
|
|
6356
6527
|
}
|
|
6357
6528
|
// =========================================================================
|
|
6358
6529
|
// Assemble final TX list
|
|
@@ -6468,7 +6639,8 @@ class Transactions {
|
|
|
6468
6639
|
const layeredDepositIxs = [];
|
|
6469
6640
|
for (let i = 0; i < strategyResults.length; i++) {
|
|
6470
6641
|
const layerStrategy = strategyResults[i];
|
|
6471
|
-
if (layerStrategy.maxAmountX.isZero() &&
|
|
6642
|
+
if (layerStrategy.maxAmountX.isZero() &&
|
|
6643
|
+
layerStrategy.maxAmountY.isZero()) {
|
|
6472
6644
|
continue;
|
|
6473
6645
|
}
|
|
6474
6646
|
const singleLayer = {
|
|
@@ -6488,7 +6660,11 @@ class Transactions {
|
|
|
6488
6660
|
tokenXProgram,
|
|
6489
6661
|
tokenYProgram, layers: [singleLayer] }, amountParams), { remainingAccountsInfo: baseRemainingAccountsInfo, pdaTokenType: types_1.TokenType.ATA, lowerBinId,
|
|
6490
6662
|
upperBinId }));
|
|
6491
|
-
layeredDepositIxs.push({
|
|
6663
|
+
layeredDepositIxs.push({
|
|
6664
|
+
label: 'deposit_v2',
|
|
6665
|
+
class: CLASS,
|
|
6666
|
+
instruction: depositIx,
|
|
6667
|
+
});
|
|
6492
6668
|
}
|
|
6493
6669
|
if (layeredDepositIxs.length > 0) {
|
|
6494
6670
|
depositTxGroups.push(layeredDepositIxs);
|
|
@@ -6608,13 +6784,29 @@ class Transactions {
|
|
|
6608
6784
|
}
|
|
6609
6785
|
/**
|
|
6610
6786
|
* Initialize bin arrays for a given bin range, skipping arrays that already exist.
|
|
6611
|
-
*
|
|
6787
|
+
* Explicitly checks account owners so generated init instructions only target missing arrays.
|
|
6612
6788
|
*/
|
|
6613
6789
|
_initBinArraysForRange(connection, lbPair, dlmmPool, lowerBinId, upperBinId) {
|
|
6614
6790
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6615
6791
|
const binArraysRequired = yield (0, dlmm_1.getBinArraysRequiredByPositionRange)(lbPair, new bn_js_1.default(lowerBinId), new bn_js_1.default(upperBinId), dlmmPool.dlmm.program.programId);
|
|
6616
|
-
if (binArraysRequired.length
|
|
6617
|
-
return
|
|
6792
|
+
if (binArraysRequired.length === 0) {
|
|
6793
|
+
return [];
|
|
6794
|
+
}
|
|
6795
|
+
const accountInfos = yield connection.getMultipleAccountsInfo(binArraysRequired.map(b => b.key));
|
|
6796
|
+
const missingIndexes = binArraysRequired.flatMap((binArray, index) => {
|
|
6797
|
+
const accountInfo = accountInfos[index];
|
|
6798
|
+
if (accountInfo === null || accountInfo === void 0 ? void 0 : accountInfo.owner.equals(dlmmPool.dlmm.program.programId)) {
|
|
6799
|
+
return [];
|
|
6800
|
+
}
|
|
6801
|
+
if (accountInfo === null ||
|
|
6802
|
+
accountInfo.owner.equals(web3.SystemProgram.programId)) {
|
|
6803
|
+
return [binArray.index];
|
|
6804
|
+
}
|
|
6805
|
+
throw new Error(`Bin array ${binArray.key.toString()} is owned by ${accountInfo.owner.toString()}, expected ${dlmmPool.dlmm.program.programId.toString()}`);
|
|
6806
|
+
});
|
|
6807
|
+
if (missingIndexes.length > 0) {
|
|
6808
|
+
const instructions = yield dlmmPool.dlmm.initializeBinArrays(missingIndexes, addresses_1.HS_AUTHORITY);
|
|
6809
|
+
return stripComputeBudgetInstructions(instructions);
|
|
6618
6810
|
}
|
|
6619
6811
|
return [];
|
|
6620
6812
|
});
|