@hawksightco/hawk-sdk 1.1.2 → 1.1.4-8.2
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/addresses.d.ts +2 -0
- package/dist/src/addresses.d.ts.map +1 -1
- package/dist/src/addresses.js +3 -1
- package/dist/src/anchor.d.ts +113 -1
- package/dist/src/anchor.d.ts.map +1 -1
- package/dist/src/anchor.js +33 -1
- package/dist/src/classes/Atomicity.d.ts +35 -0
- package/dist/src/classes/Atomicity.d.ts.map +1 -0
- package/dist/src/classes/Atomicity.js +110 -0
- package/dist/src/classes/CreateTxMetadata.d.ts +16 -0
- package/dist/src/classes/CreateTxMetadata.d.ts.map +1 -1
- package/dist/src/classes/CreateTxMetadata.js +115 -6
- package/dist/src/classes/General.d.ts +16 -0
- package/dist/src/classes/General.d.ts.map +1 -1
- package/dist/src/classes/General.js +32 -0
- package/dist/src/classes/HawkAPI.d.ts +29 -0
- package/dist/src/classes/HawkAPI.d.ts.map +1 -1
- package/dist/src/classes/HawkAPI.js +35 -0
- package/dist/src/classes/JupiterAlts.d.ts +38 -0
- package/dist/src/classes/JupiterAlts.d.ts.map +1 -0
- package/dist/src/classes/JupiterAlts.js +104 -0
- package/dist/src/classes/JupiterSwap.d.ts +20 -0
- package/dist/src/classes/JupiterSwap.d.ts.map +1 -0
- package/dist/src/classes/JupiterSwap.js +37 -0
- package/dist/src/classes/Logging.d.ts +13 -0
- package/dist/src/classes/Logging.d.ts.map +1 -0
- package/dist/src/classes/Logging.js +51 -0
- package/dist/src/classes/MultiTransaction.d.ts +76 -0
- package/dist/src/classes/MultiTransaction.d.ts.map +1 -0
- package/dist/src/classes/MultiTransaction.js +286 -0
- package/dist/src/classes/SimpleIxGenerator.d.ts +24 -0
- package/dist/src/classes/SimpleIxGenerator.d.ts.map +1 -0
- package/dist/src/classes/SimpleIxGenerator.js +29 -0
- package/dist/src/classes/Transaction.d.ts +42 -12
- package/dist/src/classes/Transaction.d.ts.map +1 -1
- package/dist/src/classes/Transaction.js +37 -15
- package/dist/src/classes/Transaction2.d.ts +108 -0
- package/dist/src/classes/Transaction2.d.ts.map +1 -0
- package/dist/src/classes/Transaction2.js +239 -0
- package/dist/src/classes/Transaction3.d.ts +166 -0
- package/dist/src/classes/Transaction3.d.ts.map +1 -0
- package/dist/src/classes/Transaction3.js +406 -0
- package/dist/src/classes/TransactionBatchExecute.d.ts +164 -0
- package/dist/src/classes/TransactionBatchExecute.d.ts.map +1 -0
- package/dist/src/classes/TransactionBatchExecute.js +456 -0
- package/dist/src/classes/TransactionBatchExecute2.d.ts +100 -0
- package/dist/src/classes/TransactionBatchExecute2.d.ts.map +1 -0
- package/dist/src/classes/TransactionBatchExecute2.js +347 -0
- package/dist/src/classes/Transactions.d.ts +51 -1
- package/dist/src/classes/Transactions.d.ts.map +1 -1
- package/dist/src/classes/Transactions.js +318 -54
- package/dist/src/classes/TxGenerator.d.ts +29 -1
- package/dist/src/classes/TxGenerator.d.ts.map +1 -1
- package/dist/src/classes/TxGenerator.js +123 -5
- package/dist/src/classes/TxGeneratorAutomations.d.ts +23 -1
- package/dist/src/classes/TxGeneratorAutomations.d.ts.map +1 -1
- package/dist/src/classes/TxGeneratorAutomations.js +72 -0
- package/dist/src/classes/Util.d.ts +22 -0
- package/dist/src/classes/Util.d.ts.map +1 -1
- package/dist/src/classes/Util.js +33 -0
- package/dist/src/functions.d.ts +61 -3
- package/dist/src/functions.d.ts.map +1 -1
- package/dist/src/functions.js +237 -3
- package/dist/src/hawksight.d.ts +8 -0
- package/dist/src/hawksight.d.ts.map +1 -1
- package/dist/src/hawksight.js +29 -1
- package/dist/src/hsToMeteora.d.ts +7 -0
- package/dist/src/hsToMeteora.d.ts.map +1 -1
- package/dist/src/hsToMeteora.js +541 -30
- package/dist/src/idl/iyf-extension-idl.d.ts +6620 -4193
- package/dist/src/idl/iyf-extension-idl.d.ts.map +1 -1
- package/dist/src/idl/iyf-extension-idl.js +6614 -4193
- package/dist/src/idl/iyf-main-idl.d.ts +244 -5
- package/dist/src/idl/iyf-main-idl.d.ts.map +1 -1
- package/dist/src/idl/iyf-main-idl.js +244 -5
- package/dist/src/idl/meteora-idl.d.ts +5251 -0
- package/dist/src/idl/meteora-idl.d.ts.map +1 -0
- package/dist/src/idl/meteora-idl.js +5252 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1
- package/dist/src/ixGenerator/IyfExtensionIxGenerator.d.ts +27 -0
- package/dist/src/ixGenerator/IyfExtensionIxGenerator.d.ts.map +1 -0
- package/dist/src/ixGenerator/IyfExtensionIxGenerator.js +71 -0
- package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts +64 -0
- package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts.map +1 -0
- package/dist/src/ixGenerator/IyfMainIxGenerator.js +203 -0
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts +50 -0
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts.map +1 -0
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.js +271 -0
- package/dist/src/meteora.d.ts +230 -1
- package/dist/src/meteora.d.ts.map +1 -1
- package/dist/src/meteora.js +708 -15
- package/dist/src/types.d.ts +40 -14
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +3 -0
- package/package.json +3 -3
package/dist/src/addresses.d.ts
CHANGED
|
@@ -11,8 +11,10 @@ export declare const SITE_FEE_OWNER: web3.PublicKey;
|
|
|
11
11
|
export declare const USDC_FARM: web3.PublicKey;
|
|
12
12
|
export declare const SOME_METEORA_DLMM_POOL: web3.PublicKey;
|
|
13
13
|
export declare const METEORA_DLMM_PROGRAM: web3.PublicKey;
|
|
14
|
+
export declare const METEORA_EVENT_AUTHORITY: web3.PublicKey;
|
|
14
15
|
export declare const COMPUTE_BUDGET: web3.PublicKey;
|
|
15
16
|
export declare const HS_AUTHORITY: web3.PublicKey;
|
|
16
17
|
export declare const ORCA_WHIRLPOOL_PROGRAM: web3.PublicKey;
|
|
17
18
|
export declare const WSOL_MINT: web3.PublicKey;
|
|
19
|
+
export declare const JUPITER_PROGRAM: web3.PublicKey;
|
|
18
20
|
//# sourceMappingURL=addresses.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../src/addresses.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,eAAO,MAAM,UAAU,UAYtB,CAAC;AAEF,eAAO,MAAM,QAAQ,gBAAqE,CAAC;AAC3F,eAAO,MAAM,aAAa,gBAAqE,CAAC;AAChG,eAAO,MAAM,YAAY,gBAAqE,CAAC;AAC/F,eAAO,MAAM,YAAY,gBAAqE,CAAC;AAC/F,eAAO,MAAM,gBAAgB,gBAAoE,CAAC;AAClG,eAAO,MAAM,wBAAwB,gBAAqE,CAAC;AAC3G,eAAO,MAAM,cAAc,gBAAqE,CAAC;AACjG,eAAO,MAAM,SAAS,gBAAqE,CAAC;AAC5F,eAAO,MAAM,sBAAsB,gBAAqE,CAAC;AACzG,eAAO,MAAM,oBAAoB,gBAAoE,CAAC;AACtG,eAAO,MAAM,cAAc,gBAAoE,CAAC;AAChG,eAAO,MAAM,YAAY,gBAAoE,CAAC;AAC9F,eAAO,MAAM,sBAAsB,gBAAoE,CAAC;AACxG,eAAO,MAAM,SAAS,gBAAoE,CAAC"}
|
|
1
|
+
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../src/addresses.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,eAAO,MAAM,UAAU,UAYtB,CAAC;AAEF,eAAO,MAAM,QAAQ,gBAAqE,CAAC;AAC3F,eAAO,MAAM,aAAa,gBAAqE,CAAC;AAChG,eAAO,MAAM,YAAY,gBAAqE,CAAC;AAC/F,eAAO,MAAM,YAAY,gBAAqE,CAAC;AAC/F,eAAO,MAAM,gBAAgB,gBAAoE,CAAC;AAClG,eAAO,MAAM,wBAAwB,gBAAqE,CAAC;AAC3G,eAAO,MAAM,cAAc,gBAAqE,CAAC;AACjG,eAAO,MAAM,SAAS,gBAAqE,CAAC;AAC5F,eAAO,MAAM,sBAAsB,gBAAqE,CAAC;AACzG,eAAO,MAAM,oBAAoB,gBAAoE,CAAC;AACtG,eAAO,MAAM,uBAAuB,gBAAqE,CAAC;AAC1G,eAAO,MAAM,cAAc,gBAAoE,CAAC;AAChG,eAAO,MAAM,YAAY,gBAAoE,CAAC;AAC9F,eAAO,MAAM,sBAAsB,gBAAoE,CAAC;AACxG,eAAO,MAAM,SAAS,gBAAoE,CAAC;AAC3F,eAAO,MAAM,eAAe,gBAAoE,CAAC"}
|
package/dist/src/addresses.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.WSOL_MINT = exports.ORCA_WHIRLPOOL_PROGRAM = exports.HS_AUTHORITY = exports.COMPUTE_BUDGET = exports.METEORA_DLMM_PROGRAM = exports.SOME_METEORA_DLMM_POOL = exports.USDC_FARM = exports.SITE_FEE_OWNER = exports.ASSOCIATED_TOKEN_PROGRAM = exports.TOKEN_PROGRAM_ID = exports.STABLEMINT_2 = exports.STABLEMINT_1 = exports.IYF_EXTENSION = exports.IYF_MAIN = exports.GLOBAL_ALT = void 0;
|
|
26
|
+
exports.JUPITER_PROGRAM = exports.WSOL_MINT = exports.ORCA_WHIRLPOOL_PROGRAM = exports.HS_AUTHORITY = exports.COMPUTE_BUDGET = exports.METEORA_EVENT_AUTHORITY = exports.METEORA_DLMM_PROGRAM = exports.SOME_METEORA_DLMM_POOL = exports.USDC_FARM = exports.SITE_FEE_OWNER = exports.ASSOCIATED_TOKEN_PROGRAM = exports.TOKEN_PROGRAM_ID = exports.STABLEMINT_2 = exports.STABLEMINT_1 = exports.IYF_EXTENSION = exports.IYF_MAIN = exports.GLOBAL_ALT = void 0;
|
|
27
27
|
const web3 = __importStar(require("@solana/web3.js"));
|
|
28
28
|
exports.GLOBAL_ALT = [
|
|
29
29
|
"AC3t5k5PUTJirxGEHgGGQStafu1vXkvddPyqVNDrRQDt",
|
|
@@ -48,7 +48,9 @@ exports.SITE_FEE_OWNER = new web3.PublicKey("4K3a2ucXiGvuMJMPNneRDyzmNp6i4RdzXJm
|
|
|
48
48
|
exports.USDC_FARM = new web3.PublicKey("7jLQhREMxXjKdpwVuN6gwsWt3BNfAg9WqbepffPbi4ww");
|
|
49
49
|
exports.SOME_METEORA_DLMM_POOL = new web3.PublicKey("7eexH14UjhNxJe6zTT3f1Vb1E8iACsBMVaWheDEmxdT2");
|
|
50
50
|
exports.METEORA_DLMM_PROGRAM = new web3.PublicKey("LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo");
|
|
51
|
+
exports.METEORA_EVENT_AUTHORITY = new web3.PublicKey("D1ZN9Wj1fRSUQfCjhvnu1hqDMT7hzjzBBpi12nVniYD6");
|
|
51
52
|
exports.COMPUTE_BUDGET = new web3.PublicKey("ComputeBudget111111111111111111111111111111");
|
|
52
53
|
exports.HS_AUTHORITY = new web3.PublicKey("dche7M2764e8AxNihBdn7uffVzZvTBNeL8x4LZg5E2c");
|
|
53
54
|
exports.ORCA_WHIRLPOOL_PROGRAM = new web3.PublicKey("whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc");
|
|
54
55
|
exports.WSOL_MINT = new web3.PublicKey("So11111111111111111111111111111111111111112");
|
|
56
|
+
exports.JUPITER_PROGRAM = new web3.PublicKey("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4");
|
package/dist/src/anchor.d.ts
CHANGED
|
@@ -2,8 +2,118 @@
|
|
|
2
2
|
import * as web3 from "@solana/web3.js";
|
|
3
3
|
import * as anchor from "@coral-xyz/anchor";
|
|
4
4
|
import { IndexYieldFarming } from "./idl/iyf-main-idl";
|
|
5
|
-
import { IyfExtension } from "./idl/iyf-extension-idl";
|
|
5
|
+
import { IyfExtension as IyfExtensionNew } from "./idl/iyf-extension-idl";
|
|
6
6
|
import { Whirlpool } from "./idl/orca-idl";
|
|
7
|
+
import { LbClmm } from "./idl/meteora-idl";
|
|
8
|
+
type IdlInstruction = {
|
|
9
|
+
name: string;
|
|
10
|
+
docs?: string[];
|
|
11
|
+
accounts: IdlAccountItem[];
|
|
12
|
+
args: IdlField[];
|
|
13
|
+
returns?: IdlType;
|
|
14
|
+
};
|
|
15
|
+
type IdlAccountItem = IdlAccount | IdlAccounts;
|
|
16
|
+
type IdlAccount = {
|
|
17
|
+
name: string;
|
|
18
|
+
isMut: boolean;
|
|
19
|
+
isSigner: boolean;
|
|
20
|
+
isOptional?: boolean;
|
|
21
|
+
docs?: string[];
|
|
22
|
+
relations?: string[];
|
|
23
|
+
pda?: IdlPda;
|
|
24
|
+
};
|
|
25
|
+
type IdlPda = {
|
|
26
|
+
seeds: IdlSeed[];
|
|
27
|
+
programId?: IdlSeed;
|
|
28
|
+
};
|
|
29
|
+
type IdlSeed = any;
|
|
30
|
+
type IdlAccounts = {
|
|
31
|
+
name: string;
|
|
32
|
+
docs?: string[];
|
|
33
|
+
accounts: IdlAccountItem[];
|
|
34
|
+
};
|
|
35
|
+
type IdlField = {
|
|
36
|
+
name: string;
|
|
37
|
+
docs?: string[];
|
|
38
|
+
type: IdlType;
|
|
39
|
+
};
|
|
40
|
+
type IdlType = "bool" | "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "f32" | "u64" | "i64" | "f64" | "u128" | "i128" | "u256" | "i256" | "bytes" | "string" | "publicKey" | IdlTypeDefined | IdlTypeOption | IdlTypeCOption | IdlTypeVec | IdlTypeArray;
|
|
41
|
+
type IdlTypeDefined = {
|
|
42
|
+
defined: string;
|
|
43
|
+
};
|
|
44
|
+
type IdlTypeOption = {
|
|
45
|
+
option: IdlType;
|
|
46
|
+
};
|
|
47
|
+
type IdlTypeCOption = {
|
|
48
|
+
coption: IdlType;
|
|
49
|
+
};
|
|
50
|
+
type IdlTypeVec = {
|
|
51
|
+
vec: IdlType;
|
|
52
|
+
};
|
|
53
|
+
type IdlTypeArray = {
|
|
54
|
+
array: [idlType: IdlType, size: number];
|
|
55
|
+
};
|
|
56
|
+
type IdlAccountDef = {
|
|
57
|
+
name: string;
|
|
58
|
+
docs?: string[];
|
|
59
|
+
type: IdlTypeDefTyStruct;
|
|
60
|
+
};
|
|
61
|
+
type IdlTypeDefTyStruct = {
|
|
62
|
+
kind: "struct";
|
|
63
|
+
fields: IdlTypeDefStruct;
|
|
64
|
+
};
|
|
65
|
+
type IdlTypeDefStruct = Array<IdlField>;
|
|
66
|
+
type IdlTypeDef = {
|
|
67
|
+
name: string;
|
|
68
|
+
docs?: string[];
|
|
69
|
+
type: IdlTypeDefTy;
|
|
70
|
+
};
|
|
71
|
+
type IdlTypeDefTy = IdlTypeDefTyEnum | IdlTypeDefTyStruct | IdlTypeDefTyAlias;
|
|
72
|
+
type IdlTypeDefTyEnum = {
|
|
73
|
+
kind: "enum";
|
|
74
|
+
variants: IdlEnumVariant[];
|
|
75
|
+
};
|
|
76
|
+
type IdlEnumVariant = {
|
|
77
|
+
name: string;
|
|
78
|
+
fields?: IdlEnumFields;
|
|
79
|
+
};
|
|
80
|
+
type IdlTypeDefTyAlias = {
|
|
81
|
+
kind: "alias";
|
|
82
|
+
value: IdlType;
|
|
83
|
+
};
|
|
84
|
+
type IdlEnumFields = IdlEnumFieldsNamed | IdlEnumFieldsTuple;
|
|
85
|
+
type IdlEnumFieldsNamed = IdlField[];
|
|
86
|
+
type IdlEnumFieldsTuple = IdlType[];
|
|
87
|
+
type Instruction<I extends number> = {
|
|
88
|
+
name: IyfExtensionNew["instructions"][I]["name"];
|
|
89
|
+
accounts: IyfExtensionNew["instructions"][I]["accounts"];
|
|
90
|
+
args: IyfExtensionNew["instructions"][I]["args"];
|
|
91
|
+
} & IdlInstruction;
|
|
92
|
+
type GenerateInstructions<T extends any[], I extends number[] = []> = I["length"] extends T["length"] ? [] : [
|
|
93
|
+
Instruction<I["length"]>,
|
|
94
|
+
...GenerateInstructions<T, [...I, I["length"]]>
|
|
95
|
+
];
|
|
96
|
+
type FilteredInstructions = GenerateInstructions<IyfExtensionNew["instructions"]>;
|
|
97
|
+
type FindMatchingType<Name, Types extends any[]> = Types extends Array<infer T> ? T extends {
|
|
98
|
+
name: Name;
|
|
99
|
+
type: infer Type;
|
|
100
|
+
} ? Type : never : never;
|
|
101
|
+
type Account<I extends number> = {
|
|
102
|
+
name: unknown extends IyfExtensionNew["accounts"][I]["name"] ? never : IyfExtensionNew["accounts"][I]["name"];
|
|
103
|
+
type: unknown extends IyfExtensionNew["accounts"][I]["name"] ? never : FindMatchingType<IyfExtensionNew["accounts"][I]["name"], IyfExtensionNew["types"]>;
|
|
104
|
+
} & IdlAccountDef;
|
|
105
|
+
type GenerateAccounts<T extends any[], I extends number[] = []> = I["length"] extends T["length"] ? [] : [
|
|
106
|
+
Account<I["length"]>,
|
|
107
|
+
...GenerateAccounts<T, [...I, I["length"]]>
|
|
108
|
+
];
|
|
109
|
+
type FilteredAccounts = GenerateAccounts<IyfExtensionNew["accounts"]>;
|
|
110
|
+
export type IyfExtension = {
|
|
111
|
+
"version": string;
|
|
112
|
+
"name": string;
|
|
113
|
+
"instructions": FilteredInstructions;
|
|
114
|
+
"accounts": FilteredAccounts;
|
|
115
|
+
"types": IyfExtensionNew["types"] & Array<IdlTypeDef>;
|
|
116
|
+
};
|
|
7
117
|
export declare class Anchor {
|
|
8
118
|
connection: web3.Connection;
|
|
9
119
|
private static _instance;
|
|
@@ -11,8 +121,10 @@ export declare class Anchor {
|
|
|
11
121
|
iyfMain: anchor.Program<IndexYieldFarming>;
|
|
12
122
|
iyfExtension: anchor.Program<IyfExtension>;
|
|
13
123
|
orcaProgram: anchor.Program<Whirlpool>;
|
|
124
|
+
meteoraProgram: anchor.Program<LbClmm>;
|
|
14
125
|
private constructor();
|
|
15
126
|
static initialize(connection: web3.Connection): void;
|
|
16
127
|
static instance(): Anchor;
|
|
17
128
|
}
|
|
129
|
+
export {};
|
|
18
130
|
//# sourceMappingURL=anchor.d.ts.map
|
package/dist/src/anchor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/anchor.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAmB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAwB,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/anchor.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAmB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAwB,YAAY,IAAI,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAChG,OAAO,EAAqB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAkB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAS3D,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AACF,KAAK,cAAc,GAAG,UAAU,GAAG,WAAW,CAAC;AAC/C,KAAK,UAAU,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OA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__importStar(require("@coral-xyz/anchor"));
|
|
|
32
32
|
const iyf_main_idl_1 = require("./idl/iyf-main-idl");
|
|
33
33
|
const iyf_extension_idl_1 = require("./idl/iyf-extension-idl");
|
|
34
34
|
const orca_idl_1 = require("./idl/orca-idl");
|
|
35
|
+
const meteora_idl_1 = require("./idl/meteora-idl");
|
|
35
36
|
const nodewallet_1 = __importDefault(require("@coral-xyz/anchor/dist/cjs/nodewallet"));
|
|
36
37
|
const addresses_1 = require("./addresses");
|
|
37
38
|
class Anchor {
|
|
@@ -39,8 +40,39 @@ class Anchor {
|
|
|
39
40
|
this.connection = connection;
|
|
40
41
|
this.provider = new anchor.AnchorProvider(connection, new nodewallet_1.default(web3.Keypair.generate()), {});
|
|
41
42
|
this.iyfMain = new anchor.Program(iyf_main_idl_1.IDL, addresses_1.IYF_MAIN, this.provider);
|
|
42
|
-
|
|
43
|
+
const p = iyf_extension_idl_1.IDL.instructions.map(instruction => {
|
|
44
|
+
return {
|
|
45
|
+
name: instruction.name,
|
|
46
|
+
accounts: [instruction.accounts.map(account => {
|
|
47
|
+
return {
|
|
48
|
+
name: account.name,
|
|
49
|
+
isMut: "writable" in account ? account.writable : false,
|
|
50
|
+
isSigner: "signer" in account ? account.signer : false,
|
|
51
|
+
};
|
|
52
|
+
})],
|
|
53
|
+
args: instruction.args,
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
const IyfExtension = {
|
|
57
|
+
version: iyf_extension_idl_1.IDL.metadata.version,
|
|
58
|
+
name: iyf_extension_idl_1.IDL.metadata.name,
|
|
59
|
+
instructions: iyf_extension_idl_1.IDL.instructions.map((instruction, index) => {
|
|
60
|
+
return {
|
|
61
|
+
name: instruction.name,
|
|
62
|
+
accounts: instruction.accounts.map(account => {
|
|
63
|
+
return {
|
|
64
|
+
name: account.name,
|
|
65
|
+
isMut: "writable" in account ? account.writable : false,
|
|
66
|
+
isSigner: "signer" in account ? account.signer : false,
|
|
67
|
+
};
|
|
68
|
+
}),
|
|
69
|
+
args: instruction.args,
|
|
70
|
+
};
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
this.iyfExtension = new anchor.Program(IyfExtension, addresses_1.IYF_EXTENSION, this.provider);
|
|
43
74
|
this.orcaProgram = new anchor.Program(orca_idl_1.IDL, addresses_1.ORCA_WHIRLPOOL_PROGRAM, this.provider);
|
|
75
|
+
this.meteoraProgram = new anchor.Program(meteora_idl_1.IDL, addresses_1.METEORA_DLMM_PROGRAM, this.provider);
|
|
44
76
|
}
|
|
45
77
|
static initialize(connection) {
|
|
46
78
|
Anchor._instance = new Anchor(connection);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
|
+
import * as web3 from '@solana/web3.js';
|
|
3
|
+
import { DummySigners, TransactionBatchExecute } from "./TransactionBatchExecute";
|
|
4
|
+
import { SimpleIxGenerator } from './SimpleIxGenerator';
|
|
5
|
+
import { JupiterAlts } from './JupiterAlts';
|
|
6
|
+
export declare class Atomicity extends TransactionBatchExecute {
|
|
7
|
+
private ixGenerator;
|
|
8
|
+
/**
|
|
9
|
+
* User wallet
|
|
10
|
+
*/
|
|
11
|
+
private userWallet?;
|
|
12
|
+
constructor(lookupTableAddresses: web3.PublicKey[], instructions: web3.TransactionInstruction[], payer: web3.Keypair, connection: web3.Connection, signers: web3.Keypair[] | undefined, jupiterAlts: JupiterAlts, ixGenerator: SimpleIxGenerator);
|
|
13
|
+
/**
|
|
14
|
+
* Set user wallet
|
|
15
|
+
*/
|
|
16
|
+
setUserWallet(userWallet: web3.PublicKey): void;
|
|
17
|
+
/**
|
|
18
|
+
* Check whether instruction is an atomicity instruction
|
|
19
|
+
* @param ix
|
|
20
|
+
*/
|
|
21
|
+
private isAtomicityIx;
|
|
22
|
+
/**
|
|
23
|
+
* Builds a batch of executable transaction instructions
|
|
24
|
+
*/
|
|
25
|
+
buildBatch(): Promise<web3.TransactionInstruction[][]>;
|
|
26
|
+
/**
|
|
27
|
+
* Split transactions
|
|
28
|
+
*
|
|
29
|
+
* @param simulationIxs
|
|
30
|
+
* @param dummySigners
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
protected splitToTransactions(simulationIxs: web3.TransactionInstruction[], dummySigners: DummySigners): Promise<web3.TransactionInstruction[][]>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=Atomicity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Atomicity.d.ts","sourceRoot":"","sources":["../../../src/classes/Atomicity.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,SAAU,SAAQ,uBAAuB;IAclD,OAAO,CAAC,WAAW;IAZrB;;OAEG;IACH,OAAO,CAAC,UAAU,CAAC,CAAiB;gBAGlC,oBAAoB,EAAE,IAAI,CAAC,SAAS,EAAE,EACtC,YAAY,EAAE,IAAI,CAAC,sBAAsB,EAAE,EAC3C,KAAK,EAAE,IAAI,CAAC,OAAO,EACnB,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,OAAO,4BAAqB,EAC5B,WAAW,EAAE,WAAW,EAChB,WAAW,EAAE,iBAAiB;IAYxC;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS;IAIxC;;;OAGG;IACH,OAAO,CAAC,aAAa;IAIrB;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;IA4B5D;;;;;;OAMG;cACa,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,sBAAsB,EAAE,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;CAiDxJ"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Atomicity = void 0;
|
|
13
|
+
const TransactionBatchExecute_1 = require("./TransactionBatchExecute");
|
|
14
|
+
const functions_1 = require("../functions");
|
|
15
|
+
class Atomicity extends TransactionBatchExecute_1.TransactionBatchExecute {
|
|
16
|
+
constructor(lookupTableAddresses, instructions, payer, connection, signers = [], jupiterAlts, ixGenerator) {
|
|
17
|
+
super(lookupTableAddresses, instructions, payer, connection, signers, jupiterAlts);
|
|
18
|
+
this.ixGenerator = ixGenerator;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Set user wallet
|
|
22
|
+
*/
|
|
23
|
+
setUserWallet(userWallet) {
|
|
24
|
+
this.userWallet = userWallet;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check whether instruction is an atomicity instruction
|
|
28
|
+
* @param ix
|
|
29
|
+
*/
|
|
30
|
+
isAtomicityIx(ix) {
|
|
31
|
+
return ix.data.length >= 8 && (0, functions_1.sighashMatch)(ix.data, "setTransactionSlot") || (0, functions_1.sighashMatch)(ix.data, "verifyTransactionSlot");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Builds a batch of executable transaction instructions
|
|
35
|
+
*/
|
|
36
|
+
buildBatch() {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
// Download address lookup table from given cluster
|
|
39
|
+
yield this.downloadAlts();
|
|
40
|
+
// Generate dummy instructions for batch calculation
|
|
41
|
+
const [simulationIxs, dummySigners] = this.generateSimulationIxs();
|
|
42
|
+
// Split simulation ixs
|
|
43
|
+
const dummyBatches = yield this.splitToTransactions(simulationIxs, dummySigners);
|
|
44
|
+
// Batch of actual instructions
|
|
45
|
+
const batch = [];
|
|
46
|
+
let index = 0;
|
|
47
|
+
for (const dummyIxs of dummyBatches) {
|
|
48
|
+
const currentBatch = [];
|
|
49
|
+
for (const dummyIx of dummyIxs) {
|
|
50
|
+
if (this.isAtomicityIx(dummyIx)) {
|
|
51
|
+
currentBatch.push(dummyIx);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
currentBatch.push(this.instructions[index++]);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
batch.push(currentBatch);
|
|
58
|
+
}
|
|
59
|
+
return batch;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Split transactions
|
|
64
|
+
*
|
|
65
|
+
* @param simulationIxs
|
|
66
|
+
* @param dummySigners
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
splitToTransactions(simulationIxs, dummySigners) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
// Fetch latest blockhash required to calculate transaction size
|
|
72
|
+
const latestBlockhash = yield this.connection.getLatestBlockhash();
|
|
73
|
+
// User wallet must be set
|
|
74
|
+
if (this.userWallet === undefined) {
|
|
75
|
+
throw new Error(`Atomicity.userWallet is not set`);
|
|
76
|
+
}
|
|
77
|
+
// Generate set transaction slot instruction
|
|
78
|
+
const setTransactionSlotIx = yield this.ixGenerator.iyfMain.setTransactionSlot(this.connection, { userWallet: this.userWallet });
|
|
79
|
+
// Generate verify transaction slot instruction
|
|
80
|
+
const verifyTransactionSlotIx = yield this.ixGenerator.iyfMain.verifyTransactionSlot(this.connection, { userWallet: this.userWallet });
|
|
81
|
+
// Run simulation
|
|
82
|
+
let batch = [];
|
|
83
|
+
let result = [];
|
|
84
|
+
let postIx;
|
|
85
|
+
for (const ix of simulationIxs) {
|
|
86
|
+
// Include dummy ix to transaction
|
|
87
|
+
batch.push(ix);
|
|
88
|
+
// Include setTransactionSlot instruction if result batch is still zero
|
|
89
|
+
if (result.length === 0) {
|
|
90
|
+
postIx = setTransactionSlotIx;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
postIx = verifyTransactionSlotIx;
|
|
94
|
+
}
|
|
95
|
+
// Calculate transaction size
|
|
96
|
+
const txSize = this.calculateTransactionSize(latestBlockhash, [...batch, postIx], dummySigners);
|
|
97
|
+
if (txSize > this.MAX_SIZE) {
|
|
98
|
+
batch.pop();
|
|
99
|
+
result.push([...batch, postIx]);
|
|
100
|
+
batch = [ix];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (batch.length > 0 && simulationIxs.length !== 0) {
|
|
104
|
+
result.push([...batch, postIx]);
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.Atomicity = Atomicity;
|
|
@@ -47,6 +47,21 @@ export declare class CreateTxMetadata {
|
|
|
47
47
|
* @returns A promise that resolves to the address lookup table account or null if it does not exist.
|
|
48
48
|
*/
|
|
49
49
|
getAlt(alt: string): Promise<web3.AddressLookupTableAccount | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Store address lookup table in the object
|
|
52
|
+
*
|
|
53
|
+
* @param alt
|
|
54
|
+
* @param account
|
|
55
|
+
*/
|
|
56
|
+
storeAlt(alt: string, account: web3.AddressLookupTableAccount): void;
|
|
57
|
+
/**
|
|
58
|
+
* String to address lookup table. Can input multiple address lookup table addresses
|
|
59
|
+
*
|
|
60
|
+
* @param connection
|
|
61
|
+
* @param alts
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
stringToAlt(alts: string[]): Promise<web3.AddressLookupTableAccount[]>;
|
|
50
65
|
/**
|
|
51
66
|
* Asynchronously creates transaction metadata based on the provided transaction parameters and network state.
|
|
52
67
|
* This includes constructing a transaction with given instructions, calculating fees, and optionally handling priority fees.
|
|
@@ -64,5 +79,6 @@ export declare class CreateTxMetadata {
|
|
|
64
79
|
* @throws Error if there is an issue in constructing the transaction or during simulation which includes logs of errors.
|
|
65
80
|
*/
|
|
66
81
|
createTxMetadata(generalUtility: GeneralUtility, connection: web3.Connection, payer: string, data: TransactionMetadataResponse): Promise<TransactionMetadata>;
|
|
82
|
+
createTxMetadata2(generalUtility: GeneralUtility, connection: web3.Connection, payer: string, data: TransactionMetadataResponse): Promise<TransactionMetadata[]>;
|
|
67
83
|
}
|
|
68
84
|
//# sourceMappingURL=CreateTxMetadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateTxMetadata.d.ts","sourceRoot":"","sources":["../../../src/classes/CreateTxMetadata.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"CreateTxMetadata.d.ts","sourceRoot":"","sources":["../../../src/classes/CreateTxMetadata.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlD;;;GAGG;AACH,qBAAa,gBAAgB;IAE3B,OAAO;IAEP,OAAO,CAAC,UAAU,CAAC,CAAkB;IAErC;;;;OAIG;IACH,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU;IAEzC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAmB;IAE3C;;;;OAIG;IACH,MAAM,CAAC,QAAQ,IAAI,gBAAgB;IAOnC,OAAO,CAAC,IAAI,CAaV;IAEF;;OAEG;IACG,IAAI;IAIV;;OAEG;IACG,UAAU;IAUhB;;;;;;;OAOG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC;IAcvG;;;;;OAKG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAIzE;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,yBAAyB;IAI7D;;;;;;OAMG;IACG,WAAW,CACf,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC;IA8B5C;;;;;;;;;;;;;;;OAeG;IACG,gBAAgB,CACpB,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,mBAAmB,CAAC;IA8DzB,iBAAiB,CACrB,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,mBAAmB,EAAE,CAAC;CAuElC"}
|
|
@@ -35,6 +35,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
35
35
|
exports.CreateTxMetadata = void 0;
|
|
36
36
|
const web3 = __importStar(require("@solana/web3.js"));
|
|
37
37
|
const Transaction_1 = require("./Transaction");
|
|
38
|
+
const Logging_1 = require("./Logging");
|
|
39
|
+
const TransactionBatchExecute2_1 = require("./TransactionBatchExecute2");
|
|
38
40
|
/**
|
|
39
41
|
* The CreateTxMetadata class is responsible for creating and managing transaction metadata,
|
|
40
42
|
* including handling address lookup tables and constructing transactions with the necessary parameters.
|
|
@@ -132,6 +134,55 @@ class CreateTxMetadata {
|
|
|
132
134
|
return this.alts[alt];
|
|
133
135
|
});
|
|
134
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Store address lookup table in the object
|
|
139
|
+
*
|
|
140
|
+
* @param alt
|
|
141
|
+
* @param account
|
|
142
|
+
*/
|
|
143
|
+
storeAlt(alt, account) {
|
|
144
|
+
this.alts[alt] = account;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* String to address lookup table. Can input multiple address lookup table addresses
|
|
148
|
+
*
|
|
149
|
+
* @param connection
|
|
150
|
+
* @param alts
|
|
151
|
+
* @returns
|
|
152
|
+
*/
|
|
153
|
+
stringToAlt(alts) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
var _a, _b;
|
|
156
|
+
const _alts = [];
|
|
157
|
+
const notExist = [];
|
|
158
|
+
alts.map((key, index) => {
|
|
159
|
+
const alt = this.alts[key];
|
|
160
|
+
if (!!alt) {
|
|
161
|
+
_alts.push(alt);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
notExist.push(index);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
if (notExist.length === 0) {
|
|
168
|
+
return _alts;
|
|
169
|
+
}
|
|
170
|
+
const pubkeys = notExist.map(index => new web3.PublicKey(alts[index]));
|
|
171
|
+
const accountInfos = yield this.connection.getMultipleAccountsInfo(pubkeys);
|
|
172
|
+
for (let i = 0; i < accountInfos.length; i++) {
|
|
173
|
+
if (((_a = accountInfos[i]) === null || _a === void 0 ? void 0 : _a.data) && ((_b = accountInfos[i]) === null || _b === void 0 ? void 0 : _b.owner.toString()) === "AddressLookupTab1e1111111111111111111111111") {
|
|
174
|
+
const key = pubkeys[i].toString();
|
|
175
|
+
const alt = new web3.AddressLookupTableAccount({
|
|
176
|
+
key: pubkeys[i],
|
|
177
|
+
state: web3.AddressLookupTableAccount.deserialize(accountInfos[i].data)
|
|
178
|
+
});
|
|
179
|
+
this.alts[key] = alt;
|
|
180
|
+
_alts.push(alt);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return _alts;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
135
186
|
/**
|
|
136
187
|
* Asynchronously creates transaction metadata based on the provided transaction parameters and network state.
|
|
137
188
|
* This includes constructing a transaction with given instructions, calculating fees, and optionally handling priority fees.
|
|
@@ -152,12 +203,12 @@ class CreateTxMetadata {
|
|
|
152
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
204
|
// Retrieve address lookup table accounts
|
|
154
205
|
const alts = [];
|
|
155
|
-
|
|
206
|
+
(0, Logging_1.Log)(`createTxMetadata`);
|
|
156
207
|
const mainStartTime = new Date().getTime() / 1000;
|
|
157
208
|
// Find jup alts
|
|
158
209
|
let startTime = mainStartTime;
|
|
159
210
|
const jupAlts = yield generalUtility.findAltWithTxPost({ transaction: data });
|
|
160
|
-
|
|
211
|
+
(0, Logging_1.Log)(`createTxMetadata: Checkpoint: (jupAlts) ${(new Date().getTime() / 1000) - startTime}`);
|
|
161
212
|
startTime = new Date().getTime() / 1000;
|
|
162
213
|
for (const alt of data.addressLookupTableAddresses) {
|
|
163
214
|
const _alt = yield this.getAlt(alt);
|
|
@@ -175,21 +226,26 @@ class CreateTxMetadata {
|
|
|
175
226
|
alts.push(_alt);
|
|
176
227
|
}
|
|
177
228
|
else {
|
|
178
|
-
|
|
229
|
+
try {
|
|
230
|
+
alts.push(yield this.loadSingleAlt(alt, connection));
|
|
231
|
+
}
|
|
232
|
+
catch (_a) {
|
|
233
|
+
console.error(`The ALT from Jupiter: ${alt} does not exist onchain. Skipping.`);
|
|
234
|
+
}
|
|
179
235
|
}
|
|
180
236
|
}
|
|
181
237
|
}
|
|
182
238
|
else {
|
|
183
239
|
console.error(jupAlts.data);
|
|
184
240
|
}
|
|
185
|
-
|
|
241
|
+
(0, Logging_1.Log)(`createTxMetadata: Checkpoint: (jupAlts after loop) ${(new Date().getTime() / 1000) - startTime}`);
|
|
186
242
|
// Get the recent blockhash
|
|
187
243
|
startTime = new Date().getTime() / 1000;
|
|
188
244
|
const latestBlockhash = yield connection.getLatestBlockhash();
|
|
189
|
-
|
|
245
|
+
(0, Logging_1.Log)(`createTxMetadata: Checkpoint: (latestBlockhash) ${(new Date().getTime() / 1000) - startTime}`);
|
|
190
246
|
// Create initial transaction instance
|
|
191
247
|
const transaction = new Transaction_1.Transaction(data, new web3.PublicKey(payer), latestBlockhash, alts, generalUtility);
|
|
192
|
-
|
|
248
|
+
(0, Logging_1.Log)(`createTxMetadata: Elapsed time: ${(new Date().getTime() / 1000) - mainStartTime}`);
|
|
193
249
|
// Return transaction metadata
|
|
194
250
|
return {
|
|
195
251
|
description: data.description,
|
|
@@ -198,5 +254,58 @@ class CreateTxMetadata {
|
|
|
198
254
|
};
|
|
199
255
|
});
|
|
200
256
|
}
|
|
257
|
+
createTxMetadata2(generalUtility, connection, payer, data) {
|
|
258
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
259
|
+
// Retrieve address lookup table accounts
|
|
260
|
+
const alts = [];
|
|
261
|
+
(0, Logging_1.Log)(`createTxMetadata2`);
|
|
262
|
+
const mainStartTime = new Date().getTime() / 1000;
|
|
263
|
+
// Get the recent blockhash
|
|
264
|
+
let startTime = mainStartTime;
|
|
265
|
+
const latestBlockhash = yield connection.getLatestBlockhash();
|
|
266
|
+
(0, Logging_1.Log)(`createTxMetadata2: Checkpoint: (latestBlockhash) ${(new Date().getTime() / 1000) - startTime}`);
|
|
267
|
+
startTime = new Date().getTime() / 1000;
|
|
268
|
+
const batchExecute = new TransactionBatchExecute2_1.TransactionBatchExecute2(data.addressLookupTableAddresses.map(p => new web3.PublicKey(p)), data.mainInstructions.map(ix => {
|
|
269
|
+
const keys = ix.accounts.map(meta => {
|
|
270
|
+
return {
|
|
271
|
+
pubkey: new web3.PublicKey(meta.pubkey),
|
|
272
|
+
isSigner: meta.isSigner,
|
|
273
|
+
isWritable: meta.isWritable,
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
return {
|
|
277
|
+
keys,
|
|
278
|
+
programId: new web3.PublicKey(ix.programId),
|
|
279
|
+
data: Buffer.from(ix.data, 'base64'),
|
|
280
|
+
};
|
|
281
|
+
}), connection, this, latestBlockhash, new web3.PublicKey(payer));
|
|
282
|
+
(0, Logging_1.Log)(`createTxMetadata2: Checkpoint: Create 'batchExecute' instance ${(new Date().getTime() / 1000) - startTime}`);
|
|
283
|
+
startTime = new Date().getTime() / 1000;
|
|
284
|
+
const batch = yield batchExecute.buildBatch();
|
|
285
|
+
(0, Logging_1.Log)(`createTxMetadata2: Checkpoint: Create batch of transactions ${(new Date().getTime() / 1000) - startTime}`);
|
|
286
|
+
(0, Logging_1.Log)(`Number of transactions: ${batch.length}`);
|
|
287
|
+
startTime = new Date().getTime() / 1000;
|
|
288
|
+
const txMetadata = [];
|
|
289
|
+
let i = 0;
|
|
290
|
+
for (const tx of batch) {
|
|
291
|
+
let description = data.description;
|
|
292
|
+
if (batch.length > 1) {
|
|
293
|
+
description = `${description} #${i + 1}`;
|
|
294
|
+
}
|
|
295
|
+
const alts = batchExecute.findRequiredAltsForBatch2(tx);
|
|
296
|
+
// Create initial transaction instance
|
|
297
|
+
const transaction = new Transaction_1.Transaction(data, new web3.PublicKey(payer), latestBlockhash, alts, generalUtility, tx);
|
|
298
|
+
txMetadata.push({
|
|
299
|
+
description,
|
|
300
|
+
estimatedFeeInSOL: data.estimatedFeeInSOL,
|
|
301
|
+
transaction,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
(0, Logging_1.Log)(`createTxMetadata2: Checkpoint: Generated multiple transaction metadata ${(new Date().getTime() / 1000) - startTime}`);
|
|
305
|
+
(0, Logging_1.Log)(`createTxMetadata2: Elapsed time: ${(new Date().getTime() / 1000) - mainStartTime}`);
|
|
306
|
+
// Return transaction metadata
|
|
307
|
+
return txMetadata;
|
|
308
|
+
});
|
|
309
|
+
}
|
|
201
310
|
}
|
|
202
311
|
exports.CreateTxMetadata = CreateTxMetadata;
|
|
@@ -34,6 +34,12 @@ export declare class General {
|
|
|
34
34
|
* @param maxPriorityFee The fee in lamports.
|
|
35
35
|
*/
|
|
36
36
|
setMaxPriorityFee(maxPriorityFee: number): void;
|
|
37
|
+
/**
|
|
38
|
+
* @returns Returns a token supported by Hawksight
|
|
39
|
+
*/
|
|
40
|
+
token(params: {
|
|
41
|
+
address: string;
|
|
42
|
+
}): Promise<ResponseWithStatus<_client.InlineResponse200>>;
|
|
37
43
|
/**
|
|
38
44
|
* Retrieves the portfolio information for a specified wallet and optionally a pool.
|
|
39
45
|
*
|
|
@@ -53,6 +59,16 @@ export declare class General {
|
|
|
53
59
|
pools(params: {
|
|
54
60
|
hash?: string;
|
|
55
61
|
}): Promise<ResponseWithStatus<_client.HawksightPool[]>>;
|
|
62
|
+
/**
|
|
63
|
+
* Fetches a single pool either from Orca or Meteora.
|
|
64
|
+
*
|
|
65
|
+
* @param params Object containing hash of the pools
|
|
66
|
+
* @returns A Promise resolving to an array of pools, including metadata such as pool addresses and statistics.
|
|
67
|
+
*/
|
|
68
|
+
pool(params: {
|
|
69
|
+
pairAddress: string;
|
|
70
|
+
protocol: string;
|
|
71
|
+
}): Promise<ResponseWithStatus<_client.HawksightPool[]>>;
|
|
56
72
|
/**
|
|
57
73
|
* Retrieves information about the available tokens on the platform.
|
|
58
74
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"General.d.ts","sourceRoot":"","sources":["../../../src/classes/General.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,OAAO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