@haven-fi/solauto-sdk 1.0.249 → 1.0.251
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 +4 -4
- package/dist/utils/solanaUtils.d.ts +1 -1
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +4 -3
- package/package.json +1 -1
- package/src/transactions/transactionUtils.ts +8 -10
- package/src/utils/solanaUtils.ts +4 -3
@@ -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;
|
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;AAmBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAqCzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAqLjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAkH7B;AA2LD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,oBA2CzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsH5C;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsC5C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;EAuDxE"}
|
@@ -439,8 +439,8 @@ function getErrorInfo(umi, tx, error) {
|
|
439
439
|
let programError = null;
|
440
440
|
if (typeof error === "object" && error["InstructionError"]) {
|
441
441
|
const err = error["InstructionError"];
|
442
|
-
const errIx = tx.getInstructions()[Math.max(0, err[0]
|
443
|
-
const errCode = typeof err[1] === "object" ? err[1]["Custom"] : undefined;
|
442
|
+
const errIx = tx.getInstructions()[Math.max(0, err[0])];
|
443
|
+
const errCode = typeof err[1] === "object" && "Custom" in err[1] ? err[1]["Custom"] : undefined;
|
444
444
|
const errName = errCode === undefined ? err[1] : undefined;
|
445
445
|
let programName = "";
|
446
446
|
if (errIx.programId.toString() ===
|
@@ -454,11 +454,11 @@ function getErrorInfo(umi, tx, error) {
|
|
454
454
|
}
|
455
455
|
else if (errIx.programId === marginfi_sdk_1.MARGINFI_PROGRAM_ID) {
|
456
456
|
programName = "Marginfi";
|
457
|
-
programError = (0, marginfi_sdk_1.
|
457
|
+
programError = (0, marginfi_sdk_1.getMarginfiErrorFromCode)(errCode, (0, marginfi_sdk_1.createMarginfiProgram)());
|
458
458
|
}
|
459
459
|
else if (errIx.programId === jupiter_sdk_1.JUPITER_PROGRAM_ID) {
|
460
460
|
programName = "Jupiter";
|
461
|
-
programError = (0, jupiter_sdk_1.
|
461
|
+
programError = (0, jupiter_sdk_1.getJupiterErrorFromCode)(errCode, (0, jupiter_sdk_1.createJupiterProgram)());
|
462
462
|
}
|
463
463
|
if (errName && errCode === undefined) {
|
464
464
|
errorName = `${programName ?? "Program"} error`;
|
@@ -12,7 +12,7 @@ export declare function systemTransferUmiIx(signer: Signer, destination: PublicK
|
|
12
12
|
export declare function closeTokenAccountUmiIx(signer: Signer, tokenAccount: PublicKey, authority: PublicKey): WrappedInstruction;
|
13
13
|
export declare function splTokenTransferUmiIx(signer: Signer, fromTa: PublicKey, toTa: PublicKey, authority: PublicKey, amount: bigint): WrappedInstruction;
|
14
14
|
export declare function getAddressLookupInputs(umi: Umi, lookupTableAddresses: string[]): Promise<AddressLookupTableInput[]>;
|
15
|
-
export declare function assembleFinalTransaction(signer: Signer,
|
15
|
+
export declare function assembleFinalTransaction(signer: Signer, transaction: TransactionBuilder, computeUnitPrice?: number, computeUnitLimit?: number): TransactionBuilder;
|
16
16
|
export declare function getComputeUnitPriceEstimate(umi: Umi, tx: TransactionBuilder, prioritySetting: PriorityFeeSetting): Promise<number | undefined>;
|
17
17
|
export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder, txType?: TransactionRunType, prioritySetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<Uint8Array | undefined>;
|
18
18
|
//# sourceMappingURL=solanaUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,GAAG,EACH,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAKL,UAAU,EACV,SAAS,EAKT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAgBzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAIlE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,UAErD;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,UAE3D;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAgC,GAC1C,CAAC,UAAU,EAAE,GAAG,CAAC,CAQnB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,sBAAsB,GACzB,kBAAkB,CAMpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,kBAAkB,CAOpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,kBAAkB,CAOpB;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,GACd,kBAAkB,CAUpB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,EACtB,QAAQ,EAAE,MAAM,GACf,kBAAkB,CASpB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,SAAS,EACvB,SAAS,EAAE,SAAS,GACnB,kBAAkB,CAKpB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,GACb,kBAAkB,CAKpB;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,oBAAoB,EAAE,MAAM,EAAE,GAC7B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkBpC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,
|
1
|
+
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uB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BAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,oBAAoB,EAAE,MAAM,EAAE,GAC7B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkBpC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,kBAAkB,EAC/B,gBAAgB,CAAC,EAAE,MAAM,EACzB,gBAAgB,CAAC,EAAE,MAAM,sBAiE1B;AAmBD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,GAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAsB7B;AAiDD,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,eAAe,GAAE,kBAA2C,EAC5D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA6EjC"}
|
@@ -90,14 +90,15 @@ async function getAddressLookupInputs(umi, lookupTableAddresses) {
|
|
90
90
|
return acc;
|
91
91
|
}, new Array());
|
92
92
|
}
|
93
|
-
function assembleFinalTransaction(signer,
|
94
|
-
tx =
|
93
|
+
function assembleFinalTransaction(signer, transaction, computeUnitPrice, computeUnitLimit) {
|
94
|
+
let tx = (0, umi_1.transactionBuilder)()
|
95
95
|
.prepend(computeUnitPrice !== undefined
|
96
96
|
? setComputeUnitPriceUmiIx(signer, computeUnitPrice)
|
97
97
|
: (0, umi_1.transactionBuilder)())
|
98
98
|
.prepend(computeUnitLimit
|
99
99
|
? setComputeUnitLimitUmiIx(signer, computeUnitLimit)
|
100
|
-
: (0, umi_1.transactionBuilder)())
|
100
|
+
: (0, umi_1.transactionBuilder)())
|
101
|
+
.add(transaction);
|
101
102
|
const marginfiStartFlSerializer = (0, marginfi_sdk_1.getLendingAccountStartFlashloanInstructionDataSerializer)();
|
102
103
|
const marginfiStartFlDiscriminator = marginfiStartFlSerializer
|
103
104
|
.serialize({
|
package/package.json
CHANGED
@@ -15,7 +15,6 @@ import {
|
|
15
15
|
import {
|
16
16
|
InvalidRebalanceConditionError,
|
17
17
|
LendingPlatform,
|
18
|
-
RebalanceDirection,
|
19
18
|
SolautoAction,
|
20
19
|
SolautoRebalanceType,
|
21
20
|
TokenType,
|
@@ -47,7 +46,6 @@ import {
|
|
47
46
|
} from "../utils/generalUtils";
|
48
47
|
import { SolautoMarginfiClient } from "../clients/solautoMarginfiClient";
|
49
48
|
import {
|
50
|
-
fromBaseUnit,
|
51
49
|
getMaxLiqUtilizationRateBps,
|
52
50
|
uint8ArrayToBigInt,
|
53
51
|
} from "../utils/numberUtils";
|
@@ -62,16 +60,16 @@ import {
|
|
62
60
|
getLendingAccountDepositInstructionDataSerializer,
|
63
61
|
getLendingAccountRepayInstructionDataSerializer,
|
64
62
|
getLendingAccountWithdrawInstructionDataSerializer,
|
65
|
-
|
63
|
+
getMarginfiErrorFromCode,
|
66
64
|
MARGINFI_PROGRAM_ID,
|
67
65
|
} from "../marginfi-sdk";
|
68
|
-
import { ReferralStateManager
|
66
|
+
import { ReferralStateManager } from "../clients";
|
69
67
|
import {
|
70
68
|
createJupiterProgram,
|
71
|
-
|
69
|
+
getJupiterErrorFromCode,
|
72
70
|
JUPITER_PROGRAM_ID,
|
73
71
|
} from "../jupiter-sdk";
|
74
|
-
import {
|
72
|
+
import { PRICES } from "../constants";
|
75
73
|
import { TransactionItemInputs } from "../types";
|
76
74
|
|
77
75
|
interface wSolTokenUsage {
|
@@ -812,8 +810,8 @@ export function getErrorInfo(umi: Umi, tx: TransactionBuilder, error: any) {
|
|
812
810
|
|
813
811
|
if (typeof error === "object" && (error as any)["InstructionError"]) {
|
814
812
|
const err = (error as any)["InstructionError"];
|
815
|
-
const errIx = tx.getInstructions()[Math.max(0, err[0]
|
816
|
-
const errCode = typeof err[1] === "object" ? err[1]["Custom"] : undefined;
|
813
|
+
const errIx = tx.getInstructions()[Math.max(0, err[0])];
|
814
|
+
const errCode = typeof err[1] === "object" && "Custom" in err[1] ? err[1]["Custom"] : undefined;
|
817
815
|
const errName = errCode === undefined ? (err[1] as string) : undefined;
|
818
816
|
let programName = "";
|
819
817
|
|
@@ -831,13 +829,13 @@ export function getErrorInfo(umi: Umi, tx: TransactionBuilder, error: any) {
|
|
831
829
|
}
|
832
830
|
} else if (errIx.programId === MARGINFI_PROGRAM_ID) {
|
833
831
|
programName = "Marginfi";
|
834
|
-
programError =
|
832
|
+
programError = getMarginfiErrorFromCode(
|
835
833
|
errCode,
|
836
834
|
createMarginfiProgram()
|
837
835
|
);
|
838
836
|
} else if (errIx.programId === JUPITER_PROGRAM_ID) {
|
839
837
|
programName = "Jupiter";
|
840
|
-
programError =
|
838
|
+
programError = getJupiterErrorFromCode(errCode, createJupiterProgram());
|
841
839
|
}
|
842
840
|
|
843
841
|
if (errName && errCode === undefined) {
|
package/src/utils/solanaUtils.ts
CHANGED
@@ -183,11 +183,11 @@ export async function getAddressLookupInputs(
|
|
183
183
|
|
184
184
|
export function assembleFinalTransaction(
|
185
185
|
signer: Signer,
|
186
|
-
|
186
|
+
transaction: TransactionBuilder,
|
187
187
|
computeUnitPrice?: number,
|
188
188
|
computeUnitLimit?: number
|
189
189
|
) {
|
190
|
-
tx =
|
190
|
+
let tx = transactionBuilder()
|
191
191
|
.prepend(
|
192
192
|
computeUnitPrice !== undefined
|
193
193
|
? setComputeUnitPriceUmiIx(signer, computeUnitPrice)
|
@@ -197,7 +197,8 @@ export function assembleFinalTransaction(
|
|
197
197
|
computeUnitLimit
|
198
198
|
? setComputeUnitLimitUmiIx(signer, computeUnitLimit)
|
199
199
|
: transactionBuilder()
|
200
|
-
)
|
200
|
+
)
|
201
|
+
.add(transaction);
|
201
202
|
|
202
203
|
const marginfiStartFlSerializer =
|
203
204
|
getLendingAccountStartFlashloanInstructionDataSerializer();
|