Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hawksightco/hawk-sdk

Package Overview
Dependencies
Maintainers
0
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hawksightco/hawk-sdk - npm Package Compare versions

Comparing version 1.1.42-rc3 to 1.1.42

200

dist/src/hsToMeteora.js

@@ -48,9 +48,11 @@ "use strict";

return __awaiter(this, arguments, void 0, function* ({ ixs, userPda, authority }) {
return ixs.map((ix) => {
ix = HawksightMeteoraCpi.factory(ix, userPda, authority).getInstruction();
const _ixs = [];
for (const ix of ixs) {
const _ix = yield HawksightMeteoraCpi.factory(ix, userPda, authority).getInstruction();
if (ix.programId.toString() === addresses_1.ASSOCIATED_TOKEN_PROGRAM.toString() && ix.keys.length === 6) {
ix.keys[0] = Object.assign(Object.assign({}, ix.keys[0]), { pubkey: authority });
}
return ix;
});
_ixs.push(_ix);
}
return _ixs;
});

@@ -145,11 +147,32 @@ }

getInstruction() {
const matchInstance = this.sighashMatch();
if (this.programIdMatch() && matchInstance !== undefined) {
matchInstance.replace();
matchInstance.addHawksightCpi();
return __awaiter(this, void 0, void 0, function* () {
const matchInstance = this.sighashMatch();
if (this.programIdMatch() && matchInstance !== undefined) {
matchInstance.replace();
yield matchInstance.addHawksightCpi();
return this.ix;
}
return this.ix;
}
return this.ix;
});
}
/**
* Modifies the transaction instruction to include specific Hawksight CPI details.
* Prepares the instruction for execution by adjusting its program ID and data based on Hawksight criteria.
*/
addHawksightCpi() {
return __awaiter(this, void 0, void 0, function* () {
const METEORA_PROGRAM = addresses_1.METEORA_DLMM_PROGRAM;
const size = Buffer.alloc(4);
size.writeUint32LE(this.ix.data.length);
const data = Buffer.concat([util.sighash('meteora_dynamic_cpi'), size, this.ix.data]);
this.ix.programId = addresses_1.IYF_MAIN;
this.ix.data = data;
this.ix.keys.unshift(...[
{ pubkey: this.userPda, isSigner: false, isWritable: false },
{ pubkey: this.authority, isSigner: true, isWritable: true },
{ pubkey: METEORA_PROGRAM, isSigner: false, isWritable: false },
]);
});
}
/**
* Adds a subsequent CPI to the chain.

@@ -192,19 +215,2 @@ * @param next The next CPI object to link.

}
/**
* Modifies the transaction instruction to include specific Hawksight CPI details.
* Prepares the instruction for execution by adjusting its program ID and data based on Hawksight criteria.
*/
addHawksightCpi() {
const METEORA_PROGRAM = addresses_1.METEORA_DLMM_PROGRAM;
const size = Buffer.alloc(4);
size.writeUint32LE(this.ix.data.length);
const data = Buffer.concat([util.sighash('meteora_dynamic_cpi'), size, this.ix.data]);
this.ix.programId = addresses_1.IYF_MAIN;
this.ix.data = data;
this.ix.keys.unshift(...[
{ pubkey: this.userPda, isSigner: false, isWritable: false },
{ pubkey: this.authority, isSigner: true, isWritable: true },
{ pubkey: METEORA_PROGRAM, isSigner: false, isWritable: false },
]);
}
}

