@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
|
@@ -69,6 +69,18 @@ class General {
|
|
|
69
69
|
setMaxPriorityFee(maxPriorityFee) {
|
|
70
70
|
this.maxPriorityFee = maxPriorityFee;
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* @returns Returns a token supported by Hawksight
|
|
74
|
+
*/
|
|
75
|
+
token(params) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const result = yield this.client.generalEndpoints.tokenGet(params.address).catch(e => e.response);
|
|
78
|
+
return {
|
|
79
|
+
status: result.status,
|
|
80
|
+
data: result.data,
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
72
84
|
/**
|
|
73
85
|
* Retrieves the portfolio information for a specified wallet and optionally a pool.
|
|
74
86
|
*
|
|
@@ -99,6 +111,26 @@ class General {
|
|
|
99
111
|
};
|
|
100
112
|
});
|
|
101
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Fetches a single pool either from Orca or Meteora.
|
|
116
|
+
*
|
|
117
|
+
* @param params Object containing hash of the pools
|
|
118
|
+
* @returns A Promise resolving to an array of pools, including metadata such as pool addresses and statistics.
|
|
119
|
+
*/
|
|
120
|
+
pool(params) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
if (["orca", "meteora"].includes(params.protocol)) {
|
|
123
|
+
const result = yield this.client.generalEndpoints.poolGet(params.pairAddress, params.protocol).catch(e => e.response);
|
|
124
|
+
return {
|
|
125
|
+
status: result.status,
|
|
126
|
+
data: result.data,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
throw new Error(`Protocol can only be: "orca" or "meteora". Value passed: ${params.protocol}`);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
102
134
|
/**
|
|
103
135
|
* Retrieves information about the available tokens on the platform.
|
|
104
136
|
*
|
|
@@ -7,6 +7,11 @@ import { Client } from "./Client";
|
|
|
7
7
|
import { GeneralUtility } from "./GeneralUtility";
|
|
8
8
|
import { Search } from "./Search";
|
|
9
9
|
import { HawkApiOptions } from "../types";
|
|
10
|
+
import { SimpleIxGenerator } from "./SimpleIxGenerator";
|
|
11
|
+
import { TransactionBatchExecute, TransactionBatchExecuteParams } from "./TransactionBatchExecute";
|
|
12
|
+
import { Atomicity } from "./Atomicity";
|
|
13
|
+
import { JupiterAlts } from "./JupiterAlts";
|
|
14
|
+
import { JupiterSwap } from "./JupiterSwap";
|
|
10
15
|
/**
|
|
11
16
|
* HawkAPI is a central gateway class that aggregates access to various functional modules
|
|
12
17
|
* for interacting with HawkSight's blockchain APIs. This class initializes and exposes modules
|
|
@@ -36,6 +41,12 @@ export declare class HawkAPI {
|
|
|
36
41
|
readonly txGeneratorAutomation: TxGeneratorAutomations;
|
|
37
42
|
/** Search module (token search only for now...) */
|
|
38
43
|
readonly search: Search;
|
|
44
|
+
/** Simple instruction generator */
|
|
45
|
+
readonly ix: SimpleIxGenerator;
|
|
46
|
+
/** Jupiter alts */
|
|
47
|
+
readonly jupAlts: JupiterAlts;
|
|
48
|
+
/** Jupiter swap */
|
|
49
|
+
readonly jupiterSwap: JupiterSwap;
|
|
39
50
|
/**
|
|
40
51
|
* Initializes a new instance of the HawkAPI class with a specified API URL.
|
|
41
52
|
* @param url The base URL for the HawkSight API services, defaulted to "https://api2.hawksight.co" if not specified.
|
|
@@ -47,5 +58,23 @@ export declare class HawkAPI {
|
|
|
47
58
|
* @param txGenerator
|
|
48
59
|
*/
|
|
49
60
|
overrideTxGenerator(builderFn: (client: Client, generalUtility: GeneralUtility) => TxGenerator): void;
|
|
61
|
+
/**
|
|
62
|
+
* Create instance of TransactionBatchExecute class
|
|
63
|
+
*
|
|
64
|
+
* @param param
|
|
65
|
+
*/
|
|
66
|
+
batchExecute({ lookupTableAddresses, instructions, payer, connection, signers }: TransactionBatchExecuteParams): TransactionBatchExecute;
|
|
67
|
+
/**
|
|
68
|
+
* Create instance of Atomicity class
|
|
69
|
+
*
|
|
70
|
+
* @param param
|
|
71
|
+
*/
|
|
72
|
+
atomicity({ lookupTableAddresses, instructions, payer, connection, signers }: TransactionBatchExecuteParams): Atomicity;
|
|
73
|
+
/**
|
|
74
|
+
* Whether enable logging or not
|
|
75
|
+
*
|
|
76
|
+
* @param flag
|
|
77
|
+
*/
|
|
78
|
+
logging(flag: boolean): void;
|
|
50
79
|
}
|
|
51
80
|
//# sourceMappingURL=HawkAPI.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HawkAPI.d.ts","sourceRoot":"","sources":["../../../src/classes/HawkAPI.ts"],"names":[],"mappings":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nF,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,mCAAmC;IACnC,SAAgB,EAAE,EAAE,iBAAiB,CAAC;IAEtC,mBAAmB;IACnB,SAAgB,OAAO,EAAE,WAAW,CAAC;IAErC,mBAAmB;IACnB,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC;;;OAGG;gBAEkB,GAAG,GAAE,MAAoC,EACzC,OAAO,CAAC,4BAAgB;IA2B7C;;;;OAIG;IACH,mBAAmB,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,KAAK,WAAW;IAI9F;;;;OAIG;IACH,YAAY,CAAC,EAAC,oBAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAC,EAAE,6BAA6B;IAW5G;;;;OAIG;IACH,SAAS,CAAC,EAAC,oBAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAC,EAAE,6BAA6B;IAYzG;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,OAAO;CAGtB"}
|
|
@@ -10,6 +10,13 @@ const Client_1 = require("./Client");
|
|
|
10
10
|
const GeneralUtility_1 = require("./GeneralUtility");
|
|
11
11
|
const Search_1 = require("./Search");
|
|
12
12
|
const CreateTxMetadata_1 = require("./CreateTxMetadata");
|
|
13
|
+
const SimpleIxGenerator_1 = require("./SimpleIxGenerator");
|
|
14
|
+
const TransactionBatchExecute_1 = require("./TransactionBatchExecute");
|
|
15
|
+
const Atomicity_1 = require("./Atomicity");
|
|
16
|
+
const JupiterAlts_1 = require("./JupiterAlts");
|
|
17
|
+
const JupiterSwap_1 = require("./JupiterSwap");
|
|
18
|
+
const Logging_1 = require("./Logging");
|
|
19
|
+
const Transactions_1 = require("./Transactions");
|
|
13
20
|
/**
|
|
14
21
|
* HawkAPI is a central gateway class that aggregates access to various functional modules
|
|
15
22
|
* for interacting with HawkSight's blockchain APIs. This class initializes and exposes modules
|
|
@@ -37,6 +44,10 @@ class HawkAPI {
|
|
|
37
44
|
this._txGenerator = new TxGenerator_1.TxGenerator(client, this.generalUtility);
|
|
38
45
|
this.txGeneratorAutomation = new TxGeneratorAutomations_1.TxGeneratorAutomations(client, this.generalUtility);
|
|
39
46
|
this.search = new Search_1.Search(url);
|
|
47
|
+
this.ix = new SimpleIxGenerator_1.SimpleIxGenerator();
|
|
48
|
+
this.jupAlts = new JupiterAlts_1.JupiterAlts();
|
|
49
|
+
this.jupiterSwap = new JupiterSwap_1.JupiterSwap(this.ix);
|
|
50
|
+
Transactions_1.txgen.ix = this.ix;
|
|
40
51
|
// Load create tx metadata module
|
|
41
52
|
if (this.options === undefined || !this.options.disableTxMetadataLoad) {
|
|
42
53
|
CreateTxMetadata_1.CreateTxMetadata.instance().load();
|
|
@@ -54,5 +65,29 @@ class HawkAPI {
|
|
|
54
65
|
overrideTxGenerator(builderFn) {
|
|
55
66
|
this._txGenerator = builderFn(this.client, this.generalUtility);
|
|
56
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Create instance of TransactionBatchExecute class
|
|
70
|
+
*
|
|
71
|
+
* @param param
|
|
72
|
+
*/
|
|
73
|
+
batchExecute({ lookupTableAddresses, instructions, payer, connection, signers }) {
|
|
74
|
+
return new TransactionBatchExecute_1.TransactionBatchExecute(lookupTableAddresses, instructions, payer, connection, signers, this.jupAlts);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create instance of Atomicity class
|
|
78
|
+
*
|
|
79
|
+
* @param param
|
|
80
|
+
*/
|
|
81
|
+
atomicity({ lookupTableAddresses, instructions, payer, connection, signers }) {
|
|
82
|
+
return new Atomicity_1.Atomicity(lookupTableAddresses, instructions, payer, connection, signers, this.jupAlts, this.ix);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Whether enable logging or not
|
|
86
|
+
*
|
|
87
|
+
* @param flag
|
|
88
|
+
*/
|
|
89
|
+
logging(flag) {
|
|
90
|
+
(0, Logging_1.logging)(flag);
|
|
91
|
+
}
|
|
57
92
|
}
|
|
58
93
|
exports.HawkAPI = HawkAPI;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
|
+
import * as web3 from "@solana/web3.js";
|
|
3
|
+
export type Alts = Record<string, string>;
|
|
4
|
+
export declare class JupiterAlts {
|
|
5
|
+
private username?;
|
|
6
|
+
private password?;
|
|
7
|
+
private hash?;
|
|
8
|
+
private url?;
|
|
9
|
+
private _alts;
|
|
10
|
+
/**
|
|
11
|
+
* Return jupiter alts object
|
|
12
|
+
*/
|
|
13
|
+
get alts(): Alts;
|
|
14
|
+
/**
|
|
15
|
+
* Set API URL
|
|
16
|
+
*/
|
|
17
|
+
setApiUrl(url: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Find address lookup table from given public keys
|
|
20
|
+
*
|
|
21
|
+
* @param pubkeys
|
|
22
|
+
*/
|
|
23
|
+
findAltByPubkeys(pubkeys: web3.PublicKey[]): web3.PublicKey[];
|
|
24
|
+
/**
|
|
25
|
+
* Set server credentials
|
|
26
|
+
*
|
|
27
|
+
* @param username
|
|
28
|
+
* @param password
|
|
29
|
+
*/
|
|
30
|
+
setCredentials(username: string, password: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Download jupiter alts from endpoint
|
|
33
|
+
*
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
downloadAlts(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=JupiterAlts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JupiterAlts.d.ts","sourceRoot":"","sources":["../../../src/classes/JupiterAlts.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1C,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,IAAI,CAAC,CAAS;IACtB,OAAO,CAAC,GAAG,CAAC,CAAS;IACrB,OAAO,CAAC,KAAK,CAAY;IAEzB;;OAEG;IACH,IAAI,IAAI,IAAI,IAAI,CAEf;IAED;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM;IAIrB;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE;IAW7D;;;;;OAKG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAKjD;;;;OAIG;IACG,YAAY;CAsBnB"}
|
|
@@ -0,0 +1,104 @@
|
|
|
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.JupiterAlts = void 0;
|
|
36
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
37
|
+
class JupiterAlts {
|
|
38
|
+
constructor() {
|
|
39
|
+
this._alts = {};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Return jupiter alts object
|
|
43
|
+
*/
|
|
44
|
+
get alts() {
|
|
45
|
+
return this._alts;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Set API URL
|
|
49
|
+
*/
|
|
50
|
+
setApiUrl(url) {
|
|
51
|
+
this.url = url;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Find address lookup table from given public keys
|
|
55
|
+
*
|
|
56
|
+
* @param pubkeys
|
|
57
|
+
*/
|
|
58
|
+
findAltByPubkeys(pubkeys) {
|
|
59
|
+
const alts = [];
|
|
60
|
+
for (const pubkey of pubkeys) {
|
|
61
|
+
const alt = this._alts[pubkey.toBase58()];
|
|
62
|
+
if (alt !== undefined) {
|
|
63
|
+
alts.push(new web3.PublicKey(alt));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return alts;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Set server credentials
|
|
70
|
+
*
|
|
71
|
+
* @param username
|
|
72
|
+
* @param password
|
|
73
|
+
*/
|
|
74
|
+
setCredentials(username, password) {
|
|
75
|
+
this.username = username;
|
|
76
|
+
this.password = password;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Download jupiter alts from endpoint
|
|
80
|
+
*
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
downloadAlts() {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
if (this.url === undefined) {
|
|
86
|
+
throw new Error('Please set endpoint URL via hawkAPI.jupAlts.setApiUrl first!');
|
|
87
|
+
}
|
|
88
|
+
if (this.username === undefined || this.password === undefined) {
|
|
89
|
+
throw new Error('Please set credentials via hawkAPI.jupAlts.setCredentials() first!');
|
|
90
|
+
}
|
|
91
|
+
const base64Credentials = btoa(`${this.username}:${this.password}`);
|
|
92
|
+
const hash = yield (yield fetch(this.url, { headers: { Authorization: `Basic ${base64Credentials}`, Range: 'bytes=9-72' } })).text();
|
|
93
|
+
// If hash matches, then no need to download the file.
|
|
94
|
+
if (this.hash === hash)
|
|
95
|
+
return;
|
|
96
|
+
// Otherwise, download the alts
|
|
97
|
+
const response = yield fetch(this.url, { headers: { Authorization: `Basic ${base64Credentials}` } });
|
|
98
|
+
const content = yield response.text();
|
|
99
|
+
const jsonString = content.slice(82, content.length - 1);
|
|
100
|
+
this._alts = JSON.parse(jsonString);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.JupiterAlts = JupiterAlts;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
|
+
import * as web3 from "@solana/web3.js";
|
|
3
|
+
import { SimpleIxGenerator } from "./SimpleIxGenerator";
|
|
4
|
+
import BN from "bn.js";
|
|
5
|
+
import { JupiterRouteIxReturn } from '../ixGenerator/IyfMainIxGenerator';
|
|
6
|
+
type JupiterIxToHawksight = {
|
|
7
|
+
connection: web3.Connection;
|
|
8
|
+
swapInstruction: web3.TransactionInstruction;
|
|
9
|
+
quotedOutAmountOverride?: BN;
|
|
10
|
+
slippageBpsOverride?: number;
|
|
11
|
+
platformFeeBpsOverride?: number;
|
|
12
|
+
checkDestinationTokenAccount?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare class JupiterSwap {
|
|
15
|
+
private ix;
|
|
16
|
+
constructor(ix: SimpleIxGenerator);
|
|
17
|
+
jupiterIxToHawksight({ connection, swapInstruction, quotedOutAmountOverride, slippageBpsOverride, platformFeeBpsOverride, checkDestinationTokenAccount }: JupiterIxToHawksight): Promise<JupiterRouteIxReturn>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=JupiterSwap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JupiterSwap.d.ts","sourceRoot":"","sources":["../../../src/classes/JupiterSwap.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,KAAK,oBAAoB,GAAG;IAC1B,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC;IAC5B,eAAe,EAAE,IAAI,CAAC,sBAAsB,CAAC;IAC7C,uBAAuB,CAAC,EAAE,EAAE,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AAEF,qBAAa,WAAW;IAGpB,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,iBAAiB;IAGzB,oBAAoB,CAAC,EAAC,UAAU,EAAE,eAAe,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,4BAA4B,EAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAiBnN"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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.JupiterSwap = void 0;
|
|
13
|
+
class JupiterSwap {
|
|
14
|
+
constructor(ix) {
|
|
15
|
+
this.ix = ix;
|
|
16
|
+
}
|
|
17
|
+
jupiterIxToHawksight(_a) {
|
|
18
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, swapInstruction, quotedOutAmountOverride, slippageBpsOverride, platformFeeBpsOverride, checkDestinationTokenAccount }) {
|
|
19
|
+
return yield this.ix.iyfMain.jupiterRouteIx({
|
|
20
|
+
connection,
|
|
21
|
+
userPda: swapInstruction.keys[1].pubkey,
|
|
22
|
+
sourceTokenAccount: swapInstruction.keys[2].pubkey,
|
|
23
|
+
destinationTokenAccount: swapInstruction.keys[3].pubkey,
|
|
24
|
+
destinationMint: swapInstruction.keys[5].pubkey,
|
|
25
|
+
platformFeeAccount: swapInstruction.keys[6].pubkey,
|
|
26
|
+
eventAuthority: swapInstruction.keys[7].pubkey,
|
|
27
|
+
remainingAccounts: swapInstruction.keys.slice(9),
|
|
28
|
+
data: swapInstruction.data,
|
|
29
|
+
quotedOutAmount: quotedOutAmountOverride,
|
|
30
|
+
slippageBps: slippageBpsOverride,
|
|
31
|
+
platformFeeBps: platformFeeBpsOverride,
|
|
32
|
+
checkDestinationTokenAccount,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.JupiterSwap = JupiterSwap;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log to console
|
|
3
|
+
*
|
|
4
|
+
* @param msg
|
|
5
|
+
*/
|
|
6
|
+
export declare function Log(...msg: any): void;
|
|
7
|
+
/**
|
|
8
|
+
* Whether enable logging or not
|
|
9
|
+
*
|
|
10
|
+
* @param flag
|
|
11
|
+
*/
|
|
12
|
+
export declare function logging(flag: boolean): void;
|
|
13
|
+
//# sourceMappingURL=Logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logging.d.ts","sourceRoot":"","sources":["../../../src/classes/Logging.ts"],"names":[],"mappings":"AAuCA;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,GAAG,GAAG,EAAE,GAAG,QAE9B;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,QAEpC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logging = exports.Log = void 0;
|
|
4
|
+
class Logging {
|
|
5
|
+
/**
|
|
6
|
+
* Prevent multiple instance of this class
|
|
7
|
+
*/
|
|
8
|
+
constructor() {
|
|
9
|
+
/**
|
|
10
|
+
* Whether logging is enabled
|
|
11
|
+
*/
|
|
12
|
+
this.enabled = true;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create / get the singleton instance
|
|
16
|
+
*/
|
|
17
|
+
static instance() {
|
|
18
|
+
if (this._instance === undefined) {
|
|
19
|
+
this._instance = new Logging();
|
|
20
|
+
}
|
|
21
|
+
return this._instance;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Log to console
|
|
25
|
+
*
|
|
26
|
+
* @param msg Message to log
|
|
27
|
+
*/
|
|
28
|
+
log(...msg) {
|
|
29
|
+
if (this.enabled) {
|
|
30
|
+
console.log(...msg);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Log to console
|
|
36
|
+
*
|
|
37
|
+
* @param msg
|
|
38
|
+
*/
|
|
39
|
+
function Log(...msg) {
|
|
40
|
+
Logging.instance().log(...msg);
|
|
41
|
+
}
|
|
42
|
+
exports.Log = Log;
|
|
43
|
+
/**
|
|
44
|
+
* Whether enable logging or not
|
|
45
|
+
*
|
|
46
|
+
* @param flag
|
|
47
|
+
*/
|
|
48
|
+
function logging(flag) {
|
|
49
|
+
Logging.instance().enabled = flag;
|
|
50
|
+
}
|
|
51
|
+
exports.logging = logging;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
|
+
import * as web3 from "@solana/web3.js";
|
|
3
|
+
import * as client from "@hawksightco/swagger-client";
|
|
4
|
+
import { GeneralUtility } from "./GeneralUtility";
|
|
5
|
+
import { SendSignedTx, SignerPlugin, SignerPlugin2 } from "../types";
|
|
6
|
+
type CreateDurableNonceAccountOpts = {
|
|
7
|
+
userSignedFn: () => void;
|
|
8
|
+
userDidntSignedFn: () => void;
|
|
9
|
+
successFn: (txid: string) => void;
|
|
10
|
+
failedFn: (message: string, logToMixpanel: boolean) => void;
|
|
11
|
+
};
|
|
12
|
+
type SignAndSendOpts = {
|
|
13
|
+
userSignedFn: () => void;
|
|
14
|
+
userDidntSignedFn: () => void;
|
|
15
|
+
successFn: (txids: string[]) => void;
|
|
16
|
+
failedFn: (message: string, logToMixpanel: boolean) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare class MultiTransaction {
|
|
19
|
+
readonly description: string;
|
|
20
|
+
readonly generalUtility: GeneralUtility;
|
|
21
|
+
latestBlockhash: {
|
|
22
|
+
blockhash: web3.Blockhash;
|
|
23
|
+
lastValidBlockHeight: number;
|
|
24
|
+
};
|
|
25
|
+
readonly payerKey: web3.PublicKey;
|
|
26
|
+
private txs;
|
|
27
|
+
private nonceAdvanceIxCount;
|
|
28
|
+
private nonceAccounts;
|
|
29
|
+
/**
|
|
30
|
+
* Get transaction count
|
|
31
|
+
*/
|
|
32
|
+
get count(): number;
|
|
33
|
+
constructor(description: string, generalUtility: GeneralUtility, latestBlockhash: {
|
|
34
|
+
blockhash: web3.Blockhash;
|
|
35
|
+
lastValidBlockHeight: number;
|
|
36
|
+
}, payerKey: web3.PublicKey);
|
|
37
|
+
push(alts: web3.AddressLookupTableAccount[], ixs: web3.TransactionInstruction[]): void;
|
|
38
|
+
getPayerOwnedNonceAccounts(connection: web3.Connection): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Whether there were enough nonce accounts already initialized on-chain
|
|
41
|
+
*
|
|
42
|
+
* @param connection
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
hasAvailableNonce(connection: web3.Connection): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Generate a transaction that creates durable nonce account
|
|
48
|
+
*
|
|
49
|
+
* @param connection
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
createDurableNonceAccount(connection: web3.Connection, signerFn: SignerPlugin, sendSigned: SendSignedTx, opts: CreateDurableNonceAccountOpts): Promise<boolean>;
|
|
53
|
+
signAndSend(connection: web3.Connection, priorityLevel: client.PriorityLevel, priorityFeeMaxCap: number, signMultipleTransactions: SignerPlugin2, sendSignedTx: SendSignedTx, opts: SignAndSendOpts): Promise<void>;
|
|
54
|
+
private generateTransasctions;
|
|
55
|
+
private transactionInstance;
|
|
56
|
+
/**
|
|
57
|
+
* Generate nonde advance instruction (dummy instruction)
|
|
58
|
+
*/
|
|
59
|
+
private nonceAdvanceIx;
|
|
60
|
+
/**
|
|
61
|
+
* Get nonce index
|
|
62
|
+
*
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
private getNonceIndex;
|
|
66
|
+
/**
|
|
67
|
+
* Get fee estimate
|
|
68
|
+
*
|
|
69
|
+
* @param priorityLevel
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
private getFeeEstimate;
|
|
73
|
+
private getFeeEstimate2;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=MultiTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiTransaction.d.ts","sourceRoot":"","sources":["../../../src/classes/MultiTransaction.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAA+B,MAAM,UAAU,CAAC;AAKlG,KAAK,6BAA6B,GAAG;IACnC,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7D,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,iBA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