@hawksightco/hawk-sdk 1.1.57 → 1.1.59
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/functions.d.ts +18 -0
- package/dist/src/functions.d.ts.map +1 -1
- package/dist/src/functions.js +239 -43
- package/dist/src/hsToMeteora.js +11 -0
- package/dist/src/idl/jupiter-idl.d.ts +1767 -0
- package/dist/src/idl/jupiter-idl.d.ts.map +1 -0
- package/dist/src/idl/jupiter-idl.js +1768 -0
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts.map +1 -1
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.js +1 -0
- package/package.json +1 -1
package/dist/src/functions.d.ts
CHANGED
|
@@ -299,5 +299,23 @@ export declare const benchmark: ({ end, name, msg }: {
|
|
|
299
299
|
msg: string;
|
|
300
300
|
end?: boolean | undefined;
|
|
301
301
|
}) => void;
|
|
302
|
+
export declare function tokenizer(buffer: Buffer): {
|
|
303
|
+
readBuffer: (length: number) => Buffer;
|
|
304
|
+
currentIndex: () => number;
|
|
305
|
+
remainingBytes: () => Uint8Array;
|
|
306
|
+
debug: () => string;
|
|
307
|
+
};
|
|
308
|
+
export declare function deserializeParametersFromIDL(idl: any, instruction: string, data: Buffer): {
|
|
309
|
+
discriminator: Buffer;
|
|
310
|
+
params: any;
|
|
311
|
+
};
|
|
312
|
+
export declare function extractValue(idl: any, type: any, tokens: any): Buffer;
|
|
313
|
+
export declare function resolveStruct(idl: any, fields: any, tokens: any): Buffer;
|
|
314
|
+
export declare function resolveEnum(idl: any, variants: any, tokens: any): Buffer;
|
|
315
|
+
export declare function resolveOption(idl: any, type: any, tokens: any): Buffer;
|
|
316
|
+
export declare function resolveVec(idl: any, type: any, tokens: any): Buffer;
|
|
317
|
+
export declare function resolveArray(idl: any, type: any[], tokens: any): Buffer;
|
|
318
|
+
export declare function resolveDefined(idl: any, typeName: any, tokens: any): Buffer;
|
|
319
|
+
export declare function extractPrimitives(type: string, tokens: any): Buffer | undefined;
|
|
302
320
|
export {};
|
|
303
321
|
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,EAChB,yBAAyB,EACzB,6BAA6B,EAC7B,WAAW,EACX,mBAAmB,EACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM1D,OAAO,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,EAChB,yBAAyB,EACzB,6BAA6B,EAC7B,WAAW,EACX,mBAAmB,EACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM1D,OAAO,EAAE,MAAM,OAAO,CAAC;AAMvB,eAAO,MAAM,eAAe,gCAAgC,CAAC;AAE7D;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,mBAAmB,CAAC,CAO9B;AAED,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,cAAc,EAC9B,UAAU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|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.benchmark = exports.findNonceOwnedBy = exports.generateNonceAddressesOwnedBy = exports.generateNonceAddressFromIndex = exports.mid = exports.getPriorityFeeEstimate2 = exports.getPriorityFeeEstimate = exports.stringToAlt = exports.ixStrToWeb3Ix = exports.toVersionedTransaction = exports.getJupiterRouteIxParams = exports.inputTokenExists = exports.unwrapWsolToSol = exports.unwrapSolIfMintIsWsol = exports.wrapSolToWsol = exports.wrapSolIfMintIsWsol = exports.getMintsFromInstruction = exports.createAtaIdempotentIxs = exports.parseTokenAccountData = exports.tokenAccountExists = exports.sighash = exports.sighashMatch = exports.getIxs = exports.generateUserPdaStorageAccount = exports.generateOrcaPositionPDA = exports.generateAta = exports.generateUserPda = exports.createTransactionMeta = exports.getMeteoraPool = exports.getFeeEstimate = exports.resultOrError = exports.createTxMetadata2 = exports.createTxMetadata = exports.METEORA_API_URL = void 0;
|
|
38
|
+
exports.extractPrimitives = exports.resolveDefined = exports.resolveArray = exports.resolveVec = exports.resolveOption = exports.resolveEnum = exports.resolveStruct = exports.extractValue = exports.deserializeParametersFromIDL = exports.tokenizer = exports.benchmark = exports.findNonceOwnedBy = exports.generateNonceAddressesOwnedBy = exports.generateNonceAddressFromIndex = exports.mid = exports.getPriorityFeeEstimate2 = exports.getPriorityFeeEstimate = exports.stringToAlt = exports.ixStrToWeb3Ix = exports.toVersionedTransaction = exports.getJupiterRouteIxParams = exports.inputTokenExists = exports.unwrapWsolToSol = exports.unwrapSolIfMintIsWsol = exports.wrapSolToWsol = exports.wrapSolIfMintIsWsol = exports.getMintsFromInstruction = exports.createAtaIdempotentIxs = exports.parseTokenAccountData = exports.tokenAccountExists = exports.sighash = exports.sighashMatch = exports.getIxs = exports.generateUserPdaStorageAccount = exports.generateOrcaPositionPDA = exports.generateAta = exports.generateUserPda = exports.createTransactionMeta = exports.getMeteoraPool = exports.getFeeEstimate = exports.resultOrError = exports.createTxMetadata2 = exports.createTxMetadata = exports.METEORA_API_URL = void 0;
|
|
39
39
|
const client = __importStar(require("@hawksightco/swagger-client"));
|
|
40
40
|
const web3 = __importStar(require("@solana/web3.js"));
|
|
41
41
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -48,6 +48,7 @@ const bn_js_1 = __importDefault(require("bn.js"));
|
|
|
48
48
|
const spl_token_1 = require("@solana/spl-token");
|
|
49
49
|
const bs58_1 = __importDefault(require("bs58"));
|
|
50
50
|
const Logging_1 = require("./classes/Logging");
|
|
51
|
+
const jupiter_idl_1 = require("./idl/jupiter-idl");
|
|
51
52
|
exports.METEORA_API_URL = "https://dlmm-api.meteora.ag";
|
|
52
53
|
/**
|
|
53
54
|
* Asynchronously creates transaction metadata based on the provided transaction parameters and network state.
|
|
@@ -542,48 +543,55 @@ exports.inputTokenExists = inputTokenExists;
|
|
|
542
543
|
* @param data
|
|
543
544
|
*/
|
|
544
545
|
function getJupiterRouteIxParams(data) {
|
|
545
|
-
const boolIndices = [8, 17, 18, 21, 23, 58];
|
|
546
|
-
const sideIndices = [12, 15, 16, 24, 27, 28, 39];
|
|
547
|
-
const vecSize = new
|
|
548
|
-
let lastIndex = 0;
|
|
549
|
-
for (let i = 0; i < vecSize; i++) {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
const
|
|
584
|
-
const
|
|
585
|
-
const
|
|
586
|
-
const
|
|
546
|
+
// const boolIndices = [8, 17, 18, 21, 23, 58];
|
|
547
|
+
// const sideIndices = [12, 15, 16, 24, 27, 28, 39];
|
|
548
|
+
// const vecSize = new BN(data.subarray(8, 12), 10, 'le').toNumber();
|
|
549
|
+
// let lastIndex = 0;
|
|
550
|
+
// for (let i = 0; i < vecSize; i++) {
|
|
551
|
+
// if (lastIndex === 0) lastIndex = 12;
|
|
552
|
+
// const swapEnumId = data[lastIndex];
|
|
553
|
+
// if (boolIndices.includes(swapEnumId) || sideIndices.includes(swapEnumId))
|
|
554
|
+
// lastIndex += 4 + 1;
|
|
555
|
+
// // Swap is "Symmetry"
|
|
556
|
+
// else if (swapEnumId == 29)
|
|
557
|
+
// lastIndex += 4 + 16;
|
|
558
|
+
// // Swap is "StakeDexSwapViaStake" or "StakeDexPrefundWithdrawStakeAndDepositStake"
|
|
559
|
+
// else if (swapEnumId == 33 || swapEnumId == 41)
|
|
560
|
+
// lastIndex += 4 + 4;
|
|
561
|
+
// // Swap is "Clone"
|
|
562
|
+
// else if (swapEnumId == 42)
|
|
563
|
+
// lastIndex += 4 + 3
|
|
564
|
+
// // Swap is "SanctumS"
|
|
565
|
+
// else if (swapEnumId == 43)
|
|
566
|
+
// lastIndex += 4 + 10
|
|
567
|
+
// // Swap is "SanctumSAddLiquidity" or "SanctumSRemoveLiquidity"
|
|
568
|
+
// else if (swapEnumId == 44 || swapEnumId == 45)
|
|
569
|
+
// lastIndex += 4 + 5;
|
|
570
|
+
// // Swap is "WhirlpoolSwapV2"
|
|
571
|
+
// else if (swapEnumId == 47) {
|
|
572
|
+
// lastIndex += 2;
|
|
573
|
+
// if (data[lastIndex] !== 0) {
|
|
574
|
+
// lastIndex += 1;
|
|
575
|
+
// const vecSize = new BN(data.subarray(lastIndex, lastIndex + 4), 10, 'le').toNumber();
|
|
576
|
+
// lastIndex += 4 + (vecSize * 2);
|
|
577
|
+
// }
|
|
578
|
+
// // Rest of the swaps have the standard 4-bytes
|
|
579
|
+
// } else
|
|
580
|
+
// lastIndex += 4;
|
|
581
|
+
// }
|
|
582
|
+
// const routePlan = data.subarray(8, lastIndex);
|
|
583
|
+
// const quotedOutAmount = new BN(data.subarray(lastIndex + 8, lastIndex + 16), 10, 'le');
|
|
584
|
+
// const slippageBps = new BN(data.subarray(lastIndex + 16, lastIndex + 18), 10, 'le').toNumber();
|
|
585
|
+
// const platformFeeBps = data[lastIndex + 18];
|
|
586
|
+
const result = deserializeParametersFromIDL(jupiter_idl_1.IDL, 'route', data);
|
|
587
|
+
const routePlan = result.params['route_plan'];
|
|
588
|
+
// console.log(`routePlan:`, routePlan);
|
|
589
|
+
const quotedOutAmount = new bn_js_1.default(result.params['quoted_out_amount']);
|
|
590
|
+
// console.log(quotedOutAmount);
|
|
591
|
+
const slippageBps = result.params['slippage_bps'].readUInt16LE();
|
|
592
|
+
// console.log(slippageBps);
|
|
593
|
+
const platformFeeBps = result.params['platform_fee_bps'].readUInt8();
|
|
594
|
+
// console.log(platformFeeBps);
|
|
587
595
|
return {
|
|
588
596
|
routePlan,
|
|
589
597
|
quotedOutAmount,
|
|
@@ -762,3 +770,191 @@ exports.benchmark = (() => {
|
|
|
762
770
|
}
|
|
763
771
|
};
|
|
764
772
|
})();
|
|
773
|
+
function tokenizer(buffer) {
|
|
774
|
+
let clone = buffer.map(v => v);
|
|
775
|
+
let currentIndex = 0;
|
|
776
|
+
return {
|
|
777
|
+
readBuffer: (length) => {
|
|
778
|
+
currentIndex += length;
|
|
779
|
+
const result = clone.subarray(0, length);
|
|
780
|
+
clone = clone.subarray(length);
|
|
781
|
+
return Buffer.from(result);
|
|
782
|
+
},
|
|
783
|
+
currentIndex: () => {
|
|
784
|
+
return currentIndex;
|
|
785
|
+
},
|
|
786
|
+
remainingBytes: () => {
|
|
787
|
+
return clone;
|
|
788
|
+
},
|
|
789
|
+
debug: () => {
|
|
790
|
+
const hexValues = Buffer.from(clone).toString('hex');
|
|
791
|
+
return `currentIndex: ${currentIndex}, remainingBytes: ${hexValues}`;
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
exports.tokenizer = tokenizer;
|
|
796
|
+
function deserializeParametersFromIDL(idl, instruction, data) {
|
|
797
|
+
const tokens = tokenizer(data);
|
|
798
|
+
const discriminator = tokens.readBuffer(8);
|
|
799
|
+
const params = {};
|
|
800
|
+
const ixDefinition = idl.instructions.find((ix) => ix.name === instruction);
|
|
801
|
+
if (!discriminator.equals(new Uint8Array(ixDefinition.discriminator))) {
|
|
802
|
+
throw new Error(`deserializeParametersFromIDL: Discriminator mismatch.`);
|
|
803
|
+
}
|
|
804
|
+
for (const arg of ixDefinition.args) {
|
|
805
|
+
const value = extractValue(idl, arg.type, tokens);
|
|
806
|
+
params[arg.name] = value;
|
|
807
|
+
}
|
|
808
|
+
return {
|
|
809
|
+
discriminator,
|
|
810
|
+
params,
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
exports.deserializeParametersFromIDL = deserializeParametersFromIDL;
|
|
814
|
+
function extractValue(idl, type, tokens) {
|
|
815
|
+
if (typeof type === 'object') {
|
|
816
|
+
if (typeof type.option !== 'undefined') {
|
|
817
|
+
return resolveOption(idl, type.option, tokens);
|
|
818
|
+
}
|
|
819
|
+
else if (typeof type.vec !== 'undefined') {
|
|
820
|
+
return resolveVec(idl, type.vec, tokens);
|
|
821
|
+
}
|
|
822
|
+
else if (typeof type.array !== 'undefined') {
|
|
823
|
+
return resolveArray(idl, type.array, tokens);
|
|
824
|
+
}
|
|
825
|
+
else if (typeof type.defined !== 'undefined') {
|
|
826
|
+
return resolveDefined(idl, type.defined.name, tokens);
|
|
827
|
+
}
|
|
828
|
+
else {
|
|
829
|
+
const k = Object.keys(type);
|
|
830
|
+
throw new Error(`extractValue: Unexpected error: Unexpected type key: ${k[0]}, debug: ${tokens.debug()}`);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
else if (typeof type === 'string') {
|
|
834
|
+
const value = extractPrimitives(type, tokens);
|
|
835
|
+
if (value === undefined) {
|
|
836
|
+
throw new Error(`extractValue: Unexpected error: Unable to extract value from type: ${type}, debug: ${tokens.debug()}`);
|
|
837
|
+
}
|
|
838
|
+
return value;
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
throw new Error(`extractValue: Unexpected error: Unexpected type: ${type}, debug: ${tokens.debug()}`);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
exports.extractValue = extractValue;
|
|
845
|
+
function resolveStruct(idl, fields, tokens) {
|
|
846
|
+
const values = [];
|
|
847
|
+
for (let i = 0; i < fields.length; i++) {
|
|
848
|
+
const field = fields[i];
|
|
849
|
+
const value = extractValue(idl, field.type, tokens);
|
|
850
|
+
values.push(new Uint8Array(value));
|
|
851
|
+
}
|
|
852
|
+
return Buffer.concat(values);
|
|
853
|
+
}
|
|
854
|
+
exports.resolveStruct = resolveStruct;
|
|
855
|
+
function resolveEnum(idl, variants, tokens) {
|
|
856
|
+
let index;
|
|
857
|
+
const values = [];
|
|
858
|
+
if (variants.length <= 256) {
|
|
859
|
+
const buffer = tokens.readBuffer(1);
|
|
860
|
+
index = buffer.readUint8();
|
|
861
|
+
values.push(new Uint8Array(buffer));
|
|
862
|
+
}
|
|
863
|
+
else if (variants.length <= 65536) {
|
|
864
|
+
const buffer = tokens.readBuffer(2);
|
|
865
|
+
index = buffer.readUint16LE();
|
|
866
|
+
values.push(new Uint8Array(buffer));
|
|
867
|
+
}
|
|
868
|
+
else {
|
|
869
|
+
throw new Error(`resolveEnum: Unsupported enum. Debug: ${tokens.debug()}`);
|
|
870
|
+
}
|
|
871
|
+
if (typeof variants[index].fields !== 'undefined') {
|
|
872
|
+
for (let i = 0; i < variants[index].fields.length; i++) {
|
|
873
|
+
const field = variants[index].fields[i];
|
|
874
|
+
const value = extractValue(idl, field.type, tokens);
|
|
875
|
+
values.push(new Uint8Array(value));
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return Buffer.concat(values);
|
|
879
|
+
}
|
|
880
|
+
exports.resolveEnum = resolveEnum;
|
|
881
|
+
function resolveOption(idl, type, tokens) {
|
|
882
|
+
const isSet = tokens.readBuffer(1);
|
|
883
|
+
if (isSet[0] === 0) {
|
|
884
|
+
return Buffer.from([0]);
|
|
885
|
+
}
|
|
886
|
+
else if (isSet[0] === 1) {
|
|
887
|
+
return Buffer.concat([isSet, extractValue(idl, type, tokens)]);
|
|
888
|
+
}
|
|
889
|
+
else {
|
|
890
|
+
throw new Error(`resolveOption: Value can only be 1 or 0. Actual value: ${isSet[0]}, debug: ${tokens.debug()}`);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
exports.resolveOption = resolveOption;
|
|
894
|
+
function resolveVec(idl, type, tokens) {
|
|
895
|
+
const size = tokens.readBuffer(4).readUint32LE();
|
|
896
|
+
const values = [];
|
|
897
|
+
for (let i = 0; i < size; i++) {
|
|
898
|
+
values.push(new Uint8Array(extractValue(idl, type, tokens)));
|
|
899
|
+
}
|
|
900
|
+
return Buffer.concat(values);
|
|
901
|
+
}
|
|
902
|
+
exports.resolveVec = resolveVec;
|
|
903
|
+
function resolveArray(idl, type, tokens) {
|
|
904
|
+
const _type = type[0];
|
|
905
|
+
const count = type[1];
|
|
906
|
+
const values = [];
|
|
907
|
+
if (typeof _type === 'object' && typeof _type.defined === 'object' && typeof _type.defined.name === 'string') {
|
|
908
|
+
for (let i = 0; i < count; i++) {
|
|
909
|
+
values.push(new Uint8Array(resolveDefined(idl, _type.defined.name, tokens)));
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
else if (typeof _type === 'string') {
|
|
913
|
+
for (let i = 0; i < count; i++) {
|
|
914
|
+
const value = extractPrimitives(_type, tokens);
|
|
915
|
+
if (value === undefined) {
|
|
916
|
+
throw new Error(`resolveArray: Unexpected error: Unresolvable value ${_type}, debug: ${tokens.debug()}`);
|
|
917
|
+
}
|
|
918
|
+
values.push(new Uint8Array(value));
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
else {
|
|
922
|
+
throw new Error(`resolveArray: Unexpected error: Unresolvable type: ${_type}, debug: ${tokens.debug()}`);
|
|
923
|
+
}
|
|
924
|
+
return Buffer.concat(values);
|
|
925
|
+
}
|
|
926
|
+
exports.resolveArray = resolveArray;
|
|
927
|
+
function resolveDefined(idl, typeName, tokens) {
|
|
928
|
+
const type = idl.types.find((t) => t.name === typeName);
|
|
929
|
+
if (type === undefined) {
|
|
930
|
+
throw new Error(`resolveDefined: Unexpected error: Cannot find type: ${typeName}`);
|
|
931
|
+
}
|
|
932
|
+
if (type.type.kind === 'struct') {
|
|
933
|
+
return resolveStruct(idl, type.type.fields, tokens);
|
|
934
|
+
}
|
|
935
|
+
else if (type.type.kind === 'enum') {
|
|
936
|
+
return resolveEnum(idl, type.type.variants, tokens);
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
939
|
+
throw new Error(`resolveDefined: Unexpected error: Unexpected type: ${type.type.kind}, debug: ${tokens.debug()}`);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
exports.resolveDefined = resolveDefined;
|
|
943
|
+
function extractPrimitives(type, tokens) {
|
|
944
|
+
if (type === 'u8' || type === 'i8' || type === 'bool') {
|
|
945
|
+
return tokens.readBuffer(1);
|
|
946
|
+
}
|
|
947
|
+
else if (type === 'u16' || type === 'i16') {
|
|
948
|
+
return tokens.readBuffer(2);
|
|
949
|
+
}
|
|
950
|
+
else if (type === 'u32' || type === 'i32') {
|
|
951
|
+
return tokens.readBuffer(4);
|
|
952
|
+
}
|
|
953
|
+
else if (type === 'u64' || type === '164') {
|
|
954
|
+
return tokens.readBuffer(8);
|
|
955
|
+
}
|
|
956
|
+
else if (type === 'u128' || type === 'i128') {
|
|
957
|
+
return tokens.readBuffer(16);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
exports.extractPrimitives = extractPrimitives;
|
package/dist/src/hsToMeteora.js
CHANGED
|
@@ -426,6 +426,7 @@ class ClaimFee extends HawksightMeteoraCpi {
|
|
|
426
426
|
const ownerFeeX = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenXMint);
|
|
427
427
|
const ownerFeeY = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenYMint);
|
|
428
428
|
// Generate IX via extension contract
|
|
429
|
+
// @ts-ignore
|
|
429
430
|
const claimFeeIx = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
430
431
|
.meteoraDlmmClaimFee()
|
|
431
432
|
.accounts({
|
|
@@ -522,6 +523,7 @@ class ClaimReward extends HawksightMeteoraCpi {
|
|
|
522
523
|
// Get reward index from parameter
|
|
523
524
|
const rewardIndex = new bn_js_1.BN(this.ix.data.readBigInt64LE(8).toString());
|
|
524
525
|
// Generate IX via extension contract
|
|
526
|
+
// @ts-ignore
|
|
525
527
|
const claimReward = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
526
528
|
.meteoraDlmmClaimReward(rewardIndex)
|
|
527
529
|
.accounts({
|
|
@@ -726,6 +728,7 @@ class InitializePositionAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
726
728
|
const data = this.ix.data.subarray(8);
|
|
727
729
|
const lowerBinId = data.subarray(0, 4).readInt32LE();
|
|
728
730
|
const width = data.subarray(4).readInt32LE();
|
|
731
|
+
// @ts-ignore
|
|
729
732
|
const initializePositionIx = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
730
733
|
.meteoraDlmmInitializePositionAutomation(lowerBinId, width)
|
|
731
734
|
.accounts({
|
|
@@ -810,6 +813,7 @@ class AddLiquidityByWeightAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
810
813
|
const strategyParametersMaxBinId = data.subarray(28, 32).readInt32LE();
|
|
811
814
|
const strategyParametersStrategyType = data[32];
|
|
812
815
|
const strategyParametersParameters = Array.from(data.subarray(33));
|
|
816
|
+
// @ts-ignore
|
|
813
817
|
const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
814
818
|
.meteoraDlmmDepositAutomation(activeId, maxActiveBinSlippage, strategyParametersMinBinId, strategyParametersMaxBinId, strategyParametersStrategyType, strategyParametersParameters)
|
|
815
819
|
.accounts({
|
|
@@ -902,6 +906,7 @@ class AddLiquidityOneSideAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
902
906
|
const iyfProgram = addresses_1.IYF_MAIN;
|
|
903
907
|
const hawksightAuthority = addresses_1.HS_AUTHORITY;
|
|
904
908
|
// Generate IX via extension contract
|
|
909
|
+
// @ts-ignore
|
|
905
910
|
const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
906
911
|
.meteoraDlmmOneSideDeposit(this.ix.data.subarray(8))
|
|
907
912
|
.accounts({
|
|
@@ -988,6 +993,7 @@ class RemoveLiquidityAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
988
993
|
const tokenXMint = this.ix.keys[7].pubkey;
|
|
989
994
|
const tokenYMint = this.ix.keys[8].pubkey;
|
|
990
995
|
// Generate IX via extension contract
|
|
996
|
+
// @ts-ignore
|
|
991
997
|
const withdrawIx = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
992
998
|
.meteoraDlmmWithdrawAutomation(this.ix.data)
|
|
993
999
|
.accounts({
|
|
@@ -1100,6 +1106,7 @@ class ClaimFeeAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
1100
1106
|
const ownerFeeX = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenXMint);
|
|
1101
1107
|
const ownerFeeY = util.generateAta(addresses_1.SITE_FEE_OWNER, tokenYMint);
|
|
1102
1108
|
// Generate IX via extension contract
|
|
1109
|
+
// @ts-ignore
|
|
1103
1110
|
const claimFeeIx = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
1104
1111
|
.meteoraDlmmClaimFeeAutomation()
|
|
1105
1112
|
.accounts({
|
|
@@ -1196,6 +1203,7 @@ class ClaimRewardAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
1196
1203
|
const rewardMint = this.ix.keys[6].pubkey;
|
|
1197
1204
|
const ownerFee = util.generateAta(addresses_1.SITE_FEE_OWNER, rewardMint);
|
|
1198
1205
|
// Generate IX via extension contract
|
|
1206
|
+
// @ts-ignore
|
|
1199
1207
|
const claimRewardIx = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
1200
1208
|
.meteoraDlmmClaimRewardAutomation(rewardIndex)
|
|
1201
1209
|
.accounts({
|
|
@@ -1280,6 +1288,7 @@ class ClosePositionAutomation extends HawksightMeteoraAutomationCpi {
|
|
|
1280
1288
|
const iyfProgram = addresses_1.IYF_MAIN;
|
|
1281
1289
|
const hawksightAuthority = addresses_1.HS_AUTHORITY;
|
|
1282
1290
|
// Generate IX via extension contract
|
|
1291
|
+
// @ts-ignore
|
|
1283
1292
|
const closePositionIx = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
1284
1293
|
.meteoraDlmmClosePositionAutomation()
|
|
1285
1294
|
.accounts({
|
|
@@ -1517,6 +1526,7 @@ class AddLiquidityByStrategyPda extends HawksightMeteoraPdaCpi {
|
|
|
1517
1526
|
const strategyParametersMaxBinId = data.subarray(28, 32).readInt32LE();
|
|
1518
1527
|
const strategyParametersStrategyType = data[32];
|
|
1519
1528
|
const strategyParametersParameters = Array.from(data.subarray(33));
|
|
1529
|
+
// @ts-ignore
|
|
1520
1530
|
const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
1521
1531
|
.meteoraDlmmDeposit(activeId, maxActiveBinSlippage, strategyParametersMinBinId, strategyParametersMaxBinId, strategyParametersStrategyType, strategyParametersParameters)
|
|
1522
1532
|
.accounts({
|
|
@@ -1609,6 +1619,7 @@ class AddLiquidityByStrategyOneSidePda extends HawksightMeteoraPdaCpi {
|
|
|
1609
1619
|
const authority = this.authority;
|
|
1610
1620
|
const iyfProgram = addresses_1.IYF_MAIN;
|
|
1611
1621
|
// Generate IX via extension contract
|
|
1622
|
+
// @ts-ignore
|
|
1612
1623
|
const depositIx = yield anchor_1.Anchor.instance().iyfExtension.methods
|
|
1613
1624
|
.meteoraDlmmOneSideDepositManual(this.ix.data.subarray(8))
|
|
1614
1625
|
.accounts({
|