@haven-fi/solauto-sdk 1.0.35 → 1.0.37
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoClient.d.ts +0 -1
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +3 -4
- package/dist/constants/solautoConstants.d.ts.map +1 -1
- package/dist/utils/solanaUtils.d.ts +1 -0
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +8 -1
- package/dist/utils/solauto/generalUtils.d.ts +1 -0
- package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
- package/dist/utils/solauto/generalUtils.js +1 -0
- package/package.json +1 -1
- package/src/clients/solautoClient.ts +7 -12
- package/src/constants/solautoConstants.ts +0 -2
- package/src/utils/solanaUtils.ts +10 -0
- package/src/utils/solauto/generalUtils.ts +2 -0
- package/tests/transactions/solautoMarginfi.ts +6 -6
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAEL,UAAU,EACV,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAQJ,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAEL,UAAU,EACV,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAQJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,g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AE,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,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAYlE"}
|
@@ -5,7 +5,6 @@ require("rpc-websockets/dist/lib/client");
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
6
6
|
const umi_1 = require("@metaplex-foundation/umi");
|
7
7
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
8
|
-
const umi_bundle_defaults_1 = require("@metaplex-foundation/umi-bundle-defaults");
|
9
8
|
const umi_signer_wallet_adapters_1 = require("@metaplex-foundation/umi-signer-wallet-adapters");
|
10
9
|
const generated_1 = require("../generated");
|
11
10
|
const accountUtils_1 = require("../utils/accountUtils");
|
@@ -17,11 +16,11 @@ const generalUtils_1 = require("../utils/generalUtils");
|
|
17
16
|
const generalUtils_2 = require("../utils/solauto/generalUtils");
|
18
17
|
class SolautoClient {
|
19
18
|
constructor(heliusApiKey, localTest) {
|
20
|
-
this.heliusApiKey = heliusApiKey;
|
21
19
|
this.localTest = localTest;
|
22
20
|
this.livePositionUpdates = new generalUtils_2.LivePositionUpdates();
|
23
|
-
|
24
|
-
this.
|
21
|
+
const [connection, umi] = (0, solanaUtils_1.getSolanaRpcConnection)(heliusApiKey);
|
22
|
+
this.connection = connection;
|
23
|
+
this.umi = umi.use({
|
25
24
|
install(umi) {
|
26
25
|
umi.programs.add((0, generated_1.createSolautoProgram)(), false);
|
27
26
|
},
|
@@ -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":"AAeA,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAQrC,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,kBAAkB,gDAAgD,CAAC;AAEhF,eAAO,MAAM,qBAAqB,UAWjC,CAAC"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { AddressLookupTableInput, Signer, TransactionBuilder, Umi, WrappedInstruction } from "@metaplex-foundation/umi";
|
2
2
|
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
3
|
+
export declare function getSolanaRpcConnection(heliusApiKey: string): [Connection, Umi];
|
3
4
|
export declare function currentUnixSecondsSolana(umi: Umi): Promise<number>;
|
4
5
|
export declare function getWrappedInstruction(signer: Signer, ix: TransactionInstruction): WrappedInstruction;
|
5
6
|
export declare function setComputeUnitLimitUmiIx(signer: Signer, maxComputeUnits: 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;
|
1
|
+
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAC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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,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,YAAY,CAAC,EAAE,OAAO,EACtB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAmDjC"}
|
@@ -3,15 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.sendSingleOptimizedTransaction = exports.getComputeUnitPriceEstimate = exports.assembleFinalTransaction = exports.getAdressLookupInputs = exports.splTokenTransferUmiIx = exports.closeTokenAccountUmiIx = exports.systemTransferUmiIx = exports.createAssociatedTokenAccountUmiIx = exports.setComputeUnitPriceUmiIx = exports.setComputeUnitLimitUmiIx = exports.getWrappedInstruction = exports.currentUnixSecondsSolana = void 0;
|
6
|
+
exports.sendSingleOptimizedTransaction = exports.getComputeUnitPriceEstimate = exports.assembleFinalTransaction = exports.getAdressLookupInputs = exports.splTokenTransferUmiIx = exports.closeTokenAccountUmiIx = exports.systemTransferUmiIx = exports.createAssociatedTokenAccountUmiIx = exports.setComputeUnitPriceUmiIx = exports.setComputeUnitLimitUmiIx = exports.getWrappedInstruction = exports.currentUnixSecondsSolana = exports.getSolanaRpcConnection = void 0;
|
7
7
|
const bs58_1 = __importDefault(require("bs58"));
|
8
8
|
const umi_1 = require("@metaplex-foundation/umi");
|
9
9
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
10
|
+
const umi_bundle_defaults_1 = require("@metaplex-foundation/umi-bundle-defaults");
|
10
11
|
const web3_js_1 = require("@solana/web3.js");
|
11
12
|
const spl_token_1 = require("@solana/spl-token");
|
12
13
|
const accountUtils_1 = require("./accountUtils");
|
13
14
|
const generalUtils_1 = require("./generalUtils");
|
14
15
|
const marginfi_sdk_1 = require("../marginfi-sdk");
|
16
|
+
function getSolanaRpcConnection(heliusApiKey) {
|
17
|
+
const connection = new web3_js_1.Connection(`https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`, "finalized");
|
18
|
+
const umi = (0, umi_bundle_defaults_1.createUmi)(connection);
|
19
|
+
return [connection, umi];
|
20
|
+
}
|
21
|
+
exports.getSolanaRpcConnection = getSolanaRpcConnection;
|
15
22
|
async function currentUnixSecondsSolana(umi) {
|
16
23
|
return await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
|
17
24
|
const blockTime = await umi.rpc.getBlockTime(await umi.rpc.getSlot());
|
@@ -14,6 +14,7 @@ export declare function getSolautoFeesBps(isReferred: boolean, feeType: FeeType)
|
|
14
14
|
export declare function eligibileForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters, positionDca: DCASettings): boolean;
|
15
15
|
export declare function eligibleForRefresh(positionState: PositionState, positionSettings: SolautoSettingsParameters): boolean;
|
16
16
|
export declare function getSolautoManagedPositions(umi: Umi, authority?: PublicKey): Promise<{
|
17
|
+
publicKey: PublicKey;
|
17
18
|
authority: PublicKey;
|
18
19
|
positionId: number;
|
19
20
|
lendingPlatform: LendingPlatform;
|
@@ -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,GAAG,EAAE,MAAM,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AS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,eAAe,CAAC;CAClC,EAAE,CACJ,CAmDA;AAED,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAezE;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,SAAS,EAAE,CAAC,CA2BtB;AAED,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,sBAAsB,EAAE,CAAC,CA6BnC;AA4DD,KAAK,kBAAkB,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,gCAAgC,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE/C,qBAAa,mBAAmB;IACvB,gBAAgB,EAAE,MAAM,CAAa;IACrC,cAAc,EAAE,MAAM,CAAa;IACnC,uBAAuB,EAAE,MAAM,CAAa;IAC5C,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAa;IAC5D,SAAS,EAAE,WAAW,GAAG,SAAS,CAAa;IAEtD,GAAG,CAAC,MAAM,EAAE,kBAAkB;IAyD9B,KAAK;IAQL,UAAU,IAAI,OAAO;CAQtB"}
|
@@ -133,6 +133,7 @@ async function getSolautoManagedPositions(umi, authority) {
|
|
133
133
|
...Array((0, generated_1.getSolautoPositionSize)() - x.data.length).fill(0),
|
134
134
|
]));
|
135
135
|
return {
|
136
|
+
publicKey: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey),
|
136
137
|
authority: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(position.authority),
|
137
138
|
positionId: position.positionId[0],
|
138
139
|
lendingPlatform: position.position.lendingPlatform,
|
package/package.json
CHANGED
@@ -17,7 +17,6 @@ import {
|
|
17
17
|
some,
|
18
18
|
} from "@metaplex-foundation/umi";
|
19
19
|
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
20
|
-
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
|
21
20
|
import {
|
22
21
|
WalletAdapter,
|
23
22
|
walletAdapterIdentity,
|
@@ -51,6 +50,7 @@ import {
|
|
51
50
|
import { SOLAUTO_FEES_WALLET } from "../constants/generalAccounts";
|
52
51
|
import { JupSwapDetails } from "../utils/jupiterUtils";
|
53
52
|
import {
|
53
|
+
getSolanaRpcConnection,
|
54
54
|
getWrappedInstruction,
|
55
55
|
splTokenTransferUmiIx,
|
56
56
|
} from "../utils/solanaUtils";
|
@@ -113,14 +113,12 @@ export abstract class SolautoClient {
|
|
113
113
|
public livePositionUpdates: LivePositionUpdates = new LivePositionUpdates();
|
114
114
|
|
115
115
|
constructor(
|
116
|
-
|
116
|
+
heliusApiKey: string,
|
117
117
|
public localTest?: boolean
|
118
118
|
) {
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
);
|
123
|
-
this.umi = createUmi(this.connection).use({
|
119
|
+
const [connection, umi] = getSolanaRpcConnection(heliusApiKey);
|
120
|
+
this.connection = connection;
|
121
|
+
this.umi = umi.use({
|
124
122
|
install(umi) {
|
125
123
|
umi.programs.add(createSolautoProgram(), false);
|
126
124
|
},
|
@@ -169,10 +167,7 @@ export abstract class SolautoClient {
|
|
169
167
|
this.debtMint =
|
170
168
|
args.debtMint ??
|
171
169
|
toWeb3JsPublicKey(this.solautoPositionData!.position.debtMint);
|
172
|
-
this.positionDebtTa = getTokenAccount(
|
173
|
-
this.solautoPosition,
|
174
|
-
this.debtMint
|
175
|
-
);
|
170
|
+
this.positionDebtTa = getTokenAccount(this.solautoPosition, this.debtMint);
|
176
171
|
this.signerDebtTa = getTokenAccount(
|
177
172
|
toWeb3JsPublicKey(this.signer.publicKey),
|
178
173
|
this.debtMint
|
@@ -352,7 +347,7 @@ export abstract class SolautoClient {
|
|
352
347
|
);
|
353
348
|
}
|
354
349
|
|
355
|
-
const addingReferredBy = accountsToAdd.length === 1
|
350
|
+
const addingReferredBy = accountsToAdd.length === 1;
|
356
351
|
// && accountsToAdd[0].toString().toLowerCase() ===
|
357
352
|
// this.referredBySupplyTa?.toString().toLowerCase();
|
358
353
|
|
package/src/utils/solanaUtils.ts
CHANGED
@@ -13,6 +13,7 @@ import {
|
|
13
13
|
toWeb3JsPublicKey,
|
14
14
|
toWeb3JsTransaction,
|
15
15
|
} from "@metaplex-foundation/umi-web3js-adapters";
|
16
|
+
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
|
16
17
|
import {
|
17
18
|
AddressLookupTableAccount,
|
18
19
|
ComputeBudgetProgram,
|
@@ -36,6 +37,15 @@ import {
|
|
36
37
|
getLendingAccountStartFlashloanInstructionDataSerializer,
|
37
38
|
} from "../marginfi-sdk";
|
38
39
|
|
40
|
+
export function getSolanaRpcConnection(heliusApiKey: string): [Connection, Umi] {
|
41
|
+
const connection = new Connection(
|
42
|
+
`https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`,
|
43
|
+
"finalized"
|
44
|
+
);
|
45
|
+
const umi = createUmi(connection);
|
46
|
+
return [connection, umi];
|
47
|
+
}
|
48
|
+
|
39
49
|
export async function currentUnixSecondsSolana(umi: Umi): Promise<number> {
|
40
50
|
return await retryWithExponentialBackoff(async () => {
|
41
51
|
const blockTime = await umi.rpc.getBlockTime(await umi.rpc.getSlot());
|
@@ -178,6 +178,7 @@ export async function getSolautoManagedPositions(
|
|
178
178
|
authority?: PublicKey
|
179
179
|
): Promise<
|
180
180
|
{
|
181
|
+
publicKey: PublicKey;
|
181
182
|
authority: PublicKey;
|
182
183
|
positionId: number;
|
183
184
|
lendingPlatform: LendingPlatform;
|
@@ -227,6 +228,7 @@ export async function getSolautoManagedPositions(
|
|
227
228
|
])
|
228
229
|
);
|
229
230
|
return {
|
231
|
+
publicKey: toWeb3JsPublicKey(x.publicKey),
|
230
232
|
authority: toWeb3JsPublicKey(position.authority),
|
231
233
|
positionId: position.positionId[0],
|
232
234
|
lendingPlatform: position.position.lendingPlatform,
|
@@ -24,7 +24,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
24
24
|
|
25
25
|
const payForTransactions = false;
|
26
26
|
const useJitoBundle = false;
|
27
|
-
const positionId =
|
27
|
+
const positionId = 1;
|
28
28
|
|
29
29
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
30
30
|
const client = new SolautoMarginfiClient(process.env.HELIUS_API_KEY!, true);
|
@@ -37,11 +37,11 @@ describe("Solauto Marginfi tests", async () => {
|
|
37
37
|
{
|
38
38
|
signer,
|
39
39
|
positionId,
|
40
|
-
marginfiAccount: new PublicKey(
|
41
|
-
|
42
|
-
),
|
43
|
-
supplyMint: NATIVE_MINT,
|
44
|
-
debtMint: new PublicKey(USDC_MINT),
|
40
|
+
// marginfiAccount: new PublicKey(
|
41
|
+
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
42
|
+
// ),
|
43
|
+
// supplyMint: NATIVE_MINT,
|
44
|
+
// debtMint: new PublicKey(USDC_MINT),
|
45
45
|
}
|
46
46
|
);
|
47
47
|
|