@hawksightco/hawk-sdk 1.3.51 → 1.3.52
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/hsToMeteora.js +77 -0
- package/package.json +1 -1
package/dist/src/hsToMeteora.js
CHANGED
|
@@ -1184,6 +1184,7 @@ class HawksightMeteoraAutomationCpi {
|
|
|
1184
1184
|
.next(new ClaimRewardAutomation(ix, userPda, authority, opt))
|
|
1185
1185
|
.next(new ClosePositionAutomation(ix, userPda, authority, opt))
|
|
1186
1186
|
.next(new MeteoraDlmmClaimFee2Automation(ix, userPda, authority, opt))
|
|
1187
|
+
.next(new MeteoraDlmmClaimReward2Automation(ix, userPda, authority, opt))
|
|
1187
1188
|
.next(new MeteoraDlmmDeposit2Automation(ix, userPda, authority, opt))
|
|
1188
1189
|
.next(new MeteoraDlmmWithdraw2Automation(ix, userPda, authority, opt));
|
|
1189
1190
|
return chain;
|
|
@@ -2227,6 +2228,82 @@ class MeteoraDlmmClaimFee2Automation extends HawksightMeteoraAutomationCpi {
|
|
|
2227
2228
|
});
|
|
2228
2229
|
}
|
|
2229
2230
|
}
|
|
2231
|
+
/**
|
|
2232
|
+
* Handles Meteora DLMM Claim Fee v2 Automation instruction.
|
|
2233
|
+
*/
|
|
2234
|
+
class MeteoraDlmmClaimReward2Automation extends HawksightMeteoraAutomationCpi {
|
|
2235
|
+
/**
|
|
2236
|
+
* Constructs an instance of MeteoraDlmmClaimFee2Automation with the necessary transaction parameters.
|
|
2237
|
+
*
|
|
2238
|
+
* @param ix The core transaction instruction.
|
|
2239
|
+
* @param userPda The user's program-derived address (PDA) as a public key.
|
|
2240
|
+
* @param authority The authority public key that has signing capabilities over the transaction.
|
|
2241
|
+
*/
|
|
2242
|
+
constructor(ix, userPda, authority, opt) {
|
|
2243
|
+
super(ix, userPda, authority, util.sighash("claim_reward2", undefined, true), opt);
|
|
2244
|
+
}
|
|
2245
|
+
/**
|
|
2246
|
+
* Modifies transaction keys for the purpose of claiming transaction fees.
|
|
2247
|
+
*/
|
|
2248
|
+
replace() {
|
|
2249
|
+
this.ix.keys[3].pubkey = this.userPda;
|
|
2250
|
+
this.ix.keys[3].isSigner = false;
|
|
2251
|
+
}
|
|
2252
|
+
/**
|
|
2253
|
+
* Replaces Meteora CPI with Hawksight CPI that calls the target Meteora CPI.
|
|
2254
|
+
*/
|
|
2255
|
+
replaceCpi() {
|
|
2256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2257
|
+
// Common parameters
|
|
2258
|
+
const userPda = this.userPda;
|
|
2259
|
+
const authority = this.authority;
|
|
2260
|
+
// New meteora parameters
|
|
2261
|
+
const minBinId = this.ix.data.readInt32LE(12);
|
|
2262
|
+
const maxBinId = this.ix.data.readInt32LE(16);
|
|
2263
|
+
const remainingAccountsInfo = this.ix.data.subarray(24);
|
|
2264
|
+
const rewardMint = this.ix.keys[4].pubkey;
|
|
2265
|
+
const rewardMintInfo = AccountCache_1.AccountCache.get(rewardMint);
|
|
2266
|
+
const ownerFee = util.generateAta(addresses_1.SITE_FEE_OWNER, rewardMint, rewardMintInfo === null || rewardMintInfo === void 0 ? void 0 : rewardMintInfo.info.owner);
|
|
2267
|
+
// Get reward index from parameter
|
|
2268
|
+
const rewardIndex = Number(this.ix.data.readBigInt64LE(8).toString());
|
|
2269
|
+
// Generate IX via extension contract
|
|
2270
|
+
// @ts-ignore
|
|
2271
|
+
const claimReward = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
2272
|
+
.meteoraDlmmClaimReward2(rewardIndex, minBinId, maxBinId, remainingAccountsInfo)
|
|
2273
|
+
.accounts({
|
|
2274
|
+
userPda,
|
|
2275
|
+
authority,
|
|
2276
|
+
lbPair: this.ix.keys[0].pubkey,
|
|
2277
|
+
position: this.ix.keys[1].pubkey,
|
|
2278
|
+
rewardVault: this.ix.keys[3].pubkey,
|
|
2279
|
+
rewardMint: this.ix.keys[4].pubkey,
|
|
2280
|
+
userTokenAccount: this.ix.keys[5].pubkey,
|
|
2281
|
+
tokenProgram: this.ix.keys[6].pubkey,
|
|
2282
|
+
memoProgram: this.ix.keys[7].pubkey,
|
|
2283
|
+
eventAuthority: this.ix.keys[8].pubkey,
|
|
2284
|
+
meteoraDlmmProgram: this.ix.keys[9].pubkey,
|
|
2285
|
+
ownerFee,
|
|
2286
|
+
})
|
|
2287
|
+
.remainingAccounts(this.ix.keys.slice(10))
|
|
2288
|
+
.instruction();
|
|
2289
|
+
const sighash = util.sighash("meteora_dlmm_claim_reward_2");
|
|
2290
|
+
claimReward.data.set(sighash, 0);
|
|
2291
|
+
// Instruction via main hawksight contract
|
|
2292
|
+
// @ts-ignore
|
|
2293
|
+
const ix = yield anchor_1.Anchor.instance().iyfMain.methods
|
|
2294
|
+
.iyfExtensionExecuteV2(claimReward.data)
|
|
2295
|
+
.accounts({
|
|
2296
|
+
userPda,
|
|
2297
|
+
authority,
|
|
2298
|
+
iyfExtensionProgram: addresses_1.IYF_EXTENSION,
|
|
2299
|
+
})
|
|
2300
|
+
.remainingAccounts(claimReward.keys.slice(2))
|
|
2301
|
+
.instruction();
|
|
2302
|
+
// Override the instruction
|
|
2303
|
+
this._ix = ix;
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2230
2307
|
/**
|
|
2231
2308
|
* Handles Meteora DLMM Deposit v2 Automation instruction.
|
|
2232
2309
|
*/
|