@haven-fi/solauto-sdk 1.0.45 → 1.0.46
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +2 -2
- package/dist/utils/solanaUtils.js +21 -4
- package/dist/utils/solauto/rebalanceUtils.js +1 -1
- package/package.json +1 -1
- package/src/transactions/transactionUtils.ts +2 -4
- package/src/utils/solanaUtils.ts +21 -21
- package/src/utils/solauto/rebalanceUtils.ts +1 -1
- package/tests/transactions/solautoMarginfi.ts +9 -7
@@ -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],
|
@@ -159,11 +159,28 @@ 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
|
-
const simulationResult = await
|
163
|
-
|
164
|
-
|
162
|
+
// const simulationResult = await retryWithExponentialBackoff(
|
163
|
+
// async () =>
|
164
|
+
// await simulateTransaction(
|
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);
|
165
182
|
if (!simulateOnly) {
|
166
|
-
const result = await assembleFinalTransaction(umi.identity, tx, feeEstimate,
|
183
|
+
const result = await assembleFinalTransaction(umi.identity, tx, feeEstimate, 800000).sendAndConfirm(umi, {
|
167
184
|
send: {
|
168
185
|
skipPreflight: true,
|
169
186
|
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/solanaUtils.ts
CHANGED
@@ -288,34 +288,34 @@ export async function sendSingleOptimizedTransaction(
|
|
288
288
|
const feeEstimate = await getComputeUnitPriceEstimate(umi, tx, attemptNum);
|
289
289
|
console.log("Compute unit price: ", feeEstimate);
|
290
290
|
|
291
|
-
const simulationResult = await retryWithExponentialBackoff(
|
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
|
-
const computeUnitLimit = Math.round(
|
309
|
-
|
310
|
-
);
|
311
|
-
console.log("Compute unit limit: ", computeUnitLimit);
|
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(
|
315
315
|
umi.identity,
|
316
316
|
tx,
|
317
317
|
feeEstimate,
|
318
|
-
|
318
|
+
800_000
|
319
319
|
).sendAndConfirm(umi, {
|
320
320
|
send: {
|
321
321
|
skipPreflight: true,
|
@@ -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(
|
@@ -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
|
|
@@ -115,7 +117,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
115
117
|
transactionItems.push(
|
116
118
|
new TransactionItem(
|
117
119
|
async (attemptNum) =>
|
118
|
-
await buildSolautoRebalanceTransaction(client,
|
120
|
+
await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
|
119
121
|
"rebalance"
|
120
122
|
)
|
121
123
|
);
|