@haven-fi/solauto-sdk 1.0.507 → 1.0.509

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.
@@ -15,5 +15,4 @@ export declare const PRICES: {
15
15
  export declare const SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
16
16
  export declare const STANDARD_LUT_ACCOUNTS: string[];
17
17
  export declare const JITO_BLOCK_ENGINE = "https://mainnet.block-engine.jito.wtf";
18
- export declare const BROKEN_TOKENS: string[];
19
18
  //# sourceMappingURL=solautoConstants.d.ts.map
@@ -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;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;AACpC,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,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;AAE3B,eAAO,MAAM,iBAAiB,0CAA0C,CAAC;AAEzE,eAAO,MAAM,aAAa,UAOzB,CAAA"}
1
+ {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAQzB,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;AACpC,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,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;AAE3B,eAAO,MAAM,iBAAiB,0CAA0C,CAAC"}
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BROKEN_TOKENS = exports.JITO_BLOCK_ENGINE = exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.PRICES = exports.MIN_USD_SUPPORTED_POSITION = 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;
3
+ exports.JITO_BLOCK_ENGINE = exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.PRICES = exports.MIN_USD_SUPPORTED_POSITION = 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
  const generalAccounts_1 = require("./generalAccounts");
7
7
  const jupiter_sdk_1 = require("../jupiter-sdk");
8
- const tokenConstants_1 = require("./tokenConstants");
9
8
  exports.SOLAUTO_PROD_PROGRAM = new web3_js_1.PublicKey("AutoyKBRaHSBHy9RsmXCZMy6nNFAg5FYijrvZyQcNLV");
10
9
  exports.SOLAUTO_TEST_PROGRAM = new web3_js_1.PublicKey("TesTjfQ6TbXv96Tv6fqr95XTZ1LYPxtkafmShN9PjBp");
11
10
  globalThis.LOCAL_TEST = false;
@@ -30,11 +29,3 @@ exports.STANDARD_LUT_ACCOUNTS = [
30
29
  jupiter_sdk_1.JUPITER_PROGRAM_ID,
31
30
  ].map((x) => x.toString());
32
31
  exports.JITO_BLOCK_ENGINE = "https://mainnet.block-engine.jito.wtf";
33
- exports.BROKEN_TOKENS = [
34
- tokenConstants_1.JUP,
35
- tokenConstants_1.JLP,
36
- tokenConstants_1.WETH,
37
- tokenConstants_1.HNT,
38
- tokenConstants_1.JTO,
39
- tokenConstants_1.PYTH
40
- ];
@@ -1,12 +1,11 @@
1
1
  import { TransactionBuilder, Umi } from "@metaplex-foundation/umi";
2
2
  import { PublicKey } from "@solana/web3.js";
3
3
  import { SolautoClient } from "../clients/solautoClient";
4
- import { RebalanceValues } from "../utils/solauto/rebalanceUtils";
5
4
  import { ReferralStateManager } from "../clients";
6
5
  import { TransactionItemInputs } from "../types";
7
6
  export declare function rebalanceChoresBefore(client: SolautoClient, tx: TransactionBuilder, accountsGettingCreated: string[]): Promise<TransactionBuilder>;
8
7
  export declare function getTransactionChores(client: SolautoClient, tx: TransactionBuilder): Promise<[TransactionBuilder, TransactionBuilder]>;
9
- export declare function requiresRefreshBeforeRebalance(client: SolautoClient, values: RebalanceValues): Promise<boolean>;
8
+ export declare function requiresRefreshBeforeRebalance(client: SolautoClient): Promise<boolean>;
10
9
  export declare function buildSolautoRebalanceTransaction(client: SolautoClient, targetLiqUtilizationRateBps?: number, attemptNum?: number): Promise<TransactionItemInputs | undefined>;
11
10
  export declare function convertReferralFeesToDestination(referralManager: ReferralStateManager, tokenAccount: PublicKey, destinationMint: PublicKey): Promise<TransactionItemInputs | undefined>;
12
11
  export declare function getErrorInfo(umi: Umi, txs: TransactionBuilder[], error: Error, simulationSuccessful?: boolean): {
@@ -1 +1 @@
1
- {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAoBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAOzD,OAAO,EAIL,eAAe,EAChB,MAAM,iCAAiC,CAAC;AA0BzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA6LjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAoH7B;AA2LD,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,EAAE,MAAM,EAAE,eAAe,oBAqDlG;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsI5C;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SA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,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,kBAAkB,EAAE,EACzB,KAAK,EAAE,KAAK,EACZ,oBAAoB,CAAC,EAAE,OAAO;;;;EAoG/B"}
@@ -329,7 +329,7 @@ async function getTransactionChores(client, tx) {
329
329
  choresAfter = choresAfter.add(transactionChoresAfter(client, solautoActions, client.livePositionUpdates.cancellingDca));
330
330
  return [choresBefore, choresAfter];
331
331
  }
332
- async function requiresRefreshBeforeRebalance(client, values) {
332
+ async function requiresRefreshBeforeRebalance(client) {
333
333
  const neverRefreshedBefore = client.solautoPositionData &&
334
334
  client.solautoPositionData.state.supply.amountCanBeUsed.baseUnit ===
335
335
  BigInt(0) &&
@@ -377,8 +377,7 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
377
377
  const { jupQuote, lookupTableAddresses, setupInstructions, tokenLedgerIx, swapIx, } = await (0, jupiterUtils_1.getJupSwapTransaction)(client.signer, swapDetails, attemptNum);
378
378
  const flashLoan = (0, rebalanceUtils_1.getFlashLoanDetails)(client, values, jupQuote);
379
379
  let tx = (0, umi_1.transactionBuilder)();
380
- // REVERT ME
381
- if (await requiresRefreshBeforeRebalance(client, values)) {
380
+ if (await requiresRefreshBeforeRebalance(client)) {
382
381
  tx = tx.add(client.refresh());
383
382
  }
384
383
  if (flashLoan) {
@@ -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,EAEL,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;AAc7D,qBAAa,wBAAyB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AAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAS;IAE3B,kBAAkB,SAAmB;gBAG3B,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,EACrC,WAAW,CAAC,EAAE,WAAW;YAab,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;IA0GzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YAkCxB,6BAA6B;YAsI7B,qBAAqB;YAoDrB,eAAe;YA0Df,eAAe;CA4D9B"}
@@ -289,7 +289,6 @@ class TransactionsManager {
289
289
  .stale;
290
290
  if (stale) {
291
291
  this.txHandler.log("Requires oracle update...");
292
- console.log(mint);
293
292
  const swbTx = new TransactionItem(async () => (0, utils_1.buildSwbSubmitResponseTx)(client.connection, client.signer, mint), this.updateOracleTxName);
294
293
  await swbTx.initialize();
295
294
  items.unshift(swbTx);
@@ -1,18 +1,20 @@
1
1
  import { Signer, TransactionBuilder } from "@metaplex-foundation/umi";
2
2
  import { PublicKey } from "@solana/web3.js";
3
3
  import { QuoteResponse } from "@jup-ag/api";
4
- export interface JupSwapDetails {
4
+ export interface JupSwapInput {
5
5
  inputMint: PublicKey;
6
6
  outputMint: PublicKey;
7
- destinationWallet: PublicKey;
8
7
  amount: bigint;
9
- slippageIncFactor?: number;
10
- exactOut?: boolean;
11
8
  exactIn?: boolean;
9
+ exactOut?: boolean;
10
+ }
11
+ export interface JupSwapDetails extends JupSwapInput {
12
+ destinationWallet: PublicKey;
13
+ slippageIncFactor?: number;
12
14
  addPadding?: boolean;
13
15
  jupQuote?: QuoteResponse;
14
16
  }
15
- export declare function accountsLimit(inputMint: PublicKey, outputMint: PublicKey): 15 | 40;
17
+ export declare function getJupQuote(swapDetails: JupSwapInput): Promise<QuoteResponse>;
16
18
  export interface JupSwapTransaction {
17
19
  jupQuote: QuoteResponse;
18
20
  priceImpactBps: number;
@@ -1 +1 @@
1
- {"version":3,"file":"jupiterUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jupiterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA0B,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAGL,aAAa,EACd,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAgBD,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,WAOxE;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,aAAa,EAAE,kBAAkB,CAAC;IAClC,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,wBAAsB,qBAA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AM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAmF7B;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,EAAE,OAAO;;GA0B5E"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.accountsLimit = accountsLimit;
3
+ exports.getJupQuote = getJupQuote;
4
4
  exports.getJupSwapTransaction = getJupSwapTransaction;
5
5
  exports.getJupPriceData = getJupPriceData;
6
6
  const umi_1 = require("@metaplex-foundation/umi");
@@ -10,7 +10,6 @@ const numberUtils_1 = require("./numberUtils");
10
10
  const api_1 = require("@jup-ag/api");
11
11
  const accountUtils_1 = require("./accountUtils");
12
12
  const generalUtils_1 = require("./generalUtils");
13
- const constants_1 = require("../constants");
14
13
  const jupApi = (0, api_1.createJupiterApiClient)();
15
14
  function createTransactionInstruction(instruction) {
16
15
  return new web3_js_1.TransactionInstruction({
@@ -23,31 +22,24 @@ function createTransactionInstruction(instruction) {
23
22
  data: Buffer.from(instruction.data, "base64"),
24
23
  });
25
24
  }
26
- function accountsLimit(inputMint, outputMint) {
27
- const tokensWithLowAccounts = [constants_1.PYTH, constants_1.INF];
28
- // TEMP REVERT ME
29
- const useLowAccounts = tokensWithLowAccounts.find((x) => inputMint.equals(new web3_js_1.PublicKey(x))) ||
30
- tokensWithLowAccounts.find((x) => outputMint.equals(new web3_js_1.PublicKey(x)));
31
- return useLowAccounts ? 15 : 40;
25
+ async function getJupQuote(swapDetails) {
26
+ const memecoinSwap = (0, generalUtils_1.tokenInfo)(swapDetails.inputMint).isMeme ||
27
+ (0, generalUtils_1.tokenInfo)(swapDetails.outputMint).isMeme;
28
+ return await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await jupApi.quoteGet({
29
+ amount: Number(swapDetails.amount),
30
+ inputMint: swapDetails.inputMint.toString(),
31
+ outputMint: swapDetails.outputMint.toString(),
32
+ swapMode: swapDetails.exactIn
33
+ ? "ExactOut"
34
+ : swapDetails.exactIn
35
+ ? "ExactIn"
36
+ : undefined,
37
+ slippageBps: memecoinSwap ? 500 : 200,
38
+ maxAccounts: !swapDetails.exactOut ? 40 : undefined,
39
+ }), 2, 200);
32
40
  }
33
41
  async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
34
- const memecoinSwap = constants_1.TOKEN_INFO[swapDetails.inputMint.toString()].isMeme ||
35
- constants_1.TOKEN_INFO[swapDetails.outputMint.toString()].isMeme;
36
- const quoteResponse = swapDetails.jupQuote ??
37
- (await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await jupApi.quoteGet({
38
- amount: Number(swapDetails.amount),
39
- inputMint: swapDetails.inputMint.toString(),
40
- outputMint: swapDetails.outputMint.toString(),
41
- swapMode: swapDetails.exactOut
42
- ? "ExactOut"
43
- : swapDetails.exactIn
44
- ? "ExactIn"
45
- : undefined,
46
- slippageBps: memecoinSwap ? 500 : 200,
47
- maxAccounts: !swapDetails.exactOut
48
- ? accountsLimit(swapDetails.inputMint, swapDetails.outputMint)
49
- : undefined,
50
- }), 4, 200));
42
+ const quoteResponse = swapDetails.jupQuote ?? (await getJupQuote(swapDetails));
51
43
  const priceImpactBps = Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1;
52
44
  const finalPriceSlippageBps = Math.round(Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
53
45
  (1 + (swapDetails.slippageIncFactor ?? 0)));
@@ -1,11 +1,12 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { PublicKey as UmiPublicKey } from "@metaplex-foundation/umi";
3
+ import { QuoteGetSwapModeEnum } from "@jup-ag/api";
3
4
  export declare function fetchTokenPrices(mints: PublicKey[]): Promise<number[]>;
4
5
  export declare function getPythPrices(mints: PublicKey[]): Promise<number[]>;
5
6
  export declare function getSwitchboardPrices(mints: PublicKey[]): Promise<number[]>;
6
7
  export declare function getJupTokenPrices(mints: PublicKey[]): Promise<number[]>;
7
8
  export declare function safeGetPrice(mint: PublicKey | UmiPublicKey | undefined): number | undefined;
8
- export declare function getPriceImpact(inputMint: PublicKey, inputAmount: bigint, outputMint: PublicKey): Promise<{
9
+ export declare function getPriceImpact(inputMint: PublicKey, outputMint: PublicKey, amount: bigint, swapMode: QuoteGetSwapModeEnum): Promise<{
9
10
  priceImpact: number;
10
11
  quote: import("@jup-ag/api").QuoteResponse;
11
12
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"priceUtils.d.ts","sourceRoot":"","sources":["../../src/utils/priceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAgBrE,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqC5E;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,qBAwCrD;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAgDnB;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,qBAQzD;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GACzC,MAAM,GAAG,SAAS,CAKpB;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,SAAS;;;GAqBtB"}
1
+ {"version":3,"file":"priceUtils.d.ts","sourceRoot":"","sources":["../../src/utils/priceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAcrE,OAAO,EAA0B,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE3E,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqC5E;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,qBAwCrD;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAgDnB;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,qBAQzD;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GACzC,MAAM,GAAG,SAAS,CAKpB;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,SAAS,EACrB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,oBAAoB;;;GAc/B"}
@@ -36,7 +36,6 @@ const switchboardConstants_1 = require("../constants/switchboardConstants");
36
36
  const generalUtils_1 = require("./generalUtils");
37
37
  const OnDemand = __importStar(require("@switchboard-xyz/on-demand"));
38
38
  const jupiterUtils_1 = require("./jupiterUtils");
39
- const api_1 = require("@jup-ag/api");
40
39
  async function fetchTokenPrices(mints) {
41
40
  const currentTime = (0, generalUtils_1.currentUnixSeconds)();
42
41
  if (!mints.some((mint) => !(mint.toString() in solautoConstants_1.PRICES) ||
@@ -130,15 +129,14 @@ function safeGetPrice(mint) {
130
129
  }
131
130
  return undefined;
132
131
  }
133
- async function getPriceImpact(inputMint, inputAmount, outputMint) {
134
- const jupApi = (0, api_1.createJupiterApiClient)();
135
- const quoteResponse = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await jupApi.quoteGet({
136
- amount: Number(inputAmount),
137
- inputMint: inputMint.toString(),
138
- outputMint: outputMint.toString(),
139
- swapMode: "ExactIn",
140
- maxAccounts: (0, jupiterUtils_1.accountsLimit)(inputMint, outputMint),
141
- }), 4, 200);
132
+ async function getPriceImpact(inputMint, outputMint, amount, swapMode) {
133
+ const quoteResponse = await (0, jupiterUtils_1.getJupQuote)({
134
+ inputMint,
135
+ outputMint,
136
+ amount,
137
+ exactIn: swapMode === "ExactIn",
138
+ exactOut: swapMode === "ExactOut",
139
+ });
142
140
  return {
143
141
  priceImpact: parseFloat(quoteResponse.priceImpactPct),
144
142
  quote: quoteResponse,
@@ -13,7 +13,6 @@ export interface RebalanceValues {
13
13
  rebalanceAction: RebalanceAction;
14
14
  rebalanceDirection: RebalanceDirection;
15
15
  feesUsd: number;
16
- targetRateBps: number;
17
16
  }
18
17
  export declare function getRebalanceValues(state: PositionState, settings: SolautoSettingsParameters | undefined, dca: DCASettings | undefined, currentUnixTime: number, supplyPrice: number, debtPrice: number, targetLiqUtilizationRateBps?: number): RebalanceValues;
19
18
  export declare function rebalanceRequiresFlashLoan(client: SolautoClient, values: RebalanceValues): {
@@ -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;AAcjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAoI9C,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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B,CAAC;AAa5E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAoI9C,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,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB;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,CAwDjB;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe;;;EAsDxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CAgC9B;AAED,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC,CA0FzB"}
@@ -4,15 +4,14 @@ exports.getRebalanceValues = getRebalanceValues;
4
4
  exports.rebalanceRequiresFlashLoan = rebalanceRequiresFlashLoan;
5
5
  exports.getFlashLoanDetails = getFlashLoanDetails;
6
6
  exports.getJupSwapRebalanceDetails = getJupSwapRebalanceDetails;
7
- const web3_js_1 = require("@solana/web3.js");
8
7
  const generated_1 = require("../../generated");
9
8
  const generalUtils_1 = require("./generalUtils");
10
9
  const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
10
+ const jupiterUtils_1 = require("../jupiterUtils");
11
11
  const generalUtils_2 = require("../generalUtils");
12
12
  const numberUtils_1 = require("../numberUtils");
13
13
  const generalAccounts_1 = require("../../constants/generalAccounts");
14
14
  const priceUtils_1 = require("../priceUtils");
15
- const constants_1 = require("../../constants");
16
15
  function getAdditionalAmountToDcaIn(dca) {
17
16
  if (dca.dcaInBaseUnit === BigInt(0)) {
18
17
  return 0;
@@ -84,18 +83,7 @@ function getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, target
84
83
  }
85
84
  }
86
85
  function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice, debtPrice, targetLiqUtilizationRateBps) {
87
- let { targetRateBps, amountToDcaIn } = getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, targetLiqUtilizationRateBps);
88
- // REVERT ME AND GET TO THE ROOT OF THIS ISSUE
89
- const supplyMint = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.supply.mint);
90
- if (constants_1.BROKEN_TOKENS.includes(supplyMint.toString()) &&
91
- ((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.debt.mint).equals(new web3_js_1.PublicKey(constants_1.USDC)) ||
92
- (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.debt.mint).equals(new web3_js_1.PublicKey(constants_1.USDT))) &&
93
- settings &&
94
- settings.boostToBps ===
95
- (0, numberUtils_1.maxBoostToBps)(state.maxLtvBps, state.liqThresholdBps) &&
96
- targetRateBps === settings.boostToBps) {
97
- targetRateBps = 6500;
98
- }
86
+ const { targetRateBps, amountToDcaIn } = getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, targetLiqUtilizationRateBps);
99
87
  const amountUsdToDcaIn = (0, numberUtils_1.fromBaseUnit)(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
100
88
  (dca?.tokenType === generated_1.TokenType.Debt ? debtPrice : supplyPrice);
101
89
  const rebalanceDirection = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps <= targetRateBps
@@ -106,7 +94,6 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
106
94
  amountUsdToDcaIn;
107
95
  const debtUsd = (0, numberUtils_1.fromBaseUnit)(state.debt.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS);
108
96
  let debtAdjustmentUsd = (0, numberUtils_1.getDebtAdjustmentUsd)(state.liqThresholdBps, supplyUsd, debtUsd, targetRateBps, adjustmentFeeBps);
109
- (0, generalUtils_2.consoleLog)("Target rate:", targetRateBps, (0, numberUtils_1.maxBoostToBps)(state.maxLtvBps, state.liqThresholdBps));
110
97
  const maxRepayTo = (0, numberUtils_1.maxRepayToBps)(state.maxLtvBps, state.liqThresholdBps);
111
98
  return {
112
99
  debtAdjustmentUsd,
@@ -121,7 +108,6 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
121
108
  : "repay",
122
109
  rebalanceDirection,
123
110
  feesUsd: Math.abs(debtAdjustmentUsd * (0, numberUtils_1.fromBps)(adjustmentFeeBps)),
124
- targetRateBps,
125
111
  };
126
112
  }
127
113
  function rebalanceRequiresFlashLoan(client, values) {
@@ -180,10 +166,11 @@ async function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRa
180
166
  const output = values.rebalanceDirection === generated_1.RebalanceDirection.Boost
181
167
  ? client.solautoPositionState.supply
182
168
  : client.solautoPositionState.debt;
169
+ const rebalanceToZero = targetLiqUtilizationRateBps === 0;
183
170
  const usdToSwap = Math.abs(values.debtAdjustmentUsd) +
184
171
  (values.dcaTokenType === generated_1.TokenType.Debt ? values.amountUsdToDcaIn : 0);
185
172
  let inputAmount = (0, numberUtils_1.toBaseUnit)(usdToSwap / (0, priceUtils_1.safeGetPrice)(input.mint), input.decimals);
186
- const outputAmount = targetLiqUtilizationRateBps === 0
173
+ const outputAmount = rebalanceToZero
187
174
  ? output.amountUsed.baseUnit +
188
175
  BigInt(Math.round(Number(output.amountUsed.baseUnit) *
189
176
  // Add this small percentage to account for the APR on the debt between now and the transaction
@@ -192,36 +179,43 @@ async function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRa
192
179
  const repaying = values.rebalanceDirection === generated_1.RebalanceDirection.Repay;
193
180
  const { requiresFlashLoan, useDebtLiquidity } = rebalanceRequiresFlashLoan(client, values);
194
181
  const flashLoanRepayFromDebt = repaying && requiresFlashLoan && useDebtLiquidity;
195
- const exactOut =
196
- // targetLiqUtilizationRateBps === 0 ||
197
- // values.repayingCloseToMaxLtv ||
198
- flashLoanRepayFromDebt;
182
+ const exactOut = rebalanceToZero || flashLoanRepayFromDebt;
199
183
  const exactIn = !exactOut;
184
+ const jupSwapInput = {
185
+ inputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint),
186
+ outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint),
187
+ exactIn,
188
+ exactOut,
189
+ amount: exactOut ? outputAmount : inputAmount,
190
+ };
200
191
  let jupQuote = undefined;
201
- if (targetLiqUtilizationRateBps === 0) {
202
- let priceImpact = 0;
203
- inputAmount += BigInt(Math.round(Number(inputAmount) * 0.001));
204
- do {
205
- const res = await (0, priceUtils_1.getPriceImpact)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint), inputAmount + BigInt(Math.round(Number(inputAmount) * priceImpact)), (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint));
206
- priceImpact = res.priceImpact;
207
- jupQuote = res.quote;
208
- inputAmount =
209
- BigInt(parseInt(res.quote.inAmount)) +
210
- BigInt(Math.round(Number(inputAmount) * 0.001));
211
- } while (parseInt(jupQuote.outAmount) < outputAmount &&
212
- priceImpact > 0.001);
192
+ if (rebalanceToZero) {
193
+ try {
194
+ jupQuote = await (0, jupiterUtils_1.getJupQuote)(jupSwapInput);
195
+ }
196
+ catch {
197
+ let priceImpact = 0;
198
+ jupSwapInput.exactIn = true;
199
+ jupSwapInput.exactOut = false;
200
+ jupSwapInput.amount = inputAmount + BigInt(Math.round(Number(inputAmount) * 0.001));
201
+ do {
202
+ const res = await (0, priceUtils_1.getPriceImpact)(jupSwapInput.inputMint, jupSwapInput.outputMint, jupSwapInput.amount + BigInt(Math.round(Number(jupSwapInput.amount) * priceImpact)), "ExactIn");
203
+ priceImpact = res.priceImpact;
204
+ jupQuote = res.quote;
205
+ jupSwapInput.amount =
206
+ BigInt(parseInt(res.quote.inAmount)) +
207
+ BigInt(Math.round(Number(jupSwapInput.amount) * 0.001));
208
+ } while (parseInt(jupQuote.outAmount) < outputAmount &&
209
+ priceImpact > 0.001);
210
+ }
213
211
  }
214
212
  const addPadding = exactOut;
215
213
  return {
216
- inputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint),
217
- outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint),
214
+ ...jupSwapInput,
218
215
  destinationWallet: flashLoanRepayFromDebt
219
216
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey)
220
217
  : client.solautoPosition,
221
218
  slippageIncFactor: 0.2 + (attemptNum ?? 0) * 0.25,
222
- amount: exactOut ? outputAmount : inputAmount,
223
- exactIn,
224
- exactOut,
225
219
  addPadding,
226
220
  jupQuote,
227
221
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.507",
3
+ "version": "1.0.509",
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",
@@ -11,7 +11,6 @@ import {
11
11
  } from "@solana/spl-token";
12
12
  import { SOLAUTO_MANAGER } from "./generalAccounts";
13
13
  import { JUPITER_PROGRAM_ID } from "../jupiter-sdk";
14
- import { HNT, JLP, JTO, JUP, PYTH, WETH } from "./tokenConstants";
15
14
 
16
15
  export const SOLAUTO_PROD_PROGRAM = new PublicKey(
17
16
  "AutoyKBRaHSBHy9RsmXCZMy6nNFAg5FYijrvZyQcNLV"
@@ -46,13 +45,4 @@ export const STANDARD_LUT_ACCOUNTS = [
46
45
  JUPITER_PROGRAM_ID,
47
46
  ].map((x) => x.toString());
48
47
 
49
- export const JITO_BLOCK_ENGINE = "https://mainnet.block-engine.jito.wtf";
50
-
51
- export const BROKEN_TOKENS = [
52
- JUP,
53
- JLP,
54
- WETH,
55
- HNT,
56
- JTO,
57
- PYTH
58
- ]
48
+ export const JITO_BLOCK_ENGINE = "https://mainnet.block-engine.jito.wtf";
@@ -39,7 +39,6 @@ import {
39
39
  getFlashLoanDetails,
40
40
  getJupSwapRebalanceDetails,
41
41
  getRebalanceValues,
42
- RebalanceValues,
43
42
  } from "../utils/solauto/rebalanceUtils";
44
43
  import {
45
44
  consoleLog,
@@ -72,11 +71,10 @@ import {
72
71
  getJupiterErrorFromCode,
73
72
  JUPITER_PROGRAM_ID,
74
73
  } from "../jupiter-sdk";
75
- import { JUP, PRICES, USDC } from "../constants";
74
+ import { PRICES } from "../constants";
76
75
  import { TransactionItemInputs } from "../types";
77
76
  import { safeGetPrice } from "../utils";
78
77
  import { BundleSimulationError } from "../types/transactions";
79
- import { getPackedSettings } from "http2";
80
78
 
81
79
  interface wSolTokenUsage {
82
80
  wSolTokenAccount: PublicKey;
@@ -600,7 +598,7 @@ export async function getTransactionChores(
600
598
  return [choresBefore, choresAfter];
601
599
  }
602
600
 
603
- export async function requiresRefreshBeforeRebalance(client: SolautoClient, values: RebalanceValues) {
601
+ export async function requiresRefreshBeforeRebalance(client: SolautoClient) {
604
602
  const neverRefreshedBefore =
605
603
  client.solautoPositionData &&
606
604
  client.solautoPositionData.state.supply.amountCanBeUsed.baseUnit ===
@@ -705,13 +703,11 @@ export async function buildSolautoRebalanceTransaction(
705
703
  tokenLedgerIx,
706
704
  swapIx,
707
705
  } = await getJupSwapTransaction(client.signer, swapDetails, attemptNum);
708
-
709
706
  const flashLoan = getFlashLoanDetails(client, values, jupQuote);
710
707
 
711
708
  let tx = transactionBuilder();
712
709
 
713
- // REVERT ME
714
- if (await requiresRefreshBeforeRebalance(client, values)) {
710
+ if (await requiresRefreshBeforeRebalance(client)) {
715
711
  tx = tx.add(client.refresh());
716
712
  }
717
713
 
@@ -465,7 +465,6 @@ export class TransactionsManager {
465
465
 
466
466
  if (stale) {
467
467
  this.txHandler.log("Requires oracle update...");
468
- console.log(mint);
469
468
  const swbTx = new TransactionItem(
470
469
  async () =>
471
470
  buildSwbSubmitResponseTx(client.connection, client.signer, mint),
@@ -9,22 +9,29 @@ import { fromBps, toBps } from "./numberUtils";
9
9
  import {
10
10
  createJupiterApiClient,
11
11
  Instruction,
12
+ QuoteGetSwapModeEnum,
12
13
  QuoteResponse,
13
14
  } from "@jup-ag/api";
14
15
  import { getTokenAccount } from "./accountUtils";
15
- import { consoleLog, retryWithExponentialBackoff } from "./generalUtils";
16
- import { INF, PYTH, TOKEN_INFO } from "../constants";
16
+ import {
17
+ consoleLog,
18
+ retryWithExponentialBackoff,
19
+ tokenInfo,
20
+ } from "./generalUtils";
17
21
 
18
22
  const jupApi = createJupiterApiClient();
19
23
 
20
- export interface JupSwapDetails {
24
+ export interface JupSwapInput {
21
25
  inputMint: PublicKey;
22
26
  outputMint: PublicKey;
23
- destinationWallet: PublicKey;
24
27
  amount: bigint;
25
- slippageIncFactor?: number;
26
- exactOut?: boolean;
27
28
  exactIn?: boolean;
29
+ exactOut?: boolean;
30
+ }
31
+
32
+ export interface JupSwapDetails extends JupSwapInput {
33
+ destinationWallet: PublicKey;
34
+ slippageIncFactor?: number;
28
35
  addPadding?: boolean;
29
36
  jupQuote?: QuoteResponse;
30
37
  }
@@ -43,13 +50,28 @@ function createTransactionInstruction(
43
50
  });
44
51
  }
45
52
 
46
- export function accountsLimit(inputMint: PublicKey, outputMint: PublicKey) {
47
- const tokensWithLowAccounts = [PYTH, INF];
48
- // TEMP REVERT ME
49
- const useLowAccounts =
50
- tokensWithLowAccounts.find((x) => inputMint.equals(new PublicKey(x))) ||
51
- tokensWithLowAccounts.find((x) => outputMint.equals(new PublicKey(x)));
52
- return useLowAccounts ? 15 : 40;
53
+ export async function getJupQuote(swapDetails: JupSwapInput) {
54
+ const memecoinSwap =
55
+ tokenInfo(swapDetails.inputMint).isMeme ||
56
+ tokenInfo(swapDetails.outputMint).isMeme;
57
+
58
+ return await retryWithExponentialBackoff(
59
+ async () =>
60
+ await jupApi.quoteGet({
61
+ amount: Number(swapDetails.amount),
62
+ inputMint: swapDetails.inputMint.toString(),
63
+ outputMint: swapDetails.outputMint.toString(),
64
+ swapMode: swapDetails.exactIn
65
+ ? "ExactOut"
66
+ : swapDetails.exactIn
67
+ ? "ExactIn"
68
+ : undefined,
69
+ slippageBps: memecoinSwap ? 500 : 200,
70
+ maxAccounts: !swapDetails.exactOut ? 40 : undefined,
71
+ }),
72
+ 2,
73
+ 200
74
+ );
53
75
  }
54
76
 
55
77
  export interface JupSwapTransaction {
@@ -66,31 +88,8 @@ export async function getJupSwapTransaction(
66
88
  swapDetails: JupSwapDetails,
67
89
  attemptNum?: number
68
90
  ): Promise<JupSwapTransaction> {
69
- const memecoinSwap =
70
- TOKEN_INFO[swapDetails.inputMint.toString()].isMeme ||
71
- TOKEN_INFO[swapDetails.outputMint.toString()].isMeme;
72
-
73
91
  const quoteResponse =
74
- swapDetails.jupQuote ??
75
- (await retryWithExponentialBackoff(
76
- async () =>
77
- await jupApi.quoteGet({
78
- amount: Number(swapDetails.amount),
79
- inputMint: swapDetails.inputMint.toString(),
80
- outputMint: swapDetails.outputMint.toString(),
81
- swapMode: swapDetails.exactOut
82
- ? "ExactOut"
83
- : swapDetails.exactIn
84
- ? "ExactIn"
85
- : undefined,
86
- slippageBps: memecoinSwap ? 500 : 200,
87
- maxAccounts: !swapDetails.exactOut
88
- ? accountsLimit(swapDetails.inputMint, swapDetails.outputMint)
89
- : undefined,
90
- }),
91
- 4,
92
- 200
93
- ));
92
+ swapDetails.jupQuote ?? (await getJupQuote(swapDetails));
94
93
 
95
94
  const priceImpactBps =
96
95
  Math.round(toBps(parseFloat(quoteResponse.priceImpactPct))) + 1;
@@ -12,8 +12,8 @@ import {
12
12
  zip,
13
13
  } from "./generalUtils";
14
14
  import * as OnDemand from "@switchboard-xyz/on-demand";
15
- import { accountsLimit, getJupPriceData } from "./jupiterUtils";
16
- import { createJupiterApiClient } from "@jup-ag/api";
15
+ import { getJupPriceData, getJupQuote } from "./jupiterUtils";
16
+ import { createJupiterApiClient, QuoteGetSwapModeEnum } from "@jup-ag/api";
17
17
 
18
18
  export async function fetchTokenPrices(mints: PublicKey[]): Promise<number[]> {
19
19
  const currentTime = currentUnixSeconds();
@@ -169,23 +169,17 @@ export function safeGetPrice(
169
169
 
170
170
  export async function getPriceImpact(
171
171
  inputMint: PublicKey,
172
- inputAmount: bigint,
173
- outputMint: PublicKey
172
+ outputMint: PublicKey,
173
+ amount: bigint,
174
+ swapMode: QuoteGetSwapModeEnum
174
175
  ) {
175
- const jupApi = createJupiterApiClient();
176
-
177
- const quoteResponse = await retryWithExponentialBackoff(
178
- async () =>
179
- await jupApi.quoteGet({
180
- amount: Number(inputAmount),
181
- inputMint: inputMint.toString(),
182
- outputMint: outputMint.toString(),
183
- swapMode: "ExactIn",
184
- maxAccounts: accountsLimit(inputMint, outputMint),
185
- }),
186
- 4,
187
- 200
188
- );
176
+ const quoteResponse = await getJupQuote({
177
+ inputMint,
178
+ outputMint,
179
+ amount,
180
+ exactIn: swapMode === "ExactIn",
181
+ exactOut: swapMode === "ExactOut",
182
+ });
189
183
 
190
184
  return {
191
185
  priceImpact: parseFloat(quoteResponse.priceImpactPct),
@@ -15,7 +15,7 @@ import {
15
15
  } from "./generalUtils";
16
16
  import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
17
17
  import { QuoteResponse } from "@jup-ag/api";
18
- import { JupSwapDetails } from "../jupiterUtils";
18
+ import { getJupQuote, JupSwapDetails, JupSwapInput } from "../jupiterUtils";
19
19
  import { consoleLog, currentUnixSeconds } from "../generalUtils";
20
20
  import {
21
21
  fromBaseUnit,
@@ -24,14 +24,13 @@ import {
24
24
  getLiqUtilzationRateBps,
25
25
  getMaxLiqUtilizationRateBps,
26
26
  getSolautoFeesBps,
27
- maxBoostToBps,
28
27
  maxRepayToBps,
29
28
  toBaseUnit,
30
29
  } from "../numberUtils";
31
30
  import { USD_DECIMALS } from "../../constants/generalAccounts";
32
31
  import { RebalanceAction } from "../../types";
33
32
  import { getPriceImpact, safeGetPrice } from "../priceUtils";
34
- import { BROKEN_TOKENS, USDC, USDT } from "../../constants";
33
+ import { TOKEN_INFO } from "../../constants";
35
34
 
36
35
  function getAdditionalAmountToDcaIn(dca: DCASettings): number {
37
36
  if (dca.dcaInBaseUnit === BigInt(0)) {
@@ -170,7 +169,6 @@ export interface RebalanceValues {
170
169
  rebalanceAction: RebalanceAction;
171
170
  rebalanceDirection: RebalanceDirection;
172
171
  feesUsd: number;
173
- targetRateBps: number;
174
172
  }
175
173
 
176
174
  export function getRebalanceValues(
@@ -182,7 +180,7 @@ export function getRebalanceValues(
182
180
  debtPrice: number,
183
181
  targetLiqUtilizationRateBps?: number
184
182
  ): RebalanceValues {
185
- let { targetRateBps, amountToDcaIn } = getTargetRateAndDcaAmount(
183
+ const { targetRateBps, amountToDcaIn } = getTargetRateAndDcaAmount(
186
184
  state,
187
185
  settings,
188
186
  dca,
@@ -190,20 +188,6 @@ export function getRebalanceValues(
190
188
  targetLiqUtilizationRateBps
191
189
  );
192
190
 
193
- // REVERT ME AND GET TO THE ROOT OF THIS ISSUE
194
- const supplyMint = toWeb3JsPublicKey(state.supply.mint);
195
- if (
196
- BROKEN_TOKENS.includes(supplyMint.toString()) &&
197
- (toWeb3JsPublicKey(state.debt.mint).equals(new PublicKey(USDC)) ||
198
- toWeb3JsPublicKey(state.debt.mint).equals(new PublicKey(USDT))) &&
199
- settings &&
200
- settings.boostToBps ===
201
- maxBoostToBps(state.maxLtvBps, state.liqThresholdBps) &&
202
- targetRateBps === settings.boostToBps
203
- ) {
204
- targetRateBps = 6500;
205
- }
206
-
207
191
  const amountUsdToDcaIn =
208
192
  fromBaseUnit(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
209
193
  (dca?.tokenType === TokenType.Debt ? debtPrice : supplyPrice);
@@ -234,11 +218,6 @@ export function getRebalanceValues(
234
218
  adjustmentFeeBps
235
219
  );
236
220
 
237
- consoleLog(
238
- "Target rate:",
239
- targetRateBps,
240
- maxBoostToBps(state.maxLtvBps, state.liqThresholdBps)
241
- );
242
221
  const maxRepayTo = maxRepayToBps(state.maxLtvBps, state.liqThresholdBps);
243
222
  return {
244
223
  debtAdjustmentUsd,
@@ -255,7 +234,6 @@ export function getRebalanceValues(
255
234
  : "repay",
256
235
  rebalanceDirection,
257
236
  feesUsd: Math.abs(debtAdjustmentUsd * fromBps(adjustmentFeeBps)),
258
- targetRateBps,
259
237
  };
260
238
  }
261
239
 
@@ -376,6 +354,7 @@ export async function getJupSwapRebalanceDetails(
376
354
  ? client.solautoPositionState!.supply
377
355
  : client.solautoPositionState!.debt;
378
356
 
357
+ const rebalanceToZero = targetLiqUtilizationRateBps === 0;
379
358
  const usdToSwap =
380
359
  Math.abs(values.debtAdjustmentUsd) +
381
360
  (values.dcaTokenType === TokenType.Debt ? values.amountUsdToDcaIn : 0);
@@ -384,17 +363,16 @@ export async function getJupSwapRebalanceDetails(
384
363
  usdToSwap / safeGetPrice(input.mint)!,
385
364
  input.decimals
386
365
  );
387
- const outputAmount =
388
- targetLiqUtilizationRateBps === 0
389
- ? output.amountUsed.baseUnit +
390
- BigInt(
391
- Math.round(
392
- Number(output.amountUsed.baseUnit) *
393
- // Add this small percentage to account for the APR on the debt between now and the transaction
394
- 0.0001
395
- )
366
+ const outputAmount = rebalanceToZero
367
+ ? output.amountUsed.baseUnit +
368
+ BigInt(
369
+ Math.round(
370
+ Number(output.amountUsed.baseUnit) *
371
+ // Add this small percentage to account for the APR on the debt between now and the transaction
372
+ 0.0001
396
373
  )
397
- : toBaseUnit(usdToSwap / safeGetPrice(output.mint)!, output.decimals);
374
+ )
375
+ : toBaseUnit(usdToSwap / safeGetPrice(output.mint)!, output.decimals);
398
376
 
399
377
  const repaying = values.rebalanceDirection === RebalanceDirection.Repay;
400
378
 
@@ -405,46 +383,54 @@ export async function getJupSwapRebalanceDetails(
405
383
  const flashLoanRepayFromDebt =
406
384
  repaying && requiresFlashLoan && useDebtLiquidity;
407
385
 
408
- const exactOut =
409
- // targetLiqUtilizationRateBps === 0 ||
410
- // values.repayingCloseToMaxLtv ||
411
- flashLoanRepayFromDebt;
386
+ const exactOut = rebalanceToZero || flashLoanRepayFromDebt;
412
387
  const exactIn = !exactOut;
413
388
 
389
+ const jupSwapInput: JupSwapInput = {
390
+ inputMint: toWeb3JsPublicKey(input.mint),
391
+ outputMint: toWeb3JsPublicKey(output.mint),
392
+ exactIn,
393
+ exactOut,
394
+ amount: exactOut ? outputAmount : inputAmount,
395
+ };
396
+
414
397
  let jupQuote: QuoteResponse | undefined = undefined;
415
- if (targetLiqUtilizationRateBps === 0) {
416
- let priceImpact: number = 0;
417
- inputAmount += BigInt(Math.round(Number(inputAmount) * 0.001));
418
-
419
- do {
420
- const res = await getPriceImpact(
421
- toWeb3JsPublicKey(input.mint),
422
- inputAmount + BigInt(Math.round(Number(inputAmount) * priceImpact)),
423
- toWeb3JsPublicKey(output.mint)
398
+ if (rebalanceToZero) {
399
+ try {
400
+ jupQuote = await getJupQuote(jupSwapInput);
401
+ } catch {
402
+ let priceImpact: number = 0;
403
+ jupSwapInput.exactIn = true;
404
+ jupSwapInput.exactOut = false;
405
+ jupSwapInput.amount = inputAmount + BigInt(Math.round(Number(inputAmount) * 0.001));
406
+
407
+ do {
408
+ const res = await getPriceImpact(
409
+ jupSwapInput.inputMint,
410
+ jupSwapInput.outputMint,
411
+ jupSwapInput.amount + BigInt(Math.round(Number(jupSwapInput.amount) * priceImpact)),
412
+ "ExactIn"
413
+ );
414
+ priceImpact = res.priceImpact;
415
+ jupQuote = res.quote;
416
+ jupSwapInput.amount =
417
+ BigInt(parseInt(res.quote.inAmount)) +
418
+ BigInt(Math.round(Number(jupSwapInput.amount) * 0.001));
419
+ } while (
420
+ parseInt(jupQuote.outAmount) < outputAmount &&
421
+ priceImpact > 0.001
424
422
  );
425
- priceImpact = res.priceImpact;
426
- jupQuote = res.quote;
427
- inputAmount =
428
- BigInt(parseInt(res.quote.inAmount)) +
429
- BigInt(Math.round(Number(inputAmount) * 0.001));
430
- } while (
431
- parseInt(jupQuote.outAmount) < outputAmount &&
432
- priceImpact > 0.001
433
- );
423
+ }
434
424
  }
435
425
 
436
426
  const addPadding = exactOut;
437
427
 
438
428
  return {
439
- inputMint: toWeb3JsPublicKey(input.mint),
440
- outputMint: toWeb3JsPublicKey(output.mint),
429
+ ...jupSwapInput,
441
430
  destinationWallet: flashLoanRepayFromDebt
442
431
  ? toWeb3JsPublicKey(client.signer.publicKey)
443
432
  : client.solautoPosition,
444
433
  slippageIncFactor: 0.2 + (attemptNum ?? 0) * 0.25,
445
- amount: exactOut ? outputAmount : inputAmount,
446
- exactIn,
447
- exactOut,
448
434
  addPadding,
449
435
  jupQuote,
450
436
  };
@@ -3,16 +3,12 @@ import { none, publicKey, some } from "@metaplex-foundation/umi";
3
3
  import { setupTest } from "../shared";
4
4
  import { SolautoMarginfiClient } from "../../src/clients/solautoMarginfiClient";
5
5
  import {
6
- PositionType,
7
6
  safeFetchSolautoPosition,
8
7
  solautoAction,
9
8
  SolautoSettingsParametersInpArgs,
10
9
  } from "../../src/generated";
11
10
  import { buildSolautoRebalanceTransaction } from "../../src/transactions/transactionUtils";
12
11
  import {
13
- bytesToI80F48,
14
- getLiqUtilzationRateBps,
15
- getMaxLiqUtilizationRateBps,
16
12
  maxBoostToBps,
17
13
  maxRepayFromBps,
18
14
  maxRepayToBps,
@@ -25,20 +21,14 @@ import {
25
21
  } from "../../src/transactions/transactionsManager";
26
22
  import { PublicKey } from "@solana/web3.js";
27
23
  import {
28
- DEFAULT_MARGINFI_GROUP,
29
- MARGINFI_ACCOUNTS,
30
24
  SOLAUTO_PROD_PROGRAM,
31
25
  SOLAUTO_TEST_PROGRAM,
32
26
  USDC,
33
- USDT,
34
27
  } from "../../src/constants";
35
28
  import {
36
29
  buildHeliusApiUrl,
37
- getAllPositionsByAuthority,
38
30
  getQnComputeUnitPriceEstimate,
39
31
  getSolautoManagedPositions,
40
- getSolautoPositionAccount,
41
- retryWithExponentialBackoff,
42
32
  } from "../../src/utils";
43
33
  import { PriorityFeeSetting } from "../../src/types";
44
34
  import { buildIronforgeApiUrl } from "../../dist";
@@ -66,7 +56,7 @@ describe("Solauto Marginfi tests", async () => {
66
56
  await client.initialize({
67
57
  signer,
68
58
  positionId,
69
- authority: new PublicKey("7F6v4HWZsyFP6yVFq92HQWygUgoYm5khUX8pXWGLoqUN"),
59
+ authority: new PublicKey("He4ka5Q3N1UvZikZvykdi47xyk5PoVP2tcQL5sVp31Sz"),
70
60
  // new: true,
71
61
  // marginfiAccount: new PublicKey(
72
62
  // ""
@@ -104,15 +94,6 @@ describe("Solauto Marginfi tests", async () => {
104
94
  // targetBoostToBps: none(),
105
95
  // };
106
96
 
107
- const settingParams: SolautoSettingsParametersInpArgs = {
108
- boostToBps: client.solautoPositionSettings().boostToBps - 150,
109
- boostGap: 50,
110
- repayToBps: client.solautoPositionSettings().repayToBps - 150,
111
- repayGap: 50,
112
- automation: none(),
113
- targetBoostToBps: none(),
114
- };
115
-
116
97
  // if (client.solautoPositionData === null) {
117
98
  // transactionItems.push(
118
99
  // new TransactionItem(async () => {
@@ -163,17 +144,10 @@ describe("Solauto Marginfi tests", async () => {
163
144
  )
164
145
  );
165
146
 
166
- // transactionItems.push(
167
- // new TransactionItem(
168
- // async () => ({ tx: client.refresh() }),
169
- // "refresh"
170
- // )
171
- // );
172
-
173
147
  // transactionItems.push(
174
148
  // new TransactionItem(
175
149
  // async (attemptNum) =>
176
- // await buildSolautoRebalanceTransaction(client, 0, attemptNum),
150
+ // await buildSolautoRebalanceTransaction(client, settingParams.boostToBps, attemptNum),
177
151
  // "rebalance"
178
152
  // )
179
153
  // );