@haven-fi/solauto-sdk 1.0.400 → 1.0.402

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.
@@ -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;AAMzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAW7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AA0FD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;I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AAC,MAAM,CAAC;IACf,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,aAAa,CAAC;IACtB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;IAXpB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,SAAS,EAAE,aAAa,GAAG,oBAAoB,EAC/C,cAAc,CAAC,GAAE,CAAC,QAAQ,EAAE,0BAA0B,KAAK,IAAI,aAAA,EAC/D,MAAM,CAAC,EAAE,kBAAkB,YAAA,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,UAAU,GAAE,OAAe,EAC3B,aAAa,CAAC,EAAE,aAAa,YAAA,EAC7B,OAAO,GAAE,MAAU,EACnB,UAAU,GAAE,MAAY;YAQpB,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA6CN,aAAa;IAoB3B,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,mBAAmB;YAoBb,SAAS;IAiBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IA+FzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YA4BxB,6BAA6B;YAwH7B,qBAAqB;YA2CrB,cAAc;YAqCd,eAAe;CA0D9B"}
@@ -355,7 +355,7 @@ class TransactionsManager {
355
355
  let txSigs;
356
356
  let error;
357
357
  try {
358
- txSigs = await (0, jitoUtils_1.sendJitoBundledTransactions)(this.txHandler.umi, this.txHandler.signer, transactions, this.txType, this.getUpdatedPriorityFeeSetting(prevError, attemptNum), () => this.updateStatusForSets(itemSets, TransactionStatus.Processing, attemptNum, undefined, true));
358
+ txSigs = await (0, jitoUtils_1.sendJitoBundledTransactions)(this.txHandler.umi, this.txHandler.connection, this.txHandler.signer, transactions, this.txType, this.getUpdatedPriorityFeeSetting(prevError, attemptNum), () => this.updateStatusForSets(itemSets, TransactionStatus.Processing, attemptNum, undefined, true));
359
359
  }
360
360
  catch (e) {
361
361
  error = e;
@@ -16,7 +16,8 @@ export declare enum PriorityFeeSetting {
16
16
  Min = "Min",
17
17
  Low = "Low",
18
18
  Default = "Medium",
19
- High = "High"
19
+ High = "High",
20
+ VeryHigh = "VeryHigh"
20
21
  }
21
22
  export declare const priorityFeeSettingValues: PriorityFeeSetting[];
22
23
  export type RebalanceAction = "boost" | "repay" | "dca";
@@ -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,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,OAAO,WAAW;IAClB,IAAI,SAAS;CACd;AAED,eAAO,MAAM,wBAAwB,EAAwC,kBAAkB,EAAE,CAAC;AAElG,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,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,OAAO,WAAW;IAClB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,eAAO,MAAM,wBAAwB,EAAwC,kBAAkB,EAAE,CAAC;AAElG,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"}
@@ -8,5 +8,6 @@ var PriorityFeeSetting;
8
8
  PriorityFeeSetting["Low"] = "Low";
9
9
  PriorityFeeSetting["Default"] = "Medium";
10
10
  PriorityFeeSetting["High"] = "High";
11
+ PriorityFeeSetting["VeryHigh"] = "VeryHigh";
11
12
  })(PriorityFeeSetting || (exports.PriorityFeeSetting = PriorityFeeSetting = {}));
12
13
  exports.priorityFeeSettingValues = Object.values(PriorityFeeSetting);
@@ -1,6 +1,6 @@
1
- import { PublicKey } from "@solana/web3.js";
1
+ import { Connection, PublicKey } from "@solana/web3.js";
2
2
  import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
3
3
  import { PriorityFeeSetting, TransactionRunType } from "../types";
4
4
  export declare function getRandomTipAccount(): Promise<PublicKey>;
