@haven-fi/solauto-sdk 1.0.229 → 1.0.231
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/referralStateManager.d.ts.map +1 -1
- package/dist/clients/referralStateManager.js +2 -2
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +1 -1
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +1 -1
- package/dist/clients/txHandler.d.ts +2 -1
- package/dist/clients/txHandler.d.ts.map +1 -1
- package/dist/clients/txHandler.js +3 -6
- package/dist/constants/solautoConstants.d.ts.map +1 -1
- package/dist/constants/solautoConstants.js +12 -12
- package/dist/transactions/transactionUtils.d.ts +2 -2
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +8 -8
- package/dist/transactions/transactionsManager.js +1 -1
- package/dist/types/solauto.d.ts +1 -0
- package/dist/types/solauto.d.ts.map +1 -1
- package/dist/types/solauto.js +1 -0
- package/dist/utils/accountUtils.d.ts +3 -3
- package/dist/utils/accountUtils.d.ts.map +1 -1
- package/dist/utils/accountUtils.js +6 -7
- package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
- package/dist/utils/solauto/generalUtils.js +5 -4
- package/package.json +1 -1
- package/src/clients/referralStateManager.ts +3 -2
- package/src/clients/solautoClient.ts +2 -1
- package/src/clients/solautoMarginfiClient.ts +2 -2
- package/src/clients/txHandler.ts +5 -12
- package/src/constants/solautoConstants.ts +20 -16
- package/src/transactions/transactionUtils.ts +9 -13
- package/src/transactions/transactionsManager.ts +1 -1
- package/src/types/solauto.ts +1 -0
- package/src/utils/accountUtils.ts +8 -7
- package/src/utils/solauto/generalUtils.ts +5 -5
- package/tests/transactions/solautoMarginfi.ts +7 -6
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"referralStateManager.d.ts","sourceRoot":"","sources":["../../src/clients/referralStateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAi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B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,mBAAmB,CAAC,EAAE,SAAS,CAAC;CACjC;AAED,qBAAa,oBAAqB,SAAQ,SAAS;IAC1C,GAAG,EAAG,GAAG,CAAC;IACV,MAAM,EAAG,MAAM,CAAC;IAEhB,aAAa,EAAG,SAAS,CAAC;IAC1B,iBAAiB,EAAG,aAAa,GAAG,IAAI,CAAC;IACzC,SAAS,EAAG,SAAS,CAAC;IAEtB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,eAAe,CAAC,EAAE,SAAS,CAAC;IAE7B,UAAU,CAAC,IAAI,EAAE,wBAAwB;IA6B/C,mBAAmB,IAAI,MAAM,EAAE;IAS/B,aAAa,CAAC,UAAU,CAAC,EAAE,SAAS;IAmBpC,sBAAsB,CACpB,YAAY,CAAC,EAAE,SAAS,EACxB,WAAW,CAAC,EAAE,SAAS,GACtB,kBAAkB;IAerB,mBAAmB,IAAI,kBAAkB;IA+BnC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC3D"}
|
@@ -21,7 +21,7 @@ class ReferralStateManager extends txHandler_1.TxHandler {
|
|
21
21
|
this.signer = this.umi.identity;
|
22
22
|
this.referralState = args.referralState
|
23
23
|
? args.referralState
|
24
|
-
: (0, utils_1.getReferralState)(args.authority ?? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey));
|
24
|
+
: (0, utils_1.getReferralState)(args.authority ?? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.programId);
|
25
25
|
this.referralStateData = await (0, generated_1.safeFetchReferralState)(this.umi, (0, umi_1.publicKey)(this.referralState), { commitment: "confirmed" });
|
26
26
|
this.authority = this.referralStateData
|
27
27
|
? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.authority)
|
@@ -44,7 +44,7 @@ class ReferralStateManager extends txHandler_1.TxHandler {
|
|
44
44
|
: undefined;
|
45
45
|
this.referredBy = finalReferredBy;
|
46
46
|
this.referredByState = finalReferredBy
|
47
|
-
? (0, utils_1.getReferralState)(finalReferredBy)
|
47
|
+
? (0, utils_1.getReferralState)(finalReferredBy, this.programId)
|
48
48
|
: this.referralStateData
|
49
49
|
? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.referredByState)
|
50
50
|
: undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAEhC,sBAAsB,EAKvB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAMpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,8BAAsB,aAAc,SAAQ,oBAAoB;IACvD,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC,SAAS,EAAG,SAAS,CAAC;IACtB,MAAM,EAAG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iCAAiC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAUzD,iBAAiB,IAAI,OAAO,CAChC;QAAE,WAAW,EAAE,kBAAkB,CAAC;QAAC,iBAAiB,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAC5E;IAyDD,uBAAuB,IAAI,yBAAyB,GAAG,SAAS;IAOhE,wBAAwB,IAAI,WAAW,GAAG,SAAS;IAO7C,wBAAwB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAOvE,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IA0BrB,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB;IAwDlE,eAAe,IAAI,kBAAkB;IAYrC,WAAW,IAAI,kBAAkB;IAgCjC,QAAQ,CAAC,OAAO,IAAI,kBAAkB;IAEtC,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAuFhE,QAAQ,CAAC,WAAW,CAClB,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IAErB,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAE3E,QAAQ,CAAC,SAAS,CAChB,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,wBAAwB,EACvC,eAAe,EAAE,eAAe,EAChC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
|
@@ -22,7 +22,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
|
|
22
22
|
await super.initialize(args);
|
23
23
|
this.positionId = args.positionId ?? 0;
|
24
24
|
this.selfManaged = this.positionId === 0;
|
25
|
-
this.solautoPosition = (0, accountUtils_1.getSolautoPositionAccount)(this.authority, this.positionId);
|
25
|
+
this.solautoPosition = (0, accountUtils_1.getSolautoPositionAccount)(this.authority, this.positionId, this.programId);
|
26
26
|
this.solautoPositionData = !args.new
|
27
27
|
? await (0, generated_1.safeFetchSolautoPosition)(this.umi, (0, umi_1.publicKey)(this.solautoPosition), { commitment: "confirmed" })
|
28
28
|
: null;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EAGb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAOtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAQzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
1
|
+
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,OAAO,EACL,k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G,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA6C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,wBAAwB,EACvC,eAAe,EAAE,eAAe,EAChC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAgFrB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAoFlE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CA6ClE"}
|
@@ -30,7 +30,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
30
30
|
this.marginfiAccountSeedIdx = (0, generalUtils_1.generateRandomU64)();
|
31
31
|
this.marginfiAccount = this.solautoPositionData
|
32
32
|
? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.solautoPositionData.position.protocolAccount)
|
33
|
-
: (0, accountUtils_1.getMarginfiAccountPDA)(this.solautoPosition, this.marginfiAccountSeedIdx);
|
33
|
+
: (0, accountUtils_1.getMarginfiAccountPDA)(this.solautoPosition, this.marginfiAccountSeedIdx, this.programId);
|
34
34
|
}
|
35
35
|
this.marginfiAccountPk =
|
36
36
|
"publicKey" in this.marginfiAccount
|
@@ -2,8 +2,9 @@ import { Umi } from "@metaplex-foundation/umi";
|
|
2
2
|
import { Connection, PublicKey } from "@solana/web3.js";
|
3
3
|
export declare abstract class TxHandler {
|
4
4
|
rpcUrl: string;
|
5
|
-
|
5
|
+
programId: PublicKey;
|
6
6
|
connection: Connection;
|
7
|
+
umi: Umi;
|
7
8
|
constructor(rpcUrl: string, localTest?: boolean, programId?: PublicKey);
|
8
9
|
log(...args: any[]): void;
|
9
10
|
abstract defaultLookupTables(): string[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAOxD,8BAAsB,SAAS;IAKpB,MAAM,EAAE,MAAM;IAEd,SAAS,EAAE,SAAS;IANtB,UAAU,EAAG,UAAU,CAAC;IACxB,GAAG,EAAG,GAAG,CAAC;gBAGR,MAAM,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,OAAO,EACZ,SAAS,GAAE,SAAgC;IAWpD,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAIzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC9D"}
|
@@ -6,13 +6,10 @@ const constants_1 = require("../constants");
|
|
6
6
|
class TxHandler {
|
7
7
|
constructor(rpcUrl, localTest, programId = constants_1.SOLAUTO_PROD_PROGRAM) {
|
8
8
|
this.rpcUrl = rpcUrl;
|
9
|
-
|
9
|
+
this.programId = programId;
|
10
|
+
const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.rpcUrl, this.programId);
|
10
11
|
this.connection = connection;
|
11
|
-
this.umi = umi
|
12
|
-
install(umi) {
|
13
|
-
umi.programs.add((0, utils_1.createDynamicSolautoProgram)(programId), false);
|
14
|
-
},
|
15
|
-
});
|
12
|
+
this.umi = umi;
|
16
13
|
if (!globalThis.LOCAL_TEST && localTest) {
|
17
14
|
globalThis.LOCAL_TEST = Boolean(localTest);
|
18
15
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AASzB,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AACF,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AAIF,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAO,CAAC;AAE7E,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAC1E,eAAO,MAAM,qBAAqB,UAYR,CAAC"}
|
@@ -4,7 +4,6 @@ exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.PRICES = exports.M
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
5
5
|
const spl_token_1 = require("@solana/spl-token");
|
6
6
|
// import { JitoRpcConnection } from "jito-ts";
|
7
|
-
const generated_1 = require("../generated");
|
8
7
|
const generalAccounts_1 = require("./generalAccounts");
|
9
8
|
const jupiter_sdk_1 = require("../jupiter-sdk");
|
10
9
|
exports.SOLAUTO_PROD_PROGRAM = new web3_js_1.PublicKey("AutoyKBRaHSBHy9RsmXCZMy6nNFAg5FYijrvZyQcNLV");
|
@@ -17,17 +16,18 @@ exports.MIN_BOOST_GAP_BPS = 50;
|
|
17
16
|
exports.PRICES = {};
|
18
17
|
exports.SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
|
19
18
|
exports.STANDARD_LUT_ACCOUNTS = [
|
20
|
-
web3_js_1.PublicKey.default
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
spl_token_1.
|
26
|
-
|
27
|
-
web3_js_1.
|
28
|
-
web3_js_1.
|
29
|
-
|
30
|
-
|
19
|
+
web3_js_1.PublicKey.default,
|
20
|
+
exports.SOLAUTO_PROD_PROGRAM,
|
21
|
+
exports.SOLAUTO_TEST_PROGRAM,
|
22
|
+
generalAccounts_1.SOLAUTO_MANAGER,
|
23
|
+
web3_js_1.SystemProgram.programId,
|
24
|
+
spl_token_1.TOKEN_PROGRAM_ID,
|
25
|
+
spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
26
|
+
web3_js_1.SYSVAR_CLOCK_PUBKEY,
|
27
|
+
web3_js_1.SYSVAR_RENT_PUBKEY,
|
28
|
+
web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
29
|
+
jupiter_sdk_1.JUPITER_PROGRAM_ID,
|
30
|
+
].map((x) => x.toString());
|
31
31
|
// export const JITO_BLOCK_ENGINE = "ny.mainnet.block-engine.jito.wtf";
|
32
32
|
// export const JITO_CONNECTION = new JitoRpcConnection(
|
33
33
|
// `https://${JITO_BLOCK_ENGINE}`,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { TransactionBuilder } from "@metaplex-foundation/umi";
|
1
|
+
import { TransactionBuilder, Umi } 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";
|
@@ -8,7 +8,7 @@ export declare function getTransactionChores(client: SolautoClient, tx: Transact
|
|
8
8
|
export declare function requiresRefreshBeforeRebalance(client: SolautoClient): Promise<boolean>;
|
9
9
|
export declare function buildSolautoRebalanceTransaction(client: SolautoClient, targetLiqUtilizationRateBps?: number, attemptNum?: number): Promise<TransactionItemInputs | undefined>;
|
10
10
|
export declare function convertReferralFeesToDestination(referralManager: ReferralStateManager, tokenAccount: PublicKey, destinationMint: PublicKey): Promise<TransactionItemInputs | undefined>;
|
11
|
-
export declare function getErrorInfo(tx: TransactionBuilder, error: any): {
|
11
|
+
export declare function getErrorInfo(umi: Umi, tx: TransactionBuilder, error: any): {
|
12
12
|
errorName: string | undefined;
|
13
13
|
errorInfo: undefined;
|
14
14
|
canBeIgnored: boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,
|
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;AAwCzD,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAO7D,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;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,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;;;;EAwCxE"}
|
@@ -119,7 +119,7 @@ async function transactionChoresBefore(client, accountsGettingCreated, solautoAc
|
|
119
119
|
return chores;
|
120
120
|
}
|
121
121
|
async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
|
122
|
-
const rebalanceInstructions = getRebalanceInstructions(tx);
|
122
|
+
const rebalanceInstructions = getRebalanceInstructions(client.umi, tx);
|
123
123
|
if (rebalanceInstructions.length === 0) {
|
124
124
|
return (0, umi_1.transactionBuilder)();
|
125
125
|
}
|
@@ -184,9 +184,9 @@ function transactionChoresAfter(client, solautoActions, cancellingDcaIn) {
|
|
184
184
|
}
|
185
185
|
return chores;
|
186
186
|
}
|
187
|
-
function getRebalanceInstructions(tx) {
|
187
|
+
function getRebalanceInstructions(umi, tx) {
|
188
188
|
return tx.getInstructions().filter((x) => {
|
189
|
-
if (x.programId ===
|
189
|
+
if (x.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
|
190
190
|
try {
|
191
191
|
const serializer = (0, generated_1.getMarginfiRebalanceInstructionDataSerializer)();
|
192
192
|
const discriminator = serializer.serialize({
|
@@ -204,10 +204,10 @@ function getRebalanceInstructions(tx) {
|
|
204
204
|
}
|
205
205
|
});
|
206
206
|
}
|
207
|
-
function getSolautoActions(tx) {
|
207
|
+
function getSolautoActions(umi, tx) {
|
208
208
|
let solautoActions = [];
|
209
209
|
tx.getInstructions().forEach((x) => {
|
210
|
-
if (x.programId ===
|
210
|
+
if (x.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
|
211
211
|
try {
|
212
212
|
const serializer = (0, generated_1.getMarginfiProtocolInteractionInstructionDataSerializer)();
|
213
213
|
const discriminator = serializer.serialize({
|
@@ -318,7 +318,7 @@ async function getTransactionChores(client, tx) {
|
|
318
318
|
let choresBefore = (0, umi_1.transactionBuilder)();
|
319
319
|
let choresAfter = (0, umi_1.transactionBuilder)();
|
320
320
|
const accountsGettingCreated = [];
|
321
|
-
const solautoActions = getSolautoActions(tx);
|
321
|
+
const solautoActions = getSolautoActions(client.umi, tx);
|
322
322
|
choresBefore = choresBefore.add([
|
323
323
|
await transactionChoresBefore(client, accountsGettingCreated, solautoActions, client.livePositionUpdates.dcaInBalance),
|
324
324
|
await rebalanceChoresBefore(client, tx, accountsGettingCreated),
|
@@ -429,7 +429,7 @@ async function convertReferralFeesToDestination(referralManager, tokenAccount, d
|
|
429
429
|
.add(swapIx);
|
430
430
|
return { tx, lookupTableAddresses };
|
431
431
|
}
|
432
|
-
function getErrorInfo(tx, error) {
|
432
|
+
function getErrorInfo(umi, tx, error) {
|
433
433
|
let canBeIgnored = false;
|
434
434
|
let errorName = undefined;
|
435
435
|
let errorInfo = undefined;
|
@@ -439,7 +439,7 @@ function getErrorInfo(tx, error) {
|
|
439
439
|
const err = error["InstructionError"];
|
440
440
|
const errIx = tx.getInstructions()[Math.max(0, err[0] - 2)];
|
441
441
|
const errCode = err[1]["Custom"];
|
442
|
-
if (errIx.programId ===
|
442
|
+
if (errIx.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
|
443
443
|
programError = (0, generated_1.getSolautoErrorFromCode)(errCode, (0, generated_1.createSolautoProgram)());
|
444
444
|
if (programError?.name ===
|
445
445
|
new generated_1.InvalidRebalanceConditionError((0, generated_1.createSolautoProgram)()).name) {
|
@@ -334,7 +334,7 @@ class TransactionsManager {
|
|
334
334
|
this.updateStatus(txName, TransactionStatus.Successful, attemptNum, txSig ? bs58_1.default.encode(txSig) : undefined);
|
335
335
|
}
|
336
336
|
catch (e) {
|
337
|
-
const errorDetails = (0, transactionUtils_1.getErrorInfo)(tx, e);
|
337
|
+
const errorDetails = (0, transactionUtils_1.getErrorInfo)(this.txHandler.umi, tx, e);
|
338
338
|
this.updateStatus(txName, errorDetails.canBeIgnored
|
339
339
|
? TransactionStatus.Skipped
|
340
340
|
: TransactionStatus.Failed, attemptNum, undefined, undefined, errorDetails.errorInfo ?? errorDetails.errorName ?? "Unknown error");
|
package/dist/types/solauto.d.ts
CHANGED
@@ -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;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"}
|
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,GAAG,QAAQ;IACX,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/dist/types/solauto.js
CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PriorityFeeSetting = void 0;
|
4
4
|
var PriorityFeeSetting;
|
5
5
|
(function (PriorityFeeSetting) {
|
6
|
+
PriorityFeeSetting["Low"] = "Low";
|
6
7
|
PriorityFeeSetting["Default"] = "Medium";
|
7
8
|
PriorityFeeSetting["High"] = "High";
|
8
9
|
})(PriorityFeeSetting || (exports.PriorityFeeSetting = PriorityFeeSetting = {}));
|
@@ -5,7 +5,7 @@ export declare function bufferFromU64(num: bigint): Buffer;
|
|
5
5
|
export declare function getTokenAccount(wallet: PublicKey, tokenMint: PublicKey): PublicKey;
|
6
6
|
export declare function getTokenAccounts(wallet: PublicKey, tokenMints: PublicKey[]): PublicKey[];
|
7
7
|
export declare function getTokenAccountData(umi: Umi, tokenAccount: PublicKey): Promise<import("@solana/spl-token").RawAccount | undefined>;
|
8
|
-
export declare function getSolautoPositionAccount(signer: PublicKey, positionId: number): PublicKey;
|
9
|
-
export declare function getReferralState(authority: PublicKey): PublicKey;
|
10
|
-
export declare function getMarginfiAccountPDA(solautoPositionAccount: PublicKey, marginfiAccountSeedIdx: bigint): PublicKey;
|
8
|
+
export declare function getSolautoPositionAccount(signer: PublicKey, positionId: number, programId: PublicKey): PublicKey;
|
9
|
+
export declare function getReferralState(authority: PublicKey, programId: PublicKey): PublicKey;
|
10
|
+
export declare function getMarginfiAccountPDA(solautoPositionAccount: PublicKey, marginfiAccountSeedIdx: bigint, programId: PublicKey): PublicKey;
|
11
11
|
//# sourceMappingURL=accountUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"accountUtils.d.ts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"accountUtils.d.ts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAMlF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAExF;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,+DAO1E;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,SAAS,aAQrB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,aAU1E;AAED,wBAAgB,qBAAqB,CACnC,sBAAsB,EAAE,SAAS,EACjC,sBAAsB,EAAE,MAAM,EAC9B,SAAS,EAAE,SAAS,aAarB"}
|
@@ -10,7 +10,6 @@ exports.getReferralState = getReferralState;
|
|
10
10
|
exports.getMarginfiAccountPDA = getMarginfiAccountPDA;
|
11
11
|
const web3_js_1 = require("@solana/web3.js");
|
12
12
|
const spl_token_1 = require("@solana/spl-token");
|
13
|
-
const generated_1 = require("../generated");
|
14
13
|
const umi_1 = require("@metaplex-foundation/umi");
|
15
14
|
function bufferFromU8(num) {
|
16
15
|
const buffer = Buffer.alloc(1);
|
@@ -37,21 +36,21 @@ async function getTokenAccountData(umi, tokenAccount) {
|
|
37
36
|
return undefined;
|
38
37
|
}
|
39
38
|
}
|
40
|
-
function getSolautoPositionAccount(signer, positionId) {
|
41
|
-
const [positionAccount, _] = web3_js_1.PublicKey.findProgramAddressSync([bufferFromU8(positionId), signer.toBuffer()],
|
39
|
+
function getSolautoPositionAccount(signer, positionId, programId) {
|
40
|
+
const [positionAccount, _] = web3_js_1.PublicKey.findProgramAddressSync([bufferFromU8(positionId), signer.toBuffer()], programId);
|
42
41
|
return positionAccount;
|
43
42
|
}
|
44
|
-
function getReferralState(authority) {
|
43
|
+
function getReferralState(authority, programId) {
|
45
44
|
const str = "referral_state";
|
46
45
|
const strBuffer = Buffer.from(str, "utf-8");
|
47
|
-
const [ReferralState, _] = web3_js_1.PublicKey.findProgramAddressSync([strBuffer, authority.toBuffer()],
|
46
|
+
const [ReferralState, _] = web3_js_1.PublicKey.findProgramAddressSync([strBuffer, authority.toBuffer()], programId);
|
48
47
|
return ReferralState;
|
49
48
|
}
|
50
|
-
function getMarginfiAccountPDA(solautoPositionAccount, marginfiAccountSeedIdx) {
|
49
|
+
function getMarginfiAccountPDA(solautoPositionAccount, marginfiAccountSeedIdx, programId) {
|
51
50
|
const seeds = [
|
52
51
|
solautoPositionAccount.toBuffer(),
|
53
52
|
bufferFromU64(marginfiAccountSeedIdx),
|
54
53
|
];
|
55
|
-
const [marginfiAccount, _] = web3_js_1.PublicKey.findProgramAddressSync(seeds,
|
54
|
+
const [marginfiAccount, _] = web3_js_1.PublicKey.findProgramAddressSync(seeds, programId);
|
56
55
|
return marginfiAccount;
|
57
56
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAoB,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAElB,aAAa,EACb,YAAY,
|
1
|
+
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAoB,OAAO,EAAa,GAAG,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AC;IAAC,KAAK,EAAE,SAAS,CAAC;CAAE,CAAC;AAEjD,qBAAa,mBAAmB;IACvB,gBAAgB,SAAa;IAC7B,cAAc,SAAa;IAC3B,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAa;IAC5D,SAAS,EAAE,WAAW,GAAG,SAAS,CAAa;IAC/C,YAAY,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,CAAC;KAAE,CAAa;IACrE,aAAa,EAAE,SAAS,GAAG,SAAS,CAAa;IAExD,GAAG,CAAC,MAAM,EAAE,kBAAkB;IA6B9B,KAAK;IASL,UAAU,IAAI,OAAO;CAStB"}
|
@@ -115,7 +115,7 @@ async function getSolautoManagedPositions(umi, authority, positionTypeFilter) {
|
|
115
115
|
// protocol account: pubkey
|
116
116
|
// supply mint: pubkey
|
117
117
|
// debt mint: pubkey
|
118
|
-
const accounts = await umi.rpc.getProgramAccounts(
|
118
|
+
const accounts = await umi.rpc.getProgramAccounts(umi.programs.get("solauto").publicKey, {
|
119
119
|
commitment: "confirmed",
|
120
120
|
dataSlice: {
|
121
121
|
offset: 0,
|
@@ -169,7 +169,7 @@ async function getSolautoManagedPositions(umi, authority, positionTypeFilter) {
|
|
169
169
|
});
|
170
170
|
}
|
171
171
|
async function getAllReferralStates(umi) {
|
172
|
-
const accounts = await umi.rpc.getProgramAccounts(
|
172
|
+
const accounts = await umi.rpc.getProgramAccounts(umi.programs.get("solauto").publicKey, {
|
173
173
|
commitment: "confirmed",
|
174
174
|
dataSlice: {
|
175
175
|
offset: 0,
|
@@ -188,8 +188,9 @@ async function getReferralsByUser(umi, user) {
|
|
188
188
|
// padding: [u8; 7],
|
189
189
|
// authority: Pubkey,
|
190
190
|
// referred_by_state: Pubkey,
|
191
|
-
const
|
192
|
-
const
|
191
|
+
const programId = umi.programs.get("solauto").publicKey;
|
192
|
+
const userReferralState = (0, accountUtils_1.getReferralState)(user, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(programId));
|
193
|
+
const accounts = await umi.rpc.getProgramAccounts(programId, {
|
193
194
|
commitment: "confirmed",
|
194
195
|
dataSlice: {
|
195
196
|
offset: 0,
|
package/package.json
CHANGED
@@ -55,7 +55,8 @@ export class ReferralStateManager extends TxHandler {
|
|
55
55
|
this.referralState = args.referralState
|
56
56
|
? args.referralState
|
57
57
|
: getReferralState(
|
58
|
-
args.authority ?? toWeb3JsPublicKey(this.signer.publicKey)
|
58
|
+
args.authority ?? toWeb3JsPublicKey(this.signer.publicKey),
|
59
|
+
this.programId
|
59
60
|
);
|
60
61
|
this.referralStateData = await safeFetchReferralState(
|
61
62
|
this.umi,
|
@@ -91,7 +92,7 @@ export class ReferralStateManager extends TxHandler {
|
|
91
92
|
|
92
93
|
this.referredBy = finalReferredBy;
|
93
94
|
this.referredByState = finalReferredBy
|
94
|
-
? getReferralState(finalReferredBy)
|
95
|
+
? getReferralState(finalReferredBy, this.programId)
|
95
96
|
: this.referralStateData
|
96
97
|
? toWeb3JsPublicKey(this.referralStateData.referredByState)
|
97
98
|
: undefined;
|
@@ -93,7 +93,8 @@ export abstract class SolautoClient extends ReferralStateManager {
|
|
93
93
|
this.selfManaged = this.positionId === 0;
|
94
94
|
this.solautoPosition = getSolautoPositionAccount(
|
95
95
|
this.authority,
|
96
|
-
this.positionId
|
96
|
+
this.positionId,
|
97
|
+
this.programId
|
97
98
|
);
|
98
99
|
this.solautoPositionData = !args.new
|
99
100
|
? await safeFetchSolautoPosition(
|
@@ -64,7 +64,6 @@ import {
|
|
64
64
|
} from "../utils/marginfiUtils";
|
65
65
|
import { bytesToI80F48, fromBaseUnit, toBps } from "../utils/numberUtils";
|
66
66
|
import { QuoteResponse } from "@jup-ag/api";
|
67
|
-
import { SOLAUTO_FEES_WALLET } from "../constants";
|
68
67
|
|
69
68
|
export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
|
70
69
|
marginfiAccount?: PublicKey | Signer;
|
@@ -108,7 +107,8 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
108
107
|
? toWeb3JsPublicKey(this.solautoPositionData.position.protocolAccount)
|
109
108
|
: getMarginfiAccountPDA(
|
110
109
|
this.solautoPosition,
|
111
|
-
this.marginfiAccountSeedIdx
|
110
|
+
this.marginfiAccountSeedIdx,
|
111
|
+
this.programId
|
112
112
|
);
|
113
113
|
}
|
114
114
|
this.marginfiAccountPk =
|
package/src/clients/txHandler.ts
CHANGED
@@ -2,29 +2,22 @@ import { Umi } from "@metaplex-foundation/umi";
|
|
2
2
|
import { Connection, PublicKey } from "@solana/web3.js";
|
3
3
|
import {
|
4
4
|
consoleLog,
|
5
|
-
createDynamicSolautoProgram,
|
6
5
|
getSolanaRpcConnection,
|
7
6
|
} from "../utils";
|
8
7
|
import { SOLAUTO_PROD_PROGRAM } from "../constants";
|
9
8
|
|
10
9
|
export abstract class TxHandler {
|
11
|
-
public rpcUrl!: string;
|
12
|
-
public umi!: Umi;
|
13
10
|
public connection!: Connection;
|
11
|
+
public umi!: Umi;
|
14
12
|
|
15
13
|
constructor(
|
16
|
-
rpcUrl: string,
|
14
|
+
public rpcUrl: string,
|
17
15
|
localTest?: boolean,
|
18
|
-
programId: PublicKey = SOLAUTO_PROD_PROGRAM
|
16
|
+
public programId: PublicKey = SOLAUTO_PROD_PROGRAM
|
19
17
|
) {
|
20
|
-
this.rpcUrl
|
21
|
-
const [connection, umi] = getSolanaRpcConnection(this.rpcUrl);
|
18
|
+
const [connection, umi] = getSolanaRpcConnection(this.rpcUrl, this.programId);
|
22
19
|
this.connection = connection;
|
23
|
-
this.umi = umi
|
24
|
-
install(umi) {
|
25
|
-
umi.programs.add(createDynamicSolautoProgram(programId), false);
|
26
|
-
},
|
27
|
-
});
|
20
|
+
this.umi = umi;
|
28
21
|
|
29
22
|
if (!(globalThis as any).LOCAL_TEST && localTest) {
|
30
23
|
(globalThis as any).LOCAL_TEST = Boolean(localTest);
|
@@ -10,12 +10,15 @@ import {
|
|
10
10
|
TOKEN_PROGRAM_ID,
|
11
11
|
} from "@solana/spl-token";
|
12
12
|
// import { JitoRpcConnection } from "jito-ts";
|
13
|
-
import { SOLAUTO_PROGRAM_ID } from "../generated";
|
14
13
|
import { SOLAUTO_MANAGER } from "./generalAccounts";
|
15
14
|
import { JUPITER_PROGRAM_ID } from "../jupiter-sdk";
|
16
15
|
|
17
|
-
export const SOLAUTO_PROD_PROGRAM = new PublicKey(
|
18
|
-
|
16
|
+
export const SOLAUTO_PROD_PROGRAM = new PublicKey(
|
17
|
+
"AutoyKBRaHSBHy9RsmXCZMy6nNFAg5FYijrvZyQcNLV"
|
18
|
+
);
|
19
|
+
export const SOLAUTO_TEST_PROGRAM = new PublicKey(
|
20
|
+
"TesTjfQ6TbXv96Tv6fqr95XTZ1LYPxtkafmShN9PjBp"
|
21
|
+
);
|
19
22
|
|
20
23
|
(globalThis as any).LOCAL_TEST = false;
|
21
24
|
|
@@ -25,24 +28,25 @@ export const MIN_POSITION_STATE_FRESHNESS_SECS = 5;
|
|
25
28
|
export const MIN_REPAY_GAP_BPS = 50;
|
26
29
|
export const MIN_BOOST_GAP_BPS = 50;
|
27
30
|
|
28
|
-
export const PRICES: { [key: string]: { price: number; time: number
|
31
|
+
export const PRICES: { [key: string]: { price: number; time: number } } = {};
|
29
32
|
|
30
33
|
export const SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
|
31
34
|
export const STANDARD_LUT_ACCOUNTS = [
|
32
|
-
PublicKey.default
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
PublicKey.default,
|
36
|
+
SOLAUTO_PROD_PROGRAM,
|
37
|
+
SOLAUTO_TEST_PROGRAM,
|
38
|
+
SOLAUTO_MANAGER,
|
39
|
+
SystemProgram.programId,
|
40
|
+
TOKEN_PROGRAM_ID,
|
41
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
42
|
+
SYSVAR_CLOCK_PUBKEY,
|
43
|
+
SYSVAR_RENT_PUBKEY,
|
44
|
+
SYSVAR_INSTRUCTIONS_PUBKEY,
|
45
|
+
JUPITER_PROGRAM_ID,
|
46
|
+
].map((x) => x.toString());
|
43
47
|
|
44
48
|
// export const JITO_BLOCK_ENGINE = "ny.mainnet.block-engine.jito.wtf";
|
45
49
|
// export const JITO_CONNECTION = new JitoRpcConnection(
|
46
50
|
// `https://${JITO_BLOCK_ENGINE}`,
|
47
51
|
// "finalized"
|
48
|
-
// );
|
52
|
+
// );
|
@@ -11,13 +11,10 @@ import { PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY } from "@solana/web3.js";
|
|
11
11
|
import {
|
12
12
|
ACCOUNT_SIZE as TOKEN_ACCOUNT_SIZE,
|
13
13
|
NATIVE_MINT,
|
14
|
-
RawAccount,
|
15
14
|
} from "@solana/spl-token";
|
16
15
|
import {
|
17
16
|
InvalidRebalanceConditionError,
|
18
17
|
LendingPlatform,
|
19
|
-
ReferralState,
|
20
|
-
SOLAUTO_PROGRAM_ID,
|
21
18
|
SolautoAction,
|
22
19
|
SolautoRebalanceType,
|
23
20
|
TokenType,
|
@@ -27,7 +24,6 @@ import {
|
|
27
24
|
getMarginfiRebalanceInstructionDataSerializer,
|
28
25
|
getSolautoErrorFromCode,
|
29
26
|
isSolautoAction,
|
30
|
-
safeFetchReferralState,
|
31
27
|
solautoAction,
|
32
28
|
} from "../generated";
|
33
29
|
import { SolautoClient } from "../clients/solautoClient";
|
@@ -76,7 +72,7 @@ import {
|
|
76
72
|
getJupiterErrorFromName,
|
77
73
|
JUPITER_PROGRAM_ID,
|
78
74
|
} from "../jupiter-sdk";
|
79
|
-
import { PRICES
|
75
|
+
import { PRICES } from "../constants";
|
80
76
|
import { TransactionItemInputs } from "../types";
|
81
77
|
|
82
78
|
interface wSolTokenUsage {
|
@@ -263,7 +259,7 @@ export async function rebalanceChoresBefore(
|
|
263
259
|
tx: TransactionBuilder,
|
264
260
|
accountsGettingCreated: string[]
|
265
261
|
): Promise<TransactionBuilder> {
|
266
|
-
const rebalanceInstructions = getRebalanceInstructions(tx);
|
262
|
+
const rebalanceInstructions = getRebalanceInstructions(client.umi, tx);
|
267
263
|
if (rebalanceInstructions.length === 0) {
|
268
264
|
return transactionBuilder();
|
269
265
|
}
|
@@ -404,9 +400,9 @@ function transactionChoresAfter(
|
|
404
400
|
return chores;
|
405
401
|
}
|
406
402
|
|
407
|
-
function getRebalanceInstructions(tx: TransactionBuilder): Instruction[] {
|
403
|
+
function getRebalanceInstructions(umi: Umi, tx: TransactionBuilder): Instruction[] {
|
408
404
|
return tx.getInstructions().filter((x) => {
|
409
|
-
if (x.programId ===
|
405
|
+
if (x.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
|
410
406
|
try {
|
411
407
|
const serializer = getMarginfiRebalanceInstructionDataSerializer();
|
412
408
|
const discriminator = serializer.serialize({
|
@@ -424,11 +420,11 @@ function getRebalanceInstructions(tx: TransactionBuilder): Instruction[] {
|
|
424
420
|
});
|
425
421
|
}
|
426
422
|
|
427
|
-
function getSolautoActions(tx: TransactionBuilder): SolautoAction[] {
|
423
|
+
function getSolautoActions(umi: Umi, tx: TransactionBuilder): SolautoAction[] {
|
428
424
|
let solautoActions: SolautoAction[] = [];
|
429
425
|
|
430
426
|
tx.getInstructions().forEach((x) => {
|
431
|
-
if (x.programId ===
|
427
|
+
if (x.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
|
432
428
|
try {
|
433
429
|
const serializer =
|
434
430
|
getMarginfiProtocolInteractionInstructionDataSerializer();
|
@@ -562,7 +558,7 @@ export async function getTransactionChores(
|
|
562
558
|
let choresAfter = transactionBuilder();
|
563
559
|
const accountsGettingCreated: string[] = [];
|
564
560
|
|
565
|
-
const solautoActions = getSolautoActions(tx);
|
561
|
+
const solautoActions = getSolautoActions(client.umi, tx);
|
566
562
|
|
567
563
|
choresBefore = choresBefore.add([
|
568
564
|
await transactionChoresBefore(
|
@@ -798,7 +794,7 @@ export async function convertReferralFeesToDestination(
|
|
798
794
|
return { tx, lookupTableAddresses };
|
799
795
|
}
|
800
796
|
|
801
|
-
export function getErrorInfo(tx: TransactionBuilder, error: any) {
|
797
|
+
export function getErrorInfo(umi: Umi, tx: TransactionBuilder, error: any) {
|
802
798
|
let canBeIgnored = false;
|
803
799
|
let errorName: string | undefined = undefined;
|
804
800
|
let errorInfo: string | undefined = undefined;
|
@@ -811,7 +807,7 @@ export function getErrorInfo(tx: TransactionBuilder, error: any) {
|
|
811
807
|
const errIx = tx.getInstructions()[Math.max(0, err[0] - 2)];
|
812
808
|
const errCode = err[1]["Custom"];
|
813
809
|
|
814
|
-
if (errIx.programId ===
|
810
|
+
if (errIx.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
|
815
811
|
programError = getSolautoErrorFromCode(errCode, createSolautoProgram());
|
816
812
|
if (
|
817
813
|
programError?.name ===
|
@@ -526,7 +526,7 @@ export class TransactionsManager {
|
|
526
526
|
txSig ? bs58.encode(txSig) : undefined
|
527
527
|
);
|
528
528
|
} catch (e: any) {
|
529
|
-
const errorDetails = getErrorInfo(tx, e);
|
529
|
+
const errorDetails = getErrorInfo(this.txHandler.umi, tx, e);
|
530
530
|
|
531
531
|
this.updateStatus(
|
532
532
|
txName,
|
package/src/types/solauto.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
2
|
import { AccountLayout as SplTokenAccountLayout, getAssociatedTokenAddressSync } from "@solana/spl-token";
|
3
|
-
import { SOLAUTO_PROGRAM_ID } from "../generated";
|
4
3
|
import { publicKey, Umi } from "@metaplex-foundation/umi";
|
5
4
|
|
6
5
|
export function bufferFromU8(num: number): Buffer {
|
@@ -38,23 +37,24 @@ export async function getTokenAccountData(umi: Umi, tokenAccount: PublicKey) {
|
|
38
37
|
|
39
38
|
export function getSolautoPositionAccount(
|
40
39
|
signer: PublicKey,
|
41
|
-
positionId: number
|
40
|
+
positionId: number,
|
41
|
+
programId: PublicKey
|
42
42
|
) {
|
43
43
|
const [positionAccount, _] = PublicKey.findProgramAddressSync(
|
44
44
|
[bufferFromU8(positionId), signer.toBuffer()],
|
45
|
-
|
45
|
+
programId
|
46
46
|
);
|
47
47
|
|
48
48
|
return positionAccount;
|
49
49
|
}
|
50
50
|
|
51
|
-
export function getReferralState(authority: PublicKey) {
|
51
|
+
export function getReferralState(authority: PublicKey, programId: PublicKey) {
|
52
52
|
const str = "referral_state";
|
53
53
|
const strBuffer = Buffer.from(str, "utf-8");
|
54
54
|
|
55
55
|
const [ReferralState, _] = PublicKey.findProgramAddressSync(
|
56
56
|
[strBuffer, authority.toBuffer()],
|
57
|
-
|
57
|
+
programId
|
58
58
|
);
|
59
59
|
|
60
60
|
return ReferralState;
|
@@ -62,7 +62,8 @@ export function getReferralState(authority: PublicKey) {
|
|
62
62
|
|
63
63
|
export function getMarginfiAccountPDA(
|
64
64
|
solautoPositionAccount: PublicKey,
|
65
|
-
marginfiAccountSeedIdx: bigint
|
65
|
+
marginfiAccountSeedIdx: bigint,
|
66
|
+
programId: PublicKey
|
66
67
|
) {
|
67
68
|
const seeds = [
|
68
69
|
solautoPositionAccount.toBuffer(),
|
@@ -71,7 +72,7 @@ export function getMarginfiAccountPDA(
|
|
71
72
|
|
72
73
|
const [marginfiAccount, _] = PublicKey.findProgramAddressSync(
|
73
74
|
seeds,
|
74
|
-
|
75
|
+
programId
|
75
76
|
);
|
76
77
|
|
77
78
|
return marginfiAccount;
|
@@ -7,7 +7,6 @@ import {
|
|
7
7
|
LendingPlatform,
|
8
8
|
PositionState,
|
9
9
|
PositionType,
|
10
|
-
SOLAUTO_PROGRAM_ID,
|
11
10
|
SolautoSettingsParameters,
|
12
11
|
SolautoSettingsParametersInpArgs,
|
13
12
|
TokenType,
|
@@ -194,7 +193,7 @@ export async function getSolautoManagedPositions(
|
|
194
193
|
// supply mint: pubkey
|
195
194
|
// debt mint: pubkey
|
196
195
|
|
197
|
-
const accounts = await umi.rpc.getProgramAccounts(
|
196
|
+
const accounts = await umi.rpc.getProgramAccounts(umi.programs.get("solauto").publicKey, {
|
198
197
|
commitment: "confirmed",
|
199
198
|
dataSlice: {
|
200
199
|
offset: 0,
|
@@ -252,7 +251,7 @@ export async function getSolautoManagedPositions(
|
|
252
251
|
}
|
253
252
|
|
254
253
|
export async function getAllReferralStates(umi: Umi): Promise<PublicKey[]> {
|
255
|
-
const accounts = await umi.rpc.getProgramAccounts(
|
254
|
+
const accounts = await umi.rpc.getProgramAccounts(umi.programs.get("solauto").publicKey, {
|
256
255
|
commitment: "confirmed",
|
257
256
|
dataSlice: {
|
258
257
|
offset: 0,
|
@@ -277,8 +276,9 @@ export async function getReferralsByUser(
|
|
277
276
|
// authority: Pubkey,
|
278
277
|
// referred_by_state: Pubkey,
|
279
278
|
|
280
|
-
const
|
281
|
-
const
|
279
|
+
const programId = umi.programs.get("solauto").publicKey;
|
280
|
+
const userReferralState = getReferralState(user, toWeb3JsPublicKey(programId));
|
281
|
+
const accounts = await umi.rpc.getProgramAccounts(programId, {
|
282
282
|
commitment: "confirmed",
|
283
283
|
dataSlice: {
|
284
284
|
offset: 0,
|
@@ -20,22 +20,23 @@ import {
|
|
20
20
|
TransactionsManager,
|
21
21
|
} from "../../src/transactions/transactionsManager";
|
22
22
|
import { PublicKey } from "@solana/web3.js";
|
23
|
-
import { USDC } from "../../src/constants";
|
23
|
+
import { SOLAUTO_TEST_PROGRAM, USDC } from "../../src/constants";
|
24
24
|
import { buildHeliusApiUrl } from "../../src/utils";
|
25
25
|
import { PriorityFeeSetting } from "../../src/types";
|
26
26
|
|
27
27
|
describe("Solauto Marginfi tests", async () => {
|
28
|
-
|
29
|
-
const signer = setupTest("solauto-manager");
|
28
|
+
const signer = setupTest();
|
29
|
+
// const signer = setupTest("solauto-manager");
|
30
30
|
|
31
|
-
const payForTransactions =
|
31
|
+
const payForTransactions = false;
|
32
32
|
const useJitoBundle = false;
|
33
33
|
const positionId = 1;
|
34
34
|
|
35
35
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
36
36
|
const client = new SolautoMarginfiClient(
|
37
37
|
buildHeliusApiUrl(process.env.HELIUS_API_KEY!),
|
38
|
-
true
|
38
|
+
true,
|
39
|
+
SOLAUTO_TEST_PROGRAM
|
39
40
|
);
|
40
41
|
|
41
42
|
const supply = NATIVE_MINT;
|
@@ -128,7 +129,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
128
129
|
transactionItems.push(
|
129
130
|
new TransactionItem(
|
130
131
|
async (attemptNum) =>
|
131
|
-
await buildSolautoRebalanceTransaction(client,
|
132
|
+
await buildSolautoRebalanceTransaction(client, 7000, attemptNum),
|
132
133
|
"rebalance"
|
133
134
|
)
|
134
135
|
);
|