@haven-fi/solauto-sdk 1.0.198 → 1.0.200

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ import { ReferralStateManager } from "./referralStateManager";
9
9
  import { TxHandler } from "./txHandler";
10
10
  import { QuoteResponse } from "@jup-ag/api";
11
11
  export interface SolautoClientArgs {
12
+ new?: boolean;
12
13
  authority?: PublicKey;
13
14
  positionId?: number;
14
15
  signer?: Signer;
@@ -42,7 +43,7 @@ export declare abstract class SolautoClient extends TxHandler {
42
43
  solautoFeesSupplyTa: PublicKey;
43
44
  authorityLutAddress?: PublicKey;
44
45
  livePositionUpdates: LivePositionUpdates;
45
- constructor(heliusApiUrl: string, localTest?: boolean);
46
+ constructor(rpcUrl: string, localTest?: boolean);
46
47
  initialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform): Promise<void>;
47
48
  setReferredBy(referredBy: PublicKey): void;
48
49
  resetLiveTxUpdates(success?: boolean): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,MAAM,EACN,kBAAkB,EAOnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAEhC,sBAAsB,EAMvB,MAAM,cAAc,CAAC;AAYtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAA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EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAC5E;IAyDD,uBAAuB,IAAI,yBAAyB,GAAG,SAAS;IAOhE,wBAAwB,IAAI,WAAW,GAAG,SAAS;IAO7C,wBAAwB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAOvE,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IA0BrB,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB;IAwDlE,eAAe,IAAI,kBAAkB;IAYrC,WAAW,IAAI,kBAAkB;IAgCjC,QAAQ,CAAC,OAAO,IAAI,kBAAkB;IAEtC,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAuFhE,QAAQ,CAAC,WAAW,CAClB,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IAErB,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAE3E,QAAQ,CAAC,SAAS,CAChB,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
@@ -16,8 +16,8 @@ const generalUtils_2 = require("../utils/solauto/generalUtils");
16
16
  const referralStateManager_1 = require("./referralStateManager");
17
17
  const txHandler_1 = require("./txHandler");
18
18
  class SolautoClient extends txHandler_1.TxHandler {
19
- constructor(heliusApiUrl, localTest) {
20
- super(heliusApiUrl, localTest);
19
+ constructor(rpcUrl, localTest) {
20
+ super(rpcUrl, localTest);
21
21
  this.livePositionUpdates = new generalUtils_2.LivePositionUpdates();
22
22
  this.umi = this.umi.use({
23
23
  install(umi) {
@@ -38,8 +38,10 @@ class SolautoClient extends txHandler_1.TxHandler {
38
38
  this.selfManaged = this.positionId === 0;
39
39
  this.lendingPlatform = lendingPlatform;
40
40
  this.solautoPosition = (0, accountUtils_1.getSolautoPositionAccount)(this.authority, this.positionId);
41
- this.solautoPositionData = await (0, generated_1.safeFetchSolautoPosition)(this.umi, (0, umi_1.publicKey)(this.solautoPosition), { commitment: "confirmed" });
41
+ this.solautoPositionData = !args.new ? await (0, generated_1.safeFetchSolautoPosition)(this.umi, (0, umi_1.publicKey)(this.solautoPosition), { commitment: "confirmed" }) : null;
42
42
  this.solautoPositionState = this.solautoPositionData?.state;
43
+ this.maxLtvBps = undefined;
44
+ this.liqThresholdBps = undefined;
43
45
  this.supplyMint =
44
46
  args.supplyMint ??
45
47
  (this.solautoPositionData
@@ -54,7 +56,7 @@ class SolautoClient extends txHandler_1.TxHandler {
54
56
  : web3_js_1.PublicKey.default);
55
57
  this.positionDebtTa = (0, accountUtils_1.getTokenAccount)(this.solautoPosition, this.debtMint);
56
58
  this.signerDebtTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.debtMint);
57
- this.referralStateManager = new referralStateManager_1.ReferralStateManager(this.heliusApiUrl);
59
+ this.referralStateManager = new referralStateManager_1.ReferralStateManager(this.rpcUrl);
58
60
  await this.referralStateManager.initialize({
59
61
  referralAuthority: this.authority,
60
62
  signer: args.signer,
@@ -1 +1 @@
1
- {"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAA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GAAG,GAAG,GAAG,EACxB,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAqErB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAoFlE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CA6ClE"}
@@ -12,7 +12,6 @@ const generalUtils_1 = require("../utils/generalUtils");
12
12
  const marginfi_sdk_1 = require("../marginfi-sdk");
13
13
  const marginfiUtils_1 = require("../utils/marginfiUtils");
14
14
  const numberUtils_1 = require("../utils/numberUtils");
15
- const utils_1 = require("../utils");
16
15
  class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
17
16
  constructor() {
18
17
  super(...arguments);
@@ -30,13 +29,15 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
30
29
  this.marginfiAccountSeedIdx = (0, generalUtils_1.generateRandomU64)();
31
30
  this.marginfiAccount = this.solautoPositionData
32
31
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.solautoPositionData.position.protocolAccount)
33
- : await (0, accountUtils_1.getMarginfiAccountPDA)(this.solautoPosition, this.marginfiAccountSeedIdx);
32
+ : (0, accountUtils_1.getMarginfiAccountPDA)(this.solautoPosition, this.marginfiAccountSeedIdx);
34
33
  }
35
34
  this.marginfiAccountPk =
36
35
  "publicKey" in this.marginfiAccount
37
36
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.marginfiAccount.publicKey)
38
37
  : this.marginfiAccount;
39
- const marginfiAccountData = await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(this.umi, (0, umi_1.publicKey)(this.marginfiAccountPk), { commitment: "confirmed" });
38
+ const marginfiAccountData = !args.new
39
+ ? await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(this.umi, (0, umi_1.publicKey)(this.marginfiAccountPk), { commitment: "confirmed" })
40
+ : null;
40
41
  this.marginfiGroup = new web3_js_1.PublicKey(marginfiAccountData
41
42
  ? marginfiAccountData.group.toString()
42
43
  : (args.marginfiGroup ?? marginfiAccounts_1.DEFAULT_MARGINFI_GROUP));
@@ -44,7 +45,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
44
45
  marginfiAccounts_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.supplyMint.toString()];
45
46
  this.marginfiDebtAccounts =
46
47
  marginfiAccounts_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.debtMint.toString()];
47
- // TODO: Don't dynamically pull from bank until Marginfi sorts out their price oracle issues.
48
+ // TODO: Don't dynamically pull oracle from bank until Marginfi sorts out their price oracle issues.
48
49
  // const [supplyBank, debtBank] = await safeFetchAllBank(this.umi, [
49
50
  // publicKey(this.marginfiSupplyAccounts.bank),
50
51
  // publicKey(this.marginfiDebtAccounts.bank),
@@ -53,10 +54,6 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
53
54
  // this.debtPriceOracle = toWeb3JsPublicKey(debtBank.config.oracleKeys[0]);
54
55
  this.supplyPriceOracle = new web3_js_1.PublicKey(this.marginfiSupplyAccounts.priceOracle);
55
56
  this.debtPriceOracle = new web3_js_1.PublicKey(this.marginfiDebtAccounts.priceOracle);
56
- if (!this.solautoPositionState) {
57
- const result = await this.maxLtvAndLiqThresholdBps();
58
- this.solautoPositionState = (0, utils_1.createFakePositionState)({ mint: this.supplyMint }, { mint: this.debtMint }, result ? result[0] : 0, result ? result[1] : 0);
59
- }
60
57
  if (!this.initialized) {
61
58
  await this.setIntermediaryMarginfiDetails();
62
59
  }
@@ -1,10 +1,10 @@
1
1
  import { Umi } from "@metaplex-foundation/umi";
2
2
  import { Connection } from "@solana/web3.js";
3
3
  export declare abstract class TxHandler {
4
- heliusApiUrl: string;
4
+ rpcUrl: string;
5
5
  umi: Umi;
6
6
  connection: Connection;
7
- constructor(heliusApiUrl: string, localTest?: boolean);
7
+ constructor(rpcUrl: string, localTest?: boolean);
8
8
  log(...args: any[]): void;
9
9
  abstract defaultLookupTables(): string[];
10
10
  abstract resetLiveTxUpdates(success?: boolean): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,8BAAsB,SAAS;IACtB,YAAY,EAAG,MAAM,CAAC;IACtB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;gBAG7B,YAAY,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,OAAO;IAYrB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAIzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC9D"}
1
+ {"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,8BAAsB,SAAS;IACtB,MAAM,EAAG,MAAM,CAAC;IAChB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;gBAG7B,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,OAAO;IAYrB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAIzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC9D"}
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TxHandler = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  class TxHandler {
6
- constructor(heliusApiUrl, localTest) {
7
- this.heliusApiUrl = heliusApiUrl;
8
- const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.heliusApiUrl);
6
+ constructor(rpcUrl, localTest) {
7
+ this.rpcUrl = rpcUrl;
8
+ const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.rpcUrl);
9
9
  this.connection = connection;
10
10
  this.umi = umi;
11
11
  if (!globalThis.LOCAL_TEST && localTest) {
@@ -7,5 +7,5 @@ export declare function getTokenAccounts(wallet: PublicKey, tokenMints: PublicKe
7
7
  export declare function getTokenAccountData(umi: Umi, tokenAccount: PublicKey): Promise<import("@solana/spl-token").RawAccount | undefined>;
8
8
  export declare function getSolautoPositionAccount(signer: PublicKey, positionId: number): PublicKey;
9
9
  export declare function getReferralState(authority: PublicKey): PublicKey;
10
- export declare function getMarginfiAccountPDA(solautoPositionAccount: PublicKey, marginfiAccountSeedIdx: bigint): Promise<PublicKey>;
10
+ export declare function getMarginfiAccountPDA(solautoPositionAccount: PublicKey, marginfiAccountSeedIdx: bigint): PublicKey;
11
11
  //# sourceMappingURL=accountUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accountUtils.d.ts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MA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AAE,SAAS,EACjC,sBAAsB,EAAE,MAAM,aAa/B"}
@@ -47,11 +47,11 @@ function getReferralState(authority) {
47
47
  const [ReferralState, _] = web3_js_1.PublicKey.findProgramAddressSync([strBuffer, authority.toBuffer()], new web3_js_1.PublicKey(generated_1.SOLAUTO_PROGRAM_ID));
48
48
  return ReferralState;
49
49
  }
50
- async function getMarginfiAccountPDA(solautoPositionAccount, marginfiAccountSeedIdx) {
50
+ function getMarginfiAccountPDA(solautoPositionAccount, marginfiAccountSeedIdx) {
51
51
  const seeds = [
52
52
  solautoPositionAccount.toBuffer(),
53
53
  bufferFromU64(marginfiAccountSeedIdx),
54
54
  ];
55
- const [marginfiAccount, _] = await web3_js_1.PublicKey.findProgramAddress(seeds, new web3_js_1.PublicKey(generated_1.SOLAUTO_PROGRAM_ID));
55
+ const [marginfiAccount, _] = web3_js_1.PublicKey.findProgramAddressSync(seeds, new web3_js_1.PublicKey(generated_1.SOLAUTO_PROGRAM_ID));
56
56
  return marginfiAccount;
57
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.198",
3
+ "version": "1.0.200",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -39,7 +39,6 @@ import {
39
39
  getTokenAccount,
40
40
  } from "../utils/accountUtils";
41
41
  import { SOLAUTO_FEES_WALLET } from "../constants/generalAccounts";
42
- import { JupSwapDetails } from "../utils/jupiterUtils";
43
42
  import {
44
43
  getWrappedInstruction,
45
44
  splTokenTransferUmiIx,
@@ -56,6 +55,7 @@ import { TxHandler } from "./txHandler";
56
55
  import { QuoteResponse } from "@jup-ag/api";
57
56
 
58
57
  export interface SolautoClientArgs {
58
+ new?: boolean;
59
59
  authority?: PublicKey;
60
60
  positionId?: number;
61
61
  signer?: Signer;
@@ -103,8 +103,8 @@ export abstract class SolautoClient extends TxHandler {
103
103
 
104
104
  public livePositionUpdates: LivePositionUpdates = new LivePositionUpdates();
105
105
 
106
- constructor(heliusApiUrl: string, localTest?: boolean) {
107
- super(heliusApiUrl, localTest);
106
+ constructor(rpcUrl: string, localTest?: boolean) {
107
+ super(rpcUrl, localTest);
108
108
 
109
109
  this.umi = this.umi.use({
110
110
  install(umi) {
@@ -133,13 +133,16 @@ export abstract class SolautoClient extends TxHandler {
133
133
  this.authority,
134
134
  this.positionId
135
135
  );
136
- this.solautoPositionData = await safeFetchSolautoPosition(
136
+ this.solautoPositionData = !args.new ? await safeFetchSolautoPosition(
137
137
  this.umi,
138
138
  publicKey(this.solautoPosition),
139
139
  { commitment: "confirmed" }
140
- );
140
+ ) : null;
141
141
  this.solautoPositionState = this.solautoPositionData?.state;
142
142
 
143
+ this.maxLtvBps = undefined;
144
+ this.liqThresholdBps = undefined;
145
+
143
146
  this.supplyMint =
144
147
  args.supplyMint ??
145
148
  (this.solautoPositionData
@@ -165,7 +168,7 @@ export abstract class SolautoClient extends TxHandler {
165
168
  this.debtMint
166
169
  );
167
170
 
168
- this.referralStateManager = new ReferralStateManager(this.heliusApiUrl);
171
+ this.referralStateManager = new ReferralStateManager(this.rpcUrl);
169
172
  await this.referralStateManager.initialize({
170
173
  referralAuthority: this.authority,
171
174
  signer: args.signer,
@@ -96,7 +96,7 @@ export class SolautoMarginfiClient extends SolautoClient {
96
96
  this.marginfiAccountSeedIdx = generateRandomU64();
97
97
  this.marginfiAccount = this.solautoPositionData
98
98
  ? toWeb3JsPublicKey(this.solautoPositionData.position.protocolAccount)
99
- : await getMarginfiAccountPDA(
99
+ : getMarginfiAccountPDA(
100
100
  this.solautoPosition,
101
101
  this.marginfiAccountSeedIdx
102
102
  );
@@ -106,11 +106,13 @@ export class SolautoMarginfiClient extends SolautoClient {
106
106
  ? toWeb3JsPublicKey(this.marginfiAccount.publicKey)
107
107
  : this.marginfiAccount;
108
108
 
109
- const marginfiAccountData = await safeFetchMarginfiAccount(
110
- this.umi,
111
- publicKey(this.marginfiAccountPk),
112
- { commitment: "confirmed" }
113
- );
109
+ const marginfiAccountData = !args.new
110
+ ? await safeFetchMarginfiAccount(
111
+ this.umi,
112
+ publicKey(this.marginfiAccountPk),
113
+ { commitment: "confirmed" }
114
+ )
115
+ : null;
114
116
  this.marginfiGroup = new PublicKey(
115
117
  marginfiAccountData
116
118
  ? marginfiAccountData.group.toString()
@@ -126,29 +128,18 @@ export class SolautoMarginfiClient extends SolautoClient {
126
128
  this.debtMint.toString()
127
129
  ]!;
128
130
 
129
- // TODO: Don't dynamically pull from bank until Marginfi sorts out their price oracle issues.
131
+ // TODO: Don't dynamically pull oracle from bank until Marginfi sorts out their price oracle issues.
130
132
  // const [supplyBank, debtBank] = await safeFetchAllBank(this.umi, [
131
133
  // publicKey(this.marginfiSupplyAccounts.bank),
132
134
  // publicKey(this.marginfiDebtAccounts.bank),
133
135
  // ]);
134
136
  // this.supplyPriceOracle = toWeb3JsPublicKey(supplyBank.config.oracleKeys[0]);
135
137
  // this.debtPriceOracle = toWeb3JsPublicKey(debtBank.config.oracleKeys[0]);
136
-
137
138
  this.supplyPriceOracle = new PublicKey(
138
139
  this.marginfiSupplyAccounts.priceOracle
139
140
  );
140
141
  this.debtPriceOracle = new PublicKey(this.marginfiDebtAccounts.priceOracle);
141
142
 
142
- if (!this.solautoPositionState) {
143
- const result = await this.maxLtvAndLiqThresholdBps()!;
144
- this.solautoPositionState = createFakePositionState(
145
- { mint: this.supplyMint },
146
- { mint: this.debtMint },
147
- result ? result[0] : 0,
148
- result ? result[1] : 0
149
- );
150
- }
151
-
152
143
  if (!this.initialized) {
153
144
  await this.setIntermediaryMarginfiDetails();
154
145
  }
@@ -3,16 +3,16 @@ import { Connection } from "@solana/web3.js";
3
3
  import { consoleLog, getSolanaRpcConnection } from "../utils";
4
4
 
5
5
  export abstract class TxHandler {
6
- public heliusApiUrl!: string;
6
+ public rpcUrl!: string;
7
7
  public umi!: Umi;
8
8
  public connection!: Connection;
9
9
 
10
10
  constructor(
11
- heliusApiUrl: string,
11
+ rpcUrl: string,
12
12
  localTest?: boolean
13
13
  ) {
14
- this.heliusApiUrl = heliusApiUrl;
15
- const [connection, umi] = getSolanaRpcConnection(this.heliusApiUrl);
14
+ this.rpcUrl = rpcUrl;
15
+ const [connection, umi] = getSolanaRpcConnection(this.rpcUrl);
16
16
  this.connection = connection;
17
17
  this.umi = umi;
18
18
 
@@ -60,7 +60,7 @@ export function getReferralState(authority: PublicKey) {
60
60
  return ReferralState;
61
61
  }
62
62
 
63
- export async function getMarginfiAccountPDA(
63
+ export function getMarginfiAccountPDA(
64
64
  solautoPositionAccount: PublicKey,
65
65
  marginfiAccountSeedIdx: bigint
66
66
  ) {
@@ -69,7 +69,7 @@ export async function getMarginfiAccountPDA(
69
69
  bufferFromU64(marginfiAccountSeedIdx),
70
70
  ];
71
71
 
72
- const [marginfiAccount, _] = await PublicKey.findProgramAddress(
72
+ const [marginfiAccount, _] = PublicKey.findProgramAddressSync(
73
73
  seeds,
74
74
  new PublicKey(SOLAUTO_PROGRAM_ID)
75
75
  );