@hawksightco/hawk-sdk 0.0.47 → 0.0.51

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.
@@ -46,9 +46,12 @@ export declare class General {
46
46
  /**
47
47
  * Fetches a list of pools managed by the platform, providing details about each pool.
48
48
  *
49
+ * @param params Object containing hash of the pools
49
50
  * @returns A Promise resolving to an array of pools, including metadata such as pool addresses and statistics.
50
51
  */
51
- pools(): Promise<ResponseWithStatus<_client.HawksightPool[]>>;
52
+ pools(params: {
53
+ hash?: string;
54
+ }): Promise<ResponseWithStatus<_client.HawksightPool[]>>;
52
55
  /**
53
56
  * Retrieves information about the available tokens on the platform.
54
57
  *
@@ -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,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAoD,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACvI,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;GAKG;AACH,qBAAa,OAAO;IAahB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAZjC,4GAA4G;IAC5G,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;IAE/C,sGAAsG;IACtG,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IAEjC;;;OAGG;gBAEgB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc;IAOjD;;;;OAIG;IACH,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,aAAa;IAIrD;;;;OAIG;IACH,iBAAiB,CAAC,cAAc,EAAE,MAAM;IAIxC;;;;;OAKG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CAAC,aAAa;IAIrD;;;;OAIG;IACH,iBAAiB,CAAC,cAAc,EAAE,MAAM;IAIxC;;;;;OAKG;IACG,SAAS,CACb,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GACA,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IAQhD;;;;;OAKG;IACG,KAAK,CACT,MAAM,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GACA,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAQvD;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAQxE;;;;;;;OAOG;IACG,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CAU3I"}
@@ -87,11 +87,12 @@ class General {
87
87
  /**
88
88
  * Fetches a list of pools managed by the platform, providing details about each pool.
89
89
  *
90
+ * @param params Object containing hash of the pools
90
91
  * @returns A Promise resolving to an array of pools, including metadata such as pool addresses and statistics.
91
92
  */
92
- pools() {
93
+ pools(params) {
93
94
  return __awaiter(this, void 0, void 0, function* () {
94
- const result = yield this.client.generalEndpoints.poolsGet().catch(e => e.response);
95
+ const result = yield this.client.generalEndpoints.poolsGet(params.hash).catch(e => e.response);
95
96
  return {
96
97
  status: result.status,
97
98
  data: result.data,
@@ -1,4 +1,4 @@
1
- import { PriorityFeeEstimate, UtilGetPriorityFeeEstimateBody } from "@hawksightco/swagger-client";
1
+ import { PriorityFeeEstimate, UtilGetPriorityFeeEstimateBody, UtilFindAltWithTxBody } from "@hawksightco/swagger-client";
2
2
  import { ResponseWithStatus } from "../types";
3
3
  import { Client } from "./Client";
4
4
  /**
@@ -30,5 +30,16 @@ export declare class GeneralUtility {
30
30
  * @throws Captures and returns any errors encountered during the API call.
31
31
  */
32
32
  getPriorityFeeEstimate(params: UtilGetPriorityFeeEstimateBody): Promise<ResponseWithStatus<PriorityFeeEstimate>>;
33
+ /**
34
+ * Finds alternative public keys related to a given transaction and returns them along with the response status.
35
+ *
36
+ * This method sends a request to the `utilFindAltWithTxPost` endpoint with the provided parameters, and returns the response
37
+ * status and an array of public key strings. In case of an error, it captures the error response and includes the status and
38
+ * data in the returned object.
39
+ *
40
+ * @param {UtilFindAltWithTxBody} params - The parameters for the function, which include the transaction metadata.
41
+ * @returns {Promise<ResponseWithStatus<Array<string>>>>} A promise that resolves to an object containing the response status and an array of public key strings.
42
+ */
43
+ findAltWithTxPost(params: UtilFindAltWithTxBody): Promise<ResponseWithStatus<Array<string>>>;
33
44
  }
34
45
  //# sourceMappingURL=GeneralUtility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GeneralUtility.d.ts","sourceRoot":"","sources":["../../../src/classes/GeneralUtility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;GAMG;AACH,qBAAa,cAAc;IAQvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB;;;;OAIG;gBAEgB,MAAM,EAAE,MAAM;IAGjC;;;;;;;;;;;;OAYG;IACG,sBAAsB,CAAC,MAAM,EAAE,8BAA8B,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CAOvH"}
1
+ {"version":3,"file":"GeneralUtility.d.ts","sourceRoot":"","sources":["../../../src/classes/GeneralUtility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzH,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;GAMG;AACH,qBAAa,cAAc;IAQvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB;;;;OAIG;gBAEgB,MAAM,EAAE,MAAM;IAGjC;;;;;;;;;;;;OAYG;IACG,sBAAsB,CAAC,MAAM,EAAE,8BAA8B,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAQtH;;;;;;;;;OASG;IACG,iBAAiB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CAOnG"}
@@ -48,5 +48,24 @@ class GeneralUtility {
48
48
  };
49
49
  });
50
50
  }
51
+ /**
52
+ * Finds alternative public keys related to a given transaction and returns them along with the response status.
53
+ *
54
+ * This method sends a request to the `utilFindAltWithTxPost` endpoint with the provided parameters, and returns the response
55
+ * status and an array of public key strings. In case of an error, it captures the error response and includes the status and
56
+ * data in the returned object.
57
+ *
58
+ * @param {UtilFindAltWithTxBody} params - The parameters for the function, which include the transaction metadata.
59
+ * @returns {Promise<ResponseWithStatus<Array<string>>>>} A promise that resolves to an object containing the response status and an array of public key strings.
60
+ */
61
+ findAltWithTxPost(params) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const result = yield this.client.generalUtility.utilFindAltWithTxPost(params).catch(e => e.response);
64
+ return {
65
+ status: result.status,
66
+ data: result.data,
67
+ };
68
+ });
69
+ }
51
70
  }
