@hawksightco/hawk-sdk 1.3.201 → 1.3.203
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/src/classes/Transactions.d.ts +218 -18
- package/dist/src/classes/Transactions.d.ts.map +1 -1
- package/dist/src/classes/Transactions.js +1695 -263
- package/dist/src/classes/TxGenerator.d.ts +39 -7
- package/dist/src/classes/TxGenerator.d.ts.map +1 -1
- package/dist/src/classes/TxGenerator.js +189 -6
- package/dist/src/classes/TxGeneratorAutomations.d.ts +79 -1
- package/dist/src/classes/TxGeneratorAutomations.d.ts.map +1 -1
- package/dist/src/classes/TxGeneratorAutomations.js +288 -0
- package/dist/src/hsToMeteora.js +6 -6
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts +21 -2
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts.map +1 -1
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.js +156 -11
- package/dist/src/meteora/liquidityStrategy.d.ts +31 -0
- package/dist/src/meteora/liquidityStrategy.d.ts.map +1 -1
- package/dist/src/meteora/liquidityStrategy.js +76 -0
- package/dist/src/types.d.ts +100 -40
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +20 -1
- package/package.json +2 -2
|
@@ -1177,6 +1177,11 @@ class MeteoraDlmmIxGenerator {
|
|
|
1177
1177
|
userTokenX = (0, functions_1.generateAta)(userPda, params.tokenXMint, params.tokenXProgram);
|
|
1178
1178
|
userTokenY = (0, functions_1.generateAta)(userPda, params.tokenYMint, params.tokenYProgram);
|
|
1179
1179
|
}
|
|
1180
|
+
// Derive bin array bitmap extension
|
|
1181
|
+
const lowerBinArrayIndex = this.binIdToBinArrayIndex(new bn_js_1.default(params.strategyParametersMinBinId));
|
|
1182
|
+
const upperBinArrayIndex = this.binIdToBinArrayIndex(new bn_js_1.default(params.strategyParametersMaxBinId));
|
|
1183
|
+
const binArrayBitmapExtension = (this.isOverflowDefaultBinArrayBitmap(lowerBinArrayIndex) ||
|
|
1184
|
+
this.isOverflowDefaultBinArrayBitmap(upperBinArrayIndex)) ? this.pda.meteora.deriveBinArrayBitmapExtension(params.lbPair) : METEORA_DLMM_PROGRAM;
|
|
1180
1185
|
// Serialize RemainingAccountsInfo as Vec<u8> (Borsh format)
|
|
1181
1186
|
// This is passed directly to the on-chain instruction which forwards it to Meteora
|
|
1182
1187
|
// For SPL tokens (non-Token2022), we still need to provide the slices structure with length=0
|
|
@@ -1206,7 +1211,6 @@ class MeteoraDlmmIxGenerator {
|
|
|
1206
1211
|
...((_d = (_c = params.remainingAccountsInfo) === null || _c === void 0 ? void 0 : _c.accounts) !== null && _d !== void 0 ? _d : []),
|
|
1207
1212
|
...binArrayAccounts,
|
|
1208
1213
|
];
|
|
1209
|
-
console.log('remainingAccounts', remainingAccounts);
|
|
1210
1214
|
// Use Anchor to serialize the instruction (ensures proper Borsh serialization)
|
|
1211
1215
|
// @ts-ignore
|
|
1212
1216
|
const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
@@ -1218,7 +1222,7 @@ class MeteoraDlmmIxGenerator {
|
|
|
1218
1222
|
hawksightAuthority: addresses_1.HS_AUTHORITY,
|
|
1219
1223
|
position: params.position,
|
|
1220
1224
|
lbPair: params.lbPair,
|
|
1221
|
-
binArrayBitmapExtension
|
|
1225
|
+
binArrayBitmapExtension,
|
|
1222
1226
|
userTokenX,
|
|
1223
1227
|
userTokenY,
|
|
1224
1228
|
reserveX: actualReserveX,
|
|
@@ -1783,7 +1787,7 @@ class MeteoraDlmmIxGenerator {
|
|
|
1783
1787
|
* @returns TransactionInstruction for the rebalance_liquidity operation
|
|
1784
1788
|
*/
|
|
1785
1789
|
rebalanceLiquidity(_a) {
|
|
1786
|
-
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, position, lbPair, tokenXMint, tokenYMint, tokenXProgram, tokenYProgram, activeId, pdaTokenType, maxActiveBinSlippage, shouldClaimFee, shouldClaimReward, minWithdrawXAmount, maxDepositXAmount, minWithdrawYAmount, maxDepositYAmount, removeLiquidityParams, addLiquidityParams, }) {
|
|
1790
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, position, lbPair, tokenXMint, tokenYMint, tokenXProgram, tokenYProgram, activeId, pdaTokenType, maxActiveBinSlippage, shouldClaimFee, shouldClaimReward, minWithdrawXAmount, maxDepositXAmount, minWithdrawYAmount, maxDepositYAmount, removeLiquidityParams, addLiquidityParams, shrinkMode, }) {
|
|
1787
1791
|
// Initialize Anchor
|
|
1788
1792
|
anchor_1.Anchor.initialize(connection);
|
|
1789
1793
|
// Generate user PDA
|
|
@@ -1804,8 +1808,11 @@ class MeteoraDlmmIxGenerator {
|
|
|
1804
1808
|
userTokenX = (0, functions_1.generateAta)(userPda, tokenXMint, tokenXProgram);
|
|
1805
1809
|
userTokenY = (0, functions_1.generateAta)(userPda, tokenYMint, tokenYProgram);
|
|
1806
1810
|
}
|
|
1807
|
-
// Derive bin array bitmap extension
|
|
1808
|
-
const
|
|
1811
|
+
// Derive bin array bitmap extension
|
|
1812
|
+
const lowerBinArrayIndex = this.binIdToBinArrayIndex(new bn_js_1.default(activeId + addLiquidityParams[0].minDeltaId));
|
|
1813
|
+
const upperBinArrayIndex = this.binIdToBinArrayIndex(new bn_js_1.default(activeId + addLiquidityParams[0].maxDeltaId));
|
|
1814
|
+
const binArrayBitmapExtension = (this.isOverflowDefaultBinArrayBitmap(lowerBinArrayIndex) ||
|
|
1815
|
+
this.isOverflowDefaultBinArrayBitmap(upperBinArrayIndex)) ? this.pda.meteora.deriveBinArrayBitmapExtension(lbPair) : METEORA_DLMM_PROGRAM;
|
|
1809
1816
|
// Derive reserves
|
|
1810
1817
|
const reserveX = this.pda.meteora.deriveReserve(tokenXMint, lbPair);
|
|
1811
1818
|
const reserveY = this.pda.meteora.deriveReserve(tokenYMint, lbPair);
|
|
@@ -1823,6 +1830,7 @@ class MeteoraDlmmIxGenerator {
|
|
|
1823
1830
|
maxDepositXAmount,
|
|
1824
1831
|
minWithdrawYAmount,
|
|
1825
1832
|
maxDepositYAmount,
|
|
1833
|
+
shrinkMode,
|
|
1826
1834
|
removeLiquidityParams,
|
|
1827
1835
|
addLiquidityParams,
|
|
1828
1836
|
});
|
|
@@ -1872,6 +1880,7 @@ class MeteoraDlmmIxGenerator {
|
|
|
1872
1880
|
* Serialize RebalanceLiquidityParams to match Rust struct layout
|
|
1873
1881
|
*/
|
|
1874
1882
|
serializeRebalanceLiquidityParams(params) {
|
|
1883
|
+
var _a;
|
|
1875
1884
|
const buffers = [];
|
|
1876
1885
|
// activeId (i32)
|
|
1877
1886
|
const activeIdBuf = Buffer.alloc(4);
|
|
@@ -1893,9 +1902,9 @@ class MeteoraDlmmIxGenerator {
|
|
|
1893
1902
|
buffers.push(params.minWithdrawYAmount.toArrayLike(Buffer, 'le', 8));
|
|
1894
1903
|
// maxDepositYAmount (u64)
|
|
1895
1904
|
buffers.push(params.maxDepositYAmount.toArrayLike(Buffer, 'le', 8));
|
|
1896
|
-
// padding [u8;
|
|
1905
|
+
// shrink_mode (u8) + padding [u8; 31]
|
|
1897
1906
|
const paddingBuf = Buffer.alloc(32, 0);
|
|
1898
|
-
paddingBuf[0] =
|
|
1907
|
+
paddingBuf[0] = (_a = params.shrinkMode) !== null && _a !== void 0 ? _a : types_1.ShrinkMode.NoShrinkBoth;
|
|
1899
1908
|
buffers.push(paddingBuf);
|
|
1900
1909
|
// removeLiquidityParams Vec (length as u32, then each RemoveLiquidityParams)
|
|
1901
1910
|
const removeLenBuf = Buffer.alloc(4);
|
|
@@ -2021,8 +2030,11 @@ class MeteoraDlmmIxGenerator {
|
|
|
2021
2030
|
userTokenX = (0, functions_1.generateAta)(userPda, tokenXMint, tokenXProgram);
|
|
2022
2031
|
userTokenY = (0, functions_1.generateAta)(userPda, tokenYMint, tokenYProgram);
|
|
2023
2032
|
}
|
|
2024
|
-
// Derive bin array bitmap extension
|
|
2025
|
-
const
|
|
2033
|
+
// Derive bin array bitmap extension
|
|
2034
|
+
const lowerBinArrayIndex = this.binIdToBinArrayIndex(new bn_js_1.default(fromBinId));
|
|
2035
|
+
const upperBinArrayIndex = this.binIdToBinArrayIndex(new bn_js_1.default(toBinId));
|
|
2036
|
+
const binArrayBitmapExtension = (this.isOverflowDefaultBinArrayBitmap(lowerBinArrayIndex) ||
|
|
2037
|
+
this.isOverflowDefaultBinArrayBitmap(upperBinArrayIndex)) ? this.pda.meteora.deriveBinArrayBitmapExtension(lbPair) : METEORA_DLMM_PROGRAM;
|
|
2026
2038
|
// Derive reserves
|
|
2027
2039
|
const reserveX = this.pda.meteora.deriveReserve(tokenXMint, lbPair);
|
|
2028
2040
|
const reserveY = this.pda.meteora.deriveReserve(tokenYMint, lbPair);
|
|
@@ -2159,6 +2171,136 @@ class MeteoraDlmmIxGenerator {
|
|
|
2159
2171
|
});
|
|
2160
2172
|
});
|
|
2161
2173
|
}
|
|
2174
|
+
/**
|
|
2175
|
+
* Rebalance liquidity in a Meteora DLMM position via IYF Extension for automation.
|
|
2176
|
+
*
|
|
2177
|
+
* This is the automation version that uses HS_AUTHORITY as the signer.
|
|
2178
|
+
* Wraps via iyfExtensionExecuteV2 instead of meteoraDynamicCpi.
|
|
2179
|
+
*
|
|
2180
|
+
* @param params - RebalanceLiquidityIxParams containing all necessary accounts and parameters
|
|
2181
|
+
* @returns TransactionInstruction for the rebalance_liquidity automation operation
|
|
2182
|
+
*/
|
|
2183
|
+
rebalanceLiquidityAutomation(_a) {
|
|
2184
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, position, lbPair, tokenXMint, tokenYMint, tokenXProgram, tokenYProgram, activeId, pdaTokenType, maxActiveBinSlippage, shouldClaimFee, shouldClaimReward, minWithdrawXAmount, maxDepositXAmount, minWithdrawYAmount, maxDepositYAmount, removeLiquidityParams, addLiquidityParams, binArrayOverrides, shrinkMode, rewardInfos, remainingAccountsInfo, }) {
|
|
2185
|
+
var _b, _c;
|
|
2186
|
+
// Initialize Anchor
|
|
2187
|
+
anchor_1.Anchor.initialize(connection);
|
|
2188
|
+
// Generate user PDA
|
|
2189
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet);
|
|
2190
|
+
// Generate user token accounts based on pdaTokenType
|
|
2191
|
+
let userTokenX;
|
|
2192
|
+
let userTokenY;
|
|
2193
|
+
if (pdaTokenType === types_1.TokenType.LTA) {
|
|
2194
|
+
userTokenX = (0, functions_1.generateLimitToken)(userPda, tokenXMint);
|
|
2195
|
+
userTokenY = (0, functions_1.generateLimitToken)(userPda, tokenYMint);
|
|
2196
|
+
}
|
|
2197
|
+
else if (pdaTokenType === types_1.TokenType.STA) {
|
|
2198
|
+
userTokenX = (0, functions_1.generateUserPdaStorageAccount)(userPda, tokenXMint);
|
|
2199
|
+
userTokenY = (0, functions_1.generateUserPdaStorageAccount)(userPda, tokenYMint);
|
|
2200
|
+
}
|
|
2201
|
+
else {
|
|
2202
|
+
// Default: ATA
|
|
2203
|
+
userTokenX = (0, functions_1.generateAta)(userPda, tokenXMint, tokenXProgram);
|
|
2204
|
+
userTokenY = (0, functions_1.generateAta)(userPda, tokenYMint, tokenYProgram);
|
|
2205
|
+
}
|
|
2206
|
+
// Derive bin array bitmap extension
|
|
2207
|
+
const lowerBinArrayIndex = this.binIdToBinArrayIndex(new bn_js_1.default(activeId + addLiquidityParams[0].minDeltaId));
|
|
2208
|
+
const upperBinArrayIndex = this.binIdToBinArrayIndex(new bn_js_1.default(activeId + addLiquidityParams[0].maxDeltaId));
|
|
2209
|
+
const binArrayBitmapExtension = (this.isOverflowDefaultBinArrayBitmap(lowerBinArrayIndex) ||
|
|
2210
|
+
this.isOverflowDefaultBinArrayBitmap(upperBinArrayIndex)) ? this.pda.meteora.deriveBinArrayBitmapExtension(lbPair) : METEORA_DLMM_PROGRAM;
|
|
2211
|
+
// Derive reserves
|
|
2212
|
+
const reserveX = this.pda.meteora.deriveReserve(tokenXMint, lbPair);
|
|
2213
|
+
const reserveY = this.pda.meteora.deriveReserve(tokenYMint, lbPair);
|
|
2214
|
+
// Use overrides if provided (for reshape position covering both remove and add ranges),
|
|
2215
|
+
// otherwise derive from addLiquidityParams
|
|
2216
|
+
let binArrays;
|
|
2217
|
+
if (binArrayOverrides) {
|
|
2218
|
+
binArrays = binArrayOverrides;
|
|
2219
|
+
}
|
|
2220
|
+
else {
|
|
2221
|
+
const lowerBinId = activeId + addLiquidityParams[0].minDeltaId;
|
|
2222
|
+
const upperBinId = activeId + addLiquidityParams[0].maxDeltaId;
|
|
2223
|
+
binArrays = this.pda.meteora.deriveBinArrays(lbPair, lowerBinId, upperBinId);
|
|
2224
|
+
}
|
|
2225
|
+
// Build reward remaining accounts if shouldClaimReward and rewardInfos provided
|
|
2226
|
+
const rewardRemainingAccounts = [];
|
|
2227
|
+
if (shouldClaimReward && rewardInfos && rewardInfos.length > 0) {
|
|
2228
|
+
console.log(`[rebalanceLiquidityAutomation] Building reward accounts for ${rewardInfos.length} reward(s)`);
|
|
2229
|
+
for (const reward of rewardInfos) {
|
|
2230
|
+
// User reward token account (ATA or STA based on pdaTokenType)
|
|
2231
|
+
let userRewardToken = (0, functions_1.generateUserPdaStorageAccount)(userPda, reward.rewardMint);
|
|
2232
|
+
console.log(`[rebalanceLiquidityAutomation] Reward: vault=${reward.rewardVault.toString()}, userToken=${userRewardToken.toString()}, mint=${reward.rewardMint.toString()}, program=${reward.rewardTokenProgram.toString()}`);
|
|
2233
|
+
// Add reward accounts in order: vault, userToken, mint, tokenProgram
|
|
2234
|
+
rewardRemainingAccounts.push({ pubkey: reward.rewardVault, isSigner: false, isWritable: true }, { pubkey: userRewardToken, isSigner: false, isWritable: true }, { pubkey: reward.rewardMint, isSigner: false, isWritable: false }, { pubkey: reward.rewardTokenProgram, isSigner: false, isWritable: false });
|
|
2235
|
+
}
|
|
2236
|
+
console.log(`[rebalanceLiquidityAutomation] Total reward remaining accounts: ${rewardRemainingAccounts.length}`);
|
|
2237
|
+
}
|
|
2238
|
+
else if (shouldClaimReward) {
|
|
2239
|
+
console.log(`[rebalanceLiquidityAutomation] shouldClaimReward=true but no rewardInfos provided!`);
|
|
2240
|
+
}
|
|
2241
|
+
// Serialize RebalanceLiquidityParams
|
|
2242
|
+
const rebalanceParamsData = this.serializeRebalanceLiquidityParams({
|
|
2243
|
+
activeId,
|
|
2244
|
+
maxActiveBinSlippage,
|
|
2245
|
+
shouldClaimFee,
|
|
2246
|
+
shouldClaimReward,
|
|
2247
|
+
minWithdrawXAmount,
|
|
2248
|
+
maxDepositXAmount,
|
|
2249
|
+
minWithdrawYAmount,
|
|
2250
|
+
maxDepositYAmount,
|
|
2251
|
+
shrinkMode,
|
|
2252
|
+
removeLiquidityParams,
|
|
2253
|
+
addLiquidityParams,
|
|
2254
|
+
});
|
|
2255
|
+
// Serialize RemainingAccountsInfo from passed parameter or use empty slices
|
|
2256
|
+
const serializedRemainingAccountsInfo = this.serializeRemainingAccountsInfo({
|
|
2257
|
+
slices: (_b = remainingAccountsInfo === null || remainingAccountsInfo === void 0 ? void 0 : remainingAccountsInfo.slices) !== null && _b !== void 0 ? _b : [],
|
|
2258
|
+
});
|
|
2259
|
+
// Build instruction data: sighash + RebalanceLiquidityParams + RemainingAccountsInfo
|
|
2260
|
+
// The handler takes two typed Anchor args (not Vec<u8>), so no length prefix needed.
|
|
2261
|
+
const instructionData = Buffer.concat([
|
|
2262
|
+
Buffer.from(util.sighash("meteora_dlmm_rebalance_liquidity_automation")),
|
|
2263
|
+
rebalanceParamsData,
|
|
2264
|
+
serializedRemainingAccountsInfo,
|
|
2265
|
+
]);
|
|
2266
|
+
// Generate instruction via IYF Extension
|
|
2267
|
+
return this.ix.iyfMain.iyfExtensionExecuteV2(connection, {
|
|
2268
|
+
userPda,
|
|
2269
|
+
authority: addresses_1.HS_AUTHORITY,
|
|
2270
|
+
ix: new web3.TransactionInstruction({
|
|
2271
|
+
data: instructionData,
|
|
2272
|
+
keys: [
|
|
2273
|
+
{ pubkey: userPda, isSigner: false, isWritable: false },
|
|
2274
|
+
{ pubkey: addresses_1.HS_AUTHORITY, isSigner: true, isWritable: true },
|
|
2275
|
+
{ pubkey: position, isSigner: false, isWritable: true },
|
|
2276
|
+
{ pubkey: lbPair, isSigner: false, isWritable: true },
|
|
2277
|
+
{ pubkey: binArrayBitmapExtension, isSigner: false, isWritable: true },
|
|
2278
|
+
{ pubkey: userTokenX, isSigner: false, isWritable: true },
|
|
2279
|
+
{ pubkey: userTokenY, isSigner: false, isWritable: true },
|
|
2280
|
+
{ pubkey: reserveX, isSigner: false, isWritable: true },
|
|
2281
|
+
{ pubkey: reserveY, isSigner: false, isWritable: true },
|
|
2282
|
+
{ pubkey: tokenXMint, isSigner: false, isWritable: false },
|
|
2283
|
+
{ pubkey: tokenYMint, isSigner: false, isWritable: false },
|
|
2284
|
+
{ pubkey: tokenXProgram, isSigner: false, isWritable: false },
|
|
2285
|
+
{ pubkey: tokenYProgram, isSigner: false, isWritable: false },
|
|
2286
|
+
{ pubkey: addresses_1.MEMO_PROGRAM, isSigner: false, isWritable: false },
|
|
2287
|
+
{ pubkey: web3.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2288
|
+
{ pubkey: METEORA_EVENT_AUTHORITY, isSigner: false, isWritable: false },
|
|
2289
|
+
{ pubkey: METEORA_DLMM_PROGRAM, isSigner: false, isWritable: false },
|
|
2290
|
+
// Transfer hook accounts (from fetchRemainingAccountsInfo)
|
|
2291
|
+
...((_c = remainingAccountsInfo === null || remainingAccountsInfo === void 0 ? void 0 : remainingAccountsInfo.accounts) !== null && _c !== void 0 ? _c : []),
|
|
2292
|
+
// Bin arrays as remaining accounts
|
|
2293
|
+
...binArrays.map(pubkey => ({ pubkey, isSigner: false, isWritable: true })),
|
|
2294
|
+
// Boundary account
|
|
2295
|
+
{ pubkey: METEORA_DLMM_PROGRAM, isSigner: false, isWritable: false },
|
|
2296
|
+
// Reward accounts after boundary account
|
|
2297
|
+
...rewardRemainingAccounts,
|
|
2298
|
+
],
|
|
2299
|
+
programId: addresses_1.IYF_EXTENSION,
|
|
2300
|
+
})
|
|
2301
|
+
});
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2162
2304
|
/**
|
|
2163
2305
|
* Remove liquidity from a bin range in a Meteora DLMM position via IYF Extension for automation.
|
|
2164
2306
|
*
|
|
@@ -2191,8 +2333,11 @@ class MeteoraDlmmIxGenerator {
|
|
|
2191
2333
|
userTokenX = (0, functions_1.generateAta)(userPda, tokenXMint, tokenXProgram);
|
|
2192
2334
|
userTokenY = (0, functions_1.generateAta)(userPda, tokenYMint, tokenYProgram);
|
|
2193
2335
|
}
|
|
2194
|
-
// Derive bin array bitmap extension
|
|
2195
|
-
const
|
|
2336
|
+
// Derive bin array bitmap extension
|
|
2337
|
+
const lowerBinArrayIndex = this.binIdToBinArrayIndex(new bn_js_1.default(fromBinId));
|
|
2338
|
+
const upperBinArrayIndex = this.binIdToBinArrayIndex(new bn_js_1.default(toBinId));
|
|
2339
|
+
const binArrayBitmapExtension = (this.isOverflowDefaultBinArrayBitmap(lowerBinArrayIndex) ||
|
|
2340
|
+
this.isOverflowDefaultBinArrayBitmap(upperBinArrayIndex)) ? this.pda.meteora.deriveBinArrayBitmapExtension(lbPair) : METEORA_DLMM_PROGRAM;
|
|
2196
2341
|
// Derive reserves
|
|
2197
2342
|
const reserveX = this.pda.meteora.deriveReserve(tokenXMint, lbPair);
|
|
2198
2343
|
const reserveY = this.pda.meteora.deriveReserve(tokenYMint, lbPair);
|
|
@@ -265,4 +265,35 @@ export declare function toAmountIntoBins(activeId: BN, minDeltaId: BN, maxDeltaI
|
|
|
265
265
|
* @returns Array of chunked deposit parameters
|
|
266
266
|
*/
|
|
267
267
|
export declare function chunkDepositParameters(params: LiquidityStrategyParameters, minDeltaId: BN, maxDeltaId: BN, activeId: BN, binStep: BN, chunkSize: number, favorXInActiveBin?: boolean): ChunkedDepositParameters[];
|
|
268
|
+
/**
|
|
269
|
+
* Chunks a bin range with a custom initial chunk size and uniform subsequent chunk size.
|
|
270
|
+
*
|
|
271
|
+
* @param minBinId - The minimum bin ID of the range
|
|
272
|
+
* @param maxBinId - The maximum bin ID of the range
|
|
273
|
+
* @param initialChunkSize - Size of the first chunk (e.g., 150 bins)
|
|
274
|
+
* @param subsequentChunkSize - Size of subsequent chunks (e.g., 69 bins)
|
|
275
|
+
* @returns Array of chunk ranges with lowerBinId and upperBinId
|
|
276
|
+
*/
|
|
277
|
+
export declare function chunkBinRangeWithInitialSize(minBinId: number, maxBinId: number, initialChunkSize: number, subsequentChunkSize: number): {
|
|
278
|
+
lowerBinId: number;
|
|
279
|
+
upperBinId: number;
|
|
280
|
+
}[];
|
|
281
|
+
/**
|
|
282
|
+
* Chunks deposit parameters with a custom initial chunk size.
|
|
283
|
+
*
|
|
284
|
+
* This is useful when the first deposit can accommodate a larger bin range
|
|
285
|
+
* (e.g., 150 bins for a fresh position) but subsequent deposits need smaller
|
|
286
|
+
* chunks due to compute limits.
|
|
287
|
+
*
|
|
288
|
+
* @param params - The liquidity strategy parameters
|
|
289
|
+
* @param minDeltaId - Minimum delta from active bin
|
|
290
|
+
* @param maxDeltaId - Maximum delta from active bin
|
|
291
|
+
* @param activeId - The current active bin ID
|
|
292
|
+
* @param binStep - The bin step of the pool
|
|
293
|
+
* @param initialChunkSize - Size of the first chunk (e.g., 150 bins)
|
|
294
|
+
* @param subsequentChunkSize - Size of subsequent chunks (e.g., 69 bins)
|
|
295
|
+
* @param favorXInActiveBin - Whether to favor token X in the active bin
|
|
296
|
+
* @returns Array of chunked deposit parameters
|
|
297
|
+
*/
|
|
298
|
+
export declare function chunkDepositParametersWithInitialSize(params: LiquidityStrategyParameters, minDeltaId: BN, maxDeltaId: BN, activeId: BN, binStep: BN, initialChunkSize: number, subsequentChunkSize: number, favorXInActiveBin?: boolean): ChunkedDepositParameters[];
|
|
268
299
|
//# sourceMappingURL=liquidityStrategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liquidityStrategy.d.ts","sourceRoot":"","sources":["../../../src/mete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AAwB,EAAE,CAyD5B"}
|
|
1
|
+
{"version":3,"file":"liquidityStrategy.d.ts","sourceRoot":"","sources":["../../../src/meteora/liquidityStrategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvB;;GAEG;AACH,oBAAY,YAAY;IACtB,sEAAsE;IACtE,IAAI,IAAI;IACR,mEAAmE;IACnE,KAAK,IAAI;IACT,qEAAqE;IACrE,OAAO,IAAI;CACZ;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,2BAA2B;IAC1C,yCAAyC;IACzC,EAAE,EAAE,EAAE,CAAC;IACP,yCAAyC;IACzC,EAAE,EAAE,EAAE,CAAC;IACP,wFAAwF;IACxF,MAAM,EAAE,EAAE,CAAC;IACX,wFAAwF;IACxF,MAAM,EAAE,EAAE,CAAC;CACZ;AAmKD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,CAE1D;AAiHD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,EAAE,EACX,OAAO,EAAE,EAAE,EACX,UAAU,EAAE,EAAE,EACd,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,EAAE,EACX,QAAQ,EAAE,EAAE,EACZ,gBAAgB,GAAE,OAAe,GAChC,2BAA2B,CA0D7B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,EAAE,EACd,UAAU,EAAE,EAAE,EACd,gBAAgB,EAAE,OAAO,EACzB,MAAM,EAAE,2BAA2B,GAClC,2BAA2B,CAmB7B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,EAAE,EACX,OAAO,EAAE,EAAE,EACX,QAAQ,EAAE,EAAE,GACX,EAAE,CAUJ;AAED;;;;;;;GAOG;AACH,wBAAgB,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EAAE,EACZ,OAAO,EAAE,EAAE,EACX,SAAS,EAAE,MAAM,EACjB,iBAAiB,GAAE,OAAe,GACjC,wBAAwB,EAAE,CAyD5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,mBAAmB,EAAE,MAAM,GAC1B;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,CAmB9C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,2BAA2B,EACnC,UAAU,EAAE,EAAE,EACd,UAAU,EAAE,EAAE,EACd,QAAQ,EAAE,EAAE,EACZ,OAAO,EAAE,EAAE,EACX,gBAAgB,EAAE,MAAM,EACxB,mBAAmB,EAAE,MAAM,EAC3B,iBAAiB,GAAE,OAAe,GACjC,wBAAwB,EAAE,CAyD5B"}
|
|
@@ -17,6 +17,8 @@ exports.chunkBinRange = chunkBinRange;
|
|
|
17
17
|
exports.buildBitFlagAndNegateStrategyParameters = buildBitFlagAndNegateStrategyParameters;
|
|
18
18
|
exports.toAmountIntoBins = toAmountIntoBins;
|
|
19
19
|
exports.chunkDepositParameters = chunkDepositParameters;
|
|
20
|
+
exports.chunkBinRangeWithInitialSize = chunkBinRangeWithInitialSize;
|
|
21
|
+
exports.chunkDepositParametersWithInitialSize = chunkDepositParametersWithInitialSize;
|
|
20
22
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
21
23
|
/**
|
|
22
24
|
* Liquidity strategy types matching Meteora DLMM SDK.
|
|
@@ -1067,3 +1069,77 @@ function chunkDepositParameters(params, minDeltaId, maxDeltaId, activeId, binSte
|
|
|
1067
1069
|
}
|
|
1068
1070
|
return result;
|
|
1069
1071
|
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Chunks a bin range with a custom initial chunk size and uniform subsequent chunk size.
|
|
1074
|
+
*
|
|
1075
|
+
* @param minBinId - The minimum bin ID of the range
|
|
1076
|
+
* @param maxBinId - The maximum bin ID of the range
|
|
1077
|
+
* @param initialChunkSize - Size of the first chunk (e.g., 150 bins)
|
|
1078
|
+
* @param subsequentChunkSize - Size of subsequent chunks (e.g., 69 bins)
|
|
1079
|
+
* @returns Array of chunk ranges with lowerBinId and upperBinId
|
|
1080
|
+
*/
|
|
1081
|
+
function chunkBinRangeWithInitialSize(minBinId, maxBinId, initialChunkSize, subsequentChunkSize) {
|
|
1082
|
+
const chunkedBinRange = [];
|
|
1083
|
+
let startBinId = minBinId;
|
|
1084
|
+
let isFirstChunk = true;
|
|
1085
|
+
while (startBinId <= maxBinId) {
|
|
1086
|
+
const currentChunkSize = isFirstChunk ? initialChunkSize : subsequentChunkSize;
|
|
1087
|
+
const endBinId = Math.min(startBinId + currentChunkSize - 1, maxBinId);
|
|
1088
|
+
chunkedBinRange.push({
|
|
1089
|
+
lowerBinId: startBinId,
|
|
1090
|
+
upperBinId: endBinId,
|
|
1091
|
+
});
|
|
1092
|
+
startBinId += currentChunkSize;
|
|
1093
|
+
isFirstChunk = false;
|
|
1094
|
+
}
|
|
1095
|
+
return chunkedBinRange;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Chunks deposit parameters with a custom initial chunk size.
|
|
1099
|
+
*
|
|
1100
|
+
* This is useful when the first deposit can accommodate a larger bin range
|
|
1101
|
+
* (e.g., 150 bins for a fresh position) but subsequent deposits need smaller
|
|
1102
|
+
* chunks due to compute limits.
|
|
1103
|
+
*
|
|
1104
|
+
* @param params - The liquidity strategy parameters
|
|
1105
|
+
* @param minDeltaId - Minimum delta from active bin
|
|
1106
|
+
* @param maxDeltaId - Maximum delta from active bin
|
|
1107
|
+
* @param activeId - The current active bin ID
|
|
1108
|
+
* @param binStep - The bin step of the pool
|
|
1109
|
+
* @param initialChunkSize - Size of the first chunk (e.g., 150 bins)
|
|
1110
|
+
* @param subsequentChunkSize - Size of subsequent chunks (e.g., 69 bins)
|
|
1111
|
+
* @param favorXInActiveBin - Whether to favor token X in the active bin
|
|
1112
|
+
* @returns Array of chunked deposit parameters
|
|
1113
|
+
*/
|
|
1114
|
+
function chunkDepositParametersWithInitialSize(params, minDeltaId, maxDeltaId, activeId, binStep, initialChunkSize, subsequentChunkSize, favorXInActiveBin = false) {
|
|
1115
|
+
// Convert to absolute bin IDs for chunking
|
|
1116
|
+
const lowerBinId = activeId.add(minDeltaId).toNumber();
|
|
1117
|
+
const upperBinId = activeId.add(maxDeltaId).toNumber();
|
|
1118
|
+
// Chunk the bin range with initial size
|
|
1119
|
+
const chunks = chunkBinRangeWithInitialSize(lowerBinId, upperBinId, initialChunkSize, subsequentChunkSize);
|
|
1120
|
+
// For each chunk, calculate the deposit parameters
|
|
1121
|
+
const result = [];
|
|
1122
|
+
for (const chunk of chunks) {
|
|
1123
|
+
const chunkMinDeltaId = new bn_js_1.default(chunk.lowerBinId).sub(activeId);
|
|
1124
|
+
const chunkMaxDeltaId = new bn_js_1.default(chunk.upperBinId).sub(activeId);
|
|
1125
|
+
// Reset uninvolved params for this chunk
|
|
1126
|
+
const chunkParams = resetUninvolvedLiquidityParams(chunkMinDeltaId, chunkMaxDeltaId, favorXInActiveBin, params);
|
|
1127
|
+
// Calculate amounts for this chunk using toAmountIntoBins
|
|
1128
|
+
const binsAmounts = toAmountIntoBins(activeId, chunkMinDeltaId, chunkMaxDeltaId, chunkParams.deltaX, chunkParams.deltaY, chunkParams.x0, chunkParams.y0, binStep, favorXInActiveBin);
|
|
1129
|
+
// Sum up amounts
|
|
1130
|
+
const { totalXAmount, totalYAmount } = binsAmounts.reduce((acc, bin) => ({
|
|
1131
|
+
totalXAmount: acc.totalXAmount.add(bin.amountX),
|
|
1132
|
+
totalYAmount: acc.totalYAmount.add(bin.amountY),
|
|
1133
|
+
}), { totalXAmount: new bn_js_1.default(0), totalYAmount: new bn_js_1.default(0) });
|
|
1134
|
+
result.push({
|
|
1135
|
+
lowerBinId: chunk.lowerBinId,
|
|
1136
|
+
upperBinId: chunk.upperBinId,
|
|
1137
|
+
minDeltaId: chunkMinDeltaId,
|
|
1138
|
+
maxDeltaId: chunkMaxDeltaId,
|
|
1139
|
+
params: chunkParams,
|
|
1140
|
+
maxAmountX: totalXAmount,
|
|
1141
|
+
maxAmountY: totalYAmount,
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
return result;
|
|
1145
|
+
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -511,6 +511,82 @@ export type LabeledInstructions = {
|
|
|
511
511
|
instructions: web3.TransactionInstruction[];
|
|
512
512
|
labels: string[];
|
|
513
513
|
};
|
|
514
|
+
export type MeteoraRebalanceLargePositionAutomation2 = {
|
|
515
|
+
userWallet: web3.PublicKey;
|
|
516
|
+
lbPair: web3.PublicKey;
|
|
517
|
+
position: web3.PublicKey;
|
|
518
|
+
relativeLowerBin: number;
|
|
519
|
+
width: number;
|
|
520
|
+
distribution: Distribution;
|
|
521
|
+
shouldClaimFee?: boolean;
|
|
522
|
+
shouldClaimReward?: boolean;
|
|
523
|
+
};
|
|
524
|
+
/**
|
|
525
|
+
* Params for removing liquidity in rebalance
|
|
526
|
+
*/
|
|
527
|
+
export type RemoveLiquidityParams = {
|
|
528
|
+
minBinId?: number;
|
|
529
|
+
maxBinId?: number;
|
|
530
|
+
bps: number;
|
|
531
|
+
};
|
|
532
|
+
/**
|
|
533
|
+
* Params for adding liquidity in rebalance
|
|
534
|
+
*/
|
|
535
|
+
export type AddLiquidityParams = {
|
|
536
|
+
minDeltaId: number;
|
|
537
|
+
maxDeltaId: number;
|
|
538
|
+
x0: BN;
|
|
539
|
+
y0: BN;
|
|
540
|
+
deltaX: BN;
|
|
541
|
+
deltaY: BN;
|
|
542
|
+
bitFlag: number;
|
|
543
|
+
favorXInActiveId: boolean;
|
|
544
|
+
};
|
|
545
|
+
/**
|
|
546
|
+
* Full params for the Meteora rebalance_liquidity instruction
|
|
547
|
+
*/
|
|
548
|
+
export type RebalanceLiquidityParams = {
|
|
549
|
+
activeId: number;
|
|
550
|
+
maxActiveBinSlippage: number;
|
|
551
|
+
shouldClaimFee: boolean;
|
|
552
|
+
shouldClaimReward: boolean;
|
|
553
|
+
minWithdrawXAmount: BN;
|
|
554
|
+
maxDepositXAmount: BN;
|
|
555
|
+
minWithdrawYAmount: BN;
|
|
556
|
+
maxDepositYAmount: BN;
|
|
557
|
+
shrinkMode: number;
|
|
558
|
+
removeLiquidityParams: RemoveLiquidityParams[];
|
|
559
|
+
addLiquidityParams: AddLiquidityParams[];
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* Meteora DLMM position shrink mode for rebalance_liquidity.
|
|
563
|
+
*
|
|
564
|
+
* Controls whether the position account is shrunk (reallocated smaller)
|
|
565
|
+
* after liquidity removal during a rebalance operation.
|
|
566
|
+
*
|
|
567
|
+
* Stored in the first byte of the 32-byte padding field of RebalanceLiquidityParams.
|
|
568
|
+
*/
|
|
569
|
+
export declare enum ShrinkMode {
|
|
570
|
+
/** Default — allow shrinking on both sides (Meteora SDK default) */
|
|
571
|
+
Default = 0,
|
|
572
|
+
/** Do not shrink the lower side */
|
|
573
|
+
NoShrinkLower = 1,
|
|
574
|
+
/** Do not shrink the upper side */
|
|
575
|
+
NoShrinkUpper = 2,
|
|
576
|
+
/** Do not shrink either side */
|
|
577
|
+
NoShrinkBoth = 3
|
|
578
|
+
}
|
|
579
|
+
export type MeteoraReshapePositionAutomationParams = {
|
|
580
|
+
userWallet: web3.PublicKey;
|
|
581
|
+
lbPair: web3.PublicKey;
|
|
582
|
+
position: web3.PublicKey;
|
|
583
|
+
relativeLowerBin: number;
|
|
584
|
+
activeId: number;
|
|
585
|
+
width: number;
|
|
586
|
+
distribution: Distribution;
|
|
587
|
+
removeLiquidityParams: RemoveLiquidityParams[];
|
|
588
|
+
addLiquidityParams: AddLiquidityParams[];
|
|
589
|
+
};
|
|
514
590
|
export type MeteoraLimitCloseAutomation = {
|
|
515
591
|
userWallet: web3.PublicKey;
|
|
516
592
|
position: web3.PublicKey;
|
|
@@ -551,7 +627,7 @@ export type MeteoraCreatePoolAndPosition = {
|
|
|
551
627
|
* - Initialize position instruction (max 70 bins initial)
|
|
552
628
|
* - Multiple increase position length instructions (91 bins each) to reach the target size
|
|
553
629
|
*
|
|
554
|
-
* Maximum supported:
|
|
630
|
+
* Maximum supported: 1400 bins per position (limited by Meteora)
|
|
555
631
|
*/
|
|
556
632
|
export type MeteoraInitializeLargePosition = {
|
|
557
633
|
userWallet: web3.PublicKey;
|
|
@@ -574,8 +650,6 @@ export type MeteoraDepositToLargePosition = {
|
|
|
574
650
|
totalYAmount: BN;
|
|
575
651
|
/** Strategy type: 0 = SPOT, 1 = CURVE, 2 = BID_ASK. Defaults to SPOT. */
|
|
576
652
|
strategyType?: number;
|
|
577
|
-
/** Whether X token is favored in the active bin. Defaults to false. */
|
|
578
|
-
favorXInActiveId?: boolean;
|
|
579
653
|
pdaTokenType?: TokenType;
|
|
580
654
|
};
|
|
581
655
|
/**
|
|
@@ -607,6 +681,29 @@ export type MeteoraDepositLargerPosition = {
|
|
|
607
681
|
/** If true, initialize the position first. If false, skip position initialization. */
|
|
608
682
|
initializePosition?: boolean;
|
|
609
683
|
};
|
|
684
|
+
/**
|
|
685
|
+
* Meteora DLMM Create Position and Deposit to Large Position
|
|
686
|
+
*
|
|
687
|
+
* Combined method that creates a position AND deposits liquidity for any bin count.
|
|
688
|
+
* - For ≤149 bins: delegates to meteoraDepositLargerPosition (single tx)
|
|
689
|
+
* - For ≥150 bins: uses _meteoraInitializeLargePosition + _meteoraDepositToLargePosition (multi-tx)
|
|
690
|
+
*/
|
|
691
|
+
export type MeteoraCreatePositionAndDepositToLargePosition = {
|
|
692
|
+
userWallet: web3.PublicKey;
|
|
693
|
+
lbPair: web3.PublicKey;
|
|
694
|
+
position: web3.PublicKey;
|
|
695
|
+
lowerBinId: number;
|
|
696
|
+
upperBinId: number;
|
|
697
|
+
totalXAmount: BN;
|
|
698
|
+
totalYAmount: BN;
|
|
699
|
+
/** Strategy type: 0 = SPOT, 1 = CURVE, 2 = BID_ASK. Defaults to SPOT. Used for ≥150-bin path. */
|
|
700
|
+
strategyType?: number;
|
|
701
|
+
/** Distribution type. Used for ≤149-bin path. Defaults to 'SPOT-IMBALANCED'. */
|
|
702
|
+
distribution?: Distribution;
|
|
703
|
+
slippage?: number;
|
|
704
|
+
skipInputTokenCheck?: boolean;
|
|
705
|
+
pdaTokenType?: TokenType;
|
|
706
|
+
};
|
|
610
707
|
export type OrcaOpenPosition = {
|
|
611
708
|
userWallet: web3.PublicKey;
|
|
612
709
|
positionMint: web3.PublicKey;
|
|
@@ -858,41 +955,4 @@ export declare enum MeteoraPositionSide {
|
|
|
858
955
|
Lower = 0,
|
|
859
956
|
Upper = 1
|
|
860
957
|
}
|
|
861
|
-
/**
|
|
862
|
-
* Params for removing liquidity in rebalance
|
|
863
|
-
*/
|
|
864
|
-
export type RemoveLiquidityParams = {
|
|
865
|
-
minBinId?: number;
|
|
866
|
-
maxBinId?: number;
|
|
867
|
-
bps: number;
|
|
868
|
-
};
|
|
869
|
-
/**
|
|
870
|
-
* Params for adding liquidity in rebalance
|
|
871
|
-
*/
|
|
872
|
-
export type AddLiquidityParams = {
|
|
873
|
-
minDeltaId: number;
|
|
874
|
-
maxDeltaId: number;
|
|
875
|
-
x0: BN;
|
|
876
|
-
y0: BN;
|
|
877
|
-
deltaX: BN;
|
|
878
|
-
deltaY: BN;
|
|
879
|
-
bitFlag: number;
|
|
880
|
-
favorXInActiveId: boolean;
|
|
881
|
-
};
|
|
882
|
-
/**
|
|
883
|
-
* Full params for the Meteora rebalance_liquidity instruction
|
|
884
|
-
*/
|
|
885
|
-
export type RebalanceLiquidityParams = {
|
|
886
|
-
activeId: number;
|
|
887
|
-
maxActiveBinSlippage: number;
|
|
888
|
-
shouldClaimFee: boolean;
|
|
889
|
-
shouldClaimReward: boolean;
|
|
890
|
-
minWithdrawXAmount: BN;
|
|
891
|
-
maxDepositXAmount: BN;
|
|
892
|
-
minWithdrawYAmount: BN;
|
|
893
|
-
maxDepositYAmount: BN;
|
|
894
|
-
shrinkMode: number;
|
|
895
|
-
removeLiquidityParams: RemoveLiquidityParams[];
|
|
896
|
-
addLiquidityParams: AddLiquidityParams[];
|
|
897
|
-
};
|
|
898
958
|
//# sourceMappingURL=types.d.ts.map
|