@haven-fi/solauto-sdk 1.0.183 → 1.0.184

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.
Files changed (34) hide show
  1. package/dist/clients/txHandler.d.ts.map +1 -1
  2. package/dist/clients/txHandler.js +3 -3
  3. package/dist/constants/solautoConstants.d.ts +6 -0
  4. package/dist/constants/solautoConstants.d.ts.map +1 -1
  5. package/dist/constants/solautoConstants.js +7 -1
  6. package/dist/transactions/transactionUtils.d.ts.map +1 -1
  7. package/dist/transactions/transactionUtils.js +2 -2
  8. package/dist/utils/generalUtils.d.ts +1 -0
  9. package/dist/utils/generalUtils.d.ts.map +1 -1
  10. package/dist/utils/generalUtils.js +8 -2
  11. package/dist/utils/jitoUtils.js +6 -6
  12. package/dist/utils/jupiterUtils.d.ts.map +1 -1
  13. package/dist/utils/jupiterUtils.js +5 -7
  14. package/dist/utils/solanaUtils.js +8 -8
  15. package/dist/utils/solauto/generalUtils.d.ts +0 -1
  16. package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
  17. package/dist/utils/solauto/generalUtils.js +0 -11
  18. package/dist/utils/solauto/rebalanceUtils.d.ts +1 -1
  19. package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
  20. package/dist/utils/solauto/rebalanceUtils.js +1 -1
  21. package/package.json +1 -1
  22. package/src/clients/txHandler.ts +4 -4
  23. package/src/constants/solautoConstants.ts +10 -1
  24. package/src/transactions/transactionUtils.ts +1 -7
  25. package/src/utils/generalUtils.ts +8 -3
  26. package/src/utils/jitoUtils.ts +6 -6
  27. package/src/utils/jupiterUtils.ts +6 -8
  28. package/src/utils/solanaUtils.ts +9 -9
  29. package/src/utils/solauto/generalUtils.ts +0 -13
  30. package/src/utils/solauto/rebalanceUtils.ts +0 -1
  31. package/dist/utils/deleteme.d.ts +0 -2
  32. package/dist/utils/deleteme.d.ts.map +0 -1
  33. package/dist/utils/deleteme.js +0 -21
  34. package/src/utils/deleteme.ts +0 -40