@@ -385,2 +391,76 @@ /**

}
/**
* Overrides default add hawksight cpi to use meteoraDlmmClaimFee instead of meteoraDynamicCpi
*/
addHawksightCpi() {
return __awaiter(this, void 0, void 0, function* () {
// Common parameters
const farm = addresses_1.USDC_FARM;
const userPda = this.userPda;
const authority = this.authority;
const iyfProgram = addresses_1.IYF_MAIN;
// Get token mints X and Y
const tokenXMint = this.ix.keys[9].pubkey;
const tokenYMint = this.ix.keys[10].pubkey;
// Generate owner fee X and Y ATA
const ownerFeeX = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenXMint);
const ownerFeeY = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenYMint);
// Generate IX via extension contract
const claimFeeIx = yield anchor_1.Anchor.instance().iyfExtension.methods
.meteoraDlmmClaimFee()
.accounts({
farm,
userPda,
authority,
iyfProgram,
lbPair: this.ix.keys[0].pubkey,
position: this.ix.keys[1].pubkey,
binArrayLower: this.ix.keys[2].pubkey,
binArrayUpper: this.ix.keys[3].pubkey,
reserveX: this.ix.keys[5].pubkey,
reserveY: this.ix.keys[6].pubkey,
userTokenX: this.ix.keys[7].pubkey,
userTokenY: this.ix.keys[8].pubkey,
tokenXMint: this.ix.keys[9].pubkey,
tokenYMint: this.ix.keys[10].pubkey,
tokenProgram: this.ix.keys[11].pubkey,
eventAuthority: this.ix.keys[12].pubkey,
meteoraDlmmProgram: this.ix.keys[13].pubkey,
ownerFeeX,
ownerFeeY,
}).instruction();
// Instruction via main hawksight contract
const ix = yield anchor_1.Anchor.instance().iyfMain.methods
.iyfExtensionExecute(claimFeeIx.data)
.accounts({
farm,
userPda,
authority,
iyfProgram,
iyfExtensionProgram: addresses_1.IYF_EXTENSION,
})
.remainingAccounts([
claimFeeIx.keys[4],
claimFeeIx.keys[5],
claimFeeIx.keys[6],
claimFeeIx.keys[7],
claimFeeIx.keys[8],
claimFeeIx.keys[9],
claimFeeIx.keys[10],
claimFeeIx.keys[11],
claimFeeIx.keys[12],
claimFeeIx.keys[13],
claimFeeIx.keys[14],
claimFeeIx.keys[15],
claimFeeIx.keys[16],
claimFeeIx.keys[17],
claimFeeIx.keys[18],
])
.instruction();
// Override the instruction
this.ix.programId = ix.programId;
this.ix.data = ix.data;
this.ix.keys = ix.keys;
});
}
}

@@ -408,2 +488,68 @@ /**

}
/**
* Overrides default add hawksight cpi to use meteoraDlmmClaimReward instead of meteoraDynamicCpi
*/
addHawksightCpi() {
return __awaiter(this, void 0, void 0, function* () {
// Common parameters
const farm = addresses_1.USDC_FARM;
const userPda = this.userPda;
const authority = this.authority;
const iyfProgram = addresses_1.IYF_MAIN;
// Get token mint
const rewardMint = this.ix.keys[9].pubkey;
// Generate owner fee X and Y ATA
const ownerFee = util.generateAta(addresses_1.SITE_FEE_OWNER, rewardMint);
// Get reward index from parameter
const rewardIndex = new bn_js_1.BN(this.ix.data.readBigInt64LE(8).toString());
// Generate IX via extension contract
const claimReward = yield anchor_1.Anchor.instance().iyfExtension.methods
.meteoraDlmmClaimReward(rewardIndex)
.accounts({
farm,
userPda,
authority,
iyfProgram,
lbPair: this.ix.keys[4].pubkey,
position: this.ix.keys[5].pubkey,
binArrayLower: this.ix.keys[6].pubkey,
binArrayUpper: this.ix.keys[7].pubkey,
rewardVault: this.ix.keys[8].pubkey,
rewardMint: this.ix.keys[9].pubkey,
userTokenAccount: this.ix.keys[10].pubkey,
tokenProgram: this.ix.keys[11].pubkey,
eventAuthority: this.ix.keys[12].pubkey,
meteoraDlmmProgram: this.ix.keys[13].pubkey,
ownerFee,
}).instruction();
// Instruction via main hawksight contract
const ix = yield anchor_1.Anchor.instance().iyfMain.methods
.iyfExtensionExecute(claimReward.data)
.accounts({
farm,
userPda,
authority,
iyfProgram,
iyfExtensionProgram: addresses_1.IYF_EXTENSION,
})
.remainingAccounts([
claimReward.keys[4],
claimReward.keys[5],
claimReward.keys[6],
claimReward.keys[7],
claimReward.keys[8],
claimReward.keys[9],
claimReward.keys[10],
claimReward.keys[11],
claimReward.keys[12],
claimReward.keys[13],
claimReward.keys[14],
])
.instruction();
// Override the instruction
this.ix.programId = ix.programId;
this.ix.data = ix.data;
this.ix.keys = ix.keys;
});
}
}

@@ -410,0 +556,0 @@ /**

2

package.json
{
"name": "@hawksightco/hawk-sdk",
"version": "1.1.42-rc3",
"version": "1.1.42",
"description": "Hawksight v2 SDK",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc