@hawksightco/hawk-sdk 0.0.9 → 0.0.10

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.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/dist/src/classes/Client.d.ts +0 -33
  3. package/dist/src/classes/Client.d.ts.map +0 -1
  4. package/dist/src/classes/Client.js +0 -55
  5. package/dist/src/classes/General.d.ts +0 -66
  6. package/dist/src/classes/General.d.ts.map +0 -1
  7. package/dist/src/classes/General.js +0 -108
  8. package/dist/src/classes/HawkAPI.d.ts +0 -33
  9. package/dist/src/classes/HawkAPI.d.ts.map +0 -1
  10. package/dist/src/classes/HawkAPI.js +0 -34
  11. package/dist/src/classes/Health.d.ts +0 -29
  12. package/dist/src/classes/Health.d.ts.map +0 -1
  13. package/dist/src/classes/Health.js +0 -48
  14. package/dist/src/classes/Transaction.d.ts +0 -84
  15. package/dist/src/classes/Transaction.d.ts.map +0 -1
  16. package/dist/src/classes/Transaction.js +0 -230
  17. package/dist/src/classes/TxGenerator.d.ts +0 -129
  18. package/dist/src/classes/TxGenerator.d.ts.map +0 -1
  19. package/dist/src/classes/TxGenerator.js +0 -217
  20. package/dist/src/classes/TxGeneratorAutomations.d.ts +0 -68
  21. package/dist/src/classes/TxGeneratorAutomations.d.ts.map +0 -1
  22. package/dist/src/classes/TxGeneratorAutomations.js +0 -96
  23. package/dist/src/classes/Util.d.ts +0 -65
  24. package/dist/src/classes/Util.d.ts.map +0 -1
  25. package/dist/src/classes/Util.js +0 -115
  26. package/dist/src/functions.d.ts +0 -34
  27. package/dist/src/functions.d.ts.map +0 -1
  28. package/dist/src/functions.js +0 -159
  29. package/dist/src/index.d.ts +0 -3
  30. package/dist/src/index.d.ts.map +0 -1
  31. package/dist/src/index.js +0 -4
  32. package/dist/src/types.d.ts +0 -261
  33. package/dist/src/types.d.ts.map +0 -1
  34. package/dist/src/types.js +0 -17
