@hawksightco/hawk-sdk 1.3.99 → 1.3.100

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../../src/classes/Transactions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAoBxC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,+BAA+B,EAC/B,kCAAkC,EAClC,cAAc,EACd,0BAA0B,EAC1B,gBAAgB,EAChB,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,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EAEpB,gBAAgB,EAChB,+BAA+B,EAChC,MAAM,UAAU,CAAC;AA8BlB,OAAO,EAEL,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAKlB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAexD,qBAAa,YAAY;IACvB;;OAEG;IACH,OAAO;IAKP;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IAEtC;;OAEG;IACI,EAAE,EAAE,iBAAiB,CAAC;IAE7B;;OAEG;IACH,OAAO,CAAC,OAAO,CAAmB;IAElC;;;;OAIG;IACH,MAAM,CAAC,WAAW,IAAI,YAAY;IAOlC;;;;;;OAMG;IACH,eAAe,CACb,UAAU,EAAE,IAAI,CAAC,SAAS,EAC1B,IAAI,GAAE,I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BAA2B,CAAC;IA8H1E;;;;;;;OAOG;IACG,+BAA+B,CAAC,EACpC,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,+BAA+B,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA8GtF;;;;;;OAMG;IACG,oBAAoB,CAAC,EACzB,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAuB3E;;;;;;OAMG;IACG,wBAAwB,CAAC,EAC7B,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAmG/E;;;;;;OAMG;IACG,wBAAwB,CAAC,EAC7B,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAmFhF;AAED,eAAO,MAAM,KAAK,cAA6B,CAAC"}
1
+ {"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../../src/classes/Transactions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAoBxC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,+BAA+B,EAC/B,kCAAkC,EAClC,cAAc,EACd,0BAA0B,EAC1B,gBAAgB,EAChB,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,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EAEpB,gBAAgB,EAChB,+BAA+B,EAChC,MAAM,UAAU,CAAC;AA8BlB,OAAO,EAEL,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAKlB,OAAO,EAAE,c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U,EACV,MAAM,GACP,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAkHnE;;;;;;;OAOG;IACG,eAAe,CAAC,EACpB,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAqOnE;;;;;;;OAOG;IACG,gBAAgB,CAAC,EACrB,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAsJvE;;;;;;OAMG;IACG,mBAAmB,CAAC,EACxB,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA8H1E;;;;;;;OAOG;IACG,+BAA+B,CAAC,EACpC,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,+BAA+B,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA8GtF;;;;;;OAMG;IACG,oBAAoB,CAAC,EACzB,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAuB3E;;;;;;OAMG;IACG,wBAAwB,CAAC,EAC7B,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAmG/E;;;;;;OAMG;IACG,wBAAwB,CAAC,EAC7B,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAmFhF;AAED,eAAO,MAAM,KAAK,cAA6B,CAAC"}
@@ -1118,112 +1118,158 @@ class Transactions {
1118
1118
  }
