@haven-fi/solauto-sdk 1.0.377 → 1.0.379

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.
@@ -23,7 +23,7 @@ function getLiqUtilzationRateBps(supplyUsd, debtUsd, liqThresholdBps) {
23
23
  }
24
24
  function toBaseUnit(value, decimals) {
25
25
  if (!decimals) {
26
- return BigInt(value);
26
+ return BigInt(Math.floor(value));
27
27
  }
28
28
  return BigInt(Math.round(value * Math.pow(10, decimals)));
29
29
  }
@@ -73,11 +73,11 @@ async function getSwitchboardPrices(mints) {
73
73
  prices = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
74
74
  const res = await crossbar.simulateSolanaFeeds("mainnet", mints.map((x) => switchboardConstants_1.SWITCHBOARD_PRICE_FEED_IDS[x.toString()]));
75
75
  const p = res.flatMap((x) => x.results[0]);
76
- if (p.filter((x) => !x).length > 0) {
76
+ if (p.filter((x) => !x || isNaN(Number(x))).length > 0) {
77
77
  throw new Error("Unable to fetch Switchboard prices");
78
78
  }
79
79
  return p;
80
- }, 4, 350);
80
+ }, 2, 350);
81
81
  }
82
82
  catch {
83
83
  (0, generalUtils_1.consoleLog)("Failed to fetch Switchboard prices after multiple retries");
@@ -85,7 +85,7 @@ async function getSwitchboardPrices(mints) {
85
85
  if (prices.length === 0) {
86
86
  prices = Array(mints.length).fill(0);
87
87
  }
88
- const missingPrices = (0, generalUtils_1.zip)(mints, prices).filter((x) => !x[1]);
88
+ const missingPrices = (0, generalUtils_1.zip)(mints, prices).filter((x) => !x[1] || isNaN(Number(x)));
89
89
  const jupPrices = (0, generalUtils_1.zip)(missingPrices.map((x) => x[0]), await getJupTokenPrices(missingPrices.map((x) => x[0])));
90
90
  prices = prices.map((x, i) => x ? x : jupPrices.find((y) => y[0].toString() === mints[i].toString())[1]);
91
91
  return prices;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.377",
3
+ "version": "1.0.379",
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",
@@ -15,7 +15,7 @@ export function getLiqUtilzationRateBps(
15
15
 
16
16
  export function toBaseUnit(value: number, decimals: number): bigint {
17
17
  if (!decimals) {
18
- return BigInt(value);
18
+ return BigInt(Math.floor(value));
19
19
  }
20
20
  return BigInt(Math.round(value * Math.pow(10, decimals)));
21
21
  }
@@ -112,13 +112,13 @@ export async function getSwitchboardPrices(
112
112
  );
113
113
 
114
114
  const p = res.flatMap((x) => x.results[0]);
115
- if (p.filter((x) => !x).length > 0) {
115
+ if (p.filter((x) => !x || isNaN(Number(x))).length > 0) {
116
116
  throw new Error("Unable to fetch Switchboard prices");
117
117
  }
118
118
 
119
119
  return p;
120
120
  },
121
- 4,
121
+ 2,
122
122
  350
123
123
  );
124
124
  } catch {
@@ -129,7 +129,7 @@ export async function getSwitchboardPrices(
129
129
  prices = Array(mints.length).fill(0);
130
130
  }
131
131
 
132
- const missingPrices = zip(mints, prices).filter((x) => !x[1]);
132
+ const missingPrices = zip(mints, prices).filter((x) => !x[1] || isNaN(Number(x)));
133
133
  const jupPrices = zip(
134
134
  missingPrices.map((x) => x[0]),
135
135
  await getJupTokenPrices(missingPrices.map((x) => x[0]))
@@ -22,11 +22,12 @@ import {
22
22
  } from "../../src/transactions/transactionsManager";
23
23
  import { PublicKey } from "@solana/web3.js";
24
24
  import {
25
+ HMTR,
25
26
  SOLAUTO_PROD_PROGRAM,
26
27
  SOLAUTO_TEST_PROGRAM,
27
28
  USDC,
28
29
  } from "../../src/constants";
29
- import { buildHeliusApiUrl, getAllPositionsByAuthority, getSolautoManagedPositions } from "../../src/utils";
30
+ import { buildHeliusApiUrl, getAllPositionsByAuthority, getJupTokenPrices, getSolautoManagedPositions } from "../../src/utils";
30
31
  import { PriorityFeeSetting } from "../../src/types";
31
32
  import { buildIronforgeApiUrl, TransactionManagerStatuses } from "../../dist";
32
33
  import { connect } from "http2";
@@ -64,6 +65,8 @@ describe("Solauto Marginfi tests", async () => {
64
65
  // // debtMint: new PublicKey(USDC),
65
66
  // });
66
67
 
68
+ console.log(await getJupTokenPrices([new PublicKey(HMTR)]));
69
+
67
70
  const transactionItems: TransactionItem[] = [];
68
71
  // const settingParams: SolautoSettingsParametersInpArgs = {
69
72
  // boostToBps: maxBoostToBps(