@haven-fi/solauto-sdk 1.0.163 → 1.0.165
Sign up to get free protection for your applications and to get access to all the features.
@@ -53,8 +53,8 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
53
53
|
this.supplyPriceOracle = new web3_js_1.PublicKey(this.marginfiSupplyAccounts.priceOracle);
|
54
54
|
this.debtPriceOracle = new web3_js_1.PublicKey(this.marginfiDebtAccounts.priceOracle);
|
55
55
|
if (!this.solautoPositionState) {
|
56
|
-
const
|
57
|
-
this.solautoPositionState = (0, utils_1.createFakePositionState)({ mint: this.supplyMint }, { mint: this.debtMint }, (0, numberUtils_1.toBps)(
|
56
|
+
const result = await this.maxLtvAndLiqThreshold();
|
57
|
+
this.solautoPositionState = (0, utils_1.createFakePositionState)({ mint: this.supplyMint }, { mint: this.debtMint }, result ? (0, numberUtils_1.toBps)(result[0]) : 0, result ? (0, numberUtils_1.toBps)(result[1]) : 0);
|
58
58
|
}
|
59
59
|
if (!this.initialized) {
|
60
60
|
await this.setIntermediaryMarginfiDetails();
|
@@ -101,10 +101,10 @@ function getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, offsetFromMaxLt
|
|
101
101
|
return toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) - 1; // -1 to account for any rounding issues
|
102
102
|
}
|
103
103
|
function maxRepayFromBps(maxLtvBps, liqThresholdBps) {
|
104
|
-
return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.
|
104
|
+
return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.01));
|
105
105
|
}
|
106
106
|
function maxRepayToBps(maxLtvBps, liqThresholdBps) {
|
107
|
-
return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MIN_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.
|
107
|
+
return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MIN_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01));
|
108
108
|
}
|
109
109
|
function maxBoostToBps(maxLtvBps, liqThresholdBps) {
|
110
110
|
return Math.min(maxRepayToBps(maxLtvBps, liqThresholdBps), getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01));
|
package/package.json
CHANGED
@@ -133,12 +133,12 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
133
133
|
this.debtPriceOracle = new PublicKey(this.marginfiDebtAccounts.priceOracle);
|
134
134
|
|
135
135
|
if (!this.solautoPositionState) {
|
136
|
-
const
|
136
|
+
const result = await this.maxLtvAndLiqThreshold()!;
|
137
137
|
this.solautoPositionState = createFakePositionState(
|
138
138
|
{ mint: this.supplyMint },
|
139
139
|
{ mint: this.debtMint },
|
140
|
-
toBps(
|
141
|
-
toBps(
|
140
|
+
result ? toBps(result[0]) : 0,
|
141
|
+
result ? toBps(result[1]) : 0
|
142
142
|
);
|
143
143
|
}
|
144
144
|
|
package/src/utils/numberUtils.ts
CHANGED
@@ -139,14 +139,14 @@ export function getMaxLiqUtilizationRateBps(
|
|
139
139
|
export function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number) {
|
140
140
|
return Math.min(
|
141
141
|
9000,
|
142
|
-
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.
|
142
|
+
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.01)
|
143
143
|
);
|
144
144
|
}
|
145
145
|
|
146
146
|
export function maxRepayToBps(maxLtvBps: number, liqThresholdBps: number) {
|
147
147
|
return Math.min(
|
148
148
|
maxRepayFromBps(maxLtvBps, liqThresholdBps) - MIN_REPAY_GAP_BPS,
|
149
|
-
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.
|
149
|
+
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01)
|
150
150
|
);
|
151
151
|
}
|
152
152
|
|
@@ -21,10 +21,10 @@ import { USDC_MINT } from "../../src/constants";
|
|
21
21
|
import { buildHeliusApiUrl } from "../../src/utils";
|
22
22
|
|
23
23
|
describe("Solauto Marginfi tests", async () => {
|
24
|
-
const signer = setupTest();
|
25
|
-
|
24
|
+
// const signer = setupTest();
|
25
|
+
const signer = setupTest("solauto-manager");
|
26
26
|
|
27
|
-
const payForTransactions =
|
27
|
+
const payForTransactions = false;
|
28
28
|
const useJitoBundle = false;
|
29
29
|
const positionId = 1;
|
30
30
|
|
@@ -124,7 +124,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
124
124
|
transactionItems.push(
|
125
125
|
new TransactionItem(
|
126
126
|
async (attemptNum) =>
|
127
|
-
await buildSolautoRebalanceTransaction(client,
|
127
|
+
await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
|
128
128
|
"rebalance"
|
129
129
|
)
|
130
130
|
);
|