@haven-fi/solauto-sdk 1.0.554 → 1.0.556

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.
@@ -1 +1 @@
1
- {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAGL,OAAO,EAEP,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAElB,aAAa,EACb,YAAY,EACZ,yBAAyB,EACzB,gCAAgC,EAChC,SAAS,EAMV,MAAM,iBAAiB,CAAC;AAsBzB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG9E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAczE;AAgBD,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,kBAAkB,GAC7B,MAAM,CAKR;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,kBAAkB,EAC9B,eAAe,EAAE,MAAM,GACtB,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,kBAAkB,EAC9B,oBAAoB,EAAE,MAAM,UAY7B;AAED,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,yBAAyB,EACnC,eAAe,EAAE,MAAM,GACtB,yBAAyB,CAgB3B;AAED,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,yBAAyB,GAAG,SAAS,EACvD,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,WA6BtB;AAED,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EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,gCAAgC,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,CAAA;KAAE,CAAA;CAAE,GACzE;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,CAAC;AAE9C,qBAAa,cAAc;IAClB,gBAAgB,SAAa;IAC7B,cAAc,SAAa;IAC3B,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAa;IAC5D,SAAS,EAAE,WAAW,GAAG,SAAS,CAAa;IAC/C,YAAY,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,CAAA;KAAE,CAAa;IACpE,aAAa,EAAE,SAAS,GAAG,SAAS,CAAa;IACjD,OAAO,EAAE,aAAa,GAAG,SAAS,CAAa;IAEtD,GAAG,CAAC,MAAM,EAAE,iBAAiB;IA+B7B,KAAK;IAUL,eAAe,IAAI,OAAO;CAS3B"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LivePositionUpdates = void 0;
3
+ exports.ContextUpdates = void 0;
4
4
  exports.createDynamicSolautoProgram = createDynamicSolautoProgram;
5
5
  exports.nextAutomationPeriodTimestamp = nextAutomationPeriodTimestamp;
6
6
  exports.eligibleForNextAutomationPeriod = eligibleForNextAutomationPeriod;
@@ -401,7 +401,7 @@ function createSolautoSettings(settings) {
401
401
  padding1: [],
402
402
  };
403
403
  }
