@haven-fi/solauto-sdk 1.0.378 → 1.0.380

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.
@@ -190,19 +190,19 @@ exports.MARGINFI_ACCOUNTS = {
190
190
  priceOracle: USDC_PRICE_ORACLE,
191
191
  },
192
192
  },
193
- ["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
194
- [tokens.HMTR]: {
195
- bank: "Br3yzg2WSb81RaFWK9UsKtq8fD5viwooZG34mKqQWxdM",
196
- liquidityVault: "J45Je52qv2rDBuCQWPwp3bjRhf3bGzRWhKZtGDuLooCX",
197
- vaultAuthority: "CKDsAKjNruDSz4tmUairh8PDGD1Rqh9WMTLWERYnnZrH",
198
- priceOracle: switchboardConstants_1.SWITCHBOARD_PRICE_FEED_IDS[tokens.HMTR.toString()],
199
- },
200
- [tokens.USDC]: {
201
- bank: "9yNnhJ8c1vGbu3DMf6eeeUi6TDJ2ddGgaRA88rL2R3rP",
202
- liquidityVault: "4U1UBjXrPrW7JuQ894JbLUBqcb5LFfK9rfkWFwT7EdQ9",
203
- vaultAuthority: "CY74V1r48kuuHA6APD3AaU2oPV1mBqe9srikrQQSHNR6",
204
- priceOracle: USDC_PRICE_ORACLE,
205
- }
206
- }
193
+ // ["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
194
+ // [tokens.HMTR]: {
195
+ // bank: "Br3yzg2WSb81RaFWK9UsKtq8fD5viwooZG34mKqQWxdM",
196
+ // liquidityVault: "J45Je52qv2rDBuCQWPwp3bjRhf3bGzRWhKZtGDuLooCX",
197
+ // vaultAuthority: "CKDsAKjNruDSz4tmUairh8PDGD1Rqh9WMTLWERYnnZrH",
198
+ // priceOracle: SWITCHBOARD_PRICE_FEED_IDS[tokens.HMTR.toString()],
199
+ // },
200
+ // [tokens.USDC]: {
201
+ // bank: "9yNnhJ8c1vGbu3DMf6eeeUi6TDJ2ddGgaRA88rL2R3rP",
202
+ // liquidityVault: "4U1UBjXrPrW7JuQ894JbLUBqcb5LFfK9rfkWFwT7EdQ9",
203
+ // vaultAuthority: "CY74V1r48kuuHA6APD3AaU2oPV1mBqe9srikrQQSHNR6",
204
+ // priceOracle: USDC_PRICE_ORACLE,
205
+ // }
206
+ // }
207
207
  };
208
208
  exports.MARGINFI_ACCOUNTS_LOOKUP_TABLE = "GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
@@ -49,7 +49,7 @@ exports.ALL_SUPPORTED_TOKENS = [
49
49
  exports.POPCAT,
50
50
  exports.RETARDIO,
51
51
  exports.BILLY,
52
- exports.HMTR,
52
+ // HMTR,
53
53
  ];
54
54
  exports.TOKEN_INFO = {
55
55
  [web3_js_1.PublicKey.default.toString()]: {
@@ -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.378",
3
+ "version": "1.0.380",
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",
@@ -172,20 +172,20 @@ export const MARGINFI_ACCOUNTS: {
172
172
  priceOracle: USDC_PRICE_ORACLE,
173
173
  },
174
174
  },
175
- ["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
176
- [tokens.HMTR]: {
177
- bank: "Br3yzg2WSb81RaFWK9UsKtq8fD5viwooZG34mKqQWxdM",
178
- liquidityVault: "J45Je52qv2rDBuCQWPwp3bjRhf3bGzRWhKZtGDuLooCX",
179
- vaultAuthority: "CKDsAKjNruDSz4tmUairh8PDGD1Rqh9WMTLWERYnnZrH",
180
- priceOracle: SWITCHBOARD_PRICE_FEED_IDS[tokens.HMTR.toString()],
181
- },
182
- [tokens.USDC]: {
183
- bank: "9yNnhJ8c1vGbu3DMf6eeeUi6TDJ2ddGgaRA88rL2R3rP",
184
- liquidityVault: "4U1UBjXrPrW7JuQ894JbLUBqcb5LFfK9rfkWFwT7EdQ9",
185
- vaultAuthority: "CY74V1r48kuuHA6APD3AaU2oPV1mBqe9srikrQQSHNR6",
186
- priceOracle: USDC_PRICE_ORACLE,
187
- }
188
- }
175
+ // ["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
176
+ // [tokens.HMTR]: {
177
+ // bank: "Br3yzg2WSb81RaFWK9UsKtq8fD5viwooZG34mKqQWxdM",
178
+ // liquidityVault: "J45Je52qv2rDBuCQWPwp3bjRhf3bGzRWhKZtGDuLooCX",
179
+ // vaultAuthority: "CKDsAKjNruDSz4tmUairh8PDGD1Rqh9WMTLWERYnnZrH",
180
+ // priceOracle: SWITCHBOARD_PRICE_FEED_IDS[tokens.HMTR.toString()],
181
+ // },
182
+ // [tokens.USDC]: {
183
+ // bank: "9yNnhJ8c1vGbu3DMf6eeeUi6TDJ2ddGgaRA88rL2R3rP",
184
+ // liquidityVault: "4U1UBjXrPrW7JuQ894JbLUBqcb5LFfK9rfkWFwT7EdQ9",
185
+ // vaultAuthority: "CY74V1r48kuuHA6APD3AaU2oPV1mBqe9srikrQQSHNR6",
186
+ // priceOracle: USDC_PRICE_ORACLE,
187
+ // }
188
+ // }
189
189
  };
190
190
 
191
191
  export const MARGINFI_ACCOUNTS_LOOKUP_TABLE =
@@ -48,7 +48,7 @@ export const ALL_SUPPORTED_TOKENS = [
48
48
  POPCAT,
49
49
  RETARDIO,
50
50
  BILLY,
51
- HMTR,
51
+ // HMTR,
52
52
  ];
53
53
 
54
54
  interface TokenInfo {
@@ -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(