@haven-fi/solauto-sdk 1.0.127 → 1.0.128
Sign up to get free protection for your applications and to get access to all the features.
@@ -211,13 +211,13 @@ class TransactionsManager {
|
|
211
211
|
choresBefore.prepend(updateLookupTable.updateLutTx);
|
212
212
|
}
|
213
213
|
if (choresBefore.getInstructions().length > 0) {
|
214
|
-
const chore = new TransactionItem(async () => ({ tx: choresBefore })
|
214
|
+
const chore = new TransactionItem(async () => ({ tx: choresBefore }));
|
215
215
|
await chore.initialize();
|
216
216
|
items.unshift(chore);
|
217
217
|
this.txHandler.log("Chores before: ", choresBefore.getInstructions().length);
|
218
218
|
}
|
219
219
|
if (choresAfter.getInstructions().length > 0) {
|
220
|
-
const chore = new TransactionItem(async () => ({ tx: choresAfter }));
|
220
|
+
const chore = new TransactionItem(async () => ({ tx: choresAfter }), "closing temp accounts");
|
221
221
|
await chore.initialize();
|
222
222
|
items.push(chore);
|
223
223
|
this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
|
@@ -69,9 +69,9 @@ function getDebtAdjustmentUsd(liqThresholdBps, supplyUsd, debtUsd, targetLiqUtil
|
|
69
69
|
function getSolautoFeesBps(isReferred, targetLiqUtilizationRateBps, positionNetWorthUsd) {
|
70
70
|
const minSize = 10000; // Minimum position size
|
71
71
|
const maxSize = 500000; // Maximum position size
|
72
|
-
const maxFeeBps =
|
72
|
+
const maxFeeBps = 200; // Fee in basis points for minSize (2%)
|
73
73
|
const minFeeBps = 50; // Fee in basis points for maxSize (0.5%)
|
74
|
-
const k =
|
74
|
+
const k = 1.5;
|
75
75
|
let feeBps = 0;
|
76
76
|
if (targetLiqUtilizationRateBps !== undefined) {
|
77
77
|
feeBps = minFeeBps;
|
package/package.json
CHANGED
@@ -320,10 +320,7 @@ export class TransactionsManager {
|
|
320
320
|
choresBefore.prepend(updateLookupTable.updateLutTx);
|
321
321
|
}
|
322
322
|
if (choresBefore.getInstructions().length > 0) {
|
323
|
-
const chore = new TransactionItem(
|
324
|
-
async () => ({ tx: choresBefore }),
|
325
|
-
"create account(s)"
|
326
|
-
);
|
323
|
+
const chore = new TransactionItem(async () => ({ tx: choresBefore }));
|
327
324
|
await chore.initialize();
|
328
325
|
items.unshift(chore);
|
329
326
|
this.txHandler.log(
|
@@ -332,7 +329,10 @@ export class TransactionsManager {
|
|
332
329
|
);
|
333
330
|
}
|
334
331
|
if (choresAfter.getInstructions().length > 0) {
|
335
|
-
const chore = new TransactionItem(
|
332
|
+
const chore = new TransactionItem(
|
333
|
+
async () => ({ tx: choresAfter }),
|
334
|
+
"closing temp accounts"
|
335
|
+
);
|
336
336
|
await chore.initialize();
|
337
337
|
items.push(chore);
|
338
338
|
this.txHandler.log(
|
package/src/utils/numberUtils.ts
CHANGED
@@ -97,9 +97,9 @@ export function getSolautoFeesBps(
|
|
97
97
|
} {
|
98
98
|
const minSize = 10_000; // Minimum position size
|
99
99
|
const maxSize = 500_000; // Maximum position size
|
100
|
-
const maxFeeBps =
|
100
|
+
const maxFeeBps = 200; // Fee in basis points for minSize (2%)
|
101
101
|
const minFeeBps = 50; // Fee in basis points for maxSize (0.5%)
|
102
|
-
const k =
|
102
|
+
const k = 1.5;
|
103
103
|
|
104
104
|
let feeBps: number = 0;
|
105
105
|
|
@@ -1,20 +1,15 @@
|
|
1
1
|
import { describe, it } from "mocha";
|
2
2
|
import { none, publicKey, some } from "@metaplex-foundation/umi";
|
3
3
|
import { setupTest } from "../shared";
|
4
|
-
import {
|
4
|
+
import {
|
5
|
+
SolautoMarginfiClient,
|
6
|
+
} from "../../src/clients/solautoMarginfiClient";
|
5
7
|
import {
|
6
8
|
solautoAction,
|
7
9
|
SolautoSettingsParametersInpArgs,
|
8
10
|
} from "../../src/generated";
|
9
11
|
import { buildSolautoRebalanceTransaction } from "../../src/transactions/transactionUtils";
|
10
|
-
import {
|
11
|
-
getDebtAdjustmentUsd,
|
12
|
-
getLiqUtilzationRateBps,
|
13
|
-
maxBoostToBps,
|
14
|
-
maxRepayFromBps,
|
15
|
-
maxRepayToBps,
|
16
|
-
toBaseUnit,
|
17
|
-
} from "../../src/utils/numberUtils";
|
12
|
+
import { maxBoostToBps, maxRepayFromBps, maxRepayToBps, toBaseUnit } from "../../src/utils/numberUtils";
|
18
13
|
import { NATIVE_MINT } from "@solana/spl-token";
|
19
14
|
import { getTokenPrices } from "../../src/utils/generalUtils";
|
20
15
|
import {
|
@@ -33,22 +28,25 @@ describe("Solauto Marginfi tests", async () => {
|
|
33
28
|
const positionId = 1;
|
34
29
|
|
35
30
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
31
|
+
|
36
32
|
const client = new SolautoMarginfiClient(process.env.HELIUS_API_KEY!, true);
|
37
33
|
|
38
34
|
const supply = NATIVE_MINT;
|
39
35
|
const supplyDecimals = 9;
|
40
36
|
const debtDecimals = 6;
|
41
37
|
|
42
|
-
await client.initialize(
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
38
|
+
await client.initialize(
|
39
|
+
{
|
40
|
+
signer,
|
41
|
+
positionId,
|
42
|
+
authority: new PublicKey("AprYCPiVeKMCgjQ2ZufwChMzvQ5kFjJo2ekTLSkXsQDm")
|
43
|
+
// marginfiAccount: new PublicKey(
|
44
|
+
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
45
|
+
// ),
|
46
|
+
// supplyMint: NATIVE_MINT,
|
47
|
+
// debtMint: new PublicKey(USDC_MINT),
|
48
|
+
}
|
49
|
+
);
|
52
50
|
|
53
51
|
const transactionItems: TransactionItem[] = [];
|
54
52
|
// const settingParams: SolautoSettingsParametersInpArgs = {
|
@@ -122,13 +120,13 @@ describe("Solauto Marginfi tests", async () => {
|
|
122
120
|
// }, "deposit")
|
123
121
|
// );
|
124
122
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
123
|
+
transactionItems.push(
|
124
|
+
new TransactionItem(
|
125
|
+
async (attemptNum) =>
|
126
|
+
await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
|
127
|
+
"rebalance"
|
128
|
+
)
|
129
|
+
);
|
132
130
|
|
133
131
|
// transactionItems.push(
|
134
132
|
// new TransactionItem(
|
@@ -157,19 +155,11 @@ describe("Solauto Marginfi tests", async () => {
|
|
157
155
|
// )
|
158
156
|
// );
|
159
157
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
// const debtAdjustment = getDebtAdjustmentUsd(8696, 366, 165, 7000);
|
168
|
-
// const newLiqUtilizationRate = getLiqUtilzationRateBps(366 + debtAdjustment, 165 + debtAdjustment, 8696);
|
169
|
-
// console.log(newLiqUtilizationRate);
|
170
|
-
|
171
|
-
console.log("CURRENT", Number(client.solautoPositionState?.supply.amountUsed.baseUnit));
|
172
|
-
const freshState = await client.getFreshPositionState();
|
173
|
-
console.log("FRESH", Number(freshState!.supply.amountUsed.baseUnit));
|
158
|
+
await new TransactionsManager(
|
159
|
+
client,
|
160
|
+
undefined,
|
161
|
+
!payForTransactions ? "only-simulate" : "normal",
|
162
|
+
useJitoBundle
|
163
|
+
).clientSend(transactionItems);
|
174
164
|
});
|
175
165
|
});
|