@haven-fi/solauto-sdk 1.0.345 → 1.0.347

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":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAW7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AA0FD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;I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AAC,MAAM,CAAC;IACf,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,aAAa,CAAC;IACtB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;IAXpB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,SAAS,EAAE,aAAa,GAAG,oBAAoB,EAC/C,cAAc,CAAC,GAAE,CAAC,QAAQ,EAAE,0BAA0B,KAAK,IAAI,aAAA,EAC/D,MAAM,CAAC,EAAE,kBAAkB,YAAA,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,UAAU,GAAE,OAAe,EAC3B,aAAa,CAAC,EAAE,aAAa,YAAA,EAC7B,OAAO,GAAE,MAAU,EACnB,UAAU,GAAE,MAAY;YAQpB,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA6CN,aAAa;IAoB3B,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,mBAAmB;YAoBb,SAAS;IAiBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IA4FzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YAmCxB,6BAA6B;YAgG7B,qBAAqB;YAuDrB,cAAc;YAqCd,eAAe;CAoD9B"}
@@ -251,7 +251,7 @@ class TransactionsManager {
251
251
  }
252
252
  async updateLut(tx, newLut) {
253
253
  const updateLutTxName = `${newLut ? "create" : "update"} lookup table`;
254
- await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum, prevError) => await this.sendTransaction(tx, updateLutTxName, attemptNum, this.getUpdatedPriorityFeeSetting(prevError, attemptNum)), 3, 150, this.errorsToThrow);
254
+ await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum, prevError) => await this.sendTransaction(tx, updateLutTxName, attemptNum, this.getUpdatedPriorityFeeSetting(prevError, attemptNum), "skip-simulation"), 3, 150, this.errorsToThrow);
255
255
  }
256
256
  async clientSend(transactions) {
257
257
  const items = [...transactions];
@@ -415,10 +415,10 @@ class TransactionsManager {
415
415
  }
416
416
  return newItemSets[0];
417
417
  }
418
- async sendTransaction(tx, txName, attemptNum, priorityFeeSetting) {
418
+ async sendTransaction(tx, txName, attemptNum, priorityFeeSetting, txType) {
419
419
  this.updateStatus(txName, TransactionStatus.Processing, attemptNum);
420
420
  try {
421
- const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.txType, priorityFeeSetting, () => this.updateStatus(txName, TransactionStatus.Processing, attemptNum, undefined, true));
421
+ const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, txType ?? this.txType, priorityFeeSetting, () => this.updateStatus(txName, TransactionStatus.Processing, attemptNum, undefined, true));
422
422
  this.updateStatus(txName, TransactionStatus.Successful, attemptNum, txSig ? bs58_1.default.encode(txSig) : undefined);
423
423
  }
424
424
  catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"priceUtils.d.ts","sourceRoot":"","sources":["../../src/utils/priceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAarE,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqC5E;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,qBAwCrD;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAmCnB;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,qBAoBzD;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GACzC,MAAM,GAAG,SAAS,CAKpB"}
1
+ {"version":3,"file":"priceUtils.d.ts","sourceRoot":"","sources":["../../src/utils/priceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAYrE,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqC5E;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,qBAwCrD;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAmCnB;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,qBAoBzD;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GACzC,MAAM,GAAG,SAAS,CAKpB"}
@@ -70,12 +70,12 @@ async function getSwitchboardPrices(mints) {
70
70
  const crossbar = new on_demand_1.CrossbarClient("https://crossbar.switchboard.xyz");
71
71
  let prices = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
72
72
  const res = await crossbar.simulateSolanaFeeds("mainnet", mints.map((x) => switchboardConstants_1.SWITCHBOARD_PRICE_FEED_IDS[x.toString()]));
73
- const prices = res.flatMap((x) => x.results[0]);
74
- if (prices.find((x) => !x || x === -Infinity)) {
73
+ const p = res.flatMap((x) => x.results[0]);
74
+ if (p.filter((x) => !x).length > 0) {
75
75
  throw new Error("Unable to fetch Switchboard prices");
76
76
  }
77
- return prices;
78
- }, 8, 250);
77
+ return p;
78
+ }, 5, 250);
79
79
  const missingPrices = (0, generalUtils_1.zip)(mints, prices).filter((x) => !x[1]);
80
80
  const jupPrices = (0, generalUtils_1.zip)(missingPrices.map((x) => x[0]), await getJupTokenPrices(missingPrices.map((x) => x[0])));