1119
1119
  limitCloseAutomationIx(_a) {
1120
1120
  return __awaiter(this, arguments, void 0, function* ({ connection, params, }) {
1121
- const program = yield meteora_1.MeteoraDLMM.program(connection);
1122
- const position = yield program.account.positionV2.fetch(params.position);
1123
- const dlmmPool = yield meteora_1.MeteoraDLMM.create(connection, position.lbPair, this.ix);
1124
- const userPda = (0, functions_1.generateUserPda)(params.userWallet);
1125
- // Step 1: Claim all fees/rewards, remove all liquidity and close current position
1126
- // const { userPositions } = await dlmmPool.getPositionsByUserAndLbPair(
1127
- // userPda
1128
- // );
1129
- // const binIdsToRemove = userPositions[0].positionData.positionBinData.map(
1130
- // (bin) => bin.binId
1131
- // );
1132
- const binIdsToRemove = [];
1133
- for (let i = position.lowerBinId; i <= position.upperBinId; i++) {
1134
- binIdsToRemove.push(i);
1135
- }
1136
- // Claim fees and/or rewards, remove liquidity, and possibly close position from Meteora API (if set)
1137
- const txn = yield dlmmPool.dlmm.removeLiquidity({
1138
- user: userPda,
1139
- position: params.position,
1140
- fromBinId: position.lowerBinId,
1141
- toBinId: position.upperBinId,
1142
- bps: new bn_js_1.default(10000),
1143
- shouldClaimAndClose: true,
1144
- });
1145
- // Filter out non-meteora instructions
1146
- const ixs = (0, functions_1.getIxs)(txn).filter((ix) => ix.programId.equals(addresses_1.METEORA_DLMM_PROGRAM));
1147
- const farm = addresses_1.USDC_FARM;
1148
- const authority = params.userWallet;
1149
- const iyfProgram = addresses_1.IYF_MAIN;
1150
- const hawksightAuthority = addresses_1.HS_AUTHORITY;
1151
- const { params: _params, data } = this.removeLiquidityByRange2Info(ixs);
1152
- let { position: _position, lbPair, binArrayBitmapExtension, reserveX, reserveY, tokenXMint, tokenYMint, sender, tokenXProgram, tokenYProgram, memoProgram, eventAuthority, program: meteoraDlmmProgram, binArrays, } = _params;
1153
- let ix;
1154
- if (params.isLimitOrder) {
1155
- const limitTokenX = (0, functions_1.generateLimitToken)(userPda, tokenXMint.pubkey);
1156
- const limitTokenY = (0, functions_1.generateLimitToken)(userPda, tokenYMint.pubkey);
1157
- const authorityTokenX = (0, functions_1.generateAta)(hawksightAuthority, tokenXMint.pubkey);
1158
- const authorityTokenY = (0, functions_1.generateAta)(hawksightAuthority, tokenYMint.pubkey);
1159
- // Use MeteoraDlmmIxGenerator for limitOrderCloseV2
1160
- const limitCloseAutomationIx = yield this.ix.meteoraDlmm.limitOrderCloseV2({
1161
- connection,
1162
- userWallet: params.userWallet,
1163
- position: _position.pubkey,
1164
- lbPair: lbPair.pubkey,
1165
- tokenXMint: tokenXMint.pubkey,
1166
- tokenYMint: tokenYMint.pubkey,
1167
- reserveX: reserveX.pubkey,
1168
- reserveY: reserveY.pubkey,
1169
- tokenXProgram: tokenXProgram.pubkey,
1170
- tokenYProgram: tokenYProgram.pubkey,
1171
- useFuelAccount: false, // todo: update this
1172
- param: data,
1121
+ try {
1122
+ console.log('=== LIMIT CLOSE AUTOMATION IX START ===');
1123
+ console.log('Params:', JSON.stringify({
1124
+ userWallet: params.userWallet.toString(),
1125
+ position: params.position.toString(),
1173
1126
  minBinId: params.minBinId,
1174
1127
  maxBinId: params.maxBinId,
1175
- binArrays,
1128
+ pdaTokenType: params.pdaTokenType
1129
+ }, null, 2));
1130
+ console.log('Step 1: Fetching position data...');
1131
+ const program = yield meteora_1.MeteoraDLMM.program(connection);
1132
+ const position = yield program.account.positionV2.fetch(params.position);
1133
+ console.log('Position data:', {
1134
+ lbPair: position.lbPair.toString(),
1135
+ lowerBinId: position.lowerBinId,
1136
+ upperBinId: position.upperBinId,
1137
+ owner: position.owner.toString()
1176
1138
  });
1177
- // Instruction via main hawksight contract
1178
- // @ts-ignore
1179
- ix = yield anchor_1.Anchor.instance()
1180
- .iyfMain.methods.iyfExtensionExecuteV2(limitCloseAutomationIx.data)
1181
- .accounts({
1182
- userPda,
1183
- authority,
1184
- iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1185
- })
1186
- .remainingAccounts([...limitCloseAutomationIx.keys.slice(2)])
1187
- .instruction();
1188
- }
1189
- else {
1190
- // @ts-ignore
1191
- const limitCloseAutomationIx = yield this.ix.meteoraDlmm.meteoraDlmmLimitCloseAutomationV2({
1192
- connection,
1193
- userWallet: params.userWallet,
1194
- position: _position.pubkey,
1195
- lbPair: lbPair.pubkey,
1196
- tokenXMint: tokenXMint.pubkey,
1197
- tokenYMint: tokenYMint.pubkey,
1198
- reserveX: reserveX.pubkey,
1199
- reserveY: reserveY.pubkey,
1200
- tokenXProgram: tokenXProgram.pubkey,
1201
- tokenYProgram: tokenYProgram.pubkey,
1202
- pdaTokenType: params.pdaTokenType,
1203
- useFuelAccount: false,
1204
- param: data,
1205
- minBinId: params.minBinId,
1206
- maxBinId: params.maxBinId,
1207
- isHawkRefund: false,
1208
- binArrays: binArrays,
1139
+ console.log('Step 2: Creating DLMM pool...');
1140
+ const dlmmPool = yield meteora_1.MeteoraDLMM.create(connection, position.lbPair, this.ix);
1141
+ console.log('DLMM pool created successfully');
1142
+ const userPda = (0, functions_1.generateUserPda)(params.userWallet);
1143
+ console.log('User PDA generated:', userPda.toString());
1144
+ // Step 1: Claim all fees/rewards, remove all liquidity and close current position
1145
+ // const { userPositions } = await dlmmPool.getPositionsByUserAndLbPair(
1146
+ // userPda
1147
+ // );
1148
+ // const binIdsToRemove = userPositions[0].positionData.positionBinData.map(
1149
+ // (bin) => bin.binId
1150
+ // );
1151
+ const binIdsToRemove = [];
1152
+ for (let i = position.lowerBinId; i <= position.upperBinId; i++) {
1153
+ binIdsToRemove.push(i);
1154
+ }
1155
+ console.log('Bin IDs to remove:', binIdsToRemove);
1156
+ console.log('Step 3: Calling removeLiquidity...');
1157
+ console.log('removeLiquidity params:', {
1158
+ user: userPda.toString(),
1159
+ position: params.position.toString(),
1160
+ fromBinId: position.lowerBinId,
1161
+ toBinId: position.upperBinId,
1162
+ bps: 10000,
1163
+ shouldClaimAndClose: true
1209
1164
  });
1210
- // Instruction via main hawksight contract using iyfExtensionExecuteV2
1211
- ix = yield this.ix.iyfMain.iyfExtensionExecuteV2(connection, {
1212
- userPda,
1213
- authority: hawksightAuthority,
1214
- ix: limitCloseAutomationIx,
1165
+ // Claim fees and/or rewards, remove liquidity, and possibly close position from Meteora API (if set)
1166
+ const txn = yield dlmmPool.dlmm.removeLiquidity({
1167
+ user: userPda,
1168
+ position: params.position,
1169
+ fromBinId: position.lowerBinId,
1170
+ toBinId: position.upperBinId,
1171
+ bps: new bn_js_1.default(10000),
1172
+ shouldClaimAndClose: true,
1173
+ });
1174
+ console.log('removeLiquidity completed successfully');
1175
+ console.log('Transaction array length:', txn.length);
1176
+ console.log('Total instructions across all transactions:', txn.reduce((total, tx) => total + tx.instructions.length, 0));
1177
+ console.log('Step 4: Filtering Meteora instructions...');
1178
+ // Filter out non-meteora instructions
1179
+ const ixs = (0, functions_1.getIxs)(txn).filter((ix) => ix.programId.equals(addresses_1.METEORA_DLMM_PROGRAM));
1180
+ console.log('Filtered Meteora instructions count:', ixs.length);
1181
+ const farm = addresses_1.USDC_FARM;
1182
+ const authority = params.userWallet;
1183
+ const iyfProgram = addresses_1.IYF_MAIN;
1184
+ const hawksightAuthority = addresses_1.HS_AUTHORITY;
1185
+ const { params: _params, data } = this.removeLiquidityByRange2Info(ixs);
1186
+ let { position: _position, lbPair, binArrayBitmapExtension, reserveX, reserveY, tokenXMint, tokenYMint, sender, tokenXProgram, tokenYProgram, memoProgram, eventAuthority, program: meteoraDlmmProgram, binArrays, } = _params;
1187
+ let ix;
1188
+ if (params.isLimitOrder) {
1189
+ const limitTokenX = (0, functions_1.generateLimitToken)(userPda, tokenXMint.pubkey);
1190
+ const limitTokenY = (0, functions_1.generateLimitToken)(userPda, tokenYMint.pubkey);
1191
+ const authorityTokenX = (0, functions_1.generateAta)(hawksightAuthority, tokenXMint.pubkey);
1192
+ const authorityTokenY = (0, functions_1.generateAta)(hawksightAuthority, tokenYMint.pubkey);
1193
+ // Use MeteoraDlmmIxGenerator for limitOrderCloseV2
1194
+ const limitCloseAutomationIx = yield this.ix.meteoraDlmm.limitOrderCloseV2({
1195
+ connection,
1196
+ userWallet: params.userWallet,
1197
+ position: _position.pubkey,
1198
+ lbPair: lbPair.pubkey,
1199
+ tokenXMint: tokenXMint.pubkey,
1200
+ tokenYMint: tokenYMint.pubkey,
1201
+ reserveX: reserveX.pubkey,
1202
+ reserveY: reserveY.pubkey,
1203
+ tokenXProgram: tokenXProgram.pubkey,
1204
+ tokenYProgram: tokenYProgram.pubkey,
1205
+ useFuelAccount: false, // todo: update this
1206
+ param: data,
1207
+ minBinId: params.minBinId,
1208
+ maxBinId: params.maxBinId,
1209
+ binArrays,
1210
+ });
1211
+ // Instruction via main hawksight contract
1212
+ // @ts-ignore
1213
+ ix = yield anchor_1.Anchor.instance()
1214
+ .iyfMain.methods.iyfExtensionExecuteV2(limitCloseAutomationIx.data)
1215
+ .accounts({
1216
+ userPda,
1217
+ authority,
1218
+ iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1219
+ })
1220
+ .remainingAccounts([...limitCloseAutomationIx.keys.slice(2)])
1221
+ .instruction();
1222
+ }
1223
+ else {
1224
+ // @ts-ignore
1225
+ const limitCloseAutomationIx = yield this.ix.meteoraDlmm.meteoraDlmmLimitCloseAutomationV2({
1226
+ connection,
1227
+ userWallet: params.userWallet,
1228
+ position: _position.pubkey,
1229
+ lbPair: lbPair.pubkey,
1230
+ tokenXMint: tokenXMint.pubkey,
1231
+ tokenYMint: tokenYMint.pubkey,
1232
+ reserveX: reserveX.pubkey,
1233
+ reserveY: reserveY.pubkey,
1234
+ tokenXProgram: tokenXProgram.pubkey,
1235
+ tokenYProgram: tokenYProgram.pubkey,
1236
+ pdaTokenType: params.pdaTokenType,
1237
+ useFuelAccount: false,
1238
+ param: data,
1239
+ minBinId: params.minBinId,
1240
+ maxBinId: params.maxBinId,
1241
+ isHawkRefund: false,
1242
+ binArrays: binArrays,
1243
+ });
1244
+ // Instruction via main hawksight contract using iyfExtensionExecuteV2
1245
+ ix = yield this.ix.iyfMain.iyfExtensionExecuteV2(connection, {
1246
+ userPda,
1247
+ authority: hawksightAuthority,
1248
+ ix: limitCloseAutomationIx,
1249
+ });
1250
+ }
1251
+ console.log('Step 7: Creating transaction metadata...');
1252
+ const mainInstructions = [
1253
+ // Limit Close Automation Instruction (Hawksight CPI)
1254
+ ix,
1255
+ ];
1256
+ console.log('=== LIMIT CLOSE AUTOMATION IX SUCCESS ===');
1257
+ return (0, functions_1.createTransactionMeta)({
1258
+ payer: params.userWallet,
1259
+ description: "Automation IX: Meteora limit close instruction (Full withdraw and close on to specific bin id)",
1260
+ addressLookupTableAddresses: addresses_1.GLOBAL_ALT,
1261
+ mainInstructions,
1215
1262
  });
1216
1263
  }
1217
- const mainInstructions = [
1218
- // Limit Close Automation Instruction (Hawksight CPI)
1219
- ix,
1220
- ];
1221
- return (0, functions_1.createTransactionMeta)({
1222
- payer: params.userWallet,
1223
- description: "Automation IX: Meteora limit close instruction (Full withdraw and close on to specific bin id)",
1224
- addressLookupTableAddresses: addresses_1.GLOBAL_ALT,
1225
- mainInstructions,
1226
- });
1264
+ catch (error) {
1265
+ console.error('=== LIMIT CLOSE AUTOMATION IX ERROR ===');
1266
+ console.error('Error type:', error instanceof Error ? error.constructor.name : typeof error);
1267
+ console.error('Error message:', error instanceof Error ? error.message : String(error));
1268
+ console.error('Error stack:', error instanceof Error ? error.stack : 'No stack trace');
1269
+ console.error('Full error object:', error);
1270
+ console.error('=== END LIMIT CLOSE ERROR LOG ===');
1271
+ throw error;
1272
+ }
1227
1273
  });
1228
1274
  }
1229
1275
  limitCloseAutomationIx2(_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hawksightco/hawk-sdk",
3
- "version": "1.3.99",
3
+ "version": "1.3.100",
4
4
  "description": "Hawksight v2 SDK",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": "https://github.com/ghabxph/hawk-api-client.git",