@haven-fi/solauto-sdk 1.0.45 → 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.
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +2 -2
- package/dist/utils/numberUtils.js +1 -1
- package/dist/utils/solanaUtils.js +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +1 -1
- package/package.json +1 -1
- package/src/transactions/transactionUtils.ts +2 -4
- package/src/utils/numberUtils.ts +1 -1
- package/src/utils/solanaUtils.ts +1 -1
- package/src/utils/solauto/rebalanceUtils.ts +1 -1
- package/tests/transactions/solautoMarginfi.ts +11 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAqMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAqMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CAgHA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CA8BzC"}
|
|
@@ -120,8 +120,8 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
|
|
|
120
120
|
const checkSolautoFeesTa = usesAccount(client.solautoFeesSupplyTa);
|
|
121
121
|
const checkIntermediaryMfiAccount = client.lendingPlatform === generated_1.LendingPlatform.Marginfi &&
|
|
122
122
|
usesAccount(client.intermediaryMarginfiAccountPk);
|
|
123
|
-
const checkSignerSupplyTa =
|
|
124
|
-
const checkSignerDebtTa =
|
|
123
|
+
const checkSignerSupplyTa = usesAccount(client.signerSupplyTa);
|
|
124
|
+
const checkSignerDebtTa = usesAccount(client.signerDebtTa);
|
|
125
125
|
const accountsNeeded = [
|
|
126
126
|
...[checkReferralSupplyTa ? client.referredBySupplyTa : web3_js_1.PublicKey.default],
|
|
127
127
|
...[checkSolautoFeesTa ? client.solautoFeesSupplyTa : web3_js_1.PublicKey.default],
|
|
@@ -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) {
|
|
@@ -163,7 +163,7 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, simulateOnly,
|
|
|
163
163
|
const computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.1);
|
|
164
164
|
console.log("Compute unit limit: ", computeUnitLimit);
|
|
165
165
|
if (!simulateOnly) {
|
|
166
|
-
const result = await assembleFinalTransaction(umi.identity, tx, feeEstimate,
|
|
166
|
+
const result = await assembleFinalTransaction(umi.identity, tx, feeEstimate, 800000).sendAndConfirm(umi, {
|
|
167
167
|
send: {
|
|
168
168
|
skipPreflight: true,
|
|
169
169
|
commitment: "finalized",
|
|
@@ -187,7 +187,7 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
|
|
|
187
187
|
outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint),
|
|
188
188
|
destinationWallet: client.solautoPosition,
|
|
189
189
|
// slippageBpsIncFactor: (!values.increasingLeverage ? 0.1 : 0) + ((attemptNum ?? 0) * 0.15),
|
|
190
|
-
slippageBpsIncFactor: (attemptNum ?? 0) * 0.
|
|
190
|
+
slippageBpsIncFactor: (attemptNum ?? 0) * 0.2,
|
|
191
191
|
amount: rebalancingToZero
|
|
192
192
|
? client.solautoPositionState.debt.amountUsed.baseUnit +
|
|
193
193
|
BigInt(Math.round(Number(client.solautoPositionState.debt.amountUsed.baseUnit) *
|
package/package.json
CHANGED
|
@@ -245,10 +245,8 @@ export async function rebalanceChoresBefore(
|
|
|
245
245
|
usesAccount(
|
|
246
246
|
(client as SolautoMarginfiClient).intermediaryMarginfiAccountPk
|
|
247
247
|
);
|
|
248
|
-
const checkSignerSupplyTa =
|
|
249
|
-
|
|
250
|
-
const checkSignerDebtTa =
|
|
251
|
-
client.selfManaged && usesAccount(client.signerSupplyTa);
|
|
248
|
+
const checkSignerSupplyTa = usesAccount(client.signerSupplyTa);
|
|
249
|
+
const checkSignerDebtTa = usesAccount(client.signerDebtTa);
|
|
252
250
|
|
|
253
251
|
const accountsNeeded = [
|
|
254
252
|
...[checkReferralSupplyTa ? client.referredBySupplyTa : PublicKey.default],
|
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
|
@@ -343,7 +343,7 @@ export function getJupSwapRebalanceDetails(
|
|
|
343
343
|
outputMint: toWeb3JsPublicKey(output.mint),
|
|
344
344
|
destinationWallet: client.solautoPosition,
|
|
345
345
|
// slippageBpsIncFactor: (!values.increasingLeverage ? 0.1 : 0) + ((attemptNum ?? 0) * 0.15),
|
|
346
|
-
slippageBpsIncFactor: (attemptNum ?? 0) * 0.
|
|
346
|
+
slippageBpsIncFactor: (attemptNum ?? 0) * 0.2,
|
|
347
347
|
amount: rebalancingToZero
|
|
348
348
|
? client.solautoPositionState!.debt.amountUsed.baseUnit +
|
|
349
349
|
BigInt(
|
|
@@ -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 {
|
|
@@ -21,10 +21,11 @@ import { USDC_MINT } from "../../src/constants";
|
|
|
21
21
|
|
|
22
22
|
describe("Solauto Marginfi tests", async () => {
|
|
23
23
|
const signer = setupTest();
|
|
24
|
+
// const signer = setupTest("solauto-manager");
|
|
24
25
|
|
|
25
26
|
const payForTransactions = false;
|
|
26
27
|
const useJitoBundle = false;
|
|
27
|
-
const positionId =
|
|
28
|
+
const positionId = 1;
|
|
28
29
|
|
|
29
30
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
|
30
31
|
const client = new SolautoMarginfiClient(process.env.HELIUS_API_KEY!, true);
|
|
@@ -37,11 +38,12 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
37
38
|
{
|
|
38
39
|
signer,
|
|
39
40
|
positionId,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
authority: new PublicKey("AprYCPiVeKMCgjQ2ZufwChMzvQ5kFjJo2ekTLSkXsQDm")
|
|
42
|
+
// marginfiAccount: new PublicKey(
|
|
43
|
+
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
|
44
|
+
// ),
|
|
45
|
+
// supplyMint: NATIVE_MINT,
|
|
46
|
+
// debtMint: new PublicKey(USDC_MINT),
|
|
45
47
|
}
|
|
46
48
|
);
|
|
47
49
|
|
|
@@ -79,6 +81,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
79
81
|
// );
|
|
80
82
|
// }
|
|
81
83
|
|
|
84
|
+
// const maxLiqRate = getMaxLiqUtilizationRate(client.solautoPositionState!.maxLtvBps, client.solautoPositionState!.liqThresholdBps);
|
|
82
85
|
// transactionItems.push(
|
|
83
86
|
// new TransactionItem(
|
|
84
87
|
// async () => ({
|
|
@@ -115,7 +118,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
115
118
|
transactionItems.push(
|
|
116
119
|
new TransactionItem(
|
|
117
120
|
async (attemptNum) =>
|
|
118
|
-
await buildSolautoRebalanceTransaction(client,
|
|
121
|
+
await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
|
|
119
122
|
"rebalance"
|
|
120
123
|
)
|
|
121
124
|
);
|