@hawksightco/hawk-sdk 1.0.2 → 1.0.4
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/anchor.d.ts +2 -2
- package/dist/src/anchor.d.ts.map +1 -1
- package/dist/src/anchor.js +2 -2
- package/dist/src/classes/CreateTxMetadata.js +2 -2
- package/dist/src/classes/HawkAPI.d.ts +3 -1
- package/dist/src/classes/HawkAPI.d.ts.map +1 -1
- package/dist/src/classes/HawkAPI.js +8 -3
- package/dist/src/classes/Transactions.js +6 -6
- package/dist/src/idl/orca-idl.d.ts +3833 -0
- package/dist/src/idl/orca-idl.d.ts.map +1 -0
- package/dist/src/idl/orca-idl.js +3834 -0
- package/dist/src/types.d.ts +4 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +2 -3
package/dist/src/anchor.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import * as web3 from "@solana/web3.js";
|
|
|
3
3
|
import * as anchor from "@coral-xyz/anchor";
|
|
4
4
|
import { IndexYieldFarming } from "./idl/iyf-main-idl";
|
|
5
5
|
import { IyfExtension } from "./idl/iyf-extension-idl";
|
|
6
|
-
import {
|
|
6
|
+
import { Whirlpool } from "./idl/orca-idl";
|
|
7
7
|
export declare class Anchor {
|
|
8
8
|
connection: web3.Connection;
|
|
9
9
|
private static _instance;
|
|
10
10
|
provider: anchor.AnchorProvider;
|
|
11
11
|
iyfMain: anchor.Program<IndexYieldFarming>;
|
|
12
12
|
iyfExtension: anchor.Program<IyfExtension>;
|
|
13
|
-
|
|
13
|
+
orcaProgram: anchor.Program<Whirlpool>;
|
|
14
14
|
private constructor();
|
|
15
15
|
static initialize(connection: web3.Connection): void;
|
|
16
16
|
static instance(): Anchor;
|
package/dist/src/anchor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/anchor.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAmB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAwB,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/anchor.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAmB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAwB,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAqB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQ9D,qBAAa,MAAM;IASR,UAAU,EAAE,IAAI,CAAC,UAAU;IAPpC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAS;IACjC,QAAQ,EAAE,MAAM,CAAC,cAAc,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC3C,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEvC,OAAO;IASP,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU;IAI7C,MAAM,CAAC,QAAQ,IAAI,MAAM;CAO1B"}
|
package/dist/src/anchor.js
CHANGED
|
@@ -31,16 +31,16 @@ const web3 = __importStar(require("@solana/web3.js"));
|
|
|
31
31
|
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
32
32
|
const iyf_main_idl_1 = require("./idl/iyf-main-idl");
|
|
33
33
|
const iyf_extension_idl_1 = require("./idl/iyf-extension-idl");
|
|
34
|
+
const orca_idl_1 = require("./idl/orca-idl");
|
|
34
35
|
const nodewallet_1 = __importDefault(require("@coral-xyz/anchor/dist/cjs/nodewallet"));
|
|
35
36
|
const addresses_1 = require("./addresses");
|
|
36
|
-
const whirlpools_sdk_1 = require("@orca-so/whirlpools-sdk");
|
|
37
37
|
class Anchor {
|
|
38
38
|
constructor(connection) {
|
|
39
39
|
this.connection = connection;
|
|
40
40
|
this.provider = new anchor.AnchorProvider(connection, new nodewallet_1.default(web3.Keypair.generate()), {});
|
|
41
41
|
this.iyfMain = new anchor.Program(iyf_main_idl_1.IDL, addresses_1.IYF_MAIN, this.provider);
|
|
42
42
|
this.iyfExtension = new anchor.Program(iyf_extension_idl_1.IDL, addresses_1.IYF_EXTENSION, this.provider);
|
|
43
|
-
this.
|
|
43
|
+
this.orcaProgram = new anchor.Program(orca_idl_1.IDL, addresses_1.ORCA_WHIRLPOOL_PROGRAM, this.provider);
|
|
44
44
|
}
|
|
45
45
|
static initialize(connection) {
|
|
46
46
|
Anchor._instance = new Anchor(connection);
|
|
@@ -165,7 +165,7 @@ class CreateTxMetadata {
|
|
|
165
165
|
alts.push(_alt);
|
|
166
166
|
}
|
|
167
167
|
else {
|
|
168
|
-
alts.push(yield this.loadSingleAlt(alt));
|
|
168
|
+
alts.push(yield this.loadSingleAlt(alt, connection));
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
if (jupAlts.status === 200) {
|
|
@@ -175,7 +175,7 @@ class CreateTxMetadata {
|
|
|
175
175
|
alts.push(_alt);
|
|
176
176
|
}
|
|
177
177
|
else {
|
|
178
|
-
alts.push(yield this.loadSingleAlt(alt));
|
|
178
|
+
alts.push(yield this.loadSingleAlt(alt, connection));
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -6,6 +6,7 @@ import { TxGeneratorAutomations } from "./TxGeneratorAutomations";
|
|
|
6
6
|
import { Client } from "./Client";
|
|
7
7
|
import { GeneralUtility } from "./GeneralUtility";
|
|
8
8
|
import { Search } from "./Search";
|
|
9
|
+
import { HawkApiOptions } from "../types";
|
|
9
10
|
/**
|
|
10
11
|
* HawkAPI is a central gateway class that aggregates access to various functional modules
|
|
11
12
|
* for interacting with HawkSight's blockchain APIs. This class initializes and exposes modules
|
|
@@ -17,6 +18,7 @@ import { Search } from "./Search";
|
|
|
17
18
|
*/
|
|
18
19
|
export declare class HawkAPI {
|
|
19
20
|
protected readonly url: string;
|
|
21
|
+
protected readonly options?: HawkApiOptions | undefined;
|
|
20
22
|
/** Swagger Client Instance. */
|
|
21
23
|
private readonly client;
|
|
22
24
|
/** Health module to check system health and API connectivity. */
|
|
@@ -38,7 +40,7 @@ export declare class HawkAPI {
|
|
|
38
40
|
* Initializes a new instance of the HawkAPI class with a specified API URL.
|
|
39
41
|
* @param url The base URL for the HawkSight API services, defaulted to "https://api2.hawksight.co" if not specified.
|
|
40
42
|
*/
|
|
41
|
-
constructor(url?: string);
|
|
43
|
+
constructor(url?: string, options?: HawkApiOptions | undefined);
|
|
42
44
|
/**
|
|
43
45
|
* Override transaction generator
|
|
44
46
|
*
|
|
@@ -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;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"HawkAPI.d.ts","sourceRoot":"","sources":["../../../src/classes/HawkAPI.ts"],"names":[],"mappings":"AAAA,O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25,8 +25,9 @@ class HawkAPI {
|
|
|
25
25
|
* Initializes a new instance of the HawkAPI class with a specified API URL.
|
|
26
26
|
* @param url The base URL for the HawkSight API services, defaulted to "https://api2.hawksight.co" if not specified.
|
|
27
27
|
*/
|
|
28
|
-
constructor(url = "https://api2.hawksight.co") {
|
|
28
|
+
constructor(url = "https://api2.hawksight.co", options) {
|
|
29
29
|
this.url = url;
|
|
30
|
+
this.options = options;
|
|
30
31
|
const client = new Client_1.Client(url);
|
|
31
32
|
this.client = client;
|
|
32
33
|
this.health = new Health_1.Health(client);
|
|
@@ -37,9 +38,13 @@ class HawkAPI {
|
|
|
37
38
|
this.txGeneratorAutomation = new TxGeneratorAutomations_1.TxGeneratorAutomations(client, this.generalUtility);
|
|
38
39
|
this.search = new Search_1.Search(url);
|
|
39
40
|
// Load create tx metadata module
|
|
40
|
-
|
|
41
|
+
if (this.options === undefined || !this.options.disableTxMetadataLoad) {
|
|
42
|
+
CreateTxMetadata_1.CreateTxMetadata.instance().load();
|
|
43
|
+
}
|
|
41
44
|
// Load search module
|
|
42
|
-
this.
|
|
45
|
+
if (this.options === undefined || !this.options.disableTokenLoad) {
|
|
46
|
+
this.search.load();
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
/**
|
|
45
50
|
* Override transaction generator
|
|
@@ -752,12 +752,12 @@ class Transactions {
|
|
|
752
752
|
const userPda = (0, functions_1.generateUserPda)(params.userWallet, farm);
|
|
753
753
|
const position = (0, functions_1.generateOrcaPositionPDA)(params.positionMint);
|
|
754
754
|
const positionTokenAccount = (0, functions_1.generateAta)(userPda, params.positionMint);
|
|
755
|
-
const positionData = yield anchor_1.Anchor.instance().
|
|
755
|
+
const positionData = yield anchor_1.Anchor.instance().orcaProgram.account.position.fetch(position);
|
|
756
756
|
if (positionData === null) {
|
|
757
757
|
throw new Error(`Position: ${position} does not exist or already closed. Position mint: ${params.positionMint}`);
|
|
758
758
|
}
|
|
759
759
|
const whirlpool = positionData.whirlpool;
|
|
760
|
-
const whirlpoolData = yield anchor_1.Anchor.instance().
|
|
760
|
+
const whirlpoolData = yield anchor_1.Anchor.instance().orcaProgram.account.whirlpool.fetch(whirlpool);
|
|
761
761
|
const mintA = whirlpoolData.tokenMintA;
|
|
762
762
|
const mintB = whirlpoolData.tokenMintB;
|
|
763
763
|
const tokenSeeds = [
|
|
@@ -872,12 +872,12 @@ class Transactions {
|
|
|
872
872
|
const userPda = (0, functions_1.generateUserPda)(params.userWallet, farm);
|
|
873
873
|
const position = (0, functions_1.generateOrcaPositionPDA)(params.positionMint);
|
|
874
874
|
const positionTokenAccount = (0, functions_1.generateAta)(userPda, params.positionMint);
|
|
875
|
-
const positionData = yield anchor_1.Anchor.instance().
|
|
875
|
+
const positionData = yield anchor_1.Anchor.instance().orcaProgram.account.position.fetch(position);
|
|
876
876
|
if (positionData === null) {
|
|
877
877
|
throw new Error(`Position: ${position} does not exist or already closed. Position mint: ${params.positionMint}`);
|
|
878
878
|
}
|
|
879
879
|
const whirlpool = positionData.whirlpool;
|
|
880
|
-
const whirlpoolData = yield anchor_1.Anchor.instance().
|
|
880
|
+
const whirlpoolData = yield anchor_1.Anchor.instance().orcaProgram.account.whirlpool.fetch(whirlpool);
|
|
881
881
|
const mintA = whirlpoolData.tokenMintA;
|
|
882
882
|
const mintB = whirlpoolData.tokenMintB;
|
|
883
883
|
const tokenOwnerAccountA = (0, functions_1.generateAta)(userPda, mintA);
|
|
@@ -967,12 +967,12 @@ class Transactions {
|
|
|
967
967
|
const userPda = (0, functions_1.generateUserPda)(params.userWallet, farm);
|
|
968
968
|
const position = (0, functions_1.generateOrcaPositionPDA)(params.positionMint);
|
|
969
969
|
const positionTokenAccount = (0, functions_1.generateAta)(userPda, params.positionMint);
|
|
970
|
-
const positionData = yield anchor_1.Anchor.instance().
|
|
970
|
+
const positionData = yield anchor_1.Anchor.instance().orcaProgram.account.position.fetch(position);
|
|
971
971
|
if (positionData === null) {
|
|
972
972
|
throw new Error(`Position: ${position} does not exist or already closed. Position mint: ${params.positionMint}`);
|
|
973
973
|
}
|
|
974
974
|
const whirlpool = positionData.whirlpool;
|
|
975
|
-
const whirlpoolData = yield anchor_1.Anchor.instance().
|
|
975
|
+
const whirlpoolData = yield anchor_1.Anchor.instance().orcaProgram.account.whirlpool.fetch(whirlpool);
|
|
976
976
|
const mintA = whirlpoolData.tokenMintA;
|
|
977
977
|
const mintB = whirlpoolData.tokenMintB;
|
|
978
978
|
const tokenOwnerAccountA = (0, functions_1.generateAta)(userPda, mintA);
|