@hawksightco/hawk-sdk 1.0.2 → 1.0.3

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.
@@ -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 { WhirlpoolContext } from "@orca-so/whirlpools-sdk";
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
- whirlpoolCtx: WhirlpoolContext;
13
+ orcaProgram: anchor.Program<Whirlpool>;
14
14
  private constructor();
15
15
  static initialize(connection: web3.Connection): void;
16
16
  static instance(): Anchor;
@@ -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;AAO7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,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,YAAY,EAAE,gBAAgB,CAAA;IAE9B,OAAO;IASP,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU;IAI7C,MAAM,CAAC,QAAQ,IAAI,MAAM;CAO1B"}
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"}
@@ -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.whirlpoolCtx = whirlpools_sdk_1.WhirlpoolContext.withProvider(this.provider, addresses_1.ORCA_WHIRLPOOL_PROGRAM);
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);
@@ -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().whirlpoolCtx.fetcher.getPosition(position);
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().whirlpoolCtx.fetcher.getPool(whirlpool);
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().whirlpoolCtx.fetcher.getPosition(position);
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().whirlpoolCtx.fetcher.getPool(whirlpool);
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().whirlpoolCtx.fetcher.getPosition(position);
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().whirlpoolCtx.fetcher.getPool(whirlpool);
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);