@haven-fi/solauto-sdk 1.0.479 → 1.0.481
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/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +28 -19
- package/dist/utils/jupiterUtils.js +2 -2
- package/dist/utils/numberUtils.js +2 -2
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +28 -20
- package/src/utils/jupiterUtils.ts +2 -2
- package/src/utils/numberUtils.ts +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,OAAO,EAEL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAW7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAA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AAC,4BAA4B;IAgBpC,OAAO,CAAC,mBAAmB;YAoBb,SAAS;IAiBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IA+FzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,OAAO,EAEL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAW7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AA0FD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED,MA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AI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YAkCxB,6BAA6B;YAsI7B,qBAAqB;YAoDrB,eAAe;YA0Df,eAAe;CA4D9B"}
|
@@ -314,13 +314,20 @@ class TransactionsManager {
|
|
314
314
|
async send(items) {
|
315
315
|
this.statuses = [];
|
316
316
|
this.lookupTables.reset();
|
317
|
-
|
318
|
-
|
319
|
-
|
317
|
+
const itemSets = await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => {
|
318
|
+
if (!items[0].initialized) {
|
319
|
+
for (const item of items) {
|
320
|
+
await item.initialize();
|
321
|
+
}
|
320
322
|
}
|
321
|
-
|
322
|
-
|
323
|
-
|
323
|
+
else if (attemptNum > 0) {
|
324
|
+
for (const item of items) {
|
325
|
+
await item.refetch(0);
|
326
|
+
}
|
327
|
+
}
|
328
|
+
this.txHandler.log("Transaction items:", items.length);
|
329
|
+
return await this.assembleTransactionSets(items);
|
330
|
+
}, 2);
|
324
331
|
this.updateStatusForSets(itemSets, TransactionStatus.Queued, 0);
|
325
332
|
this.txHandler.log("Initial item sets:", itemSets.length);
|
326
333
|
if (this.atomically) {
|
@@ -421,21 +428,23 @@ class TransactionsManager {
|
|
421
428
|
}, this.totalRetries, this.retryDelay, this.errorsToThrow);
|
422
429
|
}
|
423
430
|
async refreshItemSets(itemSets, attemptNum, currentIndex) {
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
}
|
428
|
-
else {
|
429
|
-
for (const itemSet of itemSets) {
|
431
|
+
const newItemSets = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
|
432
|
+
if (currentIndex !== undefined) {
|
433
|
+
const itemSet = itemSets[currentIndex];
|
430
434
|
await itemSet.refetchAll(attemptNum);
|
431
435
|
}
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
436
|
+
else {
|
437
|
+
for (const itemSet of itemSets) {
|
438
|
+
await itemSet.refetchAll(attemptNum);
|
439
|
+
}
|
440
|
+
}
|
441
|
+
return await this.assembleTransactionSets(currentIndex !== undefined
|
442
|
+
? [
|
443
|
+
...itemSets[currentIndex].items,
|
444
|
+
...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
|
445
|
+
]
|
446
|
+
: itemSets.flatMap((set) => set.items));
|
447
|
+
}, 2);
|
439
448
|
const newItemSetNames = newItemSets.map((x) => x.name());
|
440
449
|
if (newItemSetNames.length === 1 &&
|
441
450
|
newItemSetNames[0] === this.updateOracleTxName) {
|
@@ -34,7 +34,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
|
|
34
34
|
: swapDetails.exactIn
|
35
35
|
? "ExactIn"
|
36
36
|
: undefined,
|
37
|
-
slippageBps: memecoinSwap ? 500 :
|
37
|
+
slippageBps: memecoinSwap ? 500 : 200,
|
38
38
|
maxAccounts: !swapDetails.exactOut ? 40 : undefined,
|
39
39
|
}), 4, 200);
|
40
40
|
const priceImpactBps = Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1;
|
@@ -60,7 +60,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
|
|
60
60
|
(0, generalUtils_1.consoleLog)("Increased price impact bps:", finalPriceImpactBps);
|
61
61
|
if (swapDetails.addPadding) {
|
62
62
|
(0, generalUtils_1.consoleLog)("Raw inAmount:", quoteResponse.inAmount);
|
63
|
-
const inc = Math.max((0, numberUtils_1.fromBps)(finalPriceImpactBps) * 1.1, (0, numberUtils_1.fromBps)(finalPriceSlippageBps) * 0.
|
63
|
+
const inc = Math.max((0, numberUtils_1.fromBps)(finalPriceImpactBps) * 1.1, (0, numberUtils_1.fromBps)(finalPriceSlippageBps) * 0.03);
|
64
64
|
(0, generalUtils_1.consoleLog)("Inc:", inc);
|
65
65
|
quoteResponse.inAmount = Math.round(parseInt(quoteResponse.inAmount) + parseInt(quoteResponse.inAmount) * inc).toString();
|
66
66
|
(0, generalUtils_1.consoleLog)("Increased inAmount:", quoteResponse.inAmount);
|
@@ -75,8 +75,8 @@ function getDebtAdjustmentUsd(liqThresholdBps, supplyUsd, debtUsd, targetLiqUtil
|
|
75
75
|
}
|
76
76
|
function getSolautoFeesBps(isReferred, targetLiqUtilizationRateBps, positionNetWorthUsd, rebalanceDirection) {
|
77
77
|
const minSize = 10000; // Minimum position size
|
78
|
-
const maxSize =
|
79
|
-
const maxFeeBps =
|
78
|
+
const maxSize = 250000; // Maximum position size
|
79
|
+
const maxFeeBps = 50; // Fee in basis points for minSize (0.5%)
|
80
80
|
const minFeeBps = 25; // Fee in basis points for maxSize (0.25%)
|
81
81
|
const k = 1.5;
|
82
82
|
if (targetLiqUtilizationRateBps !== undefined &&
|
package/package.json
CHANGED
@@ -515,14 +515,20 @@ export class TransactionsManager {
|
|
515
515
|
this.statuses = [];
|
516
516
|
this.lookupTables.reset();
|
517
517
|
|
518
|
-
|
519
|
-
|
520
|
-
|
518
|
+
const itemSets = await retryWithExponentialBackoff(async (attemptNum) => {
|
519
|
+
if (!items[0].initialized) {
|
520
|
+
for (const item of items) {
|
521
|
+
await item.initialize();
|
522
|
+
}
|
523
|
+
} else if (attemptNum > 0) {
|
524
|
+
for (const item of items) {
|
525
|
+
await item.refetch(0);
|
526
|
+
}
|
521
527
|
}
|
522
|
-
|
528
|
+
this.txHandler.log("Transaction items:", items.length);
|
529
|
+
return await this.assembleTransactionSets(items);
|
530
|
+
}, 2);
|
523
531
|
|
524
|
-
this.txHandler.log("Transaction items:", items.length);
|
525
|
-
const itemSets = await this.assembleTransactionSets(items);
|
526
532
|
this.updateStatusForSets(itemSets, TransactionStatus.Queued, 0);
|
527
533
|
this.txHandler.log("Initial item sets:", itemSets.length);
|
528
534
|
|
@@ -730,23 +736,25 @@ export class TransactionsManager {
|
|
730
736
|
attemptNum: number,
|
731
737
|
currentIndex?: number
|
732
738
|
): Promise<TransactionSet[] | undefined> {
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
} else {
|
737
|
-
for (const itemSet of itemSets) {
|
739
|
+
const newItemSets = await retryWithExponentialBackoff(async () => {
|
740
|
+
if (currentIndex !== undefined) {
|
741
|
+
const itemSet = itemSets[currentIndex];
|
738
742
|
await itemSet.refetchAll(attemptNum);
|
743
|
+
} else {
|
744
|
+
for (const itemSet of itemSets) {
|
745
|
+
await itemSet.refetchAll(attemptNum);
|
746
|
+
}
|
739
747
|
}
|
740
|
-
}
|
741
748
|
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
749
|
+
return await this.assembleTransactionSets(
|
750
|
+
currentIndex !== undefined
|
751
|
+
? [
|
752
|
+
...itemSets[currentIndex].items,
|
753
|
+
...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
|
754
|
+
]
|
755
|
+
: itemSets.flatMap((set) => set.items)
|
756
|
+
);
|
757
|
+
}, 2);
|
750
758
|
|
751
759
|
const newItemSetNames = newItemSets.map((x) => x.name());
|
752
760
|
if (
|
@@ -71,7 +71,7 @@ export async function getJupSwapTransaction(
|
|
71
71
|
: swapDetails.exactIn
|
72
72
|
? "ExactIn"
|
73
73
|
: undefined,
|
74
|
-
slippageBps: memecoinSwap ? 500 :
|
74
|
+
slippageBps: memecoinSwap ? 500 : 200,
|
75
75
|
maxAccounts: !swapDetails.exactOut ? 40 : undefined,
|
76
76
|
}),
|
77
77
|
4,
|
@@ -119,7 +119,7 @@ export async function getJupSwapTransaction(
|
|
119
119
|
consoleLog("Raw inAmount:", quoteResponse.inAmount);
|
120
120
|
const inc = Math.max(
|
121
121
|
fromBps(finalPriceImpactBps) * 1.1,
|
122
|
-
fromBps(finalPriceSlippageBps) * 0.
|
122
|
+
fromBps(finalPriceSlippageBps) * 0.03
|
123
123
|
);
|
124
124
|
consoleLog("Inc:", inc);
|
125
125
|
quoteResponse.inAmount = Math.round(
|
package/src/utils/numberUtils.ts
CHANGED
@@ -104,8 +104,8 @@ export function getSolautoFeesBps(
|
|
104
104
|
total: number;
|
105
105
|
} {
|
106
106
|
const minSize = 10_000; // Minimum position size
|
107
|
-
const maxSize =
|
108
|
-
const maxFeeBps =
|
107
|
+
const maxSize = 250_000; // Maximum position size
|
108
|
+
const maxFeeBps = 50; // Fee in basis points for minSize (0.5%)
|
109
109
|
const minFeeBps = 25; // Fee in basis points for maxSize (0.25%)
|
110
110
|
const k = 1.5;
|
111
111
|
|