@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.
- package/dist/constants/marginfiAccounts.js +14 -14
- package/dist/constants/tokenConstants.js +1 -1
- package/dist/utils/priceUtils.js +3 -3
- package/package.json +1 -1
- package/src/constants/marginfiAccounts.ts +14 -14
- package/src/constants/tokenConstants.ts +1 -1
- package/src/utils/priceUtils.ts +3 -3
- package/tests/transactions/solautoMarginfi.ts +4 -1
@@ -190,19 +190,19 @@ exports.MARGINFI_ACCOUNTS = {
|
|
190
190
|
priceOracle: USDC_PRICE_ORACLE,
|
191
191
|
},
|
192
192
|
},
|
193
|
-
["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
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";
|
package/dist/utils/priceUtils.js
CHANGED
@@ -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
|
-
},
|
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
@@ -172,20 +172,20 @@ export const MARGINFI_ACCOUNTS: {
|
|
172
172
|
priceOracle: USDC_PRICE_ORACLE,
|
173
173
|
},
|
174
174
|
},
|
175
|
-
["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
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 =
|
package/src/utils/priceUtils.ts
CHANGED
@@ -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
|
-
|
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(
|