5
- export declare function sendJitoBundledTransactions(umi: Umi, signer: Signer, txs: TransactionBuilder[], txType?: TransactionRunType, priorityFeeSetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<string[] | undefined>;
5
+ export declare function sendJitoBundledTransactions(umi: Umi, connection: Connection, signer: Signer, txs: TransactionBuilder[], txType?: TransactionRunType, priorityFeeSetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<string[] | undefined>;
6
6
  //# sourceMappingURL=jitoUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAIV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKlE,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AAiND,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,kBAAkB,EAAE,EACzB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAwE/B"}
1
+ {"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAIV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAMlE,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AAiND,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,kBAAkB,EAAE,EACzB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CA6E/B"}
@@ -14,6 +14,7 @@ const types_1 = require("../types");
14
14
  const axios_1 = __importDefault(require("axios"));
15
15
  const bs58_1 = __importDefault(require("bs58"));
16
16
  const transactions_1 = require("../types/transactions");
17
+ const bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
17
18
  async function getRandomTipAccount() {
18
19
  const tipAccounts = [
19
20
  "96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5",
@@ -172,7 +173,11 @@ async function sendJitoBundle(umi, transactions) {
172
173
  (0, generalUtils_1.consoleLog)("Bundle ID:", bundleId);
173
174
  return bundleId ? await pollBundleStatus(bundleId) : [];
174
175
  }
175
- async function sendJitoBundledTransactions(umi, signer, txs, txType, priorityFeeSetting = types_1.PriorityFeeSetting.Min, onAwaitingSign) {
176
+ async function sendJitoBundledTransactions(umi, connection, signer, txs, txType, priorityFeeSetting = types_1.PriorityFeeSetting.Min, onAwaitingSign) {
177
+ if (txs.length === 1) {
178
+ const resp = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(umi, connection, txs[0], txType, priorityFeeSetting, onAwaitingSign);
179
+ return resp ? [bytes_1.bs58.encode(resp)] : undefined;
180
+ }
176
181
  (0, generalUtils_1.consoleLog)("Sending Jito bundle...");
177
182
  (0, generalUtils_1.consoleLog)("Transactions: ", txs.length);
178
183
  (0, generalUtils_1.consoleLog)("Transaction sizes: ", txs.map((x) => x.getTransactionSize(umi)));
@@ -35,7 +35,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
35
35
  ? "ExactIn"
36
36
  : undefined,
37
37
  slippageBps: memecoinSwap ? 500 : 50,
38
- maxAccounts: !swapDetails.exactOut ? 50 : undefined,
38
+ maxAccounts: !swapDetails.exactOut ? 60 : undefined,
39
39
  }), 4, 200);
40
40
  const priceImpactBps = Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1;
41
41
  const finalPriceSlippageBps = Math.round(Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
@@ -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,EAIL,UAAU,EACV,SAAS,EAKT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAgBzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAIlE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,UAErD;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,UAE3D;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAgC,GAC1C,CAAC,UAAU,EAAE,GAAG,CAAC,CAQnB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,sBAAsB,GACzB,kBAAkB,CAMpB;AA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oEjC"}
@@ -79,7 +79,7 @@ function splTokenTransferUmiIx(signer, fromTa, toTa, authority, amount) {
79
79
  return getWrappedInstruction(signer, (0, spl_token_1.createTransferInstruction)(fromTa, toTa, authority, amount));
80
80
  }
81
81
  async function getAddressLookupInputs(umi, lookupTableAddresses) {
82
- const addressLookupTableAccountInfos = await umi.rpc.getAccounts(lookupTableAddresses.map((key) => (0, umi_1.publicKey)(key)));
82
+ const addressLookupTableAccountInfos = await umi.rpc.getAccounts(lookupTableAddresses.map((key) => (0, umi_1.publicKey)(key)), { commitment: "confirmed" });
83
83
  return addressLookupTableAccountInfos.reduce((acc, accountInfo, index) => {
84
84
  const addressLookupTableAddress = lookupTableAddresses[index];
85
85
  if (accountInfo.exists) {
@@ -156,36 +156,35 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting, useAccounts
156
156
  .getInstructions()
157
157
  .flatMap((x) => x.keys.flatMap((x) => x.pubkey.toString()));
158
158
  let feeEstimate;
159
- try {
160
- const resp = await umi.rpc.call("getPriorityFeeEstimate", [
161
- {
162
- transaction: !useAccounts
163
- ? bs58_1.default.encode(web3Transaction.serialize())
164
- : undefined,
165
- accountKeys: useAccounts ? accountKeys : undefined,
166
- options: {
167
- priorityLevel: prioritySetting.toString(),
168
- },
159
+ // try {
160
+ const resp = await umi.rpc.call("getPriorityFeeEstimate", [
161
+ {
162
+ transaction: !useAccounts
163
+ ? bs58_1.default.encode(web3Transaction.serialize())
164
+ : undefined,
165
+ accountKeys: useAccounts ? accountKeys : undefined,
166
+ options: {
167
+ priorityLevel: prioritySetting.toString(),
169
168
  },
170
- ]);
171
- feeEstimate = Math.round(resp.priorityFeeEstimate);
172
- }
173
- catch (e) {
174
- try {
175
- const resp = await umi.rpc.call("getPriorityFeeEstimate", [
176
- {
177
- accountKeys,
178
- options: {
179
- priorityLevel: prioritySetting.toString(),
180
- },
181
- },
182
- ]);
183
- feeEstimate = Math.round(resp.priorityFeeEstimate);
184
- }
185
- catch (e) {
186
- // console.error(e);
187
- }
188
- }
169
+ },
170
+ ]);
171
+ feeEstimate = Math.round(resp.priorityFeeEstimate);
172
+ // }
173
+ // catch (e) {
174
+ // try {
175
+ // const resp = await umi.rpc.call("getPriorityFeeEstimate", [
176
+ // {
177
+ // accountKeys,
178
+ // options: {
179
+ // priorityLevel: prioritySetting.toString(),
180
+ // },
181
+ // },
182
+ // ]);
183
+ // feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
184
+ // } catch (e) {
185
+ // // console.error(e);
186
+ // }
187
+ // }
189
188
  return feeEstimate;
190
189
  }
191
190
  async function spamSendTransactionUntilConfirmed(connection, transaction, blockhash, spamInterval = 1500) {
@@ -245,7 +244,7 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, txType, prior
245
244
  if (!cuPrice) {
246
245
  cuPrice = 1000000;
247
246
  }
248
- cuPrice = Math.min(cuPrice, 100 * 1000000);
247
+ // cuPrice = Math.min(cuPrice, 100 * 1_000_000);
249
248
  (0, generalUtils_1.consoleLog)("Compute unit price: ", cuPrice);
250
249
  }
251
250
  if (txType !== "only-simulate") {
@@ -170,7 +170,7 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
170
170
  inputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint),
171
171
  outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint),
172
172
  destinationWallet: client.solautoPosition,
173
- slippageIncFactor: 0.5 + (attemptNum ?? 0) * 0.2,
173
+ slippageIncFactor: 1 + (attemptNum ?? 0) * 0.2,
174
174
  amount: exactOut ? outputAmount : inputAmount,
175
175
  exactIn: exactIn,
176
176
  exactOut: exactOut,
package/local/.env ADDED
@@ -0,0 +1 @@
1
+ ADDRESS_WHITELIST=5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe,E5BBsR1sUToPc3jXVwhrK5ttSiy6xhWJDMdQLvkgNppe,DRP5cgM1JpnMySvwg3jqRP2VA2DXSWUjo6VGLkNZ2etb,5qbTgNHBo5kedvDCseLbn5vJCtjrpUyNWwZzRnx72rPT
@@ -1,21 +1,225 @@
1
+ import { publicKey } from "@metaplex-foundation/umi";
1
2
  import {
2
3
  buildHeliusApiUrl,
4
+ fetchTokenPrices,
3
5
  getSolanaRpcConnection,
4
6
  getSolautoManagedPositions,
7
+ PositionState,
8
+ positionStateWithLatestPrices,
9
+ PRICES,
10
+ retryWithExponentialBackoff,
11
+ safeFetchAllSolautoPosition,
12
+ safeGetPrice,
5
13
  SOLAUTO_PROD_PROGRAM,
14
+ TOKEN_INFO,
15
+ USD_DECIMALS,
6
16
  } from "../src";
17
+ import { PublicKey } from "@solana/web3.js";
18
+ import { NATIVE_MINT } from "@solana/spl-token";
19
+ import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
20
+ import { fromBaseUnit } from "../dist";
21
+ import path from 'path';
22
+ import { config } from 'dotenv';
7
23
 
8
- async function main() {
24
+ config({ path: path.join(__dirname, '.env') });
25
+
26
+ function getBatches<T>(items: T[], batchSize: number): T[][] {
27
+ const batches: T[][] = [];
28
+ for (let i = 0; i < items.length; i += batchSize) {
29
+ batches.push(items.slice(i, i + batchSize));
30
+ }
31
+ return batches;
32
+ }
33
+
34
+ export function tokenInfo(mint?: PublicKey) {
35
+ return TOKEN_INFO[mint ? mint.toString() : PublicKey.default.toString()];
36
+ }
37
+
38
+ type StrategyType = "Long" | "Short";
39
+
40
+ function solautoStrategyName(supplyMint?: PublicKey, debtMint?: PublicKey) {
41
+ const supplyInfo = tokenInfo(supplyMint);
42
+ const debtInfo = tokenInfo(debtMint);
43
+ const strat = strategyType(
44
+ supplyMint ?? PublicKey.default,
45
+ debtMint ?? PublicKey.default
46
+ );
47
+
48
+ if (strat === "Long") {
49
+ return debtInfo.isStableCoin
50
+ ? `${supplyInfo.ticker} Long`
51
+ : supplyInfo.ticker
52
+ ? `${supplyInfo.ticker}/${debtInfo.ticker} Long`
53
+ : "";
54
+ } else {
55
+ return `${debtInfo.ticker} Short`;
56
+ }
57
+ }
58
+
59
+ function strategyType(
60
+ supplyMint: PublicKey,
61
+ debtMint: PublicKey
62
+ ): StrategyType {
63
+ const supplyInfo = tokenInfo(supplyMint);
64
+ const debtInfo = tokenInfo(debtMint);
65
+
66
+ if (supplyInfo.isLST && debtMint.equals(NATIVE_MINT)) {
67
+ // Yield
68
+ throw new Error("Not yet supported");
69
+ } else if (debtInfo.isStableCoin) {
70
+ return "Long";
71
+ } else if (supplyInfo.isStableCoin) {
72
+ return "Short";
73
+ } else {
74
+ return "Long";
75
+ }
76
+ }
77
+
78
+ export function roundToDecimals(value: number, decimals: number = 2): number {
79
+ if (!value || isNaN(value)) {
80
+ return value;
81
+ }
82
+
83
+ let roundedValue: number | undefined;
84
+ do {
85
+ const factor = Math.pow(10, decimals ?? 2);
86
+ roundedValue = Math.round(value * factor) / factor;
87
+ decimals += 1;
88
+ } while (!roundedValue || decimals >= 10);
89
+
90
+ return roundedValue;
91
+ }
92
+
93
+ export function formatNumberToShortForm(
94
+ num: number,
95
+ decimals?: number
96
+ ): string {
97
+ if (decimals === undefined) {
98
+ decimals = 1;
99
+ }
100
+ if (num >= 1_000_000_000) {
101
+ return (
102
+ (num / 1_000_000_000)
103
+ .toFixed(decimals)
104
+ .replace(new RegExp(`\\.0{${decimals}}$`), "") + "B"
105
+ );
106
+ }
107
+ if (num >= 1_000_000) {
108
+ return (
109
+ (num / 1_000_000)
110
+ .toFixed(decimals)
111
+ .replace(new RegExp(`\\.0{${decimals}}$`), "") + "M"
112
+ );
113
+ }
114
+ if (num >= 1_000) {
115
+ return (
116
+ (num / 1_000)
117
+ .toFixed(decimals)
118
+ .replace(new RegExp(`\\.0{${decimals}}$`), "") + "K"
119
+ );
120
+ }
121
+ return num.toFixed(decimals).replace(new RegExp(`\\.0{${decimals}}$`), "");
122
+ }
123
+
124
+ export function formatNumber(
125
+ num: number,
126
+ decimals?: number,
127
+ shortFormAtThreshold?: number,
128
+ decimalsAtShortform?: number
129
+ ): string {
130
+ if (shortFormAtThreshold !== undefined && num > shortFormAtThreshold) {
131
+ return formatNumberToShortForm(num, decimalsAtShortform);
132
+ } else {
133
+ return num < 1
134
+ ? roundToDecimals(num, decimals).toString()
135
+ : new Intl.NumberFormat("en-US").format(
136
+ decimals !== undefined ? roundToDecimals(num, decimals) : num
137
+ );
138
+ }
139
+ }
140
+
141
+ async function main(filterWhitelist: boolean) {
9
142
  const [_, umi] = getSolanaRpcConnection(
10
143
  buildHeliusApiUrl(process.env.HELIUS_API_KEY!),
11
144
  SOLAUTO_PROD_PROGRAM
12
145
  );
13
- const positions = await getSolautoManagedPositions(umi);
14
- // TODO: filter out certain wallet authorities using an env variable
146
+ let positions = await getSolautoManagedPositions(umi);
147
+
148
+ if (filterWhitelist) {
149
+ const addressWhitelist = process.env.ADDRESS_WHITELIST?.split(",") ?? [];
150
+ positions = positions.filter(
151
+ (x) => !addressWhitelist.includes(x.authority.toString())
152
+ );
153
+ }
154
+
155
+ const batches = getBatches(positions, 30);
156
+
157
+ const solautoPositionsData = (
158
+ await Promise.all(
159
+ batches.map(async (pubkeys) => {
160
+ return retryWithExponentialBackoff(
161
+ async () =>
162
+ await safeFetchAllSolautoPosition(
163
+ umi,
164
+ pubkeys.map((x) => publicKey(x.publicKey!))
165
+ )
166
+ );
167
+ })
168
+ )
169
+ ).flat();
170
+
171
+ const tokensUsed = Array.from(
172
+ new Set(
173
+ positions.flatMap((x) => [
174
+ x.supplyMint!.toString(),
175
+ x.debtMint!.toString(),
176
+ ])
177
+ )
178
+ );
179
+
180
+ const tokenBatches = getBatches(tokensUsed, 15);
181
+ await Promise.all(
182
+ tokenBatches.map(async (batch) => {
183
+ await fetchTokenPrices(batch.map((x) => new PublicKey(x)));
184
+ })
185
+ );
186
+
187
+ console.log("\n\n");
188
+
189
+ const latestStates: PositionState[] = [];
190
+ for (const pos of solautoPositionsData) {
191
+ const latestState = await positionStateWithLatestPrices(
192
+ pos.state,
193
+ safeGetPrice(pos.state.supply.mint),
194
+ safeGetPrice(pos.state.debt.mint)
195
+ );
196
+ latestStates.push(latestState);
197
+
198
+ const strategy = solautoStrategyName(
199
+ toWeb3JsPublicKey(pos.state.supply.mint),
200
+ toWeb3JsPublicKey(pos.state.debt.mint)
201
+ );
202
+
203
+ console.log("Position:", pos.publicKey.toString());
204
+ console.log("Authority:", pos.authority.toString());
205
+ console.log(
206
+ `${strategy}: $${formatNumber(fromBaseUnit(latestState.netWorth.baseAmountUsdValue, USD_DECIMALS), 2, 10000, 2)}`
207
+ );
208
+ console.log("\n");
209
+ }
210
+
211
+ console.log("Total positions:", solautoPositionsData.length);
212
+ console.log(
213
+ "Total users:",
214
+ Array.from(new Set(solautoPositionsData.map((x) => x.authority.toString())))
215
+ .length
216
+ );
15
217
 
16
- console.log(positions);
17
- console.log("Total positions:", positions.length);
18
- // TODO: log net worth / balances
218
+ const tvl = latestStates
219
+ .map((x) => fromBaseUnit(x.netWorth.baseAmountUsdValue, USD_DECIMALS))
220
+ .reduce((acc, curr) => acc + curr, 0);
221
+ console.log(`Total TVL: $${formatNumber(tvl, 2, 10000, 2)}`);
19
222
  }
20
223
 
21
- main().then((x) => x);
224
+ const filterWhitelist = true;
225
+ main(filterWhitelist).then((x) => x);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.400",
3
+ "version": "1.0.402",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -27,6 +27,7 @@
27
27
  "axios": "^1.7.8",
28
28
  "bs58": "^5.0.0",
29
29
  "cross-fetch": "^4.0.0",
30
+ "dotenv": "^16.4.7",
30
31
  "rpc-websockets": "7.11.0"
31
32
  },
32
33
  "devDependencies": {
@@ -567,6 +567,7 @@ export class TransactionsManager {
567
567
  try {
568
568
  txSigs = await sendJitoBundledTransactions(
569
569
  this.txHandler.umi,
570
+ this.txHandler.connection,
570
571
  this.txHandler.signer,
571
572
  transactions,
572
573
  this.txType,
@@ -19,6 +19,7 @@ export enum PriorityFeeSetting {
19
19
  Low = "Low",
20
20
  Default = "Medium",
21
21
  High = "High",
22
+ VeryHigh = "VeryHigh",
22
23
  }
23
24
 
24
25
  export const priorityFeeSettingValues = Object.values(PriorityFeeSetting) as PriorityFeeSetting[];
@@ -1,4 +1,5 @@
1
1
  import {
2
+ Connection,
2
3
  PublicKey,
3
4
  SimulatedTransactionResponse,
4
5
  TransactionExpiredBlockheightExceededError,
@@ -15,6 +16,7 @@ import {
15
16
  import {
16
17
  assembleFinalTransaction,
17
18
  getComputeUnitPriceEstimate,
19
+ sendSingleOptimizedTransaction,
18
20
  systemTransferUmiIx,
19
21
  } from "./solanaUtils";
20
22
  import { consoleLog, retryWithExponentialBackoff } from "./generalUtils";
@@ -22,6 +24,7 @@ import { PriorityFeeSetting, TransactionRunType } from "../types";
22
24
  import axios from "axios";
23
25
  import base58 from "bs58";
24
26
  import { BundleSimulationError } from "../types/transactions";
27
+ import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
25
28
 
26
29
  export async function getRandomTipAccount(): Promise<PublicKey> {
27
30
  const tipAccounts = [
@@ -247,12 +250,18 @@ async function sendJitoBundle(
247
250
 
248
251
  export async function sendJitoBundledTransactions(
249
252
  umi: Umi,
253
+ connection: Connection,
250
254
  signer: Signer,
251
255
  txs: TransactionBuilder[],
252
256
  txType?: TransactionRunType,
253
257
  priorityFeeSetting: PriorityFeeSetting = PriorityFeeSetting.Min,
254
258
  onAwaitingSign?: () => void
255
259
  ): Promise<string[] | undefined> {
260
+ if (txs.length === 1) {
261
+ const resp = await sendSingleOptimizedTransaction(umi, connection, txs[0], txType, priorityFeeSetting, onAwaitingSign);
262
+ return resp ? [bs58.encode(resp)] : undefined;
263
+ }
264
+
256
265
  consoleLog("Sending Jito bundle...");
257
266
  consoleLog("Transactions: ", txs.length);
258
267
  consoleLog(
@@ -71,7 +71,7 @@ export async function getJupSwapTransaction(
71
71
  ? "ExactIn"
72
72
  : undefined,
73
73
  slippageBps: memecoinSwap ? 500 : 50,
74
- maxAccounts: !swapDetails.exactOut ? 50 : undefined,
74
+ maxAccounts: !swapDetails.exactOut ? 60 : undefined,
75
75
  }),
76
76
  4,
77
77
  200
@@ -162,7 +162,8 @@ export async function getAddressLookupInputs(
162
162
  lookupTableAddresses: string[]
163
163
  ): Promise<AddressLookupTableInput[]> {
164
164
  const addressLookupTableAccountInfos = await umi.rpc.getAccounts(
165
- lookupTableAddresses.map((key) => publicKey(key))
165
+ lookupTableAddresses.map((key) => publicKey(key)),
166
+ { commitment: "confirmed" }
166
167
  );
167
168
 
168
169
  return addressLookupTableAccountInfos.reduce((acc, accountInfo, index) => {
@@ -300,7 +301,7 @@ export async function getComputeUnitPriceEstimate(
300
301
  .flatMap((x) => x.keys.flatMap((x) => x.pubkey.toString()));
301
302
 
302
303
  let feeEstimate: number | undefined;
303
- try {
304
+ // try {
304
305
  const resp = await umi.rpc.call("getPriorityFeeEstimate", [
305
306
  {
306
307
  transaction: !useAccounts
@@ -313,21 +314,22 @@ export async function getComputeUnitPriceEstimate(
313
314
  },
314
315
  ]);
315
316
  feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
316
- } catch (e) {
317
- try {
318
- const resp = await umi.rpc.call("getPriorityFeeEstimate", [
319
- {
320
- accountKeys,
321
- options: {
322
- priorityLevel: prioritySetting.toString(),
323
- },
324
- },
325
- ]);
326
- feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
327
- } catch (e) {
328
- // console.error(e);
329
- }
330
- }
317
+ // }
318
+ // catch (e) {
319
+ // try {
320
+ // const resp = await umi.rpc.call("getPriorityFeeEstimate", [
321
+ // {
322
+ // accountKeys,
323
+ // options: {
324
+ // priorityLevel: prioritySetting.toString(),
325
+ // },
326
+ // },
327
+ // ]);
328
+ // feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
329
+ // } catch (e) {
330
+ // // console.error(e);
331
+ // }
332
+ // }
331
333
 
332
334
  return feeEstimate;
333
335
  }
@@ -426,9 +428,9 @@ export async function sendSingleOptimizedTransaction(
426
428
  if (prioritySetting !== PriorityFeeSetting.None) {
427
429
  cuPrice = await getComputeUnitPriceEstimate(umi, tx, prioritySetting);
428
430
  if (!cuPrice) {
429
- cuPrice = 1000000;
431
+ cuPrice = 1_000_000;
430
432
  }
431
- cuPrice = Math.min(cuPrice, 100 * 1_000_000);
433
+ // cuPrice = Math.min(cuPrice, 100 * 1_000_000);
432
434
  consoleLog("Compute unit price: ", cuPrice);
433
435
  }
434
436
 
@@ -361,7 +361,7 @@ export function getJupSwapRebalanceDetails(
361
361
  inputMint: toWeb3JsPublicKey(input.mint),
362
362
  outputMint: toWeb3JsPublicKey(output.mint),
363
363
  destinationWallet: client.solautoPosition,
364
- slippageIncFactor: 0.5 + (attemptNum ?? 0) * 0.2,
364
+ slippageIncFactor: 1 + (attemptNum ?? 0) * 0.2,
365
365
  amount: exactOut ? outputAmount : inputAmount,
366
366
  exactIn: exactIn,
367
367
  exactOut: exactOut,
@@ -1,23 +1,22 @@
1
1
  import { describe, it } from "mocha";
2
- import { none, publicKey, some, transactionBuilder } from "@metaplex-foundation/umi";
2
+ import {
3
+ none,
4
+ publicKey,
5
+ some,
6
+ } from "@metaplex-foundation/umi";
3
7
  import { setupTest } from "../shared";
4
8
  import { SolautoMarginfiClient } from "../../src/clients/solautoMarginfiClient";
5
9
  import {
6
- PositionType,
7
10
  safeFetchSolautoPosition,
8
11
  solautoAction,
9
12
  SolautoSettingsParametersInpArgs,
10
13
  } from "../../src/generated";
11
14
  import { buildSolautoRebalanceTransaction } from "../../src/transactions/transactionUtils";
12
15
  import {
13
- fromBaseUnit,
14
- getDebtAdjustmentUsd,
15
- getMaxLiqUtilizationRateBps,
16
16
  maxBoostToBps,
17
17
  maxRepayFromBps,
18
18
  maxRepayToBps,
19
19
  toBaseUnit,
20
- toBps,
21
20
  } from "../../src/utils/numberUtils";
22
21
  import { NATIVE_MINT } from "@solana/spl-token";
23
22
  import {
@@ -26,50 +25,28 @@ import {
26
25
  } from "../../src/transactions/transactionsManager";
27
26
  import { PublicKey } from "@solana/web3.js";
28
27
  import {
29
- B_SOL,
30
- DEFAULT_MARGINFI_GROUP,
31
- HMTR,
32
- JITO_SOL,
33
- JLP,
34
- POPCAT,
35
- RETARDIO,
36
28
  SOLAUTO_PROD_PROGRAM,
37
29
  SOLAUTO_TEST_PROGRAM,
38
- USD_DECIMALS,
39
30
  USDC,
40
- WETH,
41
31
  } from "../../src/constants";
42
- import { buildHeliusApiUrl, calcMarginfiMaxLtvAndLiqThreshold, fetchTokenPrices, getAllPositionsByAuthority, getJupPriceData, getJupTokenPrices, getMarginfiAccountPositionState, getSolautoManagedPositions, safeGetPrice } from "../../src/utils";
32
+ import {
33
+ buildHeliusApiUrl,
34
+ getSolautoManagedPositions,
35
+ } from "../../src/utils";
43
36
  import { PriorityFeeSetting } from "../../src/types";
44
- import { buildIronforgeApiUrl, MARGINFI_ACCOUNTS, TransactionManagerStatuses } from "../../dist";
45
- import { connect } from "http2";
46
- import CommonClient from "rpc-websockets/dist/lib/client";
47
- import { safeFetchAllBank } from "../../src/marginfi-sdk";
48
-
49
- export function getLeverageFactor(
50
- strategyType: "Long" | "Short",
51
- supplyUsd: number,
52
- debtUsd: number
53
- ): number {
54
- let levFactor =
55
- (strategyType === 'Long' ? supplyUsd : debtUsd) / (supplyUsd - debtUsd);
56
- if (strategyType === 'Short') {
57
- levFactor += 1;
58
- }
59
- return levFactor;
60
- }
61
37
 
62
38
  describe("Solauto Marginfi tests", async () => {
63
- const signer = setupTest();
64
- // const signer = setupTest("solauto-manager");
39
+ // const signer = setupTest();
40
+ const signer = setupTest("solauto-manager");
65
41
 
66
42
  const payForTransactions = true;
67
- const testProgram = true;
43
+ const testProgram = false;
68
44
  const positionId = 1;
69
45
 
70
46
  it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
71
47
  const client = new SolautoMarginfiClient(
72
- buildIronforgeApiUrl(process.env.IRONFORGE_API_KEY!),
48
+ // buildHeliusApiUrl(process.env.HELIUS_API_KEY!),
49
+ "https://staked.helius-rpc.com?api-key=6a7423cf-35ef-44ce-b02b-02567f57d181",
73
50
  true,
74
51
  testProgram ? SOLAUTO_TEST_PROGRAM : SOLAUTO_PROD_PROGRAM
75
52
  );
@@ -81,7 +58,7 @@ describe("Solauto Marginfi tests", async () => {
81
58
  await client.initialize({
82
59
  signer,
83
60
  positionId,
84
- authority: new PublicKey("rC5dMP5dmSsfQ66rynzfFzuc122Eex9h1RJHVDkeH6D"),
61
+ authority: new PublicKey("5bFfSCsGUgEzYH8kwwRtFnWkKZ1by8uD8RHvKQPnQReB"),
85
62
  // new: true,
86
63
  // marginfiAccount: new PublicKey(
87
64
  // "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
@@ -91,52 +68,7 @@ describe("Solauto Marginfi tests", async () => {
91
68
  // debtMint: new PublicKey(USDC),
92
69
  });
93
70
 
94
- // console.log(await getAllPositionsByAuthority(client.umi, new PublicKey("5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe"), PositionType.Leverage));
95
-
96
-
97
- // console.log(JSON.stringify(await getJupPriceData([new PublicKey("7JhmUcZrrfhyt5nTSu3AfsrUq2L9992a7AhwdSDxdoL2")], true), null, 2));
98
- // console.log(JSON.stringify(await getJupPriceData([new PublicKey(POPCAT)], true), null, 2));
99
-
100
- // const tokenMint = NATIVE_MINT.toString();
101
- // await fetchTokenPrices([new PublicKey(tokenMint)]);
102
-
103
- // // const accounts = MARGINFI_ACCOUNTS["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"];
104
- // const accounts = MARGINFI_ACCOUNTS[DEFAULT_MARGINFI_GROUP];
105
- // const [supplyBank, debtBank] = await safeFetchAllBank(client.umi, [publicKey(accounts[tokenMint].bank), publicKey(accounts[USDC].bank)]);
106
-
107
- // console.log(supplyBank, debtBank);
108
- // const [maxLtv, liqThreshold] = calcMarginfiMaxLtvAndLiqThreshold(
109
- // supplyBank,
110
- // debtBank,
111
- // safeGetPrice(new PublicKey(USDC)) ?? 0
112
- // );
113
-
114
- // console.log(maxLtv, liqThreshold);
115
-
116
- // const supplyUsd = 100;
117
- // const debtAdjustmentUsd = getDebtAdjustmentUsd(
118
- // toBps(liqThreshold),
119
- // supplyUsd,
120
- // 0,
121
- // maxBoostToBps(toBps(maxLtv), toBps(liqThreshold))
122
- // // getMaxLiqUtilizationRateBps(toBps(maxLtv), toBps(liqThreshold), 0.005)
123
- // );
124
- // const maxLeverage = getLeverageFactor(
125
- // "Long",
126
- // supplyUsd + debtAdjustmentUsd,
127
- // debtAdjustmentUsd
128
- // );
129
- // console.log(maxLeverage, supplyUsd + debtAdjustmentUsd, debtAdjustmentUsd);
130
-
131
- // const state = await getMarginfiAccountPositionState(client.umi, { pk: new PublicKey("GSw9ewsUgmuzDRJGYvSzkPPZgXfDszuGx7y22zMWSQkS") });
132
- // const stateKeverage = getLeverageFactor(
133
- // "Short",
134
- // fromBaseUnit(state.supply.amountUsed.baseAmountUsdValue, USD_DECIMALS),
135
- // fromBaseUnit(state.debt.amountUsed.baseAmountUsdValue, USD_DECIMALS)
136
- // );
137
- // console.log(stateKeverage);
138
-
139
- // console.log(await fetchTokenPrices([new PublicKey(HMTR)]));
71
+ // console.log(await getSolautoManagedPositions(client.umi));
140
72
 
141
73
  const transactionItems: TransactionItem[] = [];
142
74
  // const settingParams: SolautoSettingsParametersInpArgs = {
@@ -169,17 +101,7 @@ describe("Solauto Marginfi tests", async () => {
169
101
  // // const [supplyPrice] = await fetchTokenPrices([supply]);
170
102
  // return {
171
103
  // tx: client.protocolInteraction(
172
- // solautoAction("Deposit", [toBaseUnit(0.05, supplyDecimals)])
173
- // ),
174
- // };
175
- // }, "deposit")
176
- // );
177
- // transactionItems.push(
178
- // new TransactionItem(async () => {
179
- // // const [supplyPrice] = await fetchTokenPrices([supply]);
180
- // return {
181
- // tx: client.protocolInteraction(
182
- // solautoAction("Deposit", [toBaseUnit(0.05, supplyDecimals)])
104
+ // solautoAction("Deposit", [toBaseUnit(300, supplyDecimals)])
183
105
  // ),
184
106
  // };
185
107
  // }, "deposit")
@@ -222,66 +144,17 @@ describe("Solauto Marginfi tests", async () => {
222
144
  // )
223
145
  // );
224
146
 
225
- transactionItems.push(
226
- new TransactionItem(
227
- async () => ({
228
- tx: client.protocolInteraction(
229
- solautoAction("Withdraw", [{ __kind: "Some", fields: [toBaseUnit(0.03, 9)] }])
230
- ),
231
- }),
232
- "withdraw"
233
- )
234
- );
235
147
  // transactionItems.push(
236
148
  // new TransactionItem(
237
149
  // async () => ({
238
150
  // tx: client.protocolInteraction(
239
- // solautoAction("Withdraw", [{ __kind: "Some", fields: [toBaseUnit(0.03, 9)] }])
151
+ // solautoAction("Withdraw", [{ __kind: "All" }])
240
152
  // ),
241
153
  // }),
242
154
  // "withdraw"
243
155
  // )
244
156
  // );
245
157
 
246
- // transactionItems.push(
247
- // new TransactionItem(
248
- // async () => ({
249
- // tx: transactionBuilder()
250
- // .add(
251
- // client.protocolInteraction(
252
- // solautoAction("Withdraw", [
253
- // { __kind: "Some", fields: [toBaseUnit(0.01, 9)] },
254
- // ])
255
- // )
256
- // )
257
- // }),
258
- // "withdraw"
259
- // )
260
- // );
261
-
262
- // transactionItems.push(
263
- // new TransactionItem(
264
- // async () => ({
265
- // tx: transactionBuilder()
266
- // .add(
267
- // client.protocolInteraction(
268
- // solautoAction("Withdraw", [
269
- // { __kind: "Some", fields: [toBaseUnit(0.01, 9)] },
270
- // ])
271
- // )
272
- // )
273
- // .add(
274
- // client.protocolInteraction(
275
- // solautoAction("Withdraw", [
276
- // { __kind: "Some", fields: [toBaseUnit(300, 9)] },
277
- // ])
278
- // )
279
- // )
280
- // }),
281
- // "withdraw"
282
- // )
283
- // );
284
-
285
158
  // transactionItems.push(
286
159
  // new TransactionItem(
287
160
  // async () => ({
@@ -291,17 +164,12 @@ describe("Solauto Marginfi tests", async () => {
291
164
  // )
292
165
  // );
293
166
 
294
- const temp = (statuses: TransactionManagerStatuses) =>
295
- console.log(statuses);
296
-
297
167
  const statuses = await new TransactionsManager(
298
168
  client,
299
- temp,
300
- !payForTransactions ? "only-simulate" : "normal",
301
- PriorityFeeSetting.Low,
302
- true,
303
169
  undefined,
304
- 0
170
+ !payForTransactions ? "only-simulate" : "normal",
171
+ PriorityFeeSetting.High,
172
+ true
305
173
  ).clientSend(transactionItems);
306
174
 
307
175
  console.log(statuses);