81
81
  prices = prices.map((x, i) => x ? x : jupPrices.find((y) => y[0].toString() === mints[i].toString())[1]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.345",
3
+ "version": "1.0.347",
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",
@@ -387,7 +387,8 @@ export class TransactionsManager {
387
387
  tx,
388
388
  updateLutTxName,
389
389
  attemptNum,
390
- this.getUpdatedPriorityFeeSetting(prevError, attemptNum)
390
+ this.getUpdatedPriorityFeeSetting(prevError, attemptNum),
391
+ "skip-simulation"
391
392
  ),
392
393
  3,
393
394
  150,
@@ -718,7 +719,8 @@ export class TransactionsManager {
718
719
  tx: TransactionBuilder,
719
720
  txName: string,
720
721
  attemptNum: number,
721
- priorityFeeSetting?: PriorityFeeSetting
722
+ priorityFeeSetting?: PriorityFeeSetting,
723
+ txType?: TransactionRunType
722
724
  ) {
723
725
  this.updateStatus(txName, TransactionStatus.Processing, attemptNum);
724
726
  try {
@@ -726,7 +728,7 @@ export class TransactionsManager {
726
728
  this.txHandler.umi,
727
729
  this.txHandler.connection,
728
730
  tx,
729
- this.txType,
731
+ txType ?? this.txType,
730
732
  priorityFeeSetting,
731
733
  () =>
732
734
  this.updateStatus(
@@ -5,7 +5,6 @@ import { fromBaseUnit, toBaseUnit } from "./numberUtils";
5
5
  import { PRICES } from "../constants/solautoConstants";
6
6
  import { SWITCHBOARD_PRICE_FEED_IDS } from "../constants/switchboardConstants";
7
7
  import {
8
- consoleLog,
9
8
  currentUnixSeconds,
10
9
  retryWithExponentialBackoff,
11
10
  zip,
@@ -108,14 +107,14 @@ export async function getSwitchboardPrices(
108
107
  mints.map((x) => SWITCHBOARD_PRICE_FEED_IDS[x.toString()])
109
108
  );
110
109
 
111
- const prices = res.flatMap((x) => x.results[0]);
112
- if (prices.find((x) => !x || x === -Infinity)) {
110
+ const p = res.flatMap((x) => x.results[0]);
111
+ if (p.filter((x) => !x).length > 0) {
113
112
  throw new Error("Unable to fetch Switchboard prices");
114
113
  }
115
114
 
116
- return prices;
115
+ return p;
117
116
  },
118
- 8,
117
+ 5,
119
118
  250
120
119
  );
121
120
 
@@ -28,13 +28,12 @@ import {
28
28
  } from "../../src/constants";
29
29
  import {
30
30
  buildHeliusApiUrl,
31
- positionStateWithLatestPrices,
32
31
  } from "../../src/utils";
33
32
  import { PriorityFeeSetting } from "../../src/types";
34
33
 
35
34
  describe("Solauto Marginfi tests", async () => {
36
- // const signer = setupTest();
37
- const signer = setupTest("solauto-manager");
35
+ const signer = setupTest();
36
+ // const signer = setupTest("solauto-manager");
38
37
 
39
38
  const payForTransactions = true;
40
39
  const testProgram = false;
@@ -54,7 +53,7 @@ describe("Solauto Marginfi tests", async () => {
54
53
  await client.initialize({
55
54
  signer,
56
55
  positionId,
57
- authority: new PublicKey("5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe"),
56
+ authority: new PublicKey("rC5dMP5dmSsfQ66rynzfFzuc122Eex9h1RJHVDkeH6D"),
58
57
  // new: true,
59
58
  // marginfiAccount: new PublicKey(
60
59
  // "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
@@ -64,13 +63,6 @@ describe("Solauto Marginfi tests", async () => {
64
63
  // debtMint: new PublicKey(USDC),
65
64
  });
66
65
 
67
- const data = client.solautoPositionData;
68
- console.log(data);
69
- console.log(data?.state.supply.amountCanBeUsed);
70
- console.log(data?.state.debt.amountCanBeUsed);
71
-
72
- console.log(await positionStateWithLatestPrices(data!.state));
73
-
74
66
  const transactionItems: TransactionItem[] = [];
75
67
  // const settingParams: SolautoSettingsParametersInpArgs = {
76
68
  // boostToBps: maxBoostToBps(
@@ -129,13 +121,13 @@ describe("Solauto Marginfi tests", async () => {
129
121
  // )
130
122
  // );
131
123
 
132
- // transactionItems.push(
133
- // new TransactionItem(
134
- // async (attemptNum) =>
135
- // await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
136
- // "rebalance"
137
- // )
138
- // );
124
+ transactionItems.push(
125
+ new TransactionItem(
126
+ async (attemptNum) =>
127
+ await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
128
+ "rebalance"
129
+ )
130
+ );
139
131
 
140
132
  // transactionItems.push(
141
133
  // new TransactionItem(
@@ -165,14 +157,14 @@ describe("Solauto Marginfi tests", async () => {
165
157
  // )
166
158
  // );
167
159
 
168
- // const statuses = await new TransactionsManager(
169
- // client,
170
- // undefined,
171
- // !payForTransactions ? "only-simulate" : "normal",
172
- // PriorityFeeSetting.Low,
173
- // true
174
- // ).clientSend(transactionItems);
160
+ const statuses = await new TransactionsManager(
161
+ client,
162
+ undefined,
163
+ !payForTransactions ? "only-simulate" : "normal",
164
+ PriorityFeeSetting.Low,
165
+ true
166
+ ).clientSend(transactionItems);
175
167
 
176
- // console.log(statuses);
168
+ console.log(statuses);
177
169
  });
178
170
  });