@haven-fi/solauto-sdk 1.0.179 → 1.0.181
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 -4
- package/dist/transactions/transactionsManager.js +1 -1
- package/dist/utils/jupiterUtils.d.ts.map +1 -1
- package/dist/utils/jupiterUtils.js +7 -1
- package/dist/utils/solauto/rebalanceUtils.js +1 -1
- package/package.json +1 -1
- package/src/transactions/transactionUtils.ts +2 -4
- package/src/transactions/transactionsManager.ts +1 -1
- package/src/utils/jupiterUtils.ts +15 -8
- package/src/utils/solauto/rebalanceUtils.ts +1 -1
@@ -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;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAGL,aAAa,EAYd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAiOzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAmLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,aAAa,WAwCnE;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,CAwHA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,SAAS,GACtB,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAmCrD;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;
|
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;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAGL,aAAa,EAYd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAiOzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAmLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,aAAa,WAwCnE;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,CAwHA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,SAAS,GACtB,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAmCrD;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;EAwC9D"}
|
@@ -451,10 +451,8 @@ function getErrorInfo(tx, error) {
|
|
451
451
|
programError = (0, jupiter_sdk_1.getJupiterErrorFromName)(errCode, (0, jupiter_sdk_1.createJupiterProgram)());
|
452
452
|
}
|
453
453
|
}
|
454
|
-
|
455
|
-
|
456
|
-
errorName = programError?.message;
|
457
|
-
}
|
454
|
+
errorName = programError?.name;
|
455
|
+
errorName = programError?.message;
|
458
456
|
}
|
459
457
|
catch { }
|
460
458
|
return {
|
@@ -339,7 +339,7 @@ class TransactionsManager {
|
|
339
339
|
const errorDetails = (0, transactionUtils_1.getErrorInfo)(tx, e);
|
340
340
|
this.updateStatus(txName, errorDetails.canBeIgnored
|
341
341
|
? TransactionStatus.Skipped
|
342
|
-
: TransactionStatus.Failed, attemptNum, undefined, undefined, errorDetails.errorInfo ?? "Unknown error");
|
342
|
+
: TransactionStatus.Failed, attemptNum, undefined, undefined, errorDetails.errorInfo ?? errorDetails.errorName ?? "Unknown error");
|
343
343
|
this.txHandler.log(`${errorDetails.errorName ?? "Unknown error"}: ${errorDetails.errorInfo ?? "unknown"}`);
|
344
344
|
if (!errorDetails.canBeIgnored) {
|
345
345
|
throw e;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jupiterUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jupiterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA0B,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAGL,aAAa,EACd,MAAM,aAAa,CAAC;AAMrB,MAAM,WAAW,cAAc;IAC7B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AAE,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,aAAa,EAAE,kBAAkB,CAAC;IAClC,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAoF7B"}
|
@@ -34,11 +34,17 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
|
|
34
34
|
slippageBps: 50,
|
35
35
|
maxAccounts: !swapDetails.exactOut ? 60 : undefined,
|
36
36
|
}), 3);
|
37
|
-
const priceImpactBps =
|
37
|
+
const priceImpactBps = Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1;
|
38
38
|
const finalPriceSlippageBps = Math.round(Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
|
39
39
|
(1 + (swapDetails.slippageIncFactor ?? 0)));
|
40
40
|
quoteResponse.slippageBps = finalPriceSlippageBps;
|
41
41
|
console.log(quoteResponse);
|
42
|
+
if (swapDetails.exactOut) {
|
43
|
+
console.log(quoteResponse.inAmount);
|
44
|
+
quoteResponse.inAmount = (parseInt(quoteResponse.inAmount) +
|
45
|
+
parseInt(quoteResponse.inAmount) * (0, numberUtils_1.fromBps)(priceImpactBps)).toString();
|
46
|
+
console.log(quoteResponse.inAmount);
|
47
|
+
}
|
42
48
|
console.log("Getting jup instructions...");
|
43
49
|
const instructions = await jupApi.swapInstructionsPost({
|
44
50
|
swapRequest: {
|
@@ -67,8 +67,8 @@ function getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, target
|
|
67
67
|
throw new Error("If rebalancing a self-managed position, settings and DCA should be provided");
|
68
68
|
}
|
69
69
|
if (isDcaRebalance(state, settings, dca, currentUnixTime)) {
|
70
|
-
const amountToDcaIn = getAdditionalAmountToDcaIn(dca);
|
71
70
|
const targetLiqUtilizationRateBps = targetLiqUtilizationRateBpsFromDCA(state, settings, dca, currentUnixTime);
|
71
|
+
const amountToDcaIn = getAdditionalAmountToDcaIn(dca);
|
72
72
|
return {
|
73
73
|
targetRateBps: targetLiqUtilizationRateBps,
|
74
74
|
amountToDcaIn,
|
package/package.json
CHANGED
@@ -824,10 +824,8 @@ export function getErrorInfo(tx: TransactionBuilder, error: any) {
|
|
824
824
|
}
|
825
825
|
}
|
826
826
|
|
827
|
-
|
828
|
-
|
829
|
-
errorName = programError?.message;
|
830
|
-
}
|
827
|
+
errorName = programError?.name;
|
828
|
+
errorName = programError?.message;
|
831
829
|
} catch {}
|
832
830
|
|
833
831
|
return {
|
@@ -542,7 +542,7 @@ export class TransactionsManager {
|
|
542
542
|
attemptNum,
|
543
543
|
undefined,
|
544
544
|
undefined,
|
545
|
-
errorDetails.errorInfo ?? "Unknown error"
|
545
|
+
errorDetails.errorInfo ?? errorDetails.errorName ?? "Unknown error"
|
546
546
|
);
|
547
547
|
this.txHandler.log(`${errorDetails.errorName ?? "Unknown error"}: ${errorDetails.errorInfo ?? "unknown"}`);
|
548
548
|
|
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
} from "@metaplex-foundation/umi";
|
6
6
|
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
7
7
|
import { getWrappedInstruction } from "./solanaUtils";
|
8
|
-
import { toBps } from "./numberUtils";
|
8
|
+
import { fromBps, toBps } from "./numberUtils";
|
9
9
|
import {
|
10
10
|
createJupiterApiClient,
|
11
11
|
Instruction,
|
@@ -72,18 +72,24 @@ export async function getJupSwapTransaction(
|
|
72
72
|
3
|
73
73
|
);
|
74
74
|
|
75
|
-
const priceImpactBps =
|
75
|
+
const priceImpactBps =
|
76
|
+
Math.round(toBps(parseFloat(quoteResponse.priceImpactPct))) + 1;
|
76
77
|
const finalPriceSlippageBps = Math.round(
|
77
|
-
Math.max(
|
78
|
-
50,
|
79
|
-
quoteResponse.slippageBps,
|
80
|
-
priceImpactBps
|
81
|
-
) *
|
78
|
+
Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
|
82
79
|
(1 + (swapDetails.slippageIncFactor ?? 0))
|
83
80
|
);
|
84
81
|
quoteResponse.slippageBps = finalPriceSlippageBps;
|
85
82
|
console.log(quoteResponse);
|
86
83
|
|
84
|
+
if (swapDetails.exactOut) {
|
85
|
+
console.log(quoteResponse.inAmount);
|
86
|
+
quoteResponse.inAmount = (
|
87
|
+
parseInt(quoteResponse.inAmount) +
|
88
|
+
parseInt(quoteResponse.inAmount) * fromBps(priceImpactBps)
|
89
|
+
).toString();
|
90
|
+
console.log(quoteResponse.inAmount);
|
91
|
+
}
|
92
|
+
|
87
93
|
console.log("Getting jup instructions...");
|
88
94
|
const instructions = await jupApi.swapInstructionsPost({
|
89
95
|
swapRequest: {
|
@@ -103,7 +109,8 @@ export async function getJupSwapTransaction(
|
|
103
109
|
}
|
104
110
|
|
105
111
|
console.log("Raw price impact bps:", priceImpactBps);
|
106
|
-
const finalPriceImpactBps =
|
112
|
+
const finalPriceImpactBps =
|
113
|
+
priceImpactBps * (1 + (swapDetails.slippageIncFactor ?? 0));
|
107
114
|
console.log("Increased price impact bps:", finalPriceImpactBps);
|
108
115
|
|
109
116
|
return {
|
@@ -138,13 +138,13 @@ function getTargetRateAndDcaAmount(
|
|
138
138
|
}
|
139
139
|
|
140
140
|
if (isDcaRebalance(state, settings, dca, currentUnixTime)) {
|
141
|
-
const amountToDcaIn = getAdditionalAmountToDcaIn(dca!);
|
142
141
|
const targetLiqUtilizationRateBps = targetLiqUtilizationRateBpsFromDCA(
|
143
142
|
state,
|
144
143
|
settings,
|
145
144
|
dca!,
|
146
145
|
currentUnixTime
|
147
146
|
);
|
147
|
+
const amountToDcaIn = getAdditionalAmountToDcaIn(dca!);
|
148
148
|
|
149
149
|
return {
|
150
150
|
targetRateBps: targetLiqUtilizationRateBps,
|