404
- class LivePositionUpdates {
404
+ class ContextUpdates {
405
405
  constructor() {
406
406
  this.supplyAdjustment = BigInt(0);
407
407
  this.debtAdjustment = BigInt(0);
@@ -456,7 +456,7 @@ class LivePositionUpdates {
456
456
  this.cancellingDca = undefined;
457
457
  this.jupSwap = undefined;
458
458
  }
459
- hasUpdates() {
459
+ positionUpdates() {
460
460
  return (this.supplyAdjustment !== BigInt(0) ||
461
461
  this.debtAdjustment !== BigInt(0) ||
462
462
  this.dcaInBalance !== undefined ||
@@ -464,4 +464,4 @@ class LivePositionUpdates {
464
464
  this.cancellingDca !== undefined);
465
465
  }
466
466
  }
467
- exports.LivePositionUpdates = LivePositionUpdates;
467
+ exports.ContextUpdates = ContextUpdates;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.554",
3
+ "version": "1.0.556",
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",
@@ -46,7 +46,7 @@ import {
46
46
  SOLAUTO_LUT,
47
47
  } from "../constants/solautoConstants";
48
48
  import { currentUnixSeconds } from "../utils/generalUtils";
49
- import { LivePositionUpdates } from "../utils/solauto/generalUtils";
49
+ import { ContextUpdates } from "../utils/solauto/generalUtils";
50
50
  import {
51
51
  ReferralStateManager,
52
52
  ReferralStateManagerArgs,
@@ -87,7 +87,7 @@ export abstract class SolautoClient extends ReferralStateManager {
87
87
 
88
88
  public authorityLutAddress?: PublicKey;
89
89
 
90
- public livePositionUpdates: LivePositionUpdates = new LivePositionUpdates();
90
+ public contextUpdates: ContextUpdates = new ContextUpdates();
91
91
 
92
92
  private signerSupplyBalance: bigint | undefined;
93
93
  private signerDebtBalance: bigint | undefined;
@@ -193,18 +193,18 @@ export abstract class SolautoClient extends ReferralStateManager {
193
193
  { commitment: "confirmed" }
194
194
  );
195
195
  } else {
196
- if (this.livePositionUpdates.activeDca) {
196
+ if (this.contextUpdates.activeDca) {
197
197
  this.solautoPositionData.position.dca =
198
- this.livePositionUpdates.activeDca;
198
+ this.contextUpdates.activeDca;
199
199
  }
200
- if (this.livePositionUpdates.settings) {
200
+ if (this.contextUpdates.settings) {
201
201
  this.solautoPositionData.position.settingParams =
202
- this.livePositionUpdates.settings;
202
+ this.contextUpdates.settings;
203
203
  }
204
- // All other live position updates can be derived by getting a fresh position state, so we don't need to do anything else form livePositionUpdates
204
+ // All other live position updates can be derived by getting a fresh position state, so we don't need to do anything else form contextUpdates
205
205
  }
206
206
  }
207
- this.livePositionUpdates.reset();
207
+ this.contextUpdates.reset();
208
208
  }
209
209
 
210
210
  abstract protocolAccount(): PublicKey;
@@ -357,14 +357,14 @@ export abstract class SolautoClient extends ReferralStateManager {
357
357
 
358
358
  solautoPositionSettings(): SolautoSettingsParameters | undefined {
359
359
  return (
360
- this.livePositionUpdates.settings ??
360
+ this.contextUpdates.settings ??
361
361
  this.solautoPositionData?.position.settingParams
362
362
  );
363
363
  }
364
364
 
365
365
  solautoPositionActiveDca(): DCASettings | undefined {
366
366
  return (
367
- this.livePositionUpdates.activeDca ??
367
+ this.contextUpdates.activeDca ??
368
368
  this.solautoPositionData?.position.dca
369
369
  );
370
370
  }
@@ -381,7 +381,7 @@ export abstract class SolautoClient extends ReferralStateManager {
381
381
  dca?: DCASettingsInpArgs
382
382
  ): TransactionBuilder {
383
383
  if (dca && dca.dcaInBaseUnit > 0) {
384
- this.livePositionUpdates.new({
384
+ this.contextUpdates.new({
385
385
  type: "dcaInBalance",
386
386
  value: {
387
387
  amount: BigInt(dca.dcaInBaseUnit),
@@ -390,13 +390,13 @@ export abstract class SolautoClient extends ReferralStateManager {
390
390
  });
391
391
  }
392
392
  if (settingParams) {
393
- this.livePositionUpdates.new({
393
+ this.contextUpdates.new({
394
394
  type: "settings",
395
395
  value: settingParams,
396
396
  });
397
397
  }
398
398
  if (dca) {
399
- this.livePositionUpdates.new({
399
+ this.contextUpdates.new({
400
400
  type: "dca",
401
401
  value: dca,
402
402
  });
@@ -425,7 +425,7 @@ export abstract class SolautoClient extends ReferralStateManager {
425
425
  isSome(args.dca) &&
426
426
  args.dca.value.dcaInBaseUnit > 0
427
427
  ) {
428
- this.livePositionUpdates.new({
428
+ this.contextUpdates.new({
429
429
  type: "dcaInBalance",
430
430
  value: {
431
431
  amount: BigInt(args.dca.value.dcaInBaseUnit),
@@ -436,14 +436,14 @@ export abstract class SolautoClient extends ReferralStateManager {
436
436
  }
437
437
 
438
438
  if (isOption(args.settingParams) && isSome(args.settingParams)) {
439
- this.livePositionUpdates.new({
439
+ this.contextUpdates.new({
440
440
  type: "settings",
441
441
  value: args.settingParams.value,
442
442
  });
443
443
  }
444
444
 
445
445
  if (isOption(args.dca) && isSome(args.dca)) {
446
- this.livePositionUpdates.new({
446
+ this.contextUpdates.new({
447
447
  type: "dca",
448
448
  value: args.dca.value,
449
449
  });
@@ -488,7 +488,7 @@ export abstract class SolautoClient extends ReferralStateManager {
488
488
  signerDcaTa = publicKey(this.signerDebtTa);
489
489
  }
490
490
 
491
- this.livePositionUpdates.new({
491
+ this.contextUpdates.new({
492
492
  type: "cancellingDca",
493
493
  value: this.solautoPositionData!.position.dca.tokenType,
494
494
  });
@@ -550,18 +550,18 @@ export abstract class SolautoClient extends ReferralStateManager {
550
550
  }
551
551
 
552
552
  if (args.__kind === "Deposit") {
553
- this.livePositionUpdates.new({
553
+ this.contextUpdates.new({
554
554
  type: "supply",
555
555
  value: BigInt(args.fields[0]),
556
556
  });
557
557
  } else if (args.__kind === "Withdraw") {
558
558
  if (args.fields[0].__kind === "Some") {
559
- this.livePositionUpdates.new({
559
+ this.contextUpdates.new({
560
560
  type: "supply",
561
561
  value: BigInt(args.fields[0].fields[0]) * BigInt(-1),
562
562
  });
563
563
  } else {
564
- this.livePositionUpdates.new({
564
+ this.contextUpdates.new({
565
565
  type: "supply",
566
566
  value:
567
567
  (this.solautoPositionState?.supply.amountUsed.baseUnit ??
@@ -569,18 +569,18 @@ export abstract class SolautoClient extends ReferralStateManager {
569
569
  });
570
570
  }
571
571
  } else if (args.__kind === "Borrow") {
572
- this.livePositionUpdates.new({
572
+ this.contextUpdates.new({
573
573
  type: "debt",
574
574
  value: BigInt(args.fields[0]),
575
575
  });
576
576
  } else {
577
577
  if (args.fields[0].__kind === "Some") {
578
- this.livePositionUpdates.new({
578
+ this.contextUpdates.new({
579
579
  type: "debt",
580
580
  value: BigInt(args.fields[0].fields[0]) * BigInt(-1),
581
581
  });
582
582
  } else {
583
- this.livePositionUpdates.new({
583
+ this.contextUpdates.new({
584
584
  type: "debt",
585
585
  value:
586
586
  (this.solautoPositionState?.debt.amountUsed.baseUnit ?? BigInt(0)) *
@@ -615,7 +615,7 @@ export abstract class SolautoClient extends ReferralStateManager {
615
615
  Boolean(this.solautoPositionState) &&
616
616
  Number(this.solautoPositionState!.lastUpdated) >
617
617
  currentUnixSeconds() - MIN_POSITION_STATE_FRESHNESS_SECS &&
618
- !this.livePositionUpdates.hasUpdates()
618
+ !this.contextUpdates.positionUpdates()
619
619
  ) {
620
620
  return this.solautoPositionState;
621
621
  }
@@ -726,7 +726,7 @@ export class SolautoMarginfiClient extends SolautoClient {
726
726
  this.marginfiGroup,
727
727
  useDesignatedMint ? { mint: this.supplyMint } : undefined,
728
728
  useDesignatedMint ? { mint: this.debtMint } : undefined,
729
- this.livePositionUpdates
729
+ this.contextUpdates
730
730
  );
731
731
 
732
732
  if (resp) {
@@ -44,10 +44,6 @@ export const JITO_TIP_ACCOUNTS = [
44
44
  "3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT",
45
45
  ];
46
46
 
47
- // "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
48
- // "J97FEQeJzChRnaAjNy3dRvm9FBavKqAdxo8jKXzw17ut"
49
- // "ByhmNseaYZXBDcBm6xhbgarwixgjym6H4ddLsvgoL3BL"
50
- // "2VJK8AHqtiaiJKYbBtFr3EHV4Hcy1FHCiEYQFmUvxot8"
51
47
  export const SOLAUTO_LUT = "8b7KefQDroVLGao71J5H3hFwABeyMCgCrLpXWssNFhk9";
52
48
  export const STANDARD_LUT_ACCOUNTS = [
53
49
  PublicKey.default,
@@ -583,7 +583,7 @@ export async function getTransactionChores(
583
583
  client,
584
584
  accountsGettingCreated,
585
585
  solautoActions,
586
- client.livePositionUpdates.dcaInBalance
586
+ client.contextUpdates.dcaInBalance
587
587
  ),
588
588
  await rebalanceChoresBefore(client, tx, accountsGettingCreated),
589
589
  ]);
@@ -592,7 +592,7 @@ export async function getTransactionChores(
592
592
  transactionChoresAfter(
593
593
  client,
594
594
  solautoActions,
595
- client.livePositionUpdates.cancellingDca
595
+ client.contextUpdates.cancellingDca
596
596
  )
597
597
  );
598
598
 
@@ -620,8 +620,8 @@ export async function requiresRefreshBeforeRebalance(
620
620
  return true;
621
621
  } else if (client.solautoPositionData && !client.selfManaged) {
622
622
  if (
623
- client.livePositionUpdates.supplyAdjustment > BigInt(0) ||
624
- client.livePositionUpdates.debtAdjustment > BigInt(0)
623
+ client.contextUpdates.supplyAdjustment > BigInt(0) ||
624
+ client.contextUpdates.debtAdjustment > BigInt(0)
625
625
  ) {
626
626
  return false;
627
627
  }
@@ -638,8 +638,8 @@ export async function requiresRefreshBeforeRebalance(
638
638
 
639
639
  client.log("Liq utilization rate diff:", utilizationRateDiff);
640
640
  if (
641
- client.livePositionUpdates.supplyAdjustment === BigInt(0) &&
642
- client.livePositionUpdates.debtAdjustment === BigInt(0) &&
641
+ client.contextUpdates.supplyAdjustment === BigInt(0) &&
642
+ client.contextUpdates.debtAdjustment === BigInt(0) &&
643
643
  utilizationRateDiff >= 10
644
644
  ) {
645
645
  client.log(
@@ -667,7 +667,7 @@ export async function buildSolautoRebalanceTransaction(
667
667
 
668
668
  if (
669
669
  (client.solautoPositionState?.supply.amountUsed.baseUnit === BigInt(0) &&
670
- client.livePositionUpdates.supplyAdjustment === BigInt(0)) ||
670
+ client.contextUpdates.supplyAdjustment === BigInt(0)) ||
671
671
  (targetLiqUtilizationRateBps === undefined &&
672
672
  !eligibleForRebalance(
673
673
  client.solautoPositionState!,
@@ -1,6 +1,7 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { MaybeRpcAccount, publicKey, Umi } from "@metaplex-foundation/umi";
3
3
  import { TOKEN_INFO, TokenInfo } from "../constants";
4
+ import axios from "axios";
4
5
 
5
6
  export function consoleLog(...args: any[]): void {
6
7
  if ((globalThis as any).LOCAL_TEST) {
@@ -142,3 +143,28 @@ export function toEnumValue<E extends object>(
142
143
 
143
144
  return undefined;
144
145
  }
146
+
147
+ export async function customRpcCall(umi: Umi, method: string, params?: any) {
148
+ const data = (
149
+ await axios.post(
150
+ umi.rpc.getEndpoint(),
151
+ {
152
+ jsonrpc: "2.0",
153
+ id: 1,
154
+ method,
155
+ params,
156
+ },
157
+ {
158
+ headers: {
159
+ "Content-Type": "application/json",
160
+ },
161
+ }
162
+ )
163
+ ).data;
164
+
165
+ if ("result" in data) {
166
+ return data.result;
167
+ } else {
168
+ return data;
169
+ }
170
+ }
@@ -25,7 +25,11 @@ import {
25
25
  sendSingleOptimizedTransaction,
26
26
  systemTransferUmiIx,
27
27
  } from "./solanaUtils";
28
- import { consoleLog, retryWithExponentialBackoff } from "./generalUtils";
28
+ import {
29
+ consoleLog,
30
+ customRpcCall,
31
+ retryWithExponentialBackoff,
32
+ } from "./generalUtils";
29
33
  import { PriorityFeeSetting, TransactionRunType } from "../types";
30
34
  import axios from "axios";
31
35
  import base58 from "bs58";
@@ -74,35 +78,47 @@ function parseJitoErrorMessage(message: string) {
74
78
 
75
79
  async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
76
80
  const simulationResult = await retryWithExponentialBackoff(async () => {
77
- const resp = await axios.post(
78
- umi.rpc.getEndpoint(),
81
+ const res = await customRpcCall(umi, "simulateBundle", [
79
82
  {
80
- jsonrpc: "2.0",
81
- id: 1,
82
- method: "simulateBundle",
83
- params: [
84
- {
85
- encodedTransactions: txs.map((x) =>
86
- Buffer.from(x.serialize()).toString("base64")
87
- ),
88
- },
89
- {
90
- encoding: "base64",
91
- commitment: "confirmed",
92
- preExecutionAccountsConfigs: txs.map((_) => {}),
93
- postExecutionAccountsConfigs: txs.map((_) => {}),
94
- skipSigVerify: true,
95
- },
96
- ],
83
+ encodedTransactions: txs.map((x) =>
84
+ Buffer.from(x.serialize()).toString("base64")
85
+ ),
97
86
  },
98
87
  {
99
- headers: {
100
- "Content-Type": "application/json",
101
- },
102
- }
103
- );
104
-
105
- const res = resp.data as any;
88
+ encoding: "base64",
89
+ commitment: "confirmed",
90
+ preExecutionAccountsConfigs: txs.map((_) => {}),
91
+ postExecutionAccountsConfigs: txs.map((_) => {}),
92
+ skipSigVerify: true,
93
+ },
94
+ ]);
95
+ // const resp = await axios.post(
96
+ // umi.rpc.getEndpoint(),
97
+ // {
98
+ // jsonrpc: "2.0",
99
+ // id: 1,
100
+ // method: "simulateBundle",
101
+ // params: [
102
+ // {
103
+ // encodedTransactions: txs.map((x) =>
104
+ // Buffer.from(x.serialize()).toString("base64")
105
+ // ),
106
+ // },
107
+ // {
108
+ // encoding: "base64",
109
+ // commitment: "confirmed",
110
+ // preExecutionAccountsConfigs: txs.map((_) => {}),
111
+ // postExecutionAccountsConfigs: txs.map((_) => {}),
112
+ // skipSigVerify: true,
113
+ // },
114
+ // ],
115
+ // },
116
+ // {
117
+ // headers: {
118
+ // "Content-Type": "application/json",
119
+ // },
120
+ // }
121
+ // );
106
122
 
107
123
  if (res.result && res.result.value && res.result.value.summary.failed) {
108
124
  const resValue = res.result.value;
@@ -191,17 +207,12 @@ async function umiToVersionedTransactions(
191
207
  }
192
208
 
193
209
  async function getBundleStatus(umi: Umi, bundleId: string) {
194
- const res = await axios.post(umi.rpc.getEndpoint(), {
195
- jsonrpc: "2.0",
196
- id: 1,
197
- method: "getBundleStatuses",
198
- params: [[bundleId]],
199
- });
200
- if (res.data.error) {
201
- throw new Error(`Failed to get bundle status: ${res.data.error}`);
210
+ const res = await customRpcCall(umi, "getBundleStatuses", [[bundleId]]);
211
+ if (res.error) {
212
+ throw new Error(`Failed to get bundle status: ${res.error}`);
202
213
  }
203
214
 
204
- return res.data.result;
215
+ return res.result;
205
216
  }
206
217
 
207
218
  async function pollBundleStatus(
@@ -317,7 +328,7 @@ export async function sendJitoBundledTransactions(
317
328
  );
318
329
 
319
330
  txs[0] = txs[0].prepend(getTipInstruction(userSigner, 150_000));
320
-
331
+
321
332
  const feeEstimates =
322
333
  priorityFeeSetting !== PriorityFeeSetting.None
323
334
  ? await Promise.all(
@@ -26,7 +26,7 @@ import {
26
26
  import { MarginfiAssetAccounts } from "../types/accounts";
27
27
  import { PositionState, PositionTokenUsage } from "../generated";
28
28
  import { USD_DECIMALS } from "../constants/generalAccounts";
29
- import { LivePositionUpdates } from "./solauto/generalUtils";
29
+ import { ContextUpdates } from "./solauto/generalUtils";
30
30
  import { ALL_SUPPORTED_TOKENS, TOKEN_INFO } from "../constants";
31
31
  import { fetchTokenPrices, safeGetPrice } from "./priceUtils";
32
32
 
@@ -296,7 +296,7 @@ export async function getMarginfiAccountPositionState(
296
296
  marginfiGroup?: PublicKey,
297
297
  supply?: BankSelection,
298
298
  debt?: BankSelection,
299
- livePositionUpdates?: LivePositionUpdates
299
+ contextUpdates?: ContextUpdates
300
300
  ): Promise<
301
301
  | { supplyBank: Bank | null; debtBank: Bank | null; state: PositionState }
302
302
  | undefined
@@ -381,7 +381,7 @@ export async function getMarginfiAccountPositionState(
381
381
  supplyBank!,
382
382
  true,
383
383
  bytesToI80F48(supplyBalances[0].assetShares.value),
384
- livePositionUpdates?.supplyAdjustment
384
+ contextUpdates?.supplyAdjustment
385
385
  );
386
386
  }
387
387
 
@@ -398,7 +398,7 @@ export async function getMarginfiAccountPositionState(
398
398
  debtBank!,
399
399
  false,
400
400
  bytesToI80F48(debtBalances[0].liabilityShares.value),
401
- livePositionUpdates?.debtAdjustment
401
+ contextUpdates?.debtAdjustment
402
402
  );
403
403
  }
404
404
  }
@@ -412,7 +412,7 @@ export async function getMarginfiAccountPositionState(
412
412
  supplyBank,
413
413
  true,
414
414
  0,
415
- livePositionUpdates?.supplyAdjustment
415
+ contextUpdates?.supplyAdjustment
416
416
  );
417
417
  }
418
418
 
@@ -440,7 +440,7 @@ export async function getMarginfiAccountPositionState(
440
440
  debtBank,
441
441
  false,
442
442
  0,
443
- livePositionUpdates?.debtAdjustment
443
+ contextUpdates?.debtAdjustment
444
444
  );
445
445
  }
446
446
 
@@ -36,6 +36,7 @@ import { getTokenAccount } from "./accountUtils";
36
36
  import {
37
37
  arraysAreEqual,
38
38
  consoleLog,
39
+ customRpcCall,
39
40
  retryWithExponentialBackoff,
40
41
  } from "./generalUtils";
41
42
  import {
@@ -292,17 +293,10 @@ export async function getQnComputeUnitPriceEstimate(
292
293
  programId: PublicKey,
293
294
  blockheight: number = 50
294
295
  ): Promise<any> {
295
- return (
296
- await axios.post(umi.rpc.getEndpoint(), {
297
- method: "qn_estimatePriorityFees",
298
- jsonrpc: "2.0",
299
- id: 1,
300
- params: {
301
- last_n_blocks: blockheight,
302
- account: programId.toString(),
303
- },
304
- })
305
- ).data;
296
+ return await customRpcCall(umi, "qn_estimatePriorityFees", {
297
+ last_n_blocks: blockheight,
298
+ account: programId.toString(),
299
+ });
306
300
  }
307
301
 
308
302
  export async function getComputeUnitPriceEstimate(
@@ -321,7 +315,7 @@ export async function getComputeUnitPriceEstimate(
321
315
 
322
316
  let feeEstimate: number | undefined;
323
317
  try {
324
- const resp = await umi.rpc.call("getPriorityFeeEstimate", [
318
+ const resp = await customRpcCall(umi, "getPriorityFeeEstimate", [
325
319
  {
326
320
  transaction: !useAccounts
327
321
  ? bs58.encode(web3Transaction.serialize())
@@ -332,10 +326,22 @@ export async function getComputeUnitPriceEstimate(
332
326
  },
333
327
  },
334
328
  ]);
329
+ // const resp = await umi.rpc.call("getPriorityFeeEstimate", [
330
+ // {
331
+ // transaction: !useAccounts
332
+ // ? bs58.encode(web3Transaction.serialize())
333
+ // : undefined,
334
+ // accountKeys: useAccounts ? accountKeys : undefined,
335
+ // options: {
336
+ // priorityLevel: prioritySetting.toString(),
337
+ // },
338
+ // },
339
+ // ]);
335
340
  feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
341
+ console.log(resp);
336
342
  } catch (e) {
337
343
  try {
338
- const resp = await umi.rpc.call("getPriorityFeeEstimate", [
344
+ const resp = await customRpcCall(umi, "getPriorityFeeEstimate", [
339
345
  {
340
346
  accountKeys,
341
347
  options: {
@@ -343,6 +349,14 @@ export async function getComputeUnitPriceEstimate(
343
349
  },
344
350
  },
345
351
  ]);
352
+ // const resp = await umi.rpc.call("getPriorityFeeEstimate", [
353
+ // {
354
+ // accountKeys,
355
+ // options: {
356
+ // priorityLevel: prioritySetting.toString(),
357
+ // },
358
+ // },
359
+ // ]);
346
360
  feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
347
361
  } catch (e) {
348
362
  // console.error(e);
@@ -408,7 +422,10 @@ export async function sendSingleOptimizedTransaction(
408
422
  consoleLog("Sending single optimized transaction...");
409
423
  consoleLog("Instructions: ", tx.getInstructions().length);
410
424
  consoleLog("Serialized transaction size: ", tx.getTransactionSize(umi));
411
- consoleLog("Programs: ", tx.getInstructions().map(x => x.programId));
425
+ consoleLog(
426
+ "Programs: ",
427
+ tx.getInstructions().map((x) => x.programId)
428
+ );
412
429
 
413
430
  const accounts = tx
414
431
  .getInstructions()
@@ -625,7 +625,7 @@ export function createSolautoSettings(
625
625
  };
626
626
  }
627
627
 
628
- type PositionAdjustment =
628
+ type ContextAdjustment =
629
629
  | { type: "supply"; value: bigint }
630
630
  | { type: "debt"; value: bigint }
631
631
  | { type: "settings"; value: SolautoSettingsParametersInpArgs }
@@ -634,7 +634,7 @@ type PositionAdjustment =
634
634
  | { type: "cancellingDca"; value: TokenType }
635
635
  | { type: "jupSwap", value: QuoteResponse };
636
636
 
637
- export class LivePositionUpdates {
637
+ export class ContextUpdates {
638
638
  public supplyAdjustment = BigInt(0);
639
639
  public debtAdjustment = BigInt(0);
640
640
  public settings: SolautoSettingsParameters | undefined = undefined;
@@ -643,7 +643,7 @@ export class LivePositionUpdates {
643
643
  public cancellingDca: TokenType | undefined = undefined;
644
644
  public jupSwap: QuoteResponse | undefined = undefined;
645
645
 
646
- new(update: PositionAdjustment) {
646
+ new(update: ContextAdjustment) {
647
647
  if (update.type === "supply") {
648
648
  this.supplyAdjustment += update.value;
649
649
  } else if (update.type === "debt") {
@@ -684,7 +684,7 @@ export class LivePositionUpdates {
684
684
  this.jupSwap = undefined;
685
685
  }
686
686
 
687
- hasUpdates(): boolean {
687
+ positionUpdates(): boolean {
688
688
  return (
689
689
  this.supplyAdjustment !== BigInt(0) ||
690
690
  this.debtAdjustment !== BigInt(0) ||
@@ -44,12 +44,12 @@ import { PriorityFeeSetting } from "../../src/types";
44
44
  import { buildIronforgeApiUrl, fromBaseUnit, tokenInfo, USD_DECIMALS } from "../../dist";
45
45
 
46
46
  describe("Solauto Marginfi tests", async () => {
47
- // const signer = setupTest();
48
- const signer = setupTest("solauto-manager");
47
+ const signer = setupTest();
48
+ // const signer = setupTest("solauto-manager");
49
49
 
50
- const payForTransactions = true;
51
- const testProgram = false;
52
- const positionId = 3;
50
+ const payForTransactions = false;
51
+ const testProgram = true;
52
+ const positionId = 1;
53
53
 
54
54
  it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
55
55
  const client = new SolautoMarginfiClient(
@@ -65,7 +65,7 @@ describe("Solauto Marginfi tests", async () => {
65
65
  await client.initialize({
66
66
  signer,
67
67
  positionId,
68
- authority: new PublicKey("FKYQs7KgRvaKQHxXwb8HKfoBcFdSxLL3JvHWpPdVQ16v"),
68
+ // authority: new PublicKey("FKYQs7KgRvaKQHxXwb8HKfoBcFdSxLL3JvHWpPdVQ16v"),
69
69
  // new: true,
70
70
  // marginfiAccount: new PublicKey(
71
71
  // ""
@@ -145,7 +145,7 @@ describe("Solauto Marginfi tests", async () => {
145
145
  transactionItems.push(
146
146
  new TransactionItem(
147
147
  async (attemptNum) =>
148
- await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
148
+ await buildSolautoRebalanceTransaction(client, 2000, attemptNum),
149
149
  "rebalance"
150
150
  )
151
151
  );