@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
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var _a;
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.TransactionBatchExecute2 = void 0;
|
|
37
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
38
|
+
const TransactionBatchExecute_1 = require("./TransactionBatchExecute");
|
|
39
|
+
const MultiTransaction_1 = require("./MultiTransaction");
|
|
40
|
+
const functions_1 = require("../functions");
|
|
41
|
+
/**
|
|
42
|
+
* Executes transactions in batches
|
|
43
|
+
*/
|
|
44
|
+
class TransactionBatchExecute2 extends TransactionBatchExecute_1.TransactionBatchExecute {
|
|
45
|
+
/**
|
|
46
|
+
* Creates an instance of TransactionExecute class
|
|
47
|
+
*
|
|
48
|
+
* @param lookupTableAddresses Address lookup table addresses to be used by batch of transactions
|
|
49
|
+
* @param instructions Array of instructions to be batched into transactions
|
|
50
|
+
* @param payer Payer that will pay for the batch of transactions
|
|
51
|
+
* @param connection Connection to mainnet
|
|
52
|
+
*/
|
|
53
|
+
constructor(lookupTableAddresses, instructions, connection, createTxMetadataInstance, latestBlockhash, payerKey) {
|
|
54
|
+
super(lookupTableAddresses, instructions, new web3.Keypair(), // unused
|
|
55
|
+
connection, []);
|
|
56
|
+
this.lookupTableAddresses = lookupTableAddresses;
|
|
57
|
+
this.instructions = instructions;
|
|
58
|
+
this.connection = connection;
|
|
59
|
+
this.createTxMetadataInstance = createTxMetadataInstance;
|
|
60
|
+
this.latestBlockhash = latestBlockhash;
|
|
61
|
+
this.payerKey = payerKey;
|
|
62
|
+
this._insertNonceAt = {};
|
|
63
|
+
}
|
|
64
|
+
;
|
|
65
|
+
/**
|
|
66
|
+
* Download all jupiter alts (overridable)
|
|
67
|
+
*/
|
|
68
|
+
jupiterDownloadAlts() {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Find alt by pubkeys (overridable)
|
|
73
|
+
*/
|
|
74
|
+
jupiterFindAltByPubkeys(pubkeys) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
return yield _a.jupiterFindAltByPubkeysFn(pubkeys);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Downoad address lookup table from given cluster
|
|
81
|
+
*/
|
|
82
|
+
downloadAlts2(lookupTableAddresses) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const pubkeyStr = lookupTableAddresses.map(pubkey => pubkey.toString());
|
|
85
|
+
const alts = yield this.createTxMetadataInstance.stringToAlt(pubkeyStr);
|
|
86
|
+
this.alts.push(...alts);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Option to include nonce advance instruction
|
|
91
|
+
*
|
|
92
|
+
* @param opt
|
|
93
|
+
*/
|
|
94
|
+
insertNonceAt(opt) {
|
|
95
|
+
this._insertNonceAt = opt;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Builds a batch of executable transaction instructions
|
|
99
|
+
*/
|
|
100
|
+
buildBatch() {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
// Download address lookup table from given cluster
|
|
103
|
+
yield this.downloadAlts();
|
|
104
|
+
// Generate dummy instructions for batch calculation
|
|
105
|
+
const [simulationIxs, dummySigners] = this.generateSimulationIxs();
|
|
106
|
+
// Split simulation ixs
|
|
107
|
+
const dummyBatches = yield this.splitToTransactions(simulationIxs, dummySigners);
|
|
108
|
+
// Batch of actual instructions
|
|
109
|
+
const batch = [];
|
|
110
|
+
let index = 0;
|
|
111
|
+
let i = 0;
|
|
112
|
+
const lastIndex = dummyBatches.length - 1;
|
|
113
|
+
for (const dummyIxs of dummyBatches) {
|
|
114
|
+
const isLastIndex = i == lastIndex;
|
|
115
|
+
const currentBatch = [];
|
|
116
|
+
for (const ix of dummyIxs) {
|
|
117
|
+
// If program id is compute budget, ignore
|
|
118
|
+
if (ix.programId.equals(web3.ComputeBudgetProgram.programId))
|
|
119
|
+
continue;
|
|
120
|
+
// Otherwise, include in batch
|
|
121
|
+
currentBatch.push(this.instructions[index++]);
|
|
122
|
+
}
|
|
123
|
+
if (isLastIndex && this._insertNonceAt.onlyEndOfTx) {
|
|
124
|
+
currentBatch.push(yield this.generateNonceAdvanceIx(i));
|
|
125
|
+
}
|
|
126
|
+
batch.push(currentBatch);
|
|
127
|
+
i++;
|
|
128
|
+
}
|
|
129
|
+
return batch;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Builds a batch of executable transaction instructions
|
|
134
|
+
*/
|
|
135
|
+
buildBatchWithAlts(description, generalUtility) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
// Download address lookup table from given cluster
|
|
138
|
+
yield this.downloadAlts();
|
|
139
|
+
// Generate dummy instructions for batch calculation
|
|
140
|
+
const [simulationIxs, dummySigners] = this.generateSimulationIxs();
|
|
141
|
+
// Split simulation ixs
|
|
142
|
+
const dummyBatches = yield this.splitToTransactions(simulationIxs, dummySigners);
|
|
143
|
+
// Batch of actual instructions
|
|
144
|
+
const batch = new MultiTransaction_1.MultiTransaction(description, generalUtility, this.latestBlockhash, this.payerKey);
|
|
145
|
+
let index = 0;
|
|
146
|
+
let i = 0;
|
|
147
|
+
const lastIndex = dummyBatches.length - 1;
|
|
148
|
+
for (const dummyIxs of dummyBatches) {
|
|
149
|
+
const isLastIndex = i == lastIndex;
|
|
150
|
+
const currentBatch = [];
|
|
151
|
+
for (const ix of dummyIxs) {
|
|
152
|
+
// If program id is compute budget, ignore
|
|
153
|
+
if (ix.programId.equals(web3.ComputeBudgetProgram.programId))
|
|
154
|
+
continue;
|
|
155
|
+
// Otherwise, include in batch
|
|
156
|
+
currentBatch.push(this.instructions[index++]);
|
|
157
|
+
}
|
|
158
|
+
if (lastIndex !== 0 && isLastIndex && this._insertNonceAt.onlyEndOfTx) {
|
|
159
|
+
currentBatch.push(yield this.generateNonceAdvanceIx(i));
|
|
160
|
+
}
|
|
161
|
+
const alts = this.findRequiredAltsForBatch2(currentBatch);
|
|
162
|
+
batch.push(alts, currentBatch);
|
|
163
|
+
i++;
|
|
164
|
+
}
|
|
165
|
+
return batch;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Split transactions
|
|
170
|
+
*
|
|
171
|
+
* @param simulationIxs
|
|
172
|
+
* @param dummySigners
|
|
173
|
+
* @returns
|
|
174
|
+
*/
|
|
175
|
+
splitToTransactions(simulationIxs, dummySigners) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
// Create dummy priority fee instructions for the transaction (to account for total tx size)
|
|
178
|
+
const preIxs = [
|
|
179
|
+
web3.ComputeBudgetProgram.setComputeUnitLimit({
|
|
180
|
+
units: 1400000, // dummy value
|
|
181
|
+
}),
|
|
182
|
+
web3.ComputeBudgetProgram.setComputeUnitPrice({
|
|
183
|
+
microLamports: 1000000, // dummy value
|
|
184
|
+
}),
|
|
185
|
+
];
|
|
186
|
+
// Run simulation
|
|
187
|
+
let batch = [];
|
|
188
|
+
let result = [];
|
|
189
|
+
for (const ix of simulationIxs) {
|
|
190
|
+
// Include dummy ix to transaction
|
|
191
|
+
batch.push(ix);
|
|
192
|
+
// Calculate transaction size
|
|
193
|
+
try {
|
|
194
|
+
const estimateTxSize = this.getEstimateSize([...preIxs, ...batch]);
|
|
195
|
+
if (estimateTxSize < this.MAX_SIZE)
|
|
196
|
+
continue;
|
|
197
|
+
// Generate dummy nonce advance (anticipation)
|
|
198
|
+
const nonceAdvance = this._insertNonceAt.onlyEndOfTx ? [yield this.generateNonceAdvanceIx(result.length)] : [];
|
|
199
|
+
const txSize = this.calculateTransactionSize(this.latestBlockhash, [...preIxs, ...nonceAdvance, ...batch], dummySigners);
|
|
200
|
+
if (txSize > this.MAX_SIZE) {
|
|
201
|
+
batch.pop();
|
|
202
|
+
result.push([...preIxs, ...batch]);
|
|
203
|
+
batch = [ix];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch (_b) {
|
|
207
|
+
batch.pop();
|
|
208
|
+
result.push([...preIxs, ...batch]);
|
|
209
|
+
batch = [ix];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (batch.length > 0 && simulationIxs.length !== 0) {
|
|
213
|
+
result.push([...preIxs, ...batch]);
|
|
214
|
+
}
|
|
215
|
+
return result;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Generate nonde advance instruction (dummy instruction)
|
|
220
|
+
*/
|
|
221
|
+
generateNonceAdvanceIx(index) {
|
|
222
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
const noncePubkey = yield (0, functions_1.generateNonceAddressFromIndex)(this.payerKey, index);
|
|
224
|
+
// Generate dummy nonce ix
|
|
225
|
+
return web3.SystemProgram.nonceAdvance({
|
|
226
|
+
/** Nonce account */
|
|
227
|
+
noncePubkey,
|
|
228
|
+
/** Public key of the nonce authority */
|
|
229
|
+
authorizedPubkey: this.payerKey,
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
getEstimateSize(ixs) {
|
|
234
|
+
let length = 0;
|
|
235
|
+
const alts = {};
|
|
236
|
+
ixs.map(ix => {
|
|
237
|
+
length += ix.data.length + ix.programId.toBuffer().length;
|
|
238
|
+
ix.keys.map(meta => {
|
|
239
|
+
const alt = this.pubkeyToAlt[meta.pubkey.toString()];
|
|
240
|
+
if (!!alt) {
|
|
241
|
+
alts[alt.key.toString()] = alt;
|
|
242
|
+
length += 3;
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
length += 34;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
for (const _ in alts) {
|
|
250
|
+
length += 32;
|
|
251
|
+
}
|
|
252
|
+
return length;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Find required signers from instructions
|
|
256
|
+
*
|
|
257
|
+
* @param ixs
|
|
258
|
+
* @param dummySigners
|
|
259
|
+
*/
|
|
260
|
+
findRequiredSignersFromIxs(ixs) {
|
|
261
|
+
const signers = [];
|
|
262
|
+
signers.push(this.payerKey);
|
|
263
|
+
for (const instruction of ixs) {
|
|
264
|
+
const _signers = instruction.keys
|
|
265
|
+
.filter(meta => meta.isSigner)
|
|
266
|
+
.map(meta => meta.pubkey);
|
|
267
|
+
if (_signers.length > 0) {
|
|
268
|
+
signers.push(..._signers);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const uniqueSigners = {};
|
|
272
|
+
for (const signer of signers) {
|
|
273
|
+
uniqueSigners[signer.toBase58()] = signer;
|
|
274
|
+
}
|
|
275
|
+
const result = [];
|
|
276
|
+
for (const id in uniqueSigners) {
|
|
277
|
+
result.push(uniqueSigners[id]);
|
|
278
|
+
}
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Calculate transaction size
|
|
283
|
+
*
|
|
284
|
+
* @param batch
|
|
285
|
+
*/
|
|
286
|
+
calculateTransactionSize(latestBlockhash, batch, dummySigners) {
|
|
287
|
+
const alts = this.findRequiredAltsForBatch2(batch);
|
|
288
|
+
const messageV0 = new web3.TransactionMessage({
|
|
289
|
+
payerKey: dummySigners[this.payerKey.toString()].publicKey,
|
|
290
|
+
instructions: batch,
|
|
291
|
+
recentBlockhash: latestBlockhash.blockhash,
|
|
292
|
+
}).compileToV0Message(alts);
|
|
293
|
+
const versionedTx = new web3.VersionedTransaction(messageV0);
|
|
294
|
+
const signers = this.findRequiredSignersFromBatch2(batch, dummySigners);
|
|
295
|
+
versionedTx.sign(signers);
|
|
296
|
+
const bytes = versionedTx.serialize();
|
|
297
|
+
return bytes.length;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Find required address lookup table addresses for given batch of instructions
|
|
301
|
+
*
|
|
302
|
+
* @param batch
|
|
303
|
+
*/
|
|
304
|
+
findRequiredAltsForBatch2(batch) {
|
|
305
|
+
const pubkeys = [];
|
|
306
|
+
batch.map(ix => {
|
|
307
|
+
pubkeys.push(...ix.keys.map(meta => meta.pubkey));
|
|
308
|
+
});
|
|
309
|
+
const alts = {};
|
|
310
|
+
for (const pubkey of pubkeys) {
|
|
311
|
+
const alt = this.pubkeyToAlt[pubkey.toString()];
|
|
312
|
+
if (!!alt) {
|
|
313
|
+
alts[alt.key.toString()] = alt;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const result = [];
|
|
317
|
+
for (const key in alts) {
|
|
318
|
+
result.push(alts[key]);
|
|
319
|
+
}
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Find required signers from batch
|
|
324
|
+
*
|
|
325
|
+
* @param ixs
|
|
326
|
+
* @param dummySigners
|
|
327
|
+
*/
|
|
328
|
+
findRequiredSignersFromBatch2(batch, dummySigners) {
|
|
329
|
+
const signers = this.findRequiredSignersFromIxs(batch);
|
|
330
|
+
const result = [];
|
|
331
|
+
for (const signer of signers) {
|
|
332
|
+
const key = signer.toString();
|
|
333
|
+
result.push(dummySigners[key]);
|
|
334
|
+
}
|
|
335
|
+
return result;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
exports.TransactionBatchExecute2 = TransactionBatchExecute2;
|
|
339
|
+
_a = TransactionBatchExecute2;
|
|
340
|
+
/**
|
|
341
|
+
* Find alt by pubkeys (overridable)
|
|
342
|
+
*
|
|
343
|
+
* @param pubkeys
|
|
344
|
+
*/
|
|
345
|
+
TransactionBatchExecute2.jupiterFindAltByPubkeysFn = (pubkeys) => __awaiter(void 0, void 0, void 0, function* () {
|
|
346
|
+
throw new Error("jupiterFindAltByPubkeysFn not implemented.");
|
|
347
|
+
});
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
2
|
import * as web3 from "@solana/web3.js";
|
|
3
|
-
import { MeteoraClaim, MeteoraClose, MeteoraCompound, MeteoraCreatePositionAndDeposit, MeteoraDeposit, MeteoraInitializeBinArrays, MeteoraRebalance, MeteoraWithdraw, Register, TxgenParams, InitializeStorageTokenAccount, MeteoraLimitCloseAutomation, OrcaOpenPosition, OrcaClosePosition, OrcaDeposit, OrcaWithdraw, OrcaClaimRewards, TransactionMetadataResponse } from '../types';
|
|
3
|
+
import { MeteoraClaim, MeteoraClaimAll, MeteoraClose, MeteoraCompound, MeteoraCreatePositionAndDeposit, MeteoraDeposit, MeteoraInitializeBinArrays, MeteoraRebalance, MeteoraWithdraw, Register, TxgenParams, InitializeStorageTokenAccount, MeteoraLimitCloseAutomation, OrcaOpenPosition, OrcaClosePosition, OrcaDeposit, OrcaWithdraw, OrcaClaimRewards, TransactionMetadataResponse, MeteoraRebalance2 } from '../types';
|
|
4
|
+
import { GeneralUtility } from "./GeneralUtility";
|
|
5
|
+
import { MultiTransaction } from "./MultiTransaction";
|
|
6
|
+
import { SimpleIxGenerator } from "./SimpleIxGenerator";
|
|
4
7
|
export declare class Transactions {
|
|
8
|
+
/**
|
|
9
|
+
* Prohibit creating instance other than getInstance
|
|
10
|
+
*/
|
|
11
|
+
private constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Singleton instance
|
|
14
|
+
*/
|
|
15
|
+
private static instance;
|
|
16
|
+
/**
|
|
17
|
+
* Simple IX Generator instance (overridable)
|
|
18
|
+
*/
|
|
19
|
+
ix: SimpleIxGenerator;
|
|
20
|
+
/**
|
|
21
|
+
* Get singleton instance
|
|
22
|
+
*
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
static getInstance(): Transactions;
|
|
5
26
|
/**
|
|
6
27
|
* Generate UserPDA
|
|
7
28
|
*
|
|
@@ -28,6 +49,15 @@ export declare class Transactions {
|
|
|
28
49
|
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
29
50
|
*/
|
|
30
51
|
meteoraCreatePositionAndDeposit({ connection, params, }: TxgenParams<MeteoraCreatePositionAndDeposit>): Promise<TransactionMetadataResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates meteora instruction that creates new position and deposit.
|
|
54
|
+
*
|
|
55
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
56
|
+
* @param payer The public key of the payer for transaction fees.
|
|
57
|
+
* @param params Parameters required
|
|
58
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
59
|
+
*/
|
|
60
|
+
meteoraCreatePositionAndDepositPda({ connection, params, }: TxgenParams<MeteoraCreatePositionAndDeposit>): Promise<TransactionMetadataResponse>;
|
|
31
61
|
/**
|
|
32
62
|
* Creates meteora instruction that initializes bin arrays.
|
|
33
63
|
*
|
|
@@ -55,6 +85,15 @@ export declare class Transactions {
|
|
|
55
85
|
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
56
86
|
*/
|
|
57
87
|
meteoraWithdraw({ connection, params, }: TxgenParams<MeteoraWithdraw>): Promise<TransactionMetadataResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* Creates meteora instruction withdraws from a position.
|
|
90
|
+
*
|
|
91
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
92
|
+
* @param payer The public key of the payer for transaction fees.
|
|
93
|
+
* @param params Parameters required
|
|
94
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
95
|
+
*/
|
|
96
|
+
meteoraWithdrawPda({ connection, params, }: TxgenParams<MeteoraWithdraw>): Promise<TransactionMetadataResponse>;
|
|
58
97
|
/**
|
|
59
98
|
* Creates meteora instruction that claims fees and rewards.
|
|
60
99
|
*
|
|
@@ -64,6 +103,15 @@ export declare class Transactions {
|
|
|
64
103
|
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
65
104
|
*/
|
|
66
105
|
meteoraClaim({ connection, params, }: TxgenParams<MeteoraClaim>): Promise<TransactionMetadataResponse>;
|
|
106
|
+
/**
|
|
107
|
+
* Claim all meteora fees and rewards by list of pools owned by given user
|
|
108
|
+
*
|
|
109
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
110
|
+
* @param payer The public key of the payer for transaction fees.
|
|
111
|
+
* @param params Parameters required
|
|
112
|
+
* @returns Array of transaction instructions (simplified output)
|
|
113
|
+
*/
|
|
114
|
+
meteoraClaimAll({ connection, params, }: TxgenParams<MeteoraClaimAll>, payer: web3.PublicKey, generalUtility: GeneralUtility): Promise<MultiTransaction>;
|
|
67
115
|
/**
|
|
68
116
|
* Creates meteora instruction that closes position.
|
|
69
117
|
*
|
|
@@ -74,7 +122,9 @@ export declare class Transactions {
|
|
|
74
122
|
*/
|
|
75
123
|
meteoraClosePosition({ connection, params, }: TxgenParams<MeteoraClose>): Promise<TransactionMetadataResponse>;
|
|
76
124
|
compoundAutomationIx({ connection, params, }: TxgenParams<MeteoraCompound>): Promise<TransactionMetadataResponse>;
|
|
125
|
+
claimAutomationIx({ connection, params, }: TxgenParams<MeteoraCompound>): Promise<TransactionMetadataResponse>;
|
|
77
126
|
rebalanceAutomationIx({ connection, params, }: TxgenParams<MeteoraRebalance>): Promise<TransactionMetadataResponse>;
|
|
127
|
+
rebalanceAutomationIx2({ connection, params, }: TxgenParams<MeteoraRebalance2>): Promise<TransactionMetadataResponse>;
|
|
78
128
|
/**
|
|
79
129
|
* Creates instructions to initialize storage token accounts
|
|
80
130
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../../src/classes/Transactions.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../../src/classes/Transactions.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAiBxC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,+BAA+B,EAC/B,cAAc,EACd,0BAA0B,EAC1B,gBAAgB,EAChB,eAAe,EACf,QAAQ,EAER,WAAW,EACX,6BAA6B,EAC7B,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,2BAA2B,EAC3B,iBAAiB,EAClB,MAAM,UAAU,CAAC;AA+BlB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEx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