@haven-fi/solauto-sdk 1.0.46 → 1.0.47
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.
|
@@ -62,7 +62,7 @@ function getDebtAdjustmentUsd(liqThresholdBps, supplyUsd, debtUsd, targetLiqUtil
|
|
|
62
62
|
}
|
|
63
63
|
exports.getDebtAdjustmentUsd = getDebtAdjustmentUsd;
|
|
64
64
|
function getMaxLiqUtilizationRate(maxLtvBps, liqThresholdBps) {
|
|
65
|
-
return toBps((fromBps(maxLtvBps) - 0.
|
|
65
|
+
return toBps((fromBps(maxLtvBps) - 0.02) / fromBps(liqThresholdBps)) - 1; // -1 to account for any rounding issues
|
|
66
66
|
}
|
|
67
67
|
exports.getMaxLiqUtilizationRate = getMaxLiqUtilizationRate;
|
|
68
68
|
function maxRepayFrom(maxLtvBps, liqThresholdBps) {
|
|
@@ -159,26 +159,9 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, simulateOnly,
|
|
|
159
159
|
console.log("Serialized transaction size: ", tx.getTransactionSize(umi));
|
|
160
160
|
const feeEstimate = await getComputeUnitPriceEstimate(umi, tx, attemptNum);
|
|
161
161
|
console.log("Compute unit price: ", feeEstimate);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// connection,
|
|
166
|
-
// toWeb3JsTransaction(
|
|
167
|
-
// await (
|
|
168
|
-
// await assembleFinalTransaction(
|
|
169
|
-
// umi.identity,
|
|
170
|
-
// tx,
|
|
171
|
-
// feeEstimate,
|
|
172
|
-
// 1_400_000
|
|
173
|
-
// ).setLatestBlockhash(umi)
|
|
174
|
-
// ).build(umi)
|
|
175
|
-
// )
|
|
176
|
-
// )
|
|
177
|
-
// );
|
|
178
|
-
// const computeUnitLimit = Math.round(
|
|
179
|
-
// simulationResult.value.unitsConsumed! * 1.1
|
|
180
|
-
// );
|
|
181
|
-
// console.log("Compute unit limit: ", computeUnitLimit);
|
|
162
|
+
const simulationResult = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await simulateTransaction(connection, (0, umi_web3js_adapters_1.toWeb3JsTransaction)(await (await assembleFinalTransaction(umi.identity, tx, feeEstimate, 1400000).setLatestBlockhash(umi)).build(umi))));
|
|
163
|
+
const computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.1);
|
|
164
|
+
console.log("Compute unit limit: ", computeUnitLimit);
|
|
182
165
|
if (!simulateOnly) {
|
|
183
166
|
const result = await assembleFinalTransaction(umi.identity, tx, feeEstimate, 800000).sendAndConfirm(umi, {
|
|
184
167
|
send: {
|
package/package.json
CHANGED
package/src/utils/numberUtils.ts
CHANGED
|
@@ -81,7 +81,7 @@ export function getMaxLiqUtilizationRate(
|
|
|
81
81
|
maxLtvBps: number,
|
|
82
82
|
liqThresholdBps: number
|
|
83
83
|
): number {
|
|
84
|
-
return toBps((fromBps(maxLtvBps) - 0.
|
|
84
|
+
return toBps((fromBps(maxLtvBps) - 0.02) / fromBps(liqThresholdBps)) - 1; // -1 to account for any rounding issues
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export function maxRepayFrom(maxLtvBps: number, liqThresholdBps: number) {
|
package/src/utils/solanaUtils.ts
CHANGED
|
@@ -288,27 +288,27 @@ export async function sendSingleOptimizedTransaction(
|
|
|
288
288
|
const feeEstimate = await getComputeUnitPriceEstimate(umi, tx, attemptNum);
|
|
289
289
|
console.log("Compute unit price: ", feeEstimate);
|
|
290
290
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
291
|
+
const simulationResult = await retryWithExponentialBackoff(
|
|
292
|
+
async () =>
|
|
293
|
+
await simulateTransaction(
|
|
294
|
+
connection,
|
|
295
|
+
toWeb3JsTransaction(
|
|
296
|
+
await (
|
|
297
|
+
await assembleFinalTransaction(
|
|
298
|
+
umi.identity,
|
|
299
|
+
tx,
|
|
300
|
+
feeEstimate,
|
|
301
|
+
1_400_000
|
|
302
|
+
).setLatestBlockhash(umi)
|
|
303
|
+
).build(umi)
|
|
304
|
+
)
|
|
305
|
+
)
|
|
306
|
+
);
|
|
307
307
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
308
|
+
const computeUnitLimit = Math.round(
|
|
309
|
+
simulationResult.value.unitsConsumed! * 1.1
|
|
310
|
+
);
|
|
311
|
+
console.log("Compute unit limit: ", computeUnitLimit);
|
|
312
312
|
|
|
313
313
|
if (!simulateOnly) {
|
|
314
314
|
const result = await assembleFinalTransaction(
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
SolautoSettingsParametersInpArgs,
|
|
10
10
|
} from "../../src/generated";
|
|
11
11
|
import { buildSolautoRebalanceTransaction } from "../../src/transactions/transactionUtils";
|
|
12
|
-
import { toBaseUnit } from "../../src/utils/numberUtils";
|
|
12
|
+
import { getMaxLiqUtilizationRate, toBaseUnit } from "../../src/utils/numberUtils";
|
|
13
13
|
import { NATIVE_MINT } from "@solana/spl-token";
|
|
14
14
|
import { getTokenPrices } from "../../src/utils/generalUtils";
|
|
15
15
|
import {
|
|
@@ -81,6 +81,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
81
81
|
// );
|
|
82
82
|
// }
|
|
83
83
|
|
|
84
|
+
// const maxLiqRate = getMaxLiqUtilizationRate(client.solautoPositionState!.maxLtvBps, client.solautoPositionState!.liqThresholdBps);
|
|
84
85
|
// transactionItems.push(
|
|
85
86
|
// new TransactionItem(
|
|
86
87
|
// async () => ({
|