@haven-fi/solauto-sdk 1.0.208 → 1.0.209
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/transactionUtils.d.ts +3 -5
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +1 -1
- package/dist/transactions/transactionsManager.d.ts +3 -9
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/types/solauto.d.ts +5 -0
- package/dist/types/solauto.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/transactions/transactionUtils.ts +8 -10
- package/src/transactions/transactionsManager.ts +7 -9
- package/src/types/solauto.ts +8 -2
|
@@ -2,14 +2,12 @@ import { TransactionBuilder } from "@metaplex-foundation/umi";
|
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
3
|
import { SolautoClient } from "../clients/solautoClient";
|
|
4
4
|
import { ReferralStateManager } from "../clients";
|
|
5
|
+
import { TransactionItemInputs } from "../types";
|
|
5
6
|
export declare function rebalanceChoresBefore(client: SolautoClient, tx: TransactionBuilder, accountsGettingCreated: string[]): Promise<TransactionBuilder>;
|
|
6
7
|
export declare function getTransactionChores(client: SolautoClient, tx: TransactionBuilder): Promise<[TransactionBuilder, TransactionBuilder]>;
|
|
7
8
|
export declare function requiresRefreshBeforeRebalance(client: SolautoClient): Promise<boolean>;
|
|
8
|
-
export declare function buildSolautoRebalanceTransaction(client: SolautoClient, targetLiqUtilizationRateBps?: number, attemptNum?: number): Promise<
|
|
9
|
-
|
|
10
|
-
lookupTableAddresses: string[];
|
|
11
|
-
} | undefined>;
|
|
12
|
-
export declare function convertReferralFeesToDestination(referralManager: ReferralStateManager, tokenAccount: PublicKey, destinationMint: PublicKey): Promise<[TransactionBuilder, string[]] | undefined>;
|
|
9
|
+
export declare function buildSolautoRebalanceTransaction(client: SolautoClient, targetLiqUtilizationRateBps?: number, attemptNum?: number): Promise<TransactionItemInputs | undefined>;
|
|
10
|
+
export declare function convertReferralFeesToDestination(referralManager: ReferralStateManager, tokenAccount: PublicKey, destinationMint: PublicKey): Promise<TransactionItemInputs | undefined>;
|
|
13
11
|
export declare function getErrorInfo(tx: TransactionBuilder, error: any): {
|
|
14
12
|
errorName: string | undefined;
|
|
15
13
|
errorInfo: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAInB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAsBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAqCzD,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAInB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAsBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAqCzD,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAO7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA0LjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAkLD,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,oBAwCzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAkH5C;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,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;EAwC9D"}
|
|
@@ -423,7 +423,7 @@ async function convertReferralFeesToDestination(referralManager, tokenAccount, d
|
|
|
423
423
|
referralFeesTa: (0, umi_1.publicKey)(tokenAccount),
|
|
424
424
|
}))
|
|
425
425
|
.add(swapIx);
|
|
426
|
-
return
|
|
426
|
+
return { tx, lookupTableAddresses };
|
|
427
427
|
}
|
|
428
428
|
function getErrorInfo(tx, error) {
|
|
429
429
|
let canBeIgnored = false;
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { TransactionBuilder } from "@metaplex-foundation/umi";
|
|
2
2
|
import { SolautoClient } from "../clients/solautoClient";
|
|
3
3
|
import { ErrorsToThrow } from "../utils/generalUtils";
|
|
4
|
-
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
|
4
|
+
import { PriorityFeeSetting, TransactionItemInputs, TransactionRunType } from "../types";
|
|
5
5
|
import { ReferralStateManager } from "../clients";
|
|
6
6
|
export declare class TransactionItem {
|
|
7
|
-
fetchTx: (attemptNum: number) => Promise<
|
|
8
|
-
tx: TransactionBuilder;
|
|
9
|
-
lookupTableAddresses?: string[];
|
|
10
|
-
} | undefined>;
|
|
7
|
+
fetchTx: (attemptNum: number) => Promise<TransactionItemInputs | undefined>;
|
|
11
8
|
name?: string | undefined;
|
|
12
9
|
lookupTableAddresses: string[];
|
|
13
10
|
tx?: TransactionBuilder;
|
|
14
|
-
constructor(fetchTx: (attemptNum: number) => Promise<
|
|
15
|
-
tx: TransactionBuilder;
|
|
16
|
-
lookupTableAddresses?: string[];
|
|
17
|
-
} | undefined>, name?: string | undefined);
|
|
11
|
+
constructor(fetchTx: (attemptNum: number) => Promise<TransactionItemInputs | undefined>, name?: string | undefined);
|
|
18
12
|
initialize(): Promise<void>;
|
|
19
13
|
refetch(attemptNum: number): Promise<void>;
|
|
20
14
|
uniqueAccounts(): string[];
|
|
@@ -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;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,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;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAwC7D,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IAPtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,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BAAkB,GACnC,OAAO,CAAC,0BAA0B,CAAC;IAyEzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,EACxB,eAAe,CAAC,EAAE,kBAAkB,EACpC,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,0BAA0B,CAAC;YAwGxB,eAAe;CAoD9B"}
|
package/dist/types/solauto.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
2
|
import { LendingPlatform, PositionType } from "../generated";
|
|
3
|
+
import { TransactionBuilder } from "@metaplex-foundation/umi";
|
|
3
4
|
export interface SolautoPositionDetails {
|
|
4
5
|
publicKey?: PublicKey;
|
|
5
6
|
authority: PublicKey;
|
|
@@ -16,4 +17,8 @@ export declare enum PriorityFeeSetting {
|
|
|
16
17
|
}
|
|
17
18
|
export type RebalanceAction = "boost" | "repay" | "dca";
|
|
18
19
|
export type TransactionRunType = "skip-simulation" | "only-simulate" | "normal";
|
|
20
|
+
export interface TransactionItemInputs {
|
|
21
|
+
tx: TransactionBuilder;
|
|
22
|
+
lookupTableAddresses?: string[];
|
|
23
|
+
}
|
|
19
24
|
//# sourceMappingURL=solauto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,oBAAY,kBAAkB;IAC5B,OAAO,WAAW;IAClB,IAAI,SAAS;CACd;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,QAAQ,CAAC;AAEhF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC"}
|
package/package.json
CHANGED
|
@@ -73,6 +73,7 @@ import {
|
|
|
73
73
|
JUPITER_PROGRAM_ID,
|
|
74
74
|
} from "../jupiter-sdk";
|
|
75
75
|
import { PRICES } from "../constants";
|
|
76
|
+
import { TransactionItemInputs } from "../types";
|
|
76
77
|
|
|
77
78
|
interface wSolTokenUsage {
|
|
78
79
|
wSolTokenAccount: PublicKey;
|
|
@@ -628,13 +629,7 @@ export async function buildSolautoRebalanceTransaction(
|
|
|
628
629
|
client: SolautoClient,
|
|
629
630
|
targetLiqUtilizationRateBps?: number,
|
|
630
631
|
attemptNum?: number
|
|
631
|
-
): Promise<
|
|
632
|
-
| {
|
|
633
|
-
tx: TransactionBuilder;
|
|
634
|
-
lookupTableAddresses: string[];
|
|
635
|
-
}
|
|
636
|
-
| undefined
|
|
637
|
-
> {
|
|
632
|
+
): Promise<TransactionItemInputs | undefined> {
|
|
638
633
|
client.solautoPositionState = await client.getFreshPositionState();
|
|
639
634
|
if (
|
|
640
635
|
(client.solautoPositionState?.supply.amountUsed.baseUnit === BigInt(0) &&
|
|
@@ -754,8 +749,11 @@ export async function convertReferralFeesToDestination(
|
|
|
754
749
|
referralManager: ReferralStateManager,
|
|
755
750
|
tokenAccount: PublicKey,
|
|
756
751
|
destinationMint: PublicKey
|
|
757
|
-
): Promise<
|
|
758
|
-
const tokenAccountData = await getTokenAccountData(
|
|
752
|
+
): Promise<TransactionItemInputs | undefined> {
|
|
753
|
+
const tokenAccountData = await getTokenAccountData(
|
|
754
|
+
referralManager.umi,
|
|
755
|
+
tokenAccount
|
|
756
|
+
);
|
|
759
757
|
if (!tokenAccountData || tokenAccountData.amount === BigInt(0)) {
|
|
760
758
|
return undefined;
|
|
761
759
|
}
|
|
@@ -788,7 +786,7 @@ export async function convertReferralFeesToDestination(
|
|
|
788
786
|
)
|
|
789
787
|
.add(swapIx);
|
|
790
788
|
|
|
791
|
-
return
|
|
789
|
+
return { tx, lookupTableAddresses };
|
|
792
790
|
}
|
|
793
791
|
|
|
794
792
|
export function getErrorInfo(tx: TransactionBuilder, error: any) {
|
|
@@ -15,12 +15,8 @@ import {
|
|
|
15
15
|
retryWithExponentialBackoff,
|
|
16
16
|
} from "../utils/generalUtils";
|
|
17
17
|
import { getErrorInfo, getTransactionChores } from "./transactionUtils";
|
|
18
|
-
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
|
18
|
+
import { PriorityFeeSetting, TransactionItemInputs, TransactionRunType } from "../types";
|
|
19
19
|
import { ReferralStateManager, TxHandler } from "../clients";
|
|
20
|
-
import {
|
|
21
|
-
InvalidRebalanceConditionError,
|
|
22
|
-
SOLAUTO_PROGRAM_ID,
|
|
23
|
-
} from "../generated";
|
|
24
20
|
// import { sendJitoBundledTransactions } from "../utils/jitoUtils";
|
|
25
21
|
|
|
26
22
|
class LookupTables {
|
|
@@ -58,6 +54,8 @@ class LookupTables {
|
|
|
58
54
|
}
|
|
59
55
|
}
|
|
60
56
|
|
|
57
|
+
|
|
58
|
+
|
|
61
59
|
export class TransactionItem {
|
|
62
60
|
lookupTableAddresses!: string[];
|
|
63
61
|
tx?: TransactionBuilder;
|
|
@@ -65,9 +63,7 @@ export class TransactionItem {
|
|
|
65
63
|
constructor(
|
|
66
64
|
public fetchTx: (
|
|
67
65
|
attemptNum: number
|
|
68
|
-
) => Promise<
|
|
69
|
-
{ tx: TransactionBuilder; lookupTableAddresses?: string[] } | undefined
|
|
70
|
-
>,
|
|
66
|
+
) => Promise<TransactionItemInputs | undefined>,
|
|
71
67
|
public name?: string
|
|
72
68
|
) {}
|
|
73
69
|
|
|
@@ -542,7 +538,9 @@ export class TransactionsManager {
|
|
|
542
538
|
undefined,
|
|
543
539
|
errorDetails.errorInfo ?? errorDetails.errorName ?? "Unknown error"
|
|
544
540
|
);
|
|
545
|
-
this.txHandler.log(
|
|
541
|
+
this.txHandler.log(
|
|
542
|
+
`${errorDetails.errorName ?? "Unknown error"}: ${errorDetails.errorInfo ?? "unknown"}`
|
|
543
|
+
);
|
|
546
544
|
|
|
547
545
|
if (!errorDetails.canBeIgnored) {
|
|
548
546
|
throw e;
|
package/src/types/solauto.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
2
|
import { LendingPlatform, PositionType } from "../generated";
|
|
3
|
+
import { TransactionBuilder } from "@metaplex-foundation/umi";
|
|
3
4
|
|
|
4
5
|
export interface SolautoPositionDetails {
|
|
5
6
|
publicKey?: PublicKey;
|
|
@@ -14,9 +15,14 @@ export interface SolautoPositionDetails {
|
|
|
14
15
|
|
|
15
16
|
export enum PriorityFeeSetting {
|
|
16
17
|
Default = "Medium",
|
|
17
|
-
High = "High"
|
|
18
|
+
High = "High",
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export type RebalanceAction = "boost" | "repay" | "dca";
|
|
21
22
|
|
|
22
|
-
export type TransactionRunType = "skip-simulation" | "only-simulate" | "normal";
|
|
23
|
+
export type TransactionRunType = "skip-simulation" | "only-simulate" | "normal";
|
|
24
|
+
|
|
25
|
+
export interface TransactionItemInputs {
|
|
26
|
+
tx: TransactionBuilder;
|
|
27
|
+
lookupTableAddresses?: string[];
|
|
28
|
+
}
|