@haven-fi/solauto-sdk 1.0.344 → 1.0.346

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.
@@ -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.344",
3
+ "version": "1.0.346",
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",
@@ -24,7 +24,7 @@
24
24
  "@metaplex-foundation/umi-signer-wallet-adapters": "^0.9.1",
25
25
  "@metaplex-foundation/umi-web3js-adapters": "^0.9.1",
26
26
  "@solana/spl-token": "^0.4.0",
27
- "@solana/web3.js": "^1.95.4",
27
+ "@solana/web3.js": "=1.95.8",
28
28
  "@switchboard-xyz/on-demand": "^1.2.51",
29
29
  "axios": "^1.7.8",
30
30
  "bs58": "^5.0.0",
@@ -108,14 +108,14 @@ export async function getSwitchboardPrices(
108
108
  mints.map((x) => SWITCHBOARD_PRICE_FEED_IDS[x.toString()])
109
109
  );
110
110
 
111
- const prices = res.flatMap((x) => x.results[0]);
112
- if (prices.find((x) => !x || x === -Infinity)) {
111
+ const p = res.flatMap((x) => x.results[0]);
112
+ if (p.filter((x) => !x).length > 0) {
113
113
  throw new Error("Unable to fetch Switchboard prices");
114
114
  }
115
115
 
116
- return prices;
116
+ return p;
117
117
  },
118
- 8,
118
+ 5,
119
119
  250
120
120
  );
121
121
 
@@ -22,12 +22,14 @@ import {
22
22
  } from "../../src/transactions/transactionsManager";
23
23
  import { PublicKey } from "@solana/web3.js";
24
24
  import {
25
+ POPCAT,
25
26
  SOLAUTO_PROD_PROGRAM,
26
27
  SOLAUTO_TEST_PROGRAM,
27
28
  USDC,
28
29
  } from "../../src/constants";
29
30
  import {
30
31
  buildHeliusApiUrl,
32
+ fetchTokenPrices,
31
33
  positionStateWithLatestPrices,
32
34
  } from "../../src/utils";
33
35
  import { PriorityFeeSetting } from "../../src/types";
@@ -64,12 +66,7 @@ describe("Solauto Marginfi tests", async () => {
64
66
  // debtMint: new PublicKey(USDC),
65
67
  });
66
68
 
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));
69
+ console.log(await fetchTokenPrices([new PublicKey(POPCAT)]));
73
70
 
74
71
  const transactionItems: TransactionItem[] = [];
75
72
  // const settingParams: SolautoSettingsParametersInpArgs = {