@@ -1 +1 @@
1
- {"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,8BAAsB,SAAS;IAOpB,SAAS,CAAC,EAAE,OAAO;IANrB,YAAY,EAAG,MAAM,CAAC;IACtB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;gBAG7B,YAAY,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,OAAO,YAAA;IAQ5B,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAMzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC9D"}
1
+ {"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,8BAAsB,SAAS;IAOpB,SAAS,CAAC,EAAE,OAAO;IANrB,YAAY,EAAG,MAAM,CAAC;IACtB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;gBAG7B,YAAY,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,OAAO,YAAA;IAS5B,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAIzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC9D"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TxHandler = void 0;
4
4
  const utils_1 = require("../utils");
5
+ const constants_1 = require("../constants");
5
6
  class TxHandler {
6
7
  constructor(heliusApiUrl, localTest) {
7
8
  this.localTest = localTest;
@@ -9,11 +10,10 @@ class TxHandler {
9
10
  const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.heliusApiUrl);
10
11
  this.connection = connection;
11
12
  this.umi = umi;
13
+ constants_1.RUNTIME_DATA.localTest = Boolean(localTest);
12
14
  }
13
15
  log(...args) {
14
- if (this.localTest) {
15
- console.log(...args);
16
- }
16
+ (0, utils_1.consoleLog)(...args);
17
17
  }
18
18
  }
19
19
  exports.TxHandler = TxHandler;
@@ -11,4 +11,10 @@ export declare const PRICES: {
11
11
  };
12
12
  export declare const SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
13
13
  export declare const STANDARD_LUT_ACCOUNTS: string[];
14
+ declare class RuntimeData {
15
+ localTest: boolean;
16
+ constructor();
17
+ }
18
+ export declare const RUNTIME_DATA: RuntimeData;
19
+ export {};
14
20
  //# sourceMappingURL=solautoConstants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAQpC,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;KAAE,CAAA;CAAO,CAAC;AAE9E,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAE1E,eAAO,MAAM,qBAAqB,UAWjC,CAAC"}
1
+ {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAQpC,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;KAAE,CAAA;CAAO,CAAC;AAE9E,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAE1E,eAAO,MAAM,qBAAqB,UAWjC,CAAC;AAEF,cAAM,WAAW;IACR,SAAS,EAAE,OAAO,CAAC;;CAI3B;AAED,eAAO,MAAM,YAAY,aAAoB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.PRICES = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.DEFAULT_LIMIT_GAP_BPS = exports.BASIS_POINTS = void 0;
3
+ exports.RUNTIME_DATA = exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.PRICES = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.DEFAULT_LIMIT_GAP_BPS = exports.BASIS_POINTS = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const spl_token_1 = require("@solana/spl-token");
6
6
  // import { JitoRpcConnection } from "jito-ts";
@@ -31,3 +31,9 @@ exports.STANDARD_LUT_ACCOUNTS = [
31
31
  web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY.toString(),
32
32
  jupiter_sdk_1.JUPITER_PROGRAM_ID
33
33
  ];
34
+ class RuntimeData {
35
+ constructor() {
36
+ this.localTest = false;
37
+ }
38
+ }
39
+ exports.RUNTIME_DATA = new RuntimeData();
@@ -1 +1 @@
1
- {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAGL,aAAa,EAYd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAiOzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAmLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,aAAa,WAwCnE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CAwHA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,SAAS,GACtB,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CA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 -361,8 +361,8 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
361
361
  const values = (0, rebalanceUtils_1.getRebalanceValues)(client.solautoPositionState, client.solautoPositionSettings(), client.solautoPositionActiveDca(), (0, generalUtils_1.currentUnixSeconds)(), (0, generalUtils_1.safeGetPrice)(client.supplyMint), (0, generalUtils_1.safeGetPrice)(client.debtMint), targetLiqUtilizationRateBps);
362
362
  client.log("Rebalance values: ", values);
363
363
  const swapDetails = (0, rebalanceUtils_1.getJupSwapRebalanceDetails)(client, values, targetLiqUtilizationRateBps, attemptNum);
364
- const { jupQuote, priceImpactBps, lookupTableAddresses, setupInstructions, tokenLedgerIx, swapIx, } = await (0, jupiterUtils_1.getJupSwapTransaction)(client.signer, swapDetails, attemptNum);
365
- const flashLoan = (0, rebalanceUtils_1.getFlashLoanDetails)(client, values, jupQuote, priceImpactBps);
364
+ const { jupQuote, lookupTableAddresses, setupInstructions, tokenLedgerIx, swapIx, } = await (0, jupiterUtils_1.getJupSwapTransaction)(client.signer, swapDetails, attemptNum);
365
+ const flashLoan = (0, rebalanceUtils_1.getFlashLoanDetails)(client, values, jupQuote);
366
366
  let tx = (0, umi_1.transactionBuilder)();
367
367
  if (requiresRefreshBeforeRebalance(client)) {
368
368
  tx = tx.add(client.refresh());
@@ -1,5 +1,6 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { MaybeRpcAccount, Umi, PublicKey as UmiPublicKey } from "@metaplex-foundation/umi";
3
+ export declare function consoleLog(...args: any[]): void;
3
4
  export declare function generateRandomU8(): number;
4
5
  export declare function generateRandomU64(): bigint;
5
6
  export declare function currentUnixSeconds(): number;
@@ -1 +1 @@
1
- {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,eAAe,EAEf,GAAG,EACH,SAAS,IAAI,YAAY,EAC1B,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I/C;AACD,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,SAAS,GACZ,OAAO,CAAC,OAAO,CAAC,CAKlB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAEnE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAU1E;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAwD5E;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GACzC,MAAM,GAAG,SAAS,CAKpB;AAED,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC,CAAC;AAEjE,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EACtC,OAAO,GAAE,MAAU,EACnB,KAAK,GAAE,MAAY,EACnB,aAAa,CAAC,EAAE,aAAa,GAC5B,OAAO,CAAC,CAAC,CAAC,CA8BZ"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.consoleLog = consoleLog;
3
4
  exports.generateRandomU8 = generateRandomU8;
4
5
  exports.generateRandomU64 = generateRandomU64;
5
6
  exports.currentUnixSeconds = currentUnixSeconds;
@@ -13,6 +14,11 @@ const umi_1 = require("@metaplex-foundation/umi");
13
14
  const pythConstants_1 = require("../constants/pythConstants");
14
15
  const numberUtils_1 = require("./numberUtils");
15
16
  const solautoConstants_1 = require("../constants/solautoConstants");
17
+ function consoleLog(...args) {
18
+ if (solautoConstants_1.RUNTIME_DATA.localTest) {
19
+ console.log(...args);
20
+ }
21
+ }
16
22
  function generateRandomU8() {
17
23
  return Math.floor(Math.random() * 255 + 1);
18
24
  }
@@ -104,9 +110,9 @@ function retryWithExponentialBackoff(fn, retries = 5, delay = 150, errorsToThrow
104
110
  return;
105
111
  }
106
112
  if (attemptNum < retries) {
107
- console.log(error);
113
+ consoleLog(error);
108
114
  setTimeout(() => {
109
- console.log("Retrying...");
115
+ consoleLog("Retrying...");
110
116
  return attempt(attemptNum);
111
117
  }, delay);
112
118
  delay *= 2;
@@ -45,7 +45,7 @@
45
45
  // const nextLeader = await searcher.getNextScheduledLeader();
46
46
  // const numSlots = nextLeader.nextLeaderSlot - nextLeader.currentSlot;
47
47
  // isLeaderSlot = numSlots <= distanceFromJitoSlot && numSlots > 1;
48
- // console.log(`Next jito leader slot in ${numSlots} slots`);
48
+ // consoleLog(`Next jito leader slot in ${numSlots} slots`);
49
49
  // await new Promise((r) => setTimeout(r, 500));
50
50
  // }
51
51
  // }
@@ -70,7 +70,7 @@
70
70
  // simulationResult.value.transactionResults.forEach((tx) => {
71
71
  // if (tx.err) {
72
72
  // tx.logs?.forEach((x) => {
73
- // console.log(x);
73
+ // consoleLog(x);
74
74
  // });
75
75
  // throw tx.err;
76
76
  // }
@@ -102,10 +102,10 @@
102
102
  // async function sendJitoBundle(bundle: Bundle): Promise<BundleResult> {
103
103
  // await waitUntilJitoNextLeader();
104
104
  // let searcher = getSearcherClient();
105
- // console.log("Sending bundle...");
105
+ // consoleLog("Sending bundle...");
106
106
  // try {
107
107
  // const resp = await searcher.sendBundle(bundle);
108
- // console.log("Send bundle response:", resp);
108
+ // consoleLog("Send bundle response:", resp);
109
109
  // } catch (e) {
110
110
  // console.error("Error sending bundle:", e);
111
111
  // }
@@ -115,12 +115,12 @@
115
115
  // if (res.accepted || res.processed || res.finalized) {
116
116
  // resolve(res);
117
117
  // } else {
118
- // console.log(res);
118
+ // consoleLog(res);
119
119
  // return reject("Bundle not accepted");
120
120
  // }
121
121
  // },
122
122
  // (err) => {
123
- // console.log("Error: ", err);
123
+ // consoleLog("Error: ", err);
124
124
  // return reject(err);
125
125
  // }
126
126
  // );
@@ -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;AAMrB,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;CACnB;AAgBD,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,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAoF7B"}
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;AAMrB,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;CACnB;AAgBD,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,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAkF7B"}
@@ -21,7 +21,7 @@ function createTransactionInstruction(instruction) {
21
21
  });
22
22
  }
23
23
  async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
24
- console.log("Getting jup quote...");
24
+ (0, generalUtils_1.consoleLog)("Getting jup quote...");
25
25
  const quoteResponse = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await jupApi.quoteGet({
26
26
  amount: Number(swapDetails.amount),
27
27
  inputMint: swapDetails.inputMint.toString(),
@@ -38,14 +38,12 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
38
38
  const finalPriceSlippageBps = Math.round(Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
39
39
  (1 + (swapDetails.slippageIncFactor ?? 0)));
40
40
  quoteResponse.slippageBps = finalPriceSlippageBps;
41
- console.log(quoteResponse);
41
+ (0, generalUtils_1.consoleLog)(quoteResponse);
42
42
  if (swapDetails.exactOut) {
43
- console.log(quoteResponse.inAmount);
44
43
  quoteResponse.inAmount = (parseInt(quoteResponse.inAmount) +
45
44
  Math.ceil(parseInt(quoteResponse.inAmount) * (0, numberUtils_1.fromBps)(finalPriceSlippageBps))).toString();
46
- console.log(quoteResponse.inAmount);
47
45
  }
48
- console.log("Getting jup instructions...");
46
+ (0, generalUtils_1.consoleLog)("Getting jup instructions...");
49
47
  const instructions = await jupApi.swapInstructionsPost({
50
48
  swapRequest: {
51
49
  userPublicKey: signer.publicKey.toString(),
@@ -58,9 +56,9 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
58
56
  if (!instructions.swapInstruction) {
59
57
  throw new Error("No swap instruction was returned by Jupiter");
60
58
  }
61
- console.log("Raw price impact bps:", priceImpactBps);
59
+ (0, generalUtils_1.consoleLog)("Raw price impact bps:", priceImpactBps);
62
60
  const finalPriceImpactBps = priceImpactBps * (1 + (swapDetails.slippageIncFactor ?? 0));
63
- console.log("Increased price impact bps:", finalPriceImpactBps);
61
+ (0, generalUtils_1.consoleLog)("Increased price impact bps:", finalPriceImpactBps);
64
62
  return {
65
63
  jupQuote: quoteResponse,
66
64
  priceImpactBps: finalPriceImpactBps,
@@ -128,7 +128,7 @@ async function simulateTransaction(connection, transaction) {
128
128
  });
129
129
  if (simulationResult.value.err) {
130
130
  simulationResult.value.logs?.forEach((x) => {
131
- console.log(x);
131
+ (0, generalUtils_1.consoleLog)(x);
132
132
  });
133
133
  throw simulationResult.value.err;
134
134
  }
@@ -149,17 +149,17 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting) {
149
149
  return feeEstimate;
150
150
  }
151
151
  async function sendSingleOptimizedTransaction(umi, connection, tx, txType, attemptNum, prioritySetting = types_1.PriorityFeeSetting.Default, onAwaitingSign) {
152
- console.log("Sending single optimized transaction...");
153
- console.log("Instructions: ", tx.getInstructions().length);
154
- console.log("Serialized transaction size: ", tx.getTransactionSize(umi));
152
+ (0, generalUtils_1.consoleLog)("Sending single optimized transaction...");
153
+ (0, generalUtils_1.consoleLog)("Instructions: ", tx.getInstructions().length);
154
+ (0, generalUtils_1.consoleLog)("Serialized transaction size: ", tx.getTransactionSize(umi));
155
155
  const feeEstimate = await getComputeUnitPriceEstimate(umi, tx, prioritySetting);
156
- console.log("Compute unit price: ", feeEstimate);
156
+ (0, generalUtils_1.consoleLog)("Compute unit price: ", feeEstimate);
157
157
  let computeUnitLimit = undefined;
158
158
  if (txType !== "skip-simulation") {
159
159
  // TODO: we should only retry simulation if it's not a solauto error
160
160
  const simulationResult = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await simulateTransaction(connection, (0, umi_web3js_adapters_1.toWeb3JsTransaction)(await (await assembleFinalTransaction(umi.identity, tx, feeEstimate, 1400000).setLatestBlockhash(umi)).build(umi))), 3);
161
161
  computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.1);
162
- console.log("Compute unit limit: ", computeUnitLimit);
162
+ (0, generalUtils_1.consoleLog)("Compute unit limit: ", computeUnitLimit);
163
163
  }
164
164
  if (txType !== "only-simulate") {
165
165
  onAwaitingSign?.();
@@ -171,8 +171,8 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, txType, attem
171
171
  confirm: { commitment: "confirmed" },
172
172
  });
173
173
  const txSig = bs58_1.default.encode(result.signature);
174
- console.log(`Transaction signature: ${txSig}`);
175
- console.log(`https://solscan.io/tx/${txSig}`);
174
+ (0, generalUtils_1.consoleLog)(`Transaction signature: ${txSig}`);
175
+ (0, generalUtils_1.consoleLog)(`https://solscan.io/tx/${txSig}`);
176
176
  if (result.result.value.err !== null) {
177
177
  throw new Error(result.result.value.err.toString());
178
178
  }
@@ -2,7 +2,6 @@ import { PublicKey } from "@solana/web3.js";
2
2
  import { Umi } from "@metaplex-foundation/umi";
3
3
  import { AutomationSettings, DCASettings, DCASettingsInpArgs, PositionState, PositionType, SolautoSettingsParameters, SolautoSettingsParametersInpArgs, TokenType } from "../../generated";
4
4
  import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
5
- export declare function findMintByTicker(ticker: string): PublicKey;
6
5
  export declare function nextAutomationPeriodTimestamp(automation: AutomationSettings): number;
7
6
  export declare function eligibleForNextAutomationPeriod(automation: AutomationSettings, currentUnixTime: number): boolean;
8
7
  export declare function getUpdatedValueFromAutomation(currValue: number, targetValue: number, automation: AutomationSettings, currentUnixTimestamp: number): number;
@@ -1 +1 @@
1
- {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAA+B,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAElB,aAAa,EACb,YAAY,EAEZ,yBAAyB,EACzB,gCAAgC,EAChC,SAAS,EAIV,MAAM,iBAAiB,CAAC;AAezB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAW1D;AAgBD,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,kBAAkB,GAC7B,MAAM,CAKR;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,kBAAkB,EAC9B,eAAe,EAAE,MAAM,GACtB,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,kBAAkB,EAC9B,oBAAoB,EAAE,MAAM,UAY7B;AAED,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,yBAAyB,EACnC,eAAe,EAAE,MAAM,GACtB,yBAAyB,CAgB3B;AAED,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,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EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,CAAC;KAAE,CAAa;IACrE,aAAa,EAAE,SAAS,GAAG,SAAS,CAAa;IAExD,GAAG,CAAC,MAAM,EAAE,kBAAkB;IA6B9B,KAAK;IASL,UAAU,IAAI,OAAO;CAStB"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LivePositionUpdates = void 0;
4
- exports.findMintByTicker = findMintByTicker;
5
4
  exports.nextAutomationPeriodTimestamp = nextAutomationPeriodTimestamp;
6
5
  exports.eligibleForNextAutomationPeriod = eligibleForNextAutomationPeriod;
7
6
  exports.getUpdatedValueFromAutomation = getUpdatedValueFromAutomation;
@@ -24,16 +23,6 @@ const accountUtils_1 = require("../accountUtils");
24
23
  const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
25
24
  const constants_1 = require("../../constants");
26
25
  const marginfiUtils_1 = require("../marginfiUtils");
27
- function findMintByTicker(ticker) {
28
- for (const key in constants_1.TOKEN_INFO) {
29
- const account = constants_1.TOKEN_INFO[key];
30
- if (account.ticker.toString().toLowerCase() ===
31
- ticker.toString().toLowerCase()) {
32
- return new web3_js_1.PublicKey(key);
33
- }
34
- }
35
- throw new Error(`Token mint not found by the ticker: ${ticker}`);
36
- }
37
26
  function newPeriodsPassed(automation, currentUnixTimestamp) {
38
27
  return Math.min(automation.targetPeriods, automation.periodsPassed +
39
28
  Math.floor((currentUnixTimestamp - Number(automation.unixStartDate)) /
@@ -16,6 +16,6 @@ export interface FlashLoanDetails {
16
16
  baseUnitAmount: bigint;
17
17
  mint: PublicKey;
18
18
  }
19
- export declare function getFlashLoanDetails(client: SolautoClient, values: RebalanceValues, jupQuote: QuoteResponse, priceImpactBps: number): FlashLoanDetails | undefined;
19
+ export declare function getFlashLoanDetails(client: SolautoClient, values: RebalanceValues, jupQuote: QuoteResponse): FlashLoanDetails | undefined;
20
20
  export declare function getJupSwapRebalanceDetails(client: SolautoClient, values: RebalanceValues, targetLiqUtilizationRateBps?: number, attemptNum?: number): JupSwapDetails;
21
21
  //# sourceMappingURL=rebalanceUtils.d.ts.map
@@ -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,yBAAyB,EACzB,SAAS,EACV,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+IjD,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,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;CAC1B;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,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,CAoEjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,EACvB,cAAc,EAAE,MAAM,GACr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EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CA0D9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAyChB"}
@@ -116,7 +116,7 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
116
116
  dcaTokenType: dca?.tokenType,
117
117
  };
118
118
  }
119
- function getFlashLoanDetails(client, values, jupQuote, priceImpactBps) {
119
+ function getFlashLoanDetails(client, values, jupQuote) {
120
120
  let supplyUsd = (0, numberUtils_1.fromBaseUnit)(client.solautoPositionState.supply.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS) +
121
121
  (values.dcaTokenType === generated_1.TokenType.Supply ? values.amountUsdToDcaIn : 0);
122
122
  let debtUsd = (0, numberUtils_1.fromBaseUnit)(client.solautoPositionState.debt.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.183",
3
+ "version": "1.0.184",
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",
@@ -1,6 +1,7 @@
1
1
  import { Umi } from "@metaplex-foundation/umi";
2
2
  import { Connection } from "@solana/web3.js";
3
- import { getSolanaRpcConnection } from "../utils";
3
+ import { consoleLog, getSolanaRpcConnection } from "../utils";
4
+ import { RUNTIME_DATA } from "../constants";
4
5
 
5
6
  export abstract class TxHandler {
6
7
  public heliusApiUrl!: string;
@@ -15,12 +16,11 @@ export abstract class TxHandler {
15
16
  const [connection, umi] = getSolanaRpcConnection(this.heliusApiUrl);
16
17
  this.connection = connection;
17
18
  this.umi = umi;
19
+ RUNTIME_DATA.localTest = Boolean(localTest);
18
20
  }
19
21
 
20
22
  log(...args: any[]): void {
21
- if (this.localTest) {
22
- console.log(...args);
23
- }
23
+ consoleLog(...args);
24
24
  }
25
25
 
26
26
  abstract defaultLookupTables(): string[];
@@ -42,4 +42,13 @@ export const STANDARD_LUT_ACCOUNTS = [
42
42
  SYSVAR_RENT_PUBKEY.toString(),
43
43
  SYSVAR_INSTRUCTIONS_PUBKEY.toString(),
44
44
  JUPITER_PROGRAM_ID
45
- ];
45
+ ];
46
+
47
+ class RuntimeData {
48
+ public localTest: boolean;
49
+ constructor() {
50
+ this.localTest = false;
51
+ }
52
+ }
53
+
54
+ export const RUNTIME_DATA = new RuntimeData();
@@ -666,18 +666,12 @@ export async function buildSolautoRebalanceTransaction(
666
666
  );
667
667
  const {
668
668
  jupQuote,
669
- priceImpactBps,
670
669
  lookupTableAddresses,
671
670
  setupInstructions,
672
671
  tokenLedgerIx,
673
672
  swapIx,
674
673
  } = await getJupSwapTransaction(client.signer, swapDetails, attemptNum);
675
- const flashLoan = getFlashLoanDetails(
676
- client,
677
- values,
678
- jupQuote,
679
- priceImpactBps
680
- );
674
+ const flashLoan = getFlashLoanDetails(client, values, jupQuote);
681
675
 
682
676
  let tx = transactionBuilder();
683
677
 
@@ -7,8 +7,13 @@ import {
7
7
  } from "@metaplex-foundation/umi";
8
8
  import { PYTH_PRICE_FEED_IDS } from "../constants/pythConstants";
9
9
  import { fromBaseUnit, toBaseUnit } from "./numberUtils";
10
- import { PRICES } from "../constants/solautoConstants";
10
+ import { PRICES, RUNTIME_DATA } from "../constants/solautoConstants";
11
11
 
12
+ export function consoleLog(...args: any[]): void {
13
+ if (RUNTIME_DATA.localTest) {
14
+ console.log(...args);
15
+ }
16
+ }
12
17
  export function generateRandomU8(): number {
13
18
  return Math.floor(Math.random() * 255 + 1);
14
19
  }
@@ -143,9 +148,9 @@ export function retryWithExponentialBackoff<T>(
143
148
  }
144
149
 
145
150
  if (attemptNum < retries) {
146
- console.log(error);
151
+ consoleLog(error);
147
152
  setTimeout(() => {
148
- console.log("Retrying...");
153
+ consoleLog("Retrying...");
149
154
  return attempt(attemptNum);
150
155
  }, delay);
151
156
  delay *= 2;
@@ -48,7 +48,7 @@
48
48
  // const nextLeader = await searcher.getNextScheduledLeader();
49
49
  // const numSlots = nextLeader.nextLeaderSlot - nextLeader.currentSlot;
50
50
  // isLeaderSlot = numSlots <= distanceFromJitoSlot && numSlots > 1;
51
- // console.log(`Next jito leader slot in ${numSlots} slots`);
51
+ // consoleLog(`Next jito leader slot in ${numSlots} slots`);
52
52
  // await new Promise((r) => setTimeout(r, 500));
53
53
  // }
54
54
  // }
@@ -76,7 +76,7 @@
76
76
  // simulationResult.value.transactionResults.forEach((tx) => {
77
77
  // if (tx.err) {
78
78
  // tx.logs?.forEach((x) => {
79
- // console.log(x);
79
+ // consoleLog(x);
80
80
  // });
81
81
  // throw tx.err;
82
82
  // }
@@ -112,10 +112,10 @@
112
112
  // await waitUntilJitoNextLeader();
113
113
  // let searcher = getSearcherClient();
114
114
 
115
- // console.log("Sending bundle...");
115
+ // consoleLog("Sending bundle...");
116
116
  // try {
117
117
  // const resp = await searcher.sendBundle(bundle);
118
- // console.log("Send bundle response:", resp);
118
+ // consoleLog("Send bundle response:", resp);
119
119
  // } catch (e) {
120
120
  // console.error("Error sending bundle:", e);
121
121
  // }
@@ -126,12 +126,12 @@
126
126
  // if (res.accepted || res.processed || res.finalized) {
127
127
  // resolve(res);
128
128
  // } else {
129
- // console.log(res);
129
+ // consoleLog(res);
130
130
  // return reject("Bundle not accepted");
131
131
  // }
132
132
  // },
133
133
  // (err) => {
134
- // console.log("Error: ", err);
134
+ // consoleLog("Error: ", err);
135
135
  // return reject(err);
136
136
  // }
137
137
  // );
@@ -12,7 +12,7 @@ import {
12
12
  QuoteResponse,
13
13
  } from "@jup-ag/api";
14
14
  import { getTokenAccount } from "./accountUtils";
15
- import { retryWithExponentialBackoff } from "./generalUtils";
15
+ import { consoleLog, retryWithExponentialBackoff } from "./generalUtils";
16
16
 
17
17
  const jupApi = createJupiterApiClient();
18
18
 
@@ -54,7 +54,7 @@ export async function getJupSwapTransaction(
54
54
  swapDetails: JupSwapDetails,
55
55
  attemptNum?: number
56
56
  ): Promise<JupSwapTransaction> {
57
- console.log("Getting jup quote...");
57
+ consoleLog("Getting jup quote...");
58
58
  const quoteResponse = await retryWithExponentialBackoff(
59
59
  async () =>
60
60
  await jupApi.quoteGet({
@@ -79,18 +79,16 @@ export async function getJupSwapTransaction(
79
79
  (1 + (swapDetails.slippageIncFactor ?? 0))
80
80
  );
81
81
  quoteResponse.slippageBps = finalPriceSlippageBps;
82
- console.log(quoteResponse);
82
+ consoleLog(quoteResponse);
83
83
 
84
84
  if (swapDetails.exactOut) {
85
- console.log(quoteResponse.inAmount);
86
85
  quoteResponse.inAmount = (
87
86
  parseInt(quoteResponse.inAmount) +
88
87
  Math.ceil(parseInt(quoteResponse.inAmount) * fromBps(finalPriceSlippageBps))
89
88
  ).toString();
90
- console.log(quoteResponse.inAmount);
91
89
  }
92
90
 
93
- console.log("Getting jup instructions...");
91
+ consoleLog("Getting jup instructions...");
94
92
  const instructions = await jupApi.swapInstructionsPost({
95
93
  swapRequest: {
96
94
  userPublicKey: signer.publicKey.toString(),
@@ -108,10 +106,10 @@ export async function getJupSwapTransaction(
108
106
  throw new Error("No swap instruction was returned by Jupiter");
109
107
  }
110
108
 
111
- console.log("Raw price impact bps:", priceImpactBps);
109
+ consoleLog("Raw price impact bps:", priceImpactBps);
112
110
  const finalPriceImpactBps =
113
111
  priceImpactBps * (1 + (swapDetails.slippageIncFactor ?? 0));
114
- console.log("Increased price impact bps:", finalPriceImpactBps);
112
+ consoleLog("Increased price impact bps:", finalPriceImpactBps);
115
113
 
116
114
  return {
117
115
  jupQuote: quoteResponse,
@@ -31,7 +31,7 @@ import {
31
31
  createTransferInstruction,
32
32
  } from "@solana/spl-token";
33
33
  import { getTokenAccount } from "./accountUtils";
34
- import { arraysAreEqual, retryWithExponentialBackoff } from "./generalUtils";
34
+ import { arraysAreEqual, consoleLog, retryWithExponentialBackoff } from "./generalUtils";
35
35
  import {
36
36
  getLendingAccountEndFlashloanInstructionDataSerializer,
37
37
  getLendingAccountStartFlashloanInstructionDataSerializer,
@@ -239,7 +239,7 @@ async function simulateTransaction(
239
239
  });
240
240
  if (simulationResult.value.err) {
241
241
  simulationResult.value.logs?.forEach((x: any) => {
242
- console.log(x);
242
+ consoleLog(x);
243
243
  });
244
244
  throw simulationResult.value.err;
245
245
  }
@@ -277,16 +277,16 @@ export async function sendSingleOptimizedTransaction(
277
277
  prioritySetting: PriorityFeeSetting = PriorityFeeSetting.Default,
278
278
  onAwaitingSign?: () => void
279
279
  ): Promise<Uint8Array | undefined> {
280
- console.log("Sending single optimized transaction...");
281
- console.log("Instructions: ", tx.getInstructions().length);
282
- console.log("Serialized transaction size: ", tx.getTransactionSize(umi));
280
+ consoleLog("Sending single optimized transaction...");
281
+ consoleLog("Instructions: ", tx.getInstructions().length);
282
+ consoleLog("Serialized transaction size: ", tx.getTransactionSize(umi));
283
283
 
284
284
  const feeEstimate = await getComputeUnitPriceEstimate(
285
285
  umi,
286
286
  tx,
287
287
  prioritySetting
288
288
  );
289
- console.log("Compute unit price: ", feeEstimate);
289
+ consoleLog("Compute unit price: ", feeEstimate);
290
290
 
291
291
  let computeUnitLimit = undefined;
292
292
  if (txType !== "skip-simulation") {
@@ -312,7 +312,7 @@ export async function sendSingleOptimizedTransaction(
312
312
  computeUnitLimit = Math.round(
313
313
  simulationResult.value.unitsConsumed! * 1.1
314
314
  );
315
- console.log("Compute unit limit: ", computeUnitLimit);
315
+ consoleLog("Compute unit limit: ", computeUnitLimit);
316
316
  }
317
317
 
318
318
  if (txType !== "only-simulate") {
@@ -330,8 +330,8 @@ export async function sendSingleOptimizedTransaction(
330
330
  confirm: { commitment: "confirmed" },
331
331
  });
332
332
  const txSig = bs58.encode(result.signature);
333
- console.log(`Transaction signature: ${txSig}`);
334
- console.log(`https://solscan.io/tx/${txSig}`);
333
+ consoleLog(`Transaction signature: ${txSig}`);
334
+ consoleLog(`https://solscan.io/tx/${txSig}`);
335
335
  if (result.result.value.err !== null) {
336
336
  throw new Error(result.result.value.err.toString());
337
337
  }
@@ -31,19 +31,6 @@ import {
31
31
  import { getAllMarginfiAccountsByAuthority } from "../marginfiUtils";
32
32
  import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
33
33
 
34
- export function findMintByTicker(ticker: string): PublicKey {
35
- for (const key in TOKEN_INFO) {
36
- const account = TOKEN_INFO[key];
37
- if (
38
- account.ticker.toString().toLowerCase() ===
39
- ticker.toString().toLowerCase()
40
- ) {
41
- return new PublicKey(key);
42
- }
43
- }
44
- throw new Error(`Token mint not found by the ticker: ${ticker}`);
45
- }
46
-
47
34
  function newPeriodsPassed(
48
35
  automation: AutomationSettings,
49
36
  currentUnixTimestamp: number
@@ -254,7 +254,6 @@ export function getFlashLoanDetails(
254
254
  client: SolautoClient,
255
255
  values: RebalanceValues,
256
256
  jupQuote: QuoteResponse,
257
- priceImpactBps: number
258
257
  ): FlashLoanDetails | undefined {
259
258
  let supplyUsd =
260
259
  fromBaseUnit(
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=deleteme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deleteme.d.ts","sourceRoot":"","sources":["../../src/utils/deleteme.ts"],"names":[],"mappings":""}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const numberUtils_1 = require("./numberUtils");
4
- // TODO delete this file
5
- async function check() {
6
- let supply = 458948;
7
- let debt = 212846;
8
- let supply_weight = 0.899999976158142;
9
- let debt_weight = 1.100000023841858;
10
- let liq_threshold = (supply_weight / debt_weight) * 10000;
11
- console.log(liq_threshold);
12
- let liq_utilization_rate = (0, numberUtils_1.getLiqUtilzationRateBps)(supply, debt, liq_threshold);
13
- console.log(liq_utilization_rate);
14
- let debt_adjustment_usd = (0, numberUtils_1.getDebtAdjustmentUsd)(liq_threshold, supply, debt, 6000, 0);
15
- supply += debt_adjustment_usd;
16
- debt += debt_adjustment_usd;
17
- liq_utilization_rate = (0, numberUtils_1.getLiqUtilzationRateBps)(supply, debt, liq_threshold);
18
- console.log(debt_adjustment_usd);
19
- console.log(liq_utilization_rate);
20
- }
21
- check();
@@ -1,40 +0,0 @@
1
- import { getDebtAdjustmentUsd, getLiqUtilzationRateBps } from "./numberUtils";
2
-
3
- // TODO delete this file
4
- async function check() {
5
- let supply = 458948;
6
- let debt = 212846;
7
- let supply_weight = 0.899999976158142;
8
- let debt_weight = 1.100000023841858;
9
- let liq_threshold = (supply_weight / debt_weight) * 10000;
10
-
11
- console.log(liq_threshold);
12
- let liq_utilization_rate = getLiqUtilzationRateBps(
13
- supply,
14
- debt,
15
- liq_threshold
16
- );
17
- console.log!(liq_utilization_rate);
18
-
19
- let debt_adjustment_usd = getDebtAdjustmentUsd(
20
- liq_threshold,
21
- supply,
22
- debt,
23
- 6000,
24
- 0
25
- );
26
-
27
- supply += debt_adjustment_usd;
28
- debt += debt_adjustment_usd;
29
-
30
- liq_utilization_rate = getLiqUtilzationRateBps(
31
- supply,
32
- debt,
33
- liq_threshold
34
- );
35
-
36
- console.log(debt_adjustment_usd);
37
- console.log!(liq_utilization_rate);
38
- }
39
-
40
- check();