52
71
  exports.GeneralUtility = GeneralUtility;
@@ -3,6 +3,7 @@ import { Health } from "./Health";
3
3
  import { TxGenerator } from "./TxGenerator";
4
4
  import { Util } from "./Util";
5
5
  import { TxGeneratorAutomations } from "./TxGeneratorAutomations";
6
+ import { Client } from "./Client";
6
7
  import { GeneralUtility } from "./GeneralUtility";
7
8
  import { Search } from "./Search";
8
9
  /**
@@ -16,6 +17,8 @@ import { Search } from "./Search";
16
17
  */
17
18
  export declare class HawkAPI {
18
19
  protected readonly url: string;
20
+ /** Swagger Client Instance. */
21
+ private readonly client;
19
22
  /** Health module to check system health and API connectivity. */
20
23
  readonly health: Health;
21
24
  /** General module for basic blockchain operations like portfolio management, token information retrieval. */
@@ -25,7 +28,8 @@ export declare class HawkAPI {
25
28
  /** Util module for various utility functions that assist with blockchain interactions. */
26
29
  readonly util: Util;
27
30
  /** TxGenerator module for creating and managing transactions on the blockchain. */
28
- readonly txGenerator: TxGenerator;
31
+ private _txGenerator;
32
+ get txGenerator(): TxGenerator;
29
33
  /** TxGeneratorAutomations module for automating and optimizing transaction creation processes. */
30
34
  readonly txGeneratorAutomation: TxGeneratorAutomations;
31
35
  /** Search module (token search only for now...) */
@@ -35,5 +39,11 @@ export declare class HawkAPI {
35
39
  * @param url The base URL for the HawkSight API services, defaulted to "https://api2.hawksight.co" if not specified.
36
40
  */
37
41
  constructor(url?: string);
42
+ /**
43
+ * Override transaction generator
44
+ *
45
+ * @param txGenerator
46
+ */
47
+ overrideTxGenerator(builderFn: (client: Client, generalUtility: GeneralUtility) => TxGenerator): void;
38
48
  }
39
49
  //# sourceMappingURL=HawkAPI.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HawkAPI.d.ts","sourceRoot":"","sources":["../../../src/classes/HawkAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MA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AA6G;IAC7G,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC,+BAA+B;IAC/B,SAAgB,cAAc,EAAE,cAAc,CAAC;IAE/C,0FAA0F;IAC1F,SAAgB,IAAI,EAAE,IAAI,CAAC;IAE3B,mFAAmF;IACnF,OAAO,CAAC,YAAY,CAAc;IAClC,IAAI,WAAW,gBAAgC;IAE/C,kGAAkG;IAClG,SAAgB,qBAAqB,EAAE,sBAAsB,CAAC;IAE9D,mDAAmD;IACnD,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B;;;OAGG;gBAEkB,GAAG,GAAE,MAAoC;IAe9D;;;;OAIG;IACH,mBAAmB,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,KAAK,WAAW;CAG/F"}
@@ -19,6 +19,7 @@ const Search_1 = require("./Search");
19
19
  * making it easier to manage and use HawkSight's comprehensive blockchain features.
20
20
  */
21
21
  class HawkAPI {
22
+ get txGenerator() { return this._txGenerator; }
22
23
  /**
23
24
  * Initializes a new instance of the HawkAPI class with a specified API URL.
24
25
  * @param url The base URL for the HawkSight API services, defaulted to "https://api2.hawksight.co" if not specified.
@@ -26,15 +27,24 @@ class HawkAPI {
26
27
  constructor(url = "https://api2.hawksight.co") {
27
28
  this.url = url;
28
29
  const client = new Client_1.Client(url);
30
+ this.client = client;
29
31
  this.health = new Health_1.Health(client);
30
32
  this.generalUtility = new GeneralUtility_1.GeneralUtility(client);
31
33
  this.general = new General_1.General(client, this.generalUtility);
32
34
  this.util = new Util_1.Util(client);
33
- this.txGenerator = new TxGenerator_1.TxGenerator(client, this.generalUtility);
35
+ this._txGenerator = new TxGenerator_1.TxGenerator(client, this.generalUtility);
34
36
  this.txGeneratorAutomation = new TxGeneratorAutomations_1.TxGeneratorAutomations(client, this.generalUtility);
35
37
  this.search = new Search_1.Search(url);
36
38
  // Load search module
37
39
  this.search.load();
38
40
  }
41
+ /**
42
+ * Override transaction generator
43
+ *
44
+ * @param txGenerator
45
+ */
46
+ overrideTxGenerator(builderFn) {
47
+ this._txGenerator = builderFn(this.client, this.generalUtility);
48
+ }
39
49
  }
40
50
  exports.HawkAPI = HawkAPI;
@@ -1,9 +1,32 @@
1
- import { Token } from "../types";
1
+ import { SearchIndices, Token } from "../types";
2
+ export interface SearchTokenStore {
3
+ tokenIndices: SearchIndices;
4
+ tokens: Token[];
5
+ }
6
+ export type LoadFromPersistenceFn = () => Promise<[SearchIndices | undefined, Token[] | undefined]>;
7
+ export type StoreToPersistenceFn = (tokenIndices: SearchIndices, tokens: Token[]) => Promise<void>;
2
8
  export declare class Search {
3
9
  protected readonly url: string;
4
10
  private tokenIndices?;
5
11
  private tokens?;
6
12
  private _loaded;
13
+ private _loadedFromPersistence;
14
+ private previousHash;
15
+ private latestHash;
16
+ private loadFromPersistenceFn?;
17
+ private storeToPersistenceFn?;
18
+ /**
19
+ * Set load persistence callback
20
+ *
21
+ * @param loadFromPersistenceFn
22
+ */
23
+ setLoadFromPersistenceFn(loadFromPersistenceFn: LoadFromPersistenceFn): void;
24
+ /**
25
+ * Set store to persistence callback
26
+ *
27
+ * @param storeToPersistenceFn
28
+ */
29
+ setStoreToPersistenceFn(storeToPersistenceFn: StoreToPersistenceFn): void;
7
30
  /**
8
31
  * Checks if the token indices and tokens have been loaded.
9
32
  *
@@ -37,6 +60,14 @@ export declare class Search {
37
60
  * @returns {Promise<void>} A promise that resolves when the initial load is complete.
38
61
  */
39
62
  load(): Promise<void>;
63
+ /**
64
+ * Load tokens and indices from persistence
65
+ *
66
+ * @param tokenIndices
67
+ * @param tokens
68
+ * @returns
69
+ */
70
+ private loadFromPersistence;
40
71
  /**
41
72
  * Retrieves and updates the token indices and tokens if necessary.
42
73
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Search.d.ts","sourceRoot":"","sources":["../../../src/classes/Search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAGhD,qBAAa,MAAM;IA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AAsB,CAAS;IACvC,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,UAAU,CAAc;IAEhC,OAAO,CAAC,qBAAqB,CAAC,CAAwB;IACtD,OAAO,CAAC,oBAAoB,CAAC,CAAuB;IAEpD;;;;OAIG;IACH,wBAAwB,CAAC,qBAAqB,EAAE,qBAAqB;IAIrE;;;;OAIG;IACH,uBAAuB,CAAC,oBAAoB,EAAE,oBAAoB;IAIlE;;;;OAIG;IACH,IAAI,MAAM,IAAI,OAAO,CAAwB;IAE7C;;;;OAIG;gBAEkB,GAAG,EAAE,MAAM;IAGhC;;;;;;;;;;OAUG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,MAAY,EAAE,OAAO,GAAE,OAAe,GAAG,KAAK,EAAE;IAiB9E;;;;;;;OAOG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA2B3B;;;;;;OAMG;YACW,mBAAmB;IAWjC;;;;;;;;;;OAUG;YACW,eAAe;IAmB7B;;;;;;;OAOG;YACW,YAAY;IAI1B;;;;;;;;;;OAUG;YACW,gBAAgB;CAO/B"}
@@ -14,7 +14,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Search = void 0;
16
16
  const axios_1 = __importDefault(require("axios"));
17
+ ;
17
18
  class Search {
19
+ /**
20
+ * Set load persistence callback
21
+ *
22
+ * @param loadFromPersistenceFn
23
+ */
24
+ setLoadFromPersistenceFn(loadFromPersistenceFn) {
25
+ this.loadFromPersistenceFn = loadFromPersistenceFn;
26
+ }
27
+ /**
28
+ * Set store to persistence callback
29
+ *
30
+ * @param storeToPersistenceFn
31
+ */
32
+ setStoreToPersistenceFn(storeToPersistenceFn) {
33
+ this.storeToPersistenceFn = storeToPersistenceFn;
34
+ }
18
35
  /**
19
36
  * Checks if the token indices and tokens have been loaded.
20
37
  *
@@ -29,6 +46,9 @@ class Search {
29
46
  constructor(url) {
30
47
  this.url = url;
31
48
  this._loaded = false;
49
+ this._loadedFromPersistence = false;
50
+ this.previousHash = '';
51
+ this.latestHash = '';
32
52
  }
33
53
  /**
34
54
  * Retrieves tokens that match the given keyword.
@@ -70,14 +90,52 @@ class Search {
70
90
  return __awaiter(this, void 0, void 0, function* () {
71
91
  if (!this.loaded) {
72
92
  this._loaded = true;
93
+ let firstRun = true;
73
94
  const update = () => __awaiter(this, void 0, void 0, function* () {
74
95
  yield this.getTokenIndices();
75
- setTimeout(update, 5 * 1000);
96
+ setTimeout(update, 60 * 1000);
97
+ });
98
+ const updateFromPersistence = () => __awaiter(this, void 0, void 0, function* () {
99
+ yield this.loadFromPersistence();
100
+ if (firstRun && this.loadFromPersistenceFn !== undefined) {
101
+ yield update();
102
+ firstRun = false;
103
+ }
104
+ if (!!this.tokens && !!this.tokenIndices) {
105
+ if (!!this.storeToPersistenceFn && this.tokens.length > 0 && this.previousHash !== this.latestHash) {
106
+ yield this.storeToPersistenceFn(this.tokenIndices, this.tokens);
107
+ }
108
+ setTimeout(updateFromPersistence, 60 * 1000);
109
+ return;
110
+ }
111
+ setTimeout(updateFromPersistence, 1 * 1000);
76
112
  });
77
- yield update();
113
+ yield updateFromPersistence();
78
114
  }
79
115
  });
80
116
  }
117
+ /**
118
+ * Load tokens and indices from persistence
119
+ *
120
+ * @param tokenIndices
121
+ * @param tokens
122
+ * @returns
123
+ */
124
+ loadFromPersistence() {
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ if (this._loadedFromPersistence)
127
+ return;
128
+ if (this.loadFromPersistenceFn === undefined)
129
+ return;
130
+ const [tokenIndices, tokens] = yield this.loadFromPersistenceFn();
131
+ if (tokenIndices === undefined || tokens === undefined)
132
+ return;
133
+ this.tokenIndices = tokenIndices;
134
+ this.tokens = tokens;
135
+ this.latestHash = tokenIndices.hash;
136
+ this._loadedFromPersistence = true;
137
+ });
138
+ }
81
139
  /**
82
140
  * Retrieves and updates the token indices and tokens if necessary.
83
141
  *
@@ -91,16 +149,19 @@ class Search {
91
149
  */
92
150
  getTokenIndices() {
93
151
  return __awaiter(this, void 0, void 0, function* () {
94
- if (this.tokenIndices === undefined) {
152
+ if (this.tokenIndices === undefined || this.latestHash === '') {
95
153
  this.tokenIndices = yield this.getSearchIndices('tokens');
96
- }
97
- if (this.tokens === undefined) {
98
154
  this.tokens = yield this.getAllTokens();
155
+ this.previousHash = '';
156
+ this.latestHash = this.tokenIndices.hash;
157
+ return;
99
158
  }
100
159
  const tokenIndices = yield this.getSearchIndices('tokens', this.tokenIndices.hash);
160
+ this.previousHash = this.tokenIndices.hash;
161
+ this.latestHash = tokenIndices.hash;
101
162
  // If hash doesn't match, it means there's a new token.
102
163
  if (tokenIndices.hash !== this.tokenIndices.hash) {
103
- this.tokenIndices = yield this.getSearchIndices('tokens');
164
+ this.tokenIndices = tokenIndices;
104
165
  this.tokens = yield this.getAllTokens();
105
166
  }
106
167
  });
@@ -39,15 +39,15 @@ export declare class TxGeneratorAutomations {
39
39
  */
40
40
  meteoraCompoundIxs(connection: web3.Connection, payer: string, params: _client.AutomationCompoundAutomationIxBody): Promise<ResponseWithStatus<TransactionMetadata>>;
41
41
  /**
42
- * Creates meteora auto-rebalance instruction
43
- *
44
- * NOTE: For hawksight devs only.
45
- *
46
- * @param connection The Solana web3 connection object for blockchain interactions.
47
- * @param payer The public key of the payer for transaction fees.
48
- * @param params Parameters required
49
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
50
- */
42
+ * Creates meteora auto-rebalance instruction
43
+ *
44
+ * NOTE: For hawksight devs only.
45
+ *
46
+ * @param connection The Solana web3 connection object for blockchain interactions.
47
+ * @param payer The public key of the payer for transaction fees.
48
+ * @param params Parameters required
49
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
50
+ */
51
51
  meteoraRebalanceIxs(connection: web3.Connection, payer: string, params: _client.AutomationRebalanceAutomationIxBody): Promise<ResponseWithStatus<TransactionMetadata>>;
52
52
  }
53
53
  //# sourceMappingURL=TxGeneratorAutomations.d.ts.map
@@ -1 +1 @@
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,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAoD,MAAM,UAAU,CAAC;AACrH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;GAMG;AACH,qBAAa,sBAAsB;IAkB/B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAjBjC;;OAEG;IACH,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;IAE/C;;OAEG;IACH,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IAEjC;;;;OAIG;gBAEgB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc;IAMjD;;;;;;;;;OASG;IACG,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,kCAAkC,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAWxK;;;;;;;;;KASC;IACK,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,mCAAmC,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CAU/K"}
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,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAoD,MAAM,UAAU,CAAC;AACrH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;GAMG;AACH,qBAAa,sBAAsB;IAkB/B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAjBjC;;OAEG;IACH,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;IAE/C;;OAEG;IACH,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IAEjC;;;;OAIG;gBAEgB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc;IAMjD;;;;;;;;;OASG;IACG,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,kCAAkC,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAW1K;;;;;;;;;OASG;IACK,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,mCAAmC,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CAU/K"}
@@ -74,15 +74,15 @@ class TxGeneratorAutomations {
74
74
  });
75
75
  }
76
76
  /**
77
- * Creates meteora auto-rebalance instruction
78
- *
79
- * NOTE: For hawksight devs only.
80
- *
81
- * @param connection The Solana web3 connection object for blockchain interactions.
82
- * @param payer The public key of the payer for transaction fees.
83
- * @param params Parameters required
84
- * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
85
- */
77
+ * Creates meteora auto-rebalance instruction
78
+ *
79
+ * NOTE: For hawksight devs only.
80
+ *
81
+ * @param connection The Solana web3 connection object for blockchain interactions.
82
+ * @param payer The public key of the payer for transaction fees.
83
+ * @param params Parameters required
84
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
85
+ */
86
86
  meteoraRebalanceIxs(connection, payer, params) {
87
87
  return __awaiter(this, void 0, void 0, function* () {
88
88
  const result = yield this.client.meteoraDLMMAutomationInstructionsApi.meteoraDlmmAutomationRebalanceAutomationIxPost(params).catch(e => e.response);
@@ -1 +1 @@
1
- {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,2BAA2B,EAAuB,MAAM,SAAS,CAAC;AAGpH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,gBAAgB,CACpC,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,2BAA2B,EACjC,aAAa,EAAE,MAAM,CAAC,aAAa,EACnC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,mBAAmB,CAAC,CA0C9B;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,GAAG,EAC/C,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,EAC1C,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,GAAG,CAAC,GAC1C,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAYlC;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM,CAAC,aAAa,EAC9B,WAAW,EAAE,2BAA2B,GACvC,OAAO,CAAC,MAAM,CAAC,CAwBjB"}
1
+ {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,2BAA2B,EAAuB,MAAM,SAAS,CAAC;AAGpH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,gBAAgB,CACpC,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,2BAA2B,EACjC,aAAa,EAAE,MAAM,CAAC,aAAa,EACnC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,mBAAmB,CAAC,CA0D9B;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,GAAG,EAC/C,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,EAC1C,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,GAAG,CAAC,GAC1C,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAYlC;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM,CAAC,aAAa,EAC9B,WAAW,EAAE,2BAA2B,GACvC,OAAO,CAAC,MAAM,CAAC,CAwBjB"}
@@ -57,9 +57,21 @@ function createTxMetadata(generalUtility, connection, payer, data, priorityLevel
57
57
  return __awaiter(this, void 0, void 0, function* () {
58
58
  // Retrieve address lookup table accounts
59
59
  const alts = [];
60
+ // Find jup alts
61
+ const jupAlts = yield generalUtility.findAltWithTxPost({
62
+ transaction: data,
63
+ });
60
64
  for (const alt of data.addressLookupTableAddresses) {
61
65
  alts.push((yield connection.getAddressLookupTable(new web3.PublicKey(alt))).value);
62
66
  }
67
+ if (jupAlts.status === 200) {
68
+ for (const alt of jupAlts.data) {
69
+ alts.push((yield connection.getAddressLookupTable(new web3.PublicKey(alt))).value);
70
+ }
71
+ }
72
+ else {
73
+ console.error(jupAlts.data);
74
+ }
63
75
  // Get the recent blockhash
64
76
  const latestBlockhash = yield connection.getLatestBlockhash();
65
77
  // Create initial transaction instance
@@ -1,3 +1,4 @@
1
1
  export * from "./types";
2
2
  export { HawkAPI } from "./classes/HawkAPI";
3
+ export { TxGenerator } from "./classes/TxGenerator";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
package/dist/src/index.js CHANGED
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.HawkAPI = void 0;
17
+ exports.TxGenerator = exports.HawkAPI = void 0;
18
18
  __exportStar(require("./types"), exports);
19
19
  var HawkAPI_1 = require("./classes/HawkAPI");
20
20
  Object.defineProperty(exports, "HawkAPI", { enumerable: true, get: function () { return HawkAPI_1.HawkAPI; } });
21
+ var TxGenerator_1 = require("./classes/TxGenerator");
22
+ Object.defineProperty(exports, "TxGenerator", { enumerable: true, get: function () { return TxGenerator_1.TxGenerator; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hawksightco/hawk-sdk",
3
- "version": "0.0.47",
3
+ "version": "0.0.51",
4
4
  "description": "Hawksight v2 SDK",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": "https://github.com/ghabxph/hawk-api-client.git",
@@ -20,7 +20,7 @@
20
20
  "typescript": "^5.4.5"
21
21
  },
22
22
  "dependencies": {
23
- "@hawksightco/swagger-client": "0.0.18",
23
+ "@hawksightco/swagger-client": "0.0.22",
24
24
  "@solana/web3.js": "^1.89.1",
25
25
  "bn.js": "^5.2.1"
26
26
  },