@@ -1,230 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.Transaction = void 0;
36
- const web3 = __importStar(require("@solana/web3.js"));
37
- const functions_1 = require("../functions");
38
- const bn_js_1 = require("bn.js");
39
- /**
40
- * Represents a transaction object in Solana using the web3.js library.
41
- * This class encapsulates the logic for creating, signing, and verifying signatures of transactions.
42
- */
43
- class Transaction {
44
- get txMessage() { return this._txMessage; }
45
- get versionedTransaction() { return this._versionedTransaction; }
46
- get priorityFeeEstimate() { return this._priorityFeeEstimate; }
47
- /** The blockhash of a recent ledger entry */
48
- get recentBlockhash() { return this._recentBlockhash; }
49
- /** Array of TransactionInstruction to be executed in this transaction */
50
- get instructions() { return this._instructions; }
51
- /**
52
- * Constructs a new Transaction object.
53
- *
54
- * @param payerKey PublicKey of the transaction payer
55
- * @param instructions Array of TransactionInstruction to be executed in this transaction
56
- * @param recentBlockhash The blockhash of a recent ledger entry
57
- * @param alts Address lookup tables that optimize account address storage
58
- */
59
- constructor(payerKey, _instructions, _recentBlockhash, alts) {
60
- this.payerKey = payerKey;
61
- this._instructions = _instructions;
62
- this._recentBlockhash = _recentBlockhash;
63
- this.alts = alts;
64
- /** Estimated fee in SOL for priority fee when addPriorityFee() method is called. */
65
- this._priorityFeeEstimate = "";
66
- const [txMessage, versionedTransaction] = this.buildTransaction(_recentBlockhash);
67
- this._txMessage = txMessage;
68
- this._versionedTransaction = versionedTransaction;
69
- this.requiredSigners = this.getRequiredSigners();
70
- if (typeof this.requiredSigners[payerKey.toString()] !== 'boolean') {
71
- throw new Error(`Warning: The payer ${payerKey} is not one of the required signers of this transaction.`);
72
- }
73
- }
74
- ;
75
- /**
76
- * Signs the transaction with provided signers.
77
- *
78
- * @param signers Array of Signer objects whose private keys will be used to sign the transaction.
79
- * @param idempotent Boolean indicating whether signing should be idempotent (default is false).
80
- * @throws Error if a signer is not required or has already signed the transaction when not idempotent.
81
- */
82
- sign(signers, idempotent = false) {
83
- // First validate all signers
84
- signers.forEach(signer => {
85
- const key = signer.publicKey.toString();
86
- if (typeof this.requiredSigners[key] !== 'boolean') {
87
- throw new Error(`Key ${key} is not a required signer!`);
88
- }
89
- if (!idempotent && this.requiredSigners[key]) {
90
- throw new Error(`Key ${key} has already been signed by required signer!`);
91
- }
92
- });
93
- // If all signers are valid and the process is idempotent or they haven't signed yet, update and sign
94
- signers.forEach(signer => {
95
- const key = signer.publicKey.toString();
96
- this.requiredSigners[key] = true;
97
- });
98
- this.versionedTransaction.sign(signers);
99
- }
100
- /**
101
- * Checks if all required signers have signed the transaction.
102
- *
103
- * @returns Boolean indicating whether all required signers have signed.
104
- */
105
- isSignedByRequiredSigners() {
106
- return Object.values(this.requiredSigners).every(isSigned => isSigned);
107
- }
108
- /**
109
- * Add priority fee instructions (compute budget)
110
- */
111
- addPriorityFeeIx(connection, priorityLevel, computeUnitLimit, maxPriorityFee) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- // First, remove priority fee instructions (compute budget if there is)
114
- this.removePriorityFeeIxs();
115
- // Then get fee estimate by simulating the transaction
116
- const estimate = yield (0, functions_1.getFeeEstimate)(connection, priorityLevel, this.versionedTransaction);
117
- const priorityFeeEstimate = maxPriorityFee !== undefined && maxPriorityFee > 0 ? Math.round(Math.min(estimate, maxPriorityFee)) : Math.round(estimate);
118
- // Create priority fee ixs for transaction
119
- const priorityFeeIxs = [
120
- web3.ComputeBudgetProgram.setComputeUnitLimit({ units: computeUnitLimit }),
121
- web3.ComputeBudgetProgram.setComputeUnitPrice({
122
- // CU * CU PRICE -> 1400000 * feeEstimate.priorityFeeEstimate
123
- microLamports: priorityFeeEstimate,
124
- }),
125
- ];
126
- this._priorityFeeEstimate = (new bn_js_1.BN(priorityFeeEstimate)
127
- .mul(new bn_js_1.BN(computeUnitLimit))
128
- .div(new bn_js_1.BN(1000000))
129
- .add(new bn_js_1.BN(5000)).toNumber() / 1000000000).toString();
130
- // Append priority fee instruction at the beginning
131
- this._instructions.unshift(...priorityFeeIxs);
132
- // Rebuild versioned transaction
133
- const { blockhash } = yield connection.getLatestBlockhash();
134
- this.buildTransaction(blockhash);
135
- return priorityFeeIxs;
136
- });
137
- }
138
- /**
139
- * Simulate transaction
140
- *
141
- * @param connection
142
- * @returns
143
- */
144
- simulateTransaction(connection) {
145
- return __awaiter(this, void 0, void 0, function* () {
146
- const testInstructions = [
147
- web3.ComputeBudgetProgram.setComputeUnitLimit({ units: 1400000 }),
148
- ...this.instructions,
149
- ];
150
- const testVersionedTxn = new web3.VersionedTransaction(new web3.TransactionMessage({
151
- instructions: testInstructions,
152
- payerKey: this.payerKey,
153
- recentBlockhash: web3.PublicKey.default.toString(),
154
- }).compileToV0Message(this.alts));
155
- const simulation = yield connection.simulateTransaction(testVersionedTxn, {
156
- replaceRecentBlockhash: true,
157
- sigVerify: false,
158
- });
159
- if (simulation.value.unitsConsumed === undefined) {
160
- throw new Error('Unable to calculate compute budget.');
161
- }
162
- return {
163
- err: simulation.value.err,
164
- logs: simulation.value.logs,
165
- accounts: simulation.value.accounts,
166
- unitsConsumed: simulation.value.unitsConsumed,
167
- returnData: simulation.value.returnData,
168
- };
169
- });
170
- }
171
- /**
172
- * Builds transaction object
173
- */
174
- buildTransaction(recentBlockhash) {
175
- this._txMessage = new web3.TransactionMessage({
176
- payerKey: this.payerKey,
177
- instructions: this.instructions,
178
- recentBlockhash,
179
- });
180
- this._versionedTransaction = new web3.VersionedTransaction(this.txMessage.compileToV0Message(this.alts));
181
- return [this._txMessage, this._versionedTransaction];
182
- }
183
- /**
184
- * Gathers the public keys of all parties required to sign the transaction.
185
- *
186
- * @returns A record of signer public keys mapped to a boolean indicating whether they have signed.
187
- */
188
- getRequiredSigners() {
189
- const signerKeys = this.instructions.flatMap(ix => ix.keys.filter(meta => meta.isSigner).map(meta => meta.pubkey.toString()));
190
- const result = {};
191
- signerKeys.forEach(key => result[key] = false);
192
- return result;
193
- }
194
- /**
195
- * Find setComputeUnitLimit index within the instructions
196
- */
197
- findSetComputeUnitLimitIndex() {
198
- return this.instructions.findIndex(ix => {
199
- const isComputeBudgetProgram = ix.programId.toString() === 'ComputeBudget111111111111111111111111111111';
200
- const isSetComputeLimitIx = ix.data[0] === 2;
201
- return isComputeBudgetProgram && isSetComputeLimitIx;
202
- });
203
- }
204
- /**
205
- * Find setComputeUnitPrice index within the instructions
206
- */
207
- findSetComputeUnitPriceIndex() {
208
- return this.instructions.findIndex(ix => {
209
- const isComputeBudgetProgram = ix.programId.toString() === 'ComputeBudget111111111111111111111111111111';
210
- const isSetComputeUnitPriceIx = ix.data[0] === 3;
211
- return isComputeBudgetProgram && isSetComputeUnitPriceIx;
212
- });
213
- }
214
- /**
215
- * Remove priority fee instructions
216
- */
217
- removePriorityFeeIxs() {
218
- while (true) {
219
- const setComputeUnitLimitIxIndex = this.findSetComputeUnitLimitIndex();
220
- const setComputeUnitPriceIxIndex = this.findSetComputeUnitPriceIndex();
221
- if (setComputeUnitLimitIxIndex !== -1)
222
- this._instructions.splice(setComputeUnitLimitIxIndex, 1);
223
- if (setComputeUnitPriceIxIndex !== -1)
224
- this._instructions.splice(setComputeUnitPriceIxIndex, 1);
225
- if (setComputeUnitLimitIxIndex && setComputeUnitPriceIxIndex)
226
- break;
227
- }
228
- }
229
- }
230
- exports.Transaction = Transaction;
@@ -1,129 +0,0 @@
1
- import * as web3 from "@solana/web3.js";
2
- import * as client from "@hawksightco/swagger-client";
3
- import { ResponseWithStatus, TransactionMetadata, TransactionMetadataResponse, TransactionPriority } from "../types";
4
- import { Client } from "./Client";
5
- /**
6
- * The `TxGenerator` class encapsulates methods to generate transactions with various trading operations
7
- * on decentralized market making platforms like Meteora and Orca within the Solana ecosystem. It allows
8
- * setting custom transaction priority and fees to manage transaction processing speed and cost.
9
- */
10
- export declare class TxGenerator {
11
- private readonly client;
12
- /**
13
- * The current priority level of transactions generated by this instance.
14
- */
15
- protected priorityLevel: TransactionPriority;
16
- /**
17
- * The maximum priority fee in lamports that can be added to transactions for faster processing.
18
- */
19
- protected maxPriorityFee: number;
20
- /**
21
- * Initializes a new instance of the TxGenerator class with a specified client.
22
- *
23
- * @param client An instance of Client used to interact with various APIs for transaction generation.
24
- */
25
- constructor(client: Client);
26
- /**
27
- * Sets the priority level of the transaction.
28
- *
29
- * @param priorityLevel The desired transaction priority level.
30
- */
31
- setPriorityLevel(priorityLevel: TransactionPriority): void;
32
- /**
33
- * Sets the maximum priority fee for the transaction.
34
- *
35
- * @param maxPriorityFee The maximum priority fee in lamports.
36
- */
37
- setMaxPriorityFee(maxPriorityFee: number): void;
38
- /**
39
- * Creates meteora instruction that creates new position and deposit.
40
- *
41
- * @param connection The Solana web3 connection object for blockchain interactions.
42
- * @param payer The public key of the payer for transaction fees.
43
- * @param params Parameters required
44
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
45
- */
46
- meteoraCreatePositionAndDeposit(connection: web3.Connection, payer: string, params: client.TxCreatePositionAndDepositBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
47
- /**
48
- * Creates meteora instruction that deposits to position.
49
- *
50
- * @param connection The Solana web3 connection object for blockchain interactions.
51
- * @param payer The public key of the payer for transaction fees.
52
- * @param params Parameters required
53
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
54
- */
55
- meteoraDeposit(connection: web3.Connection, payer: string, params: client.TxDepositBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
56
- /**
57
- * Creates meteora instruction withdraws from a position.
58
- *
59
- * @param connection The Solana web3 connection object for blockchain interactions.
60
- * @param payer The public key of the payer for transaction fees.
61
- * @param params Parameters required
62
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
63
- */
64
- meteoraWithdraw(connection: web3.Connection, payer: string, params: client.TxWithdrawBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
65
- /**
66
- * Creates meteora instruction that claims fees and rewards.
67
- *
68
- * @param connection The Solana web3 connection object for blockchain interactions.
69
- * @param payer The public key of the payer for transaction fees.
70
- * @param params Parameters required
71
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
72
- */
73
- meteoraClaim(connection: web3.Connection, payer: string, params: client.TxClaimBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
74
- /**
75
- * Creates meteora instruction that closes position.
76
- *
77
- * @param connection The Solana web3 connection object for blockchain interactions.
78
- * @param payer The public key of the payer for transaction fees.
79
- * @param params Parameters required
80
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
81
- */
82
- meteoraClosePosition(connection: web3.Connection, payer: string, params: client.TxClosePositionBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
83
- /**
84
- * Creates orca instruction that opens new position
85
- *
86
- * @param connection The Solana web3 connection object for blockchain interactions.
87
- * @param payer The public key of the payer for transaction fees.
88
- * @param params Parameters required
89
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
90
- */
91
- orcaOpenPosition(connection: web3.Connection, payer: string, params: client.TxOpenPositionBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
92
- /**
93
- * Creates orca instruction that closes position
94
- *
95
- * @param connection The Solana web3 connection object for blockchain interactions.
96
- * @param payer The public key of the payer for transaction fees.
97
- * @param params Parameters required
98
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
99
- */
100
- orcaClosePosition(connection: web3.Connection, payer: string, params: client.TxClosePositionBody1): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
101
- /**
102
- * Creates orca instruction that deposits to a position
103
- *
104
- * @param connection The Solana web3 connection object for blockchain interactions.
105
- * @param payer The public key of the payer for transaction fees.
106
- * @param params Parameters required
107
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
108
- */
109
- orcaDeposit(connection: web3.Connection, payer: string, params: client.TxDepositBody1): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
110
- /**
111
- * Creates orca instruction that withdraws from a position
112
- *
113
- * @param connection The Solana web3 connection object for blockchain interactions.
114
- * @param payer The public key of the payer for transaction fees.
115
- * @param params Parameters required
116
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
117
- */
118
- orcaWithdraw(connection: web3.Connection, payer: string, params: client.TxWithdrawBody1): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
119
- /**
120
- * Creates orca instruction that claims fees and rewards
121
- *
122
- * @param connection The Solana web3 connection object for blockchain interactions.
123
- * @param payer The public key of the payer for transaction fees.
124
- * @param params Parameters required
125
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
126
- */
127
- orcaClaimRewards(connection: web3.Connection, payer: string, params: client.TxClaimRewardsBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
128
- }
129
- //# sourceMappingURL=TxGenerator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TxGenerator.d.ts","sourceRoot":"","sources":["../../../src/classes/TxGenerator.ts"],"names":[],"mappings":"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"}
@@ -1,217 +0,0 @@
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.TxGenerator = void 0;
13
- const functions_1 = require("../functions");
14
- /**
15
- * The `TxGenerator` class encapsulates methods to generate transactions with various trading operations
16
- * on decentralized market making platforms like Meteora and Orca within the Solana ecosystem. It allows
17
- * setting custom transaction priority and fees to manage transaction processing speed and cost.
18
- */
19
- class TxGenerator {
20
- /**
21
- * Initializes a new instance of the TxGenerator class with a specified client.
22
- *
23
- * @param client An instance of Client used to interact with various APIs for transaction generation.
24
- */
25
- constructor(client) {
26
- this.client = client;
27
- this.priorityLevel = "Default";
28
- this.maxPriorityFee = 500000; // Default max priority fee in lamports
29
- }
30
- /**
31
- * Sets the priority level of the transaction.
32
- *
33
- * @param priorityLevel The desired transaction priority level.
34
- */
35
- setPriorityLevel(priorityLevel) {
36
- this.priorityLevel = priorityLevel;
37
- }
38
- /**
39
- * Sets the maximum priority fee for the transaction.
40
- *
41
- * @param maxPriorityFee The maximum priority fee in lamports.
42
- */
43
- setMaxPriorityFee(maxPriorityFee) {
44
- this.maxPriorityFee = maxPriorityFee;
45
- }
46
- /**
47
- * Creates meteora instruction that creates new position and deposit.
48
- *
49
- * @param connection The Solana web3 connection object for blockchain interactions.
50
- * @param payer The public key of the payer for transaction fees.
51
- * @param params Parameters required
52
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
53
- */
54
- meteoraCreatePositionAndDeposit(connection, payer, params) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxCreatePositionAndDepositPost(params).catch(e => e.response);
57
- return (0, functions_1.resultOrError)({
58
- status: result.status,
59
- data: result.data,
60
- }, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
61
- });
62
- }
63
- /**
64
- * Creates meteora instruction that deposits to position.
65
- *
66
- * @param connection The Solana web3 connection object for blockchain interactions.
67
- * @param payer The public key of the payer for transaction fees.
68
- * @param params Parameters required
69
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
70
- */
71
- meteoraDeposit(connection, payer, params) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxDepositPost(params).catch(e => e.response);
74
- return (0, functions_1.resultOrError)({
75
- status: result.status,
76
- data: result.data,
77
- }, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
78
- });
79
- }
80
- /**
81
- * Creates meteora instruction withdraws from a position.
82
- *
83
- * @param connection The Solana web3 connection object for blockchain interactions.
84
- * @param payer The public key of the payer for transaction fees.
85
- * @param params Parameters required
86
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
87
- */
88
- meteoraWithdraw(connection, payer, params) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxWithdrawPost(params).catch(e => e.response);
91
- return (0, functions_1.resultOrError)({
92
- status: result.status,
93
- data: result.data,
94
- }, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
95
- });
96
- }
97
- /**
98
- * Creates meteora instruction that claims fees and rewards.
99
- *
100
- * @param connection The Solana web3 connection object for blockchain interactions.
101
- * @param payer The public key of the payer for transaction fees.
102
- * @param params Parameters required
103
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
104
- */
105
- meteoraClaim(connection, payer, params) {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxClaimPost(params).catch(e => e.response);
108
- return (0, functions_1.resultOrError)({
109
- status: result.status,
110
- data: result.data,
111
- }, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
112
- });
113
- }
114
- /**
115
- * Creates meteora instruction that closes position.
116
- *
117
- * @param connection The Solana web3 connection object for blockchain interactions.
118
- * @param payer The public key of the payer for transaction fees.
119
- * @param params Parameters required
120
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
121
- */
122
- meteoraClosePosition(connection, payer, params) {
123
- return __awaiter(this, void 0, void 0, function* () {
124
- const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxClosePositionPost(params).catch(e => e.response);
125
- return (0, functions_1.resultOrError)({
126
- status: result.status,
127
- data: result.data,
128
- }, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
129
- });
130
- }
131
- /**
132
- * Creates orca instruction that opens new position
133
- *
134
- * @param connection The Solana web3 connection object for blockchain interactions.
135
- * @param payer The public key of the payer for transaction fees.
136
- * @param params Parameters required
137
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
138
- */
139
- orcaOpenPosition(connection, payer, params) {
140
- return __awaiter(this, void 0, void 0, function* () {
141
- const result = yield this.client.orcaCLMMInstructionsApi.orcaTxOpenPositionPost(params).catch(e => e.response);
142
- return (0, functions_1.resultOrError)({
143
- status: result.status,
144
- data: result.data,
145
- }, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
146
- });
147
- }
148
- /**
149
- * Creates orca instruction that closes position
150
- *
151
- * @param connection The Solana web3 connection object for blockchain interactions.
152
- * @param payer The public key of the payer for transaction fees.
153
- * @param params Parameters required
154
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
155
- */
156
- orcaClosePosition(connection, payer, params) {
157
- return __awaiter(this, void 0, void 0, function* () {
158
- const result = yield this.client.orcaCLMMInstructionsApi.orcaTxClosePositionPost(params).catch(e => e.response);
159
- return (0, functions_1.resultOrError)({
160
- status: result.status,
161
- data: result.data,
162
- }, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
163
- });
164
- }
165
- /**
166
- * Creates orca instruction that deposits to a position
167
- *
168
- * @param connection The Solana web3 connection object for blockchain interactions.
169
- * @param payer The public key of the payer for transaction fees.
170
- * @param params Parameters required
171
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
172
- */
173
- orcaDeposit(connection, payer, params) {
174
- return __awaiter(this, void 0, void 0, function* () {
175
- const result = yield this.client.orcaCLMMInstructionsApi.orcaTxDepositPost(params).catch(e => e.response);
176
- return (0, functions_1.resultOrError)({
177
- status: result.status,
178
- data: result.data,
179
- }, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
180
- });
181
- }
182
- /**
183
- * Creates orca instruction that withdraws from a position
184
- *
185
- * @param connection The Solana web3 connection object for blockchain interactions.
186
- * @param payer The public key of the payer for transaction fees.
187
- * @param params Parameters required
188
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
189
- */
190
- orcaWithdraw(connection, payer, params) {
191
- return __awaiter(this, void 0, void 0, function* () {
192
- const result = yield this.client.orcaCLMMInstructionsApi.orcaTxWithdrawPost(params).catch(e => e.response);
193
- return (0, functions_1.resultOrError)({
194
- status: result.status,
195
- data: result.data,
196
- }, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
197
- });
198
- }
199
- /**
200
- * Creates orca instruction that claims fees and rewards
201
- *
202
- * @param connection The Solana web3 connection object for blockchain interactions.
203
- * @param payer The public key of the payer for transaction fees.
204
- * @param params Parameters required
205
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
206
- */
207
- orcaClaimRewards(connection, payer, params) {
208
- return __awaiter(this, void 0, void 0, function* () {
209
- const result = yield this.client.orcaCLMMInstructionsApi.orcaTxClaimRewardsPost(params).catch(e => e.response);
210
- return (0, functions_1.resultOrError)({
211
- status: result.status,
212
- data: result.data,
213
- }, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
214
- });
215
- }
216
- }
217
- exports.TxGenerator = TxGenerator;
@@ -1,68 +0,0 @@
1
- import * as web3 from "@solana/web3.js";
2
- import * as client from "@hawksightco/swagger-client";
3
- import { ResponseWithStatus, TransactionMetadata, TransactionMetadataResponse, TransactionPriority } from "../types";
4
- import { Client } from "./Client";
5
- /**
6
- * The `TxGeneratorAutomations` class encapsulates methods to generate transactions with various trading operations
7
- * on decentralized market making platforms like Meteora and Orca within the Solana ecosystem. It allows
8
- * setting custom transaction priority and fees to manage transaction processing speed and cost.
9
- *
10
- * NOTE: For hawksight devs only.
11
- */
12
- export declare class TxGeneratorAutomations {
13
- private readonly client;
14
- /**
15
- * The current priority level of transactions generated by this instance.
16
- */
17
- protected priorityLevel: TransactionPriority;
18
- /**
19
- * The maximum priority fee in lamports that can be added to transactions for faster processing.
20
- */
21
- protected maxPriorityFee: number;
22
- /**
23
- * Initializes a new instance of the TxGenerator class with a specified client.
24
- *
25
- * @param client An instance of Client used to interact with various APIs for transaction generation.
26
- */
27
- constructor(client: Client);
28
- /**
29
- * Creates meteora automation instruction that claims fee and rewards
30
- *
31
- * NOTE: For hawksight devs only.
32
- *
33
- * Autocompound IX
34
- *
35
- * @param connection The Solana web3 connection object for blockchain interactions.
36
- * @param payer The public key of the payer for transaction fees.
37
- * @param params Parameters required
38
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
39
- */
40
- meteoraClaimFeeAndRewards(connection: web3.Connection, payer: string, params: client.AutomationClaimFeeAndRewardsAutomationIxBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
41
- /**
42
- * Creates meteora automation instruction fully withdraws position and closes it
43
- *
44
- * NOTE: For hawksight devs only.
45
- *
46
- * Rebalance IX Part 1
47
- *
48
- * @param connection The Solana web3 connection object for blockchain interactions.
49
- * @param payer The public key of the payer for transaction fees.
50
- * @param params Parameters required
51
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
52
- */
53
- meteoraFullWithdrawalAndClosePosition(connection: web3.Connection, payer: string, params: client.AutomationFullWithdrawAndClosePositionAutomationIxBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
54
- /**
55
- * Creates meteora automation instruction that creates new position and deposit to that position
56
- *
57
- * NOTE: For hawksight devs only.
58
- *
59
- * Rebalance IX Part 2
60
- *
61
- * @param connection The Solana web3 connection object for blockchain interactions.
62
- * @param payer The public key of the payer for transaction fees.
63
- * @param params Parameters required
64
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
65
- */
66
- meteoraCreatePositionAndDeposit(connection: web3.Connection, payer: string, params: client.AutomationCreatePositionAndDepositAutomationIxBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
67
- }
68
- //# sourceMappingURL=TxGeneratorAutomations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TxGeneratorAutomations.d.ts","sourceRoot":"","sources":["../../../src/classes/TxGeneratorAutomations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACrH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC;;;;;;GAMG;AACH,qBAAa,sBAAsB;IAkB/B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAhBzB;;OAEG;IACH,SAAS,CAAC,aAAa,EAAE,mBAAmB,CAAC;IAE7C;;OAEG;IACH,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IAEjC;;;;OAIG;gBAEgB,MAAM,EAAE,MAAM;IAMjC;;;;;;;;;;;OAWG;IACG,yBAAyB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,4CAA4C,GAAG,OAAO,CAAC,kBAAkB,CAAC,2BAA2B,CAAC,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAW5O;;;;;;;;;;;OAWG;IACG,qCAAqC,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,sDAAsD,GAAG,OAAO,CAAC,kBAAkB,CAAC,2BAA2B,CAAC,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAWlQ;;;;;;;;;;;OAWG;IACG,+BAA+B,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,kDAAkD,GAAG,OAAO,CAAC,kBAAkB,CAAC,2BAA2B,CAAC,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CAUzP"}