@haven-fi/solauto-sdk 1.0.227 → 1.0.229
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/referralStateManager.d.ts +0 -2
- package/dist/clients/referralStateManager.d.ts.map +1 -1
- package/dist/clients/referralStateManager.js +0 -9
- package/dist/clients/txHandler.d.ts +2 -2
- package/dist/clients/txHandler.d.ts.map +1 -1
- package/dist/clients/txHandler.js +7 -2
- package/dist/constants/solautoConstants.d.ts +3 -0
- package/dist/constants/solautoConstants.d.ts.map +1 -1
- package/dist/constants/solautoConstants.js +8 -6
- package/dist/utils/solanaUtils.d.ts +1 -1
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +8 -2
- package/dist/utils/solauto/generalUtils.d.ts +2 -1
- package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
- package/dist/utils/solauto/generalUtils.js +16 -0
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +1 -1
- package/package.json +1 -1
- package/src/clients/referralStateManager.ts +0 -13
- package/src/clients/txHandler.ts +13 -3
- package/src/constants/solautoConstants.ts +10 -8
- package/src/utils/solanaUtils.ts +9 -2
- package/src/utils/solauto/generalUtils.ts +19 -1
- package/src/utils/solauto/rebalanceUtils.ts +1 -2
@@ -11,7 +11,6 @@ export interface ReferralStateManagerArgs {
|
|
11
11
|
referredByAuthority?: PublicKey;
|
12
12
|
}
|
13
13
|
export declare class ReferralStateManager extends TxHandler {
|
14
|
-
localTest?: boolean | undefined;
|
15
14
|
umi: Umi;
|
16
15
|
signer: Signer;
|
17
16
|
referralState: PublicKey;
|
@@ -19,7 +18,6 @@ export declare class ReferralStateManager extends TxHandler {
|
|
19
18
|
authority: PublicKey;
|
20
19
|
referredBy?: PublicKey;
|
21
20
|
referredByState?: PublicKey;
|
22
|
-
constructor(rpcUrl: string, localTest?: boolean | undefined);
|
23
21
|
initialize(args: ReferralStateManagerArgs): Promise<void>;
|
24
22
|
defaultLookupTables(): string[];
|
25
23
|
setReferredBy(referredBy?: PublicKey): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"referralStateManager.d.ts","sourceRoot":"","sources":["../../src/clients/referralStateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAEL,MAAM,EAEN,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,
|
1
|
+
{"version":3,"file":"referralStateManager.d.ts","sourceRoot":"","sources":["../../src/clients/referralStateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAEL,MAAM,EAEN,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAEL,aAAa,EAGd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,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;IA4B/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"}
|
@@ -11,15 +11,6 @@ const utils_1 = require("../utils");
|
|
11
11
|
const txHandler_1 = require("./txHandler");
|
12
12
|
const constants_1 = require("../constants");
|
13
13
|
class ReferralStateManager extends txHandler_1.TxHandler {
|
14
|
-
constructor(rpcUrl, localTest) {
|
15
|
-
super(rpcUrl, localTest);
|
16
|
-
this.localTest = localTest;
|
17
|
-
this.umi = this.umi.use({
|
18
|
-
install(umi) {
|
19
|
-
umi.programs.add((0, generated_1.createSolautoProgram)(), false);
|
20
|
-
},
|
21
|
-
});
|
22
|
-
}
|
23
14
|
async initialize(args) {
|
24
15
|
if (!args.signer && !args.wallet) {
|
25
16
|
throw new Error("Signer or wallet must be provided");
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { Umi } from "@metaplex-foundation/umi";
|
2
|
-
import { Connection } from "@solana/web3.js";
|
2
|
+
import { Connection, PublicKey } from "@solana/web3.js";
|
3
3
|
export declare abstract class TxHandler {
|
4
4
|
rpcUrl: string;
|
5
5
|
umi: Umi;
|
6
6
|
connection: Connection;
|
7
|
-
constructor(rpcUrl: string, localTest?: boolean);
|
7
|
+
constructor(rpcUrl: string, localTest?: boolean, programId?: PublicKey);
|
8
8
|
log(...args: any[]): void;
|
9
9
|
abstract defaultLookupTables(): string[];
|
10
10
|
abstract resetLiveTxUpdates(success?: boolean): Promise<void>;
|
@@ -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,
|
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;AAQxD,8BAAsB,SAAS;IACtB,MAAM,EAAG,MAAM,CAAC;IAChB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;gBAG7B,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,OAAO,EACnB,SAAS,GAAE,SAAgC;IAgB7C,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"}
|
@@ -2,12 +2,17 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.TxHandler = void 0;
|
4
4
|
const utils_1 = require("../utils");
|
5
|
+
const constants_1 = require("../constants");
|
5
6
|
class TxHandler {
|
6
|
-
constructor(rpcUrl, localTest) {
|
7
|
+
constructor(rpcUrl, localTest, programId = constants_1.SOLAUTO_PROD_PROGRAM) {
|
7
8
|
this.rpcUrl = rpcUrl;
|
8
9
|
const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.rpcUrl);
|
9
10
|
this.connection = connection;
|
10
|
-
this.umi = umi
|
11
|
+
this.umi = umi.use({
|
12
|
+
install(umi) {
|
13
|
+
umi.programs.add((0, utils_1.createDynamicSolautoProgram)(programId), false);
|
14
|
+
},
|
15
|
+
});
|
11
16
|
if (!globalThis.LOCAL_TEST && localTest) {
|
12
17
|
globalThis.LOCAL_TEST = Boolean(localTest);
|
13
18
|
}
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
2
|
+
export declare const SOLAUTO_PROD_PROGRAM: PublicKey;
|
3
|
+
export declare const SOLAUTO_TEST_PROGRAM: PublicKey;
|
1
4
|
export declare const BASIS_POINTS = 10000;
|
2
5
|
export declare const MIN_POSITION_STATE_FRESHNESS_SECS = 5;
|
3
6
|
export declare const MIN_REPAY_GAP_BPS = 50;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAUzB,eAAO,MAAM,oBAAoB,WAA+D,CAAC;AACjG,eAAO,MAAM,oBAAoB,WAA+D,CAAC;AAIjG,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,CAAC;KAAE,CAAA;CAAO,CAAC;AAE9E,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAC1E,eAAO,MAAM,qBAAqB,UAWjC,CAAC"}
|
@@ -1,22 +1,19 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.PRICES = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.BASIS_POINTS = void 0;
|
3
|
+
exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.PRICES = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.BASIS_POINTS = exports.SOLAUTO_TEST_PROGRAM = exports.SOLAUTO_PROD_PROGRAM = void 0;
|
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
7
|
const generated_1 = require("../generated");
|
8
8
|
const generalAccounts_1 = require("./generalAccounts");
|
9
9
|
const jupiter_sdk_1 = require("../jupiter-sdk");
|
10
|
+
exports.SOLAUTO_PROD_PROGRAM = new web3_js_1.PublicKey("AutoyKBRaHSBHy9RsmXCZMy6nNFAg5FYijrvZyQcNLV");
|
11
|
+
exports.SOLAUTO_TEST_PROGRAM = new web3_js_1.PublicKey("TesTjfQ6TbXv96Tv6fqr95XTZ1LYPxtkafmShN9PjBp");
|
10
12
|
globalThis.LOCAL_TEST = false;
|
11
13
|
exports.BASIS_POINTS = 10000;
|
12
14
|
exports.MIN_POSITION_STATE_FRESHNESS_SECS = 5;
|
13
15
|
exports.MIN_REPAY_GAP_BPS = 50;
|
14
16
|
exports.MIN_BOOST_GAP_BPS = 50;
|
15
|
-
// export const JITO_BLOCK_ENGINE = "ny.mainnet.block-engine.jito.wtf";
|
16
|
-
// export const JITO_CONNECTION = new JitoRpcConnection(
|
17
|
-
// `https://${JITO_BLOCK_ENGINE}`,
|
18
|
-
// "finalized"
|
19
|
-
// );
|
20
17
|
exports.PRICES = {};
|
21
18
|
exports.SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
|
22
19
|
exports.STANDARD_LUT_ACCOUNTS = [
|
@@ -31,3 +28,8 @@ exports.STANDARD_LUT_ACCOUNTS = [
|
|
31
28
|
web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY.toString(),
|
32
29
|
jupiter_sdk_1.JUPITER_PROGRAM_ID
|
33
30
|
];
|
31
|
+
// export const JITO_BLOCK_ENGINE = "ny.mainnet.block-engine.jito.wtf";
|
32
|
+
// export const JITO_CONNECTION = new JitoRpcConnection(
|
33
|
+
// `https://${JITO_BLOCK_ENGINE}`,
|
34
|
+
// "finalized"
|
35
|
+
// );
|
@@ -3,7 +3,7 @@ import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
3
3
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
4
4
|
export declare function buildHeliusApiUrl(heliusApiKey: string): string;
|
5
5
|
export declare function buildIronforgeApiUrl(ironforgeApiKey: string): string;
|
6
|
-
export declare function getSolanaRpcConnection(rpcUrl: string): [Connection, Umi];
|
6
|
+
export declare function getSolanaRpcConnection(rpcUrl: string, programId?: PublicKey): [Connection, Umi];
|
7
7
|
export declare function getWrappedInstruction(signer: Signer, ix: TransactionInstruction): WrappedInstruction;
|
8
8
|
export declare function setComputeUnitLimitUmiIx(signer: Signer, maxComputeUnits: number): WrappedInstruction;
|
9
9
|
export declare function setComputeUnitPriceUmiIx(signer: Signer, lamports: number): WrappedInstruction;
|
@@ -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,EAGL,UAAU,EACV,SAAS,EAIT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB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AE,GAAG,EACR,oBAAoB,EAAE,MAAM,EAAE,GAC7B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkBpC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,kBAAkB,EACtB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,CAAC,EAAE,MAAM,sBA4D1B;AAmBD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,GAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAsB7B;AAED,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,UAAU,CAAC,EAAE,MAAM,EACnB,eAAe,GAAE,kBAA+C,EAChE,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAmEjC"}
|
@@ -27,15 +27,21 @@ const accountUtils_1 = require("./accountUtils");
|
|
27
27
|
const generalUtils_1 = require("./generalUtils");
|
28
28
|
const marginfi_sdk_1 = require("../marginfi-sdk");
|
29
29
|
const types_1 = require("../types");
|
30
|
+
const solauto_1 = require("./solauto");
|
31
|
+
const constants_1 = require("../constants");
|
30
32
|
function buildHeliusApiUrl(heliusApiKey) {
|
31
33
|
return `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
|
32
34
|
}
|
33
35
|
function buildIronforgeApiUrl(ironforgeApiKey) {
|
34
36
|
return `https://rpc.ironforge.network/mainnet?apiKey=${ironforgeApiKey}`;
|
35
37
|
}
|
36
|
-
function getSolanaRpcConnection(rpcUrl) {
|
38
|
+
function getSolanaRpcConnection(rpcUrl, programId = constants_1.SOLAUTO_PROD_PROGRAM) {
|
37
39
|
const connection = new web3_js_1.Connection(rpcUrl, "confirmed");
|
38
|
-
const umi = (0, umi_bundle_defaults_1.createUmi)(connection)
|
40
|
+
const umi = (0, umi_bundle_defaults_1.createUmi)(connection).use({
|
41
|
+
install(umi) {
|
42
|
+
umi.programs.add((0, solauto_1.createDynamicSolautoProgram)(programId), false);
|
43
|
+
},
|
44
|
+
});
|
39
45
|
return [connection, umi];
|
40
46
|
}
|
41
47
|
function getWrappedInstruction(signer, ix) {
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
|
-
import { Umi } from "@metaplex-foundation/umi";
|
2
|
+
import { Program, Umi } from "@metaplex-foundation/umi";
|
3
3
|
import { AutomationSettings, DCASettings, DCASettingsInpArgs, PositionState, PositionType, SolautoSettingsParameters, SolautoSettingsParametersInpArgs, TokenType } from "../../generated";
|
4
4
|
import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
|
5
|
+
export declare function createDynamicSolautoProgram(programId: PublicKey): Program;
|
5
6
|
export declare function nextAutomationPeriodTimestamp(automation: AutomationSettings): number;
|
6
7
|
export declare function eligibleForNextAutomationPeriod(automation: AutomationSettings, currentUnixTime: number): boolean;
|
7
8
|
export declare function getUpdatedValueFromAutomation(currValue: number, targetValue: number, automation: AutomationSettings, currentUnixTimestamp: number): number;
|
@@ -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,
|
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,EAEZ,y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;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"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.LivePositionUpdates = void 0;
|
4
|
+
exports.createDynamicSolautoProgram = createDynamicSolautoProgram;
|
4
5
|
exports.nextAutomationPeriodTimestamp = nextAutomationPeriodTimestamp;
|
5
6
|
exports.eligibleForNextAutomationPeriod = eligibleForNextAutomationPeriod;
|
6
7
|
exports.getUpdatedValueFromAutomation = getUpdatedValueFromAutomation;
|
@@ -23,6 +24,21 @@ const accountUtils_1 = require("../accountUtils");
|
|
23
24
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
24
25
|
const constants_1 = require("../../constants");
|
25
26
|
const marginfiUtils_1 = require("../marginfiUtils");
|
27
|
+
function createDynamicSolautoProgram(programId) {
|
28
|
+
return {
|
29
|
+
name: 'solauto',
|
30
|
+
publicKey: (0, umi_1.publicKey)(programId),
|
31
|
+
getErrorFromCode(code, cause) {
|
32
|
+
return (0, generated_1.getSolautoErrorFromCode)(code, this, cause);
|
33
|
+
},
|
34
|
+
getErrorFromName(name, cause) {
|
35
|
+
return (0, generated_1.getSolautoErrorFromName)(name, this, cause);
|
36
|
+
},
|
37
|
+
isOnCluster() {
|
38
|
+
return true;
|
39
|
+
},
|
40
|
+
};
|
41
|
+
}
|
26
42
|
function newPeriodsPassed(automation, currentUnixTimestamp) {
|
27
43
|
return Math.min(automation.targetPeriods, automation.periodsPassed +
|
28
44
|
Math.floor((currentUnixTimestamp - Number(automation.unixStartDate)) /
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/rebalanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,aAAa,EAEb,kBAAkB,EAClB,yBAAyB,EACzB,SAAS,EACV,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"rebalanceUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/rebalanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,aAAa,EAEb,kBAAkB,EAClB,yBAAyB,EACzB,SAAS,EACV,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAYjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAkI9C,MAAM,WAAW,eAAe;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,kBAAkB,CAAA;CACvC;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,yBAAyB,GAAG,SAAS,EAC/C,GAAG,EAAE,WAAW,GAAG,SAAS,EAC5B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,2BAA2B,CAAC,EAAE,MAAM,GACnC,eAAe,CAgDjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CA0D9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAyChB"}
|
@@ -149,7 +149,7 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
|
|
149
149
|
? output.amountUsed.baseUnit +
|
150
150
|
BigInt(Math.round(Number(output.amountUsed.baseUnit) *
|
151
151
|
// Add this small percentage to account for the APR on the debt between now and the transaction
|
152
|
-
0.
|
152
|
+
0.00001))
|
153
153
|
: (0, numberUtils_1.toBaseUnit)(usdToSwap / (0, generalUtils_2.safeGetPrice)(output.mint), output.decimals);
|
154
154
|
const exactOut = targetLiqUtilizationRateBps === 0 || values.repayingCloseToMaxLtv;
|
155
155
|
const exactIn = !exactOut;
|
package/package.json
CHANGED
@@ -14,7 +14,6 @@ import {
|
|
14
14
|
} from "@metaplex-foundation/umi-signer-wallet-adapters";
|
15
15
|
import {
|
16
16
|
claimReferralFees,
|
17
|
-
createSolautoProgram,
|
18
17
|
ReferralState,
|
19
18
|
safeFetchReferralState,
|
20
19
|
updateReferralStates,
|
@@ -42,18 +41,6 @@ export class ReferralStateManager extends TxHandler {
|
|
42
41
|
public referredBy?: PublicKey;
|
43
42
|
public referredByState?: PublicKey;
|
44
43
|
|
45
|
-
constructor(
|
46
|
-
rpcUrl: string,
|
47
|
-
public localTest?: boolean
|
48
|
-
) {
|
49
|
-
super(rpcUrl, localTest);
|
50
|
-
this.umi = this.umi.use({
|
51
|
-
install(umi) {
|
52
|
-
umi.programs.add(createSolautoProgram(), false);
|
53
|
-
},
|
54
|
-
});
|
55
|
-
}
|
56
|
-
|
57
44
|
async initialize(args: ReferralStateManagerArgs) {
|
58
45
|
if (!args.signer && !args.wallet) {
|
59
46
|
throw new Error("Signer or wallet must be provided");
|
package/src/clients/txHandler.ts
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
import { Umi } from "@metaplex-foundation/umi";
|
2
2
|
import { Connection, PublicKey } from "@solana/web3.js";
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
consoleLog,
|
5
|
+
createDynamicSolautoProgram,
|
6
|
+
getSolanaRpcConnection,
|
7
|
+
} from "../utils";
|
8
|
+
import { SOLAUTO_PROD_PROGRAM } from "../constants";
|
4
9
|
|
5
10
|
export abstract class TxHandler {
|
6
11
|
public rpcUrl!: string;
|
@@ -9,12 +14,17 @@ export abstract class TxHandler {
|
|
9
14
|
|
10
15
|
constructor(
|
11
16
|
rpcUrl: string,
|
12
|
-
localTest?: boolean
|
17
|
+
localTest?: boolean,
|
18
|
+
programId: PublicKey = SOLAUTO_PROD_PROGRAM
|
13
19
|
) {
|
14
20
|
this.rpcUrl = rpcUrl;
|
15
21
|
const [connection, umi] = getSolanaRpcConnection(this.rpcUrl);
|
16
22
|
this.connection = connection;
|
17
|
-
this.umi = umi
|
23
|
+
this.umi = umi.use({
|
24
|
+
install(umi) {
|
25
|
+
umi.programs.add(createDynamicSolautoProgram(programId), false);
|
26
|
+
},
|
27
|
+
});
|
18
28
|
|
19
29
|
if (!(globalThis as any).LOCAL_TEST && localTest) {
|
20
30
|
(globalThis as any).LOCAL_TEST = Boolean(localTest);
|
@@ -14,6 +14,9 @@ import { SOLAUTO_PROGRAM_ID } from "../generated";
|
|
14
14
|
import { SOLAUTO_MANAGER } from "./generalAccounts";
|
15
15
|
import { JUPITER_PROGRAM_ID } from "../jupiter-sdk";
|
16
16
|
|
17
|
+
export const SOLAUTO_PROD_PROGRAM = new PublicKey("AutoyKBRaHSBHy9RsmXCZMy6nNFAg5FYijrvZyQcNLV");
|
18
|
+
export const SOLAUTO_TEST_PROGRAM = new PublicKey("TesTjfQ6TbXv96Tv6fqr95XTZ1LYPxtkafmShN9PjBp");
|
19
|
+
|
17
20
|
(globalThis as any).LOCAL_TEST = false;
|
18
21
|
|
19
22
|
export const BASIS_POINTS = 10000;
|
@@ -22,16 +25,9 @@ export const MIN_POSITION_STATE_FRESHNESS_SECS = 5;
|
|
22
25
|
export const MIN_REPAY_GAP_BPS = 50;
|
23
26
|
export const MIN_BOOST_GAP_BPS = 50;
|
24
27
|
|
25
|
-
// export const JITO_BLOCK_ENGINE = "ny.mainnet.block-engine.jito.wtf";
|
26
|
-
// export const JITO_CONNECTION = new JitoRpcConnection(
|
27
|
-
// `https://${JITO_BLOCK_ENGINE}`,
|
28
|
-
// "finalized"
|
29
|
-
// );
|
30
|
-
|
31
28
|
export const PRICES: { [key: string]: { price: number; time: number; } } = {};
|
32
29
|
|
33
30
|
export const SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
|
34
|
-
|
35
31
|
export const STANDARD_LUT_ACCOUNTS = [
|
36
32
|
PublicKey.default.toString(),
|
37
33
|
SOLAUTO_PROGRAM_ID,
|
@@ -43,4 +39,10 @@ export const STANDARD_LUT_ACCOUNTS = [
|
|
43
39
|
SYSVAR_RENT_PUBKEY.toString(),
|
44
40
|
SYSVAR_INSTRUCTIONS_PUBKEY.toString(),
|
45
41
|
JUPITER_PROGRAM_ID
|
46
|
-
];
|
42
|
+
];
|
43
|
+
|
44
|
+
// export const JITO_BLOCK_ENGINE = "ny.mainnet.block-engine.jito.wtf";
|
45
|
+
// export const JITO_CONNECTION = new JitoRpcConnection(
|
46
|
+
// `https://${JITO_BLOCK_ENGINE}`,
|
47
|
+
// "finalized"
|
48
|
+
// );
|
package/src/utils/solanaUtils.ts
CHANGED
@@ -37,6 +37,8 @@ import {
|
|
37
37
|
getLendingAccountStartFlashloanInstructionDataSerializer,
|
38
38
|
} from "../marginfi-sdk";
|
39
39
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
40
|
+
import { createDynamicSolautoProgram } from "./solauto";
|
41
|
+
import { SOLAUTO_PROD_PROGRAM } from "../constants";
|
40
42
|
|
41
43
|
export function buildHeliusApiUrl(heliusApiKey: string) {
|
42
44
|
return `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
|
@@ -47,10 +49,15 @@ export function buildIronforgeApiUrl(ironforgeApiKey: string) {
|
|
47
49
|
}
|
48
50
|
|
49
51
|
export function getSolanaRpcConnection(
|
50
|
-
rpcUrl: string
|
52
|
+
rpcUrl: string,
|
53
|
+
programId: PublicKey = SOLAUTO_PROD_PROGRAM,
|
51
54
|
): [Connection, Umi] {
|
52
55
|
const connection = new Connection(rpcUrl, "confirmed");
|
53
|
-
const umi = createUmi(connection)
|
56
|
+
const umi = createUmi(connection).use({
|
57
|
+
install(umi) {
|
58
|
+
umi.programs.add(createDynamicSolautoProgram(programId), false);
|
59
|
+
},
|
60
|
+
});
|
54
61
|
return [connection, umi];
|
55
62
|
}
|
56
63
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
|
-
import { isOption, isSome, publicKey, Umi } from "@metaplex-foundation/umi";
|
2
|
+
import { isOption, isSome, Program, publicKey, Umi } from "@metaplex-foundation/umi";
|
3
3
|
import {
|
4
4
|
AutomationSettings,
|
5
5
|
DCASettings,
|
@@ -12,6 +12,8 @@ import {
|
|
12
12
|
SolautoSettingsParametersInpArgs,
|
13
13
|
TokenType,
|
14
14
|
getReferralStateSize,
|
15
|
+
getSolautoErrorFromCode,
|
16
|
+
getSolautoErrorFromName,
|
15
17
|
getSolautoPositionAccountDataSerializer,
|
16
18
|
getSolautoPositionSize,
|
17
19
|
} from "../../generated";
|
@@ -31,6 +33,22 @@ import {
|
|
31
33
|
import { getAllMarginfiAccountsByAuthority } from "../marginfiUtils";
|
32
34
|
import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
|
33
35
|
|
36
|
+
export function createDynamicSolautoProgram(programId: PublicKey): Program {
|
37
|
+
return {
|
38
|
+
name: 'solauto',
|
39
|
+
publicKey: publicKey(programId),
|
40
|
+
getErrorFromCode(code: number, cause?: Error) {
|
41
|
+
return getSolautoErrorFromCode(code, this, cause);
|
42
|
+
},
|
43
|
+
getErrorFromName(name: string, cause?: Error) {
|
44
|
+
return getSolautoErrorFromName(name, this, cause);
|
45
|
+
},
|
46
|
+
isOnCluster() {
|
47
|
+
return true;
|
48
|
+
},
|
49
|
+
};
|
50
|
+
}
|
51
|
+
|
34
52
|
function newPeriodsPassed(
|
35
53
|
automation: AutomationSettings,
|
36
54
|
currentUnixTimestamp: number
|
@@ -19,7 +19,6 @@ import { JupSwapDetails } from "../jupiterUtils";
|
|
19
19
|
import { currentUnixSeconds, safeGetPrice } from "../generalUtils";
|
20
20
|
import {
|
21
21
|
fromBaseUnit,
|
22
|
-
fromBps,
|
23
22
|
getDebtAdjustmentUsd,
|
24
23
|
getLiqUtilzationRateBps,
|
25
24
|
getMaxLiqUtilizationRateBps,
|
@@ -323,7 +322,7 @@ export function getJupSwapRebalanceDetails(
|
|
323
322
|
Math.round(
|
324
323
|
Number(output.amountUsed.baseUnit) *
|
325
324
|
// Add this small percentage to account for the APR on the debt between now and the transaction
|
326
|
-
0.
|
325
|
+
0.00001
|
327
326
|
)
|
328
327
|
)
|
329
328
|
: toBaseUnit(usdToSwap / safeGetPrice(output.mint)!, output.decimals);
|