@haven-fi/solauto-sdk 1.0.624 → 1.0.625

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 (130) hide show
  1. package/dist/constants/{generalAccounts.d.ts → generalConstants.d.ts} +3 -1
  2. package/dist/constants/generalConstants.d.ts.map +1 -0
  3. package/dist/constants/{generalAccounts.js → generalConstants.js} +4 -1
  4. package/dist/constants/index.d.ts +6 -5
  5. package/dist/constants/index.d.ts.map +1 -1
  6. package/dist/constants/index.js +2 -1
  7. package/dist/constants/marginfiAccounts.d.ts +4 -1
  8. package/dist/constants/marginfiAccounts.d.ts.map +1 -1
  9. package/dist/constants/marginfiAccounts.js +7 -5
  10. package/dist/constants/solautoConstants.d.ts +0 -3
  11. package/dist/constants/solautoConstants.d.ts.map +1 -1
  12. package/dist/constants/solautoConstants.js +3 -8
  13. package/dist/services/flashLoans/flProviderAggregator.d.ts +3 -3
  14. package/dist/services/flashLoans/flProviderAggregator.d.ts.map +1 -1
  15. package/dist/services/flashLoans/flProviderAggregator.js +5 -5
  16. package/dist/services/flashLoans/flProviderBase.d.ts +4 -3
  17. package/dist/services/flashLoans/flProviderBase.d.ts.map +1 -1
  18. package/dist/services/flashLoans/flProviderBase.js +3 -2
  19. package/dist/services/flashLoans/marginfiFlProvider.d.ts +2 -2
  20. package/dist/services/flashLoans/marginfiFlProvider.d.ts.map +1 -1
  21. package/dist/services/flashLoans/marginfiFlProvider.js +2 -3
  22. package/dist/services/rebalance/rebalanceSwapManager.d.ts.map +1 -1
  23. package/dist/services/rebalance/rebalanceSwapManager.js +1 -1
  24. package/dist/services/rebalance/rebalanceTxBuilder.d.ts.map +1 -1
  25. package/dist/services/rebalance/rebalanceTxBuilder.js +4 -4
  26. package/dist/services/rebalance/rebalanceValues.d.ts.map +1 -1
  27. package/dist/services/rebalance/solautoFees.d.ts.map +1 -1
  28. package/dist/services/rebalance/solautoFees.js +4 -2
  29. package/dist/services/solauto/solautoClient.d.ts +4 -3
  30. package/dist/services/solauto/solautoClient.d.ts.map +1 -1
  31. package/dist/services/solauto/solautoClient.js +21 -24
  32. package/dist/services/solauto/solautoMarginfiClient.d.ts +3 -4
  33. package/dist/services/solauto/solautoMarginfiClient.d.ts.map +1 -1
  34. package/dist/services/solauto/solautoMarginfiClient.js +19 -20
  35. package/dist/services/solauto/txHandler.d.ts +4 -2
  36. package/dist/services/solauto/txHandler.d.ts.map +1 -1
  37. package/dist/services/solauto/txHandler.js +4 -6
  38. package/dist/services/swap/jupSwapManager.d.ts +1 -1
  39. package/dist/services/swap/jupSwapManager.d.ts.map +1 -1
  40. package/dist/services/swap/jupSwapManager.js +7 -10
  41. package/dist/services/transactions/transactionUtils.d.ts +2 -3
  42. package/dist/services/transactions/transactionUtils.d.ts.map +1 -1
  43. package/dist/services/transactions/transactionUtils.js +43 -46
  44. package/dist/services/transactions/transactionsManager.d.ts +2 -3
  45. package/dist/services/transactions/transactionsManager.d.ts.map +1 -1
  46. package/dist/services/transactions/transactionsManager.js +16 -20
  47. package/dist/solautoPosition/marginfiSolautoPositionEx.d.ts.map +1 -1
  48. package/dist/solautoPosition/marginfiSolautoPositionEx.js +1 -1
  49. package/dist/solautoPosition/solautoPositionEx.d.ts +1 -1
  50. package/dist/solautoPosition/solautoPositionEx.d.ts.map +1 -1
  51. package/dist/solautoPosition/solautoPositionEx.js +1 -1
  52. package/dist/solautoPosition/utils.d.ts +2 -2
  53. package/dist/solautoPosition/utils.d.ts.map +1 -1
  54. package/dist/solautoPosition/utils.js +2 -2
  55. package/dist/types/solauto.d.ts +1 -0
  56. package/dist/types/solauto.d.ts.map +1 -1
  57. package/dist/utils/generalUtils.d.ts +2 -0
  58. package/dist/utils/generalUtils.d.ts.map +1 -1
  59. package/dist/utils/generalUtils.js +9 -1
  60. package/dist/utils/index.d.ts +1 -0
  61. package/dist/utils/index.d.ts.map +1 -1
  62. package/dist/utils/index.js +1 -0
  63. package/dist/utils/jitoUtils.d.ts.map +1 -1
  64. package/dist/utils/jitoUtils.js +7 -8
  65. package/dist/utils/jupiterUtils.d.ts.map +1 -1
  66. package/dist/utils/marginfiUtils.d.ts +7 -3
  67. package/dist/utils/marginfiUtils.d.ts.map +1 -1
  68. package/dist/utils/marginfiUtils.js +50 -19
  69. package/dist/utils/numberUtils.d.ts.map +1 -1
  70. package/dist/utils/priceUtils.d.ts.map +1 -1
  71. package/dist/utils/priceUtils.js +13 -15
  72. package/dist/utils/solanaUtils.d.ts +3 -5
  73. package/dist/utils/solanaUtils.d.ts.map +1 -1
  74. package/dist/utils/solanaUtils.js +7 -15
  75. package/dist/utils/solautoUtils.d.ts +3 -3
  76. package/dist/utils/solautoUtils.d.ts.map +1 -1
  77. package/dist/utils/solautoUtils.js +5 -5
  78. package/dist/utils/stringUtils.d.ts.map +1 -1
  79. package/dist/utils/stringUtils.js +3 -3
  80. package/dist/utils/switchboardUtils.d.ts +1 -1
  81. package/dist/utils/switchboardUtils.d.ts.map +1 -1
  82. package/dist/utils/switchboardUtils.js +4 -4
  83. package/local/createISMAccounts.ts +29 -12
  84. package/local/createTokenAccounts.ts +12 -11
  85. package/local/logPositions.ts +5 -5
  86. package/local/shared.ts +16 -10
  87. package/local/txSandbox.ts +5 -5
  88. package/local/updateMarginfiLUT.ts +35 -41
  89. package/local/updateSolautoLUT.ts +11 -13
  90. package/package.json +1 -1
  91. package/src/constants/{generalAccounts.ts → generalConstants.ts} +6 -1
  92. package/src/constants/index.ts +6 -5
  93. package/src/constants/marginfiAccounts.ts +15 -6
  94. package/src/constants/solautoConstants.ts +2 -10
  95. package/src/services/flashLoans/flProviderAggregator.ts +9 -7
  96. package/src/services/flashLoans/flProviderBase.ts +5 -4
  97. package/src/services/flashLoans/marginfiFlProvider.ts +3 -4
  98. package/src/services/rebalance/rebalanceSwapManager.ts +1 -1
  99. package/src/services/rebalance/rebalanceTxBuilder.ts +5 -5
  100. package/src/services/rebalance/rebalanceValues.ts +1 -1
  101. package/src/services/rebalance/solautoFees.ts +3 -4
  102. package/src/services/solauto/solautoClient.ts +9 -15
  103. package/src/services/solauto/solautoMarginfiClient.ts +21 -23
  104. package/src/services/solauto/txHandler.ts +10 -9
  105. package/src/services/swap/jupSwapManager.ts +7 -6
  106. package/src/services/transactions/transactionUtils.ts +17 -18
  107. package/src/services/transactions/transactionsManager.ts +23 -22
  108. package/src/solautoPosition/marginfiSolautoPositionEx.ts +1 -2
  109. package/src/solautoPosition/solautoPositionEx.ts +5 -5
  110. package/src/solautoPosition/utils.ts +7 -7
  111. package/src/types/solauto.ts +2 -0
  112. package/src/utils/generalUtils.ts +9 -1
  113. package/src/utils/index.ts +1 -0
  114. package/src/utils/jitoUtils.ts +17 -14
  115. package/src/utils/jupiterUtils.ts +1 -1
  116. package/src/utils/marginfiUtils.ts +56 -14
  117. package/src/utils/numberUtils.ts +0 -1
  118. package/src/utils/priceUtils.ts +7 -5
  119. package/src/utils/solanaUtils.ts +24 -32
  120. package/src/utils/solautoUtils.ts +13 -13
  121. package/src/utils/stringUtils.ts +3 -3
  122. package/src/utils/switchboardUtils.ts +4 -4
  123. package/tests/transactions/shared.ts +9 -14
  124. package/tests/transactions/solautoMarginfi.ts +13 -3
  125. package/tests/unit/accounts.ts +14 -17
  126. package/tests/unit/lookupTables.ts +5 -5
  127. package/tests/unit/rebalanceCalculations.ts +17 -11
  128. package/README.md +0 -3
  129. package/dist/constants/generalAccounts.d.ts.map +0 -1
  130. package/src/constants/README.md +0 -7
@@ -1,16 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SolautoMarginfiClient = void 0;
4
- const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
5
- const umi_1 = require("@metaplex-foundation/umi");
6
4
  const web3_js_1 = require("@solana/web3.js");
7
- const solautoClient_1 = require("./solautoClient");
8
- const marginfiAccounts_1 = require("../../constants/marginfiAccounts");
5
+ const umi_1 = require("@metaplex-foundation/umi");
6
+ const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
7
+ const constants_1 = require("../../constants");
9
8
  const generated_1 = require("../../generated");
10
- const accountUtils_1 = require("../../utils/accountUtils");
9
+ const utils_1 = require("../../utils");
11
10
  const marginfi_sdk_1 = require("../../marginfi-sdk");
12
- const marginfiUtils_1 = require("../../utils/marginfiUtils");
13
- const solautoUtils_1 = require("../../utils/solautoUtils");
11
+ const solautoClient_1 = require("./solautoClient");
14
12
  class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
15
13
  constructor() {
16
14
  super(...arguments);
@@ -18,6 +16,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
18
16
  }
19
17
  async initialize(args) {
20
18
  await super.initialize(args);
19
+ this.marginfiProgram = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.umi.programs.get("marginfi").publicKey);
21
20
  this.marginfiGroup = await this.pos.lendingPool();
22
21
  if (this.selfManaged) {
23
22
  this.marginfiAccount =
@@ -29,9 +28,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
29
28
  this.marginfiAccount = this.pos.lpUserAccount;
30
29
  }
31
30
  else {
32
- const accounts = await (0, marginfiUtils_1.getAllMarginfiAccountsByAuthority)(this.umi, this.pos.publicKey, this.marginfiGroup, false);
31
+ const accounts = await (0, utils_1.getAllMarginfiAccountsByAuthority)(this.umi, this.pos.publicKey, this.marginfiGroup, false);
33
32
  const reusableAccounts = accounts.length > 0
34
- ? (await (0, marginfi_sdk_1.safeFetchAllMarginfiAccount)(this.umi, accounts.map((x) => (0, umi_1.publicKey)(x.marginfiAccount)))).filter((x) => (0, marginfiUtils_1.marginfiAccountEmpty)(x))
33
+ ? (await (0, marginfi_sdk_1.safeFetchAllMarginfiAccount)(this.umi, accounts.map((x) => (0, umi_1.publicKey)(x.marginfiAccount)))).filter((x) => (0, utils_1.marginfiAccountEmpty)(x))
35
34
  : [];
36
35
  this.marginfiAccount =
37
36
  reusableAccounts.length > 0
@@ -47,9 +46,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
47
46
  this.otherSigners.push(this.marginfiAccount);
48
47
  }
49
48
  this.marginfiSupplyAccounts =
50
- marginfiAccounts_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.pos.supplyMint().toString()];
49
+ constants_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.pos.supplyMint().toString()];
51
50
  this.marginfiDebtAccounts =
52
- marginfiAccounts_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.pos.debtMint().toString()];
51
+ constants_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.pos.debtMint().toString()];
53
52
  // TODO: Don't dynamically pull oracle from bank until Marginfi sorts out their price oracle issues.
54
53
  // const [supplyBank, debtBank] = await safeFetchAllBank(this.umi, [
55
54
  // publicKey(this.marginfiSupplyAccounts.bank),
@@ -62,7 +61,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
62
61
  this.log("Marginfi account:", this.marginfiAccountPk.toString());
63
62
  }
64
63
  defaultLookupTables() {
65
- return [marginfiAccounts_1.MARGINFI_ACCOUNTS_LOOKUP_TABLE, ...super.defaultLookupTables()];
64
+ return [constants_1.MARGINFI_ACCOUNTS_LOOKUP_TABLE, ...super.defaultLookupTables()];
66
65
  }
67
66
  lutAccountsToAdd() {
68
67
  return [...super.lutAccountsToAdd(), this.marginfiAccountPk];
@@ -87,7 +86,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
87
86
  }
88
87
  return (0, generated_1.marginfiOpenPosition)(this.umi, {
89
88
  signer: this.signer,
90
- marginfiProgram: (0, umi_1.publicKey)(marginfi_sdk_1.MARGINFI_PROGRAM_ID),
89
+ marginfiProgram: (0, umi_1.publicKey)(this.marginfiProgram),
91
90
  signerReferralState: (0, umi_1.publicKey)(this.referralState),
92
91
  referredByState: this.referredByState
93
92
  ? (0, umi_1.publicKey)(this.referredByState)
@@ -129,7 +128,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
129
128
  refreshIx() {
130
129
  return (0, generated_1.marginfiRefreshData)(this.umi, {
131
130
  signer: this.signer,
132
- marginfiProgram: (0, umi_1.publicKey)(marginfi_sdk_1.MARGINFI_PROGRAM_ID),
131
+ marginfiProgram: (0, umi_1.publicKey)(this.marginfiProgram),
133
132
  marginfiGroup: (0, umi_1.publicKey)(this.marginfiGroup),
134
133
  marginfiAccount: (0, umi_1.publicKey)(this.marginfiAccount),
135
134
  supplyBank: (0, umi_1.publicKey)(this.marginfiSupplyAccounts.bank),
@@ -229,7 +228,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
229
228
  }
230
229
  return (0, generated_1.marginfiProtocolInteraction)(this.umi, {
231
230
  signer: this.signer,
232
- marginfiProgram: (0, umi_1.publicKey)(marginfi_sdk_1.MARGINFI_PROGRAM_ID),
231
+ marginfiProgram: (0, umi_1.publicKey)(this.marginfiProgram),
233
232
  solautoPosition: (0, umi_1.publicKey)(this.pos.publicKey),
234
233
  marginfiGroup: (0, umi_1.publicKey)(this.marginfiGroup),
235
234
  marginfiAccount: (0, umi_1.publicKey)(this.marginfiAccountPk),
@@ -257,13 +256,13 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
257
256
  const needDebtAccounts = (!inputIsSupply && preSwapRebalance) ||
258
257
  (!outputIsSupply && postSwapRebalance) ||
259
258
  (!inputIsSupply && data.flashLoan !== undefined && postSwapRebalance);
260
- const isFirstRebalance = (preSwapRebalance && (0, solautoUtils_1.hasFirstRebalance)(data.rebalanceType)) ||
259
+ const isFirstRebalance = (preSwapRebalance && (0, utils_1.hasFirstRebalance)(data.rebalanceType)) ||
261
260
  (postSwapRebalance &&
262
261
  data.rebalanceType === generated_1.SolautoRebalanceType.FLSwapThenRebalance);
263
262
  const addAuthorityTas = this.selfManaged || data.values.tokenBalanceChange !== undefined;
264
263
  return (0, generated_1.marginfiRebalance)(this.umi, {
265
264
  signer: this.signer,
266
- marginfiProgram: (0, umi_1.publicKey)(marginfi_sdk_1.MARGINFI_PROGRAM_ID),
265
+ marginfiProgram: (0, umi_1.publicKey)(this.marginfiProgram),
267
266
  ixsSysvar: (0, umi_1.publicKey)(web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY),
268
267
  solautoFeesTa: (0, umi_1.publicKey)(data.values.rebalanceDirection === generated_1.RebalanceDirection.Boost
269
268
  ? this.solautoFeesSupplyTa
@@ -280,12 +279,12 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
280
279
  solautoPosition: (0, umi_1.publicKey)(this.pos.publicKey),
281
280
  marginfiGroup: (0, umi_1.publicKey)(this.marginfiGroup),
282
281
  marginfiAccount: (0, umi_1.publicKey)(this.marginfiAccountPk),
283
- intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), new web3_js_1.PublicKey(data.swapQuote.inputMint))),
282
+ intermediaryTa: (0, umi_1.publicKey)((0, utils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), new web3_js_1.PublicKey(data.swapQuote.inputMint))),
284
283
  supplyBank: (0, umi_1.publicKey)(this.marginfiSupplyAccounts.bank),
285
284
  supplyPriceOracle: (0, umi_1.publicKey)(this.supplyPriceOracle),
286
285
  positionSupplyTa: (0, umi_1.publicKey)(this.positionSupplyTa),
287
286
  authoritySupplyTa: addAuthorityTas
288
- ? (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)(this.authority, this.pos.supplyMint()))
287
+ ? (0, umi_1.publicKey)((0, utils_1.getTokenAccount)(this.authority, this.pos.supplyMint()))
289
288
  : undefined,
290
289
  vaultSupplyTa: needSupplyAccounts
291
290
  ? (0, umi_1.publicKey)(this.marginfiSupplyAccounts.liquidityVault)
@@ -297,7 +296,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
297
296
  debtPriceOracle: (0, umi_1.publicKey)(this.debtPriceOracle),
298
297
  positionDebtTa: (0, umi_1.publicKey)(this.positionDebtTa),
299
298
  authorityDebtTa: addAuthorityTas
300
- ? (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)(this.authority, this.pos.debtMint()))
299
+ ? (0, umi_1.publicKey)((0, utils_1.getTokenAccount)(this.authority, this.pos.debtMint()))
301
300
  : undefined,
302
301
  vaultDebtTa: needDebtAccounts
303
302
  ? (0, umi_1.publicKey)(this.marginfiDebtAccounts.liquidityVault)
@@ -1,18 +1,20 @@
1
- import { Signer, Umi } from "@metaplex-foundation/umi";
2
1
  import { Connection, PublicKey } from "@solana/web3.js";
2
+ import { Signer, Umi } from "@metaplex-foundation/umi";
3
3
  import { WalletAdapter } from "@metaplex-foundation/umi-signer-wallet-adapters";
4
+ import { ProgramEnv } from "../../types";
4
5
  export interface TxHandlerProps {
5
6
  signer?: Signer;
6
7
  wallet?: WalletAdapter;
7
8
  rpcUrl: string;
8
9
  showLogs?: boolean;
9
10
  programId?: PublicKey;
10
- wsEndpoint?: string;
11
+ lpEnv?: ProgramEnv;
11
12
  }
12
13
  export declare abstract class TxHandler {
13
14
  rpcUrl: string;
14
15
  showLogs: boolean;
15
16
  programId: PublicKey;
17
+ lpEnv: ProgramEnv;
16
18
  connection: Connection;
17
19
  umi: Umi;
18
20
  signer: Signer;
@@ -1 +1 @@
1
- {"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../../src/services/solauto/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AAEzD,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAA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CAAC;IACxB,GAAG,EAAG,GAAG,CAAC;IACV,MAAM,EAAG,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAM;gBAEvB,KAAK,EAAE,cAAc;IAgCjC,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,19 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TxHandler = void 0;
4
4
  const umi_1 = require("@metaplex-foundation/umi");
5
+ const umi_signer_wallet_adapters_1 = require("@metaplex-foundation/umi-signer-wallet-adapters");
5
6
  const utils_1 = require("../../utils");
6
7
  const constants_1 = require("../../constants");
7
- const umi_signer_wallet_adapters_1 = require("@metaplex-foundation/umi-signer-wallet-adapters");
8
8
  class TxHandler {
9
9
  constructor(props) {
10
10
  this.showLogs = false;
11
- this.programId = constants_1.SOLAUTO_PROD_PROGRAM;
12
11
  this.otherSigners = [];
13
- if (props.programId !== undefined) {
14
- this.programId = props.programId;
15
- }
12
+ this.programId = props.programId ?? constants_1.SOLAUTO_PROD_PROGRAM;
13
+ this.lpEnv = props.lpEnv ?? "Prod";
16
14
  this.rpcUrl = props.rpcUrl;
17
- const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.rpcUrl, this.programId, props.wsEndpoint);
15
+ const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.rpcUrl, this.programId, this.lpEnv);
18
16
  this.connection = connection;
19
17
  this.umi = umi;
20
18
  if (!props.signer && !props.wallet) {
@@ -1,6 +1,6 @@
1
+ import { PublicKey } from "@solana/web3.js";
1
2
  import { Signer, TransactionBuilder } from "@metaplex-foundation/umi";
2
3
  import { QuoteResponse } from "@jup-ag/api";
3
- import { PublicKey } from "@solana/web3.js";
4
4
  import { TransactionItemInputs } from "../../types";
5
5
  export interface SwapInput {
6
6
  inputMint: PublicKey;
@@ -1 +1 @@
1
- {"version":3,"file":"jupSwapManager.d.ts","sourceRoot":"","sources":["../../../src/services/swap/jupSwapManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,aAAa,EAEd,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,qBAAa,cAAc;IAKb,OAAO,CAAC,MAAM;IAJ1B,MAAM,mCAA4B;IAE3B,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAa;gBAEnC,MAAM,EAAE,MAAM;IAErB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC;YAoBhD,kBAAkB;IAsChC,cAAc;IAId,OAAO,CAAC,0BAA0B;IAQ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AI,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC;YAoBhD,kBAAkB;IAsChC,cAAc;IAId,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,0BAA0B;IAc5B,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA2CnE,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAYlE"}
@@ -2,12 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JupSwapManager = void 0;
4
4
  const umi_1 = require("@metaplex-foundation/umi");
5
+ const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
5
6
  const api_1 = require("@jup-ag/api");
6
- const solanaUtils_1 = require("../../utils/solanaUtils");
7
- const numberUtils_1 = require("../../utils/numberUtils");
8
- const accountUtils_1 = require("../../utils/accountUtils");
9
7
  const utils_1 = require("../../utils");
10
- const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
11
8
  class JupSwapManager {
12
9
  constructor(signer) {
13
10
  this.signer = signer;
@@ -39,7 +36,7 @@ class JupSwapManager {
39
36
  quoteResponse: this.jupQuote,
40
37
  wrapAndUnwrapSol: data.wrapAndUnwrapSol ?? false,
41
38
  useTokenLedger: !data.exactOut && !data.exactIn,
42
- destinationTokenAccount: (0, accountUtils_1.getTokenAccount)(data.destinationWallet ??
39
+ destinationTokenAccount: (0, utils_1.getTokenAccount)(data.destinationWallet ??
43
40
  (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), data.outputMint).toString(),
44
41
  },
45
42
  });
@@ -54,7 +51,7 @@ class JupSwapManager {
54
51
  return instructions;
55
52
  }
56
53
  priceImpactBps() {
57
- return Math.round((0, numberUtils_1.toBps)(parseFloat(this.jupQuote.priceImpactPct))) + 1;
54
+ return Math.round((0, utils_1.toBps)(parseFloat(this.jupQuote.priceImpactPct))) + 1;
58
55
  }
59
56
  adaptSlippageToPriceImpact(slippageIncFactor) {
60
57
  const finalPriceSlippageBps = Math.round(Math.max(20, this.jupQuote.slippageBps, this.priceImpactBps()) *
@@ -63,7 +60,7 @@ class JupSwapManager {
63
60
  }
64
61
  addInAmountSlippagePadding() {
65
62
  (0, utils_1.consoleLog)("Raw inAmount:", this.jupQuote.inAmount);
66
- const inc = Math.max((0, numberUtils_1.fromBps)(this.priceImpactBps()) * 1.1, (0, numberUtils_1.fromBps)(this.jupQuote.slippageBps) * 0.1);
63
+ const inc = Math.max((0, utils_1.fromBps)(this.priceImpactBps()) * 1.1, (0, utils_1.fromBps)(this.jupQuote.slippageBps) * 0.1);
67
64
  (0, utils_1.consoleLog)("Inc:", inc);
68
65
  this.jupQuote.inAmount = Math.round(parseInt(this.jupQuote.inAmount) +
69
66
  parseInt(this.jupQuote.inAmount) * inc).toString();
@@ -84,13 +81,13 @@ class JupSwapManager {
84
81
  return {
85
82
  jupQuote: this.jupQuote,
86
83
  lookupTableAddresses: instructions.addressLookupTableAddresses,
87
- setupIx: (0, umi_1.transactionBuilder)((instructions.setupInstructions ?? []).map((ix) => (0, solanaUtils_1.getWrappedInstruction)(this.signer, (0, utils_1.jupIxToSolanaIx)(ix)))),
84
+ setupIx: (0, umi_1.transactionBuilder)((instructions.setupInstructions ?? []).map((ix) => (0, utils_1.getWrappedInstruction)(this.signer, (0, utils_1.jupIxToSolanaIx)(ix)))),
88
85
  swapIx: (0, umi_1.transactionBuilder)([
89
- (0, solanaUtils_1.getWrappedInstruction)(this.signer, (0, utils_1.jupIxToSolanaIx)(instructions.swapInstruction)),
86
+ (0, utils_1.getWrappedInstruction)(this.signer, (0, utils_1.jupIxToSolanaIx)(instructions.swapInstruction)),
90
87
  ]),
91
88
  cleanupIx: (0, umi_1.transactionBuilder)(instructions.cleanupInstruction
92
89
  ? [
93
- (0, solanaUtils_1.getWrappedInstruction)(this.signer, (0, utils_1.jupIxToSolanaIx)(instructions.cleanupInstruction)),
90
+ (0, utils_1.getWrappedInstruction)(this.signer, (0, utils_1.jupIxToSolanaIx)(instructions.cleanupInstruction)),
94
91
  ]
95
92
  : []),
96
93
  };
@@ -1,7 +1,6 @@
1
- import { TransactionBuilder, Umi } from "@metaplex-foundation/umi";
2
1
  import { PublicKey } from "@solana/web3.js";
3
- import { SolautoClient } from "../solauto/solautoClient";
4
- import { ReferralStateManager } from "..";
2
+ import { TransactionBuilder, Umi } from "@metaplex-foundation/umi";
3
+ import { SolautoClient, ReferralStateManager } from "../solauto";
5
4
  import { TransactionItemInputs } from "../../types";
6
5
  export declare function rebalanceChoresBefore(client: SolautoClient, tx: TransactionBuilder, accountsGettingCreated: string[]): Promise<TransactionBuilder>;
7
6
  export declare function getTransactionChores(client: SolautoClient, tx: TransactionBuilder): Promise<[TransactionBuilder, TransactionBuilder]>;
@@ -1 +1 @@
1
- {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../../src/services/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAmBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAsBzD,OAAO,EAAkB,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAM1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAyLpD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAyF7B;AA6LD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAuC5C;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,kBAAkB,EAAE,EACzB,KAAK,EAAE,KAAK,EACZ,oBAAoB,CAAC,EAAE,OAAO;;;;EA6G/B"}
1
+ {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../../src/services/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAIL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAgBlC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA4BjE,OAAO,EAAE,qBAAqB,EAAyB,MAAM,aAAa,CAAC;AAuL3E,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAyF7B;AA6LD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAuC5C;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,kBAAkB,EAAE,EACzB,KAAK,EAAE,KAAK,EACZ,oBAAoB,CAAC,EAAE,OAAO;;;;EA8G/B"}
@@ -4,20 +4,16 @@ exports.rebalanceChoresBefore = rebalanceChoresBefore;
4
4
  exports.getTransactionChores = getTransactionChores;
5
5
  exports.convertReferralFeesToDestination = convertReferralFeesToDestination;
6
6
  exports.getErrorInfo = getErrorInfo;
7
- const umi_1 = require("@metaplex-foundation/umi");
8
- const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
9
7
  const web3_js_1 = require("@solana/web3.js");
10
8
  const spl_token_1 = require("@solana/spl-token");
9
+ const umi_1 = require("@metaplex-foundation/umi");
10
+ const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
11
11
  const generated_1 = require("../../generated");
12
- const solanaUtils_1 = require("../../utils/solanaUtils");
13
- const generalUtils_1 = require("../../utils/generalUtils");
14
- const numberUtils_1 = require("../../utils/numberUtils");
15
- const accountUtils_1 = require("../../utils/accountUtils");
12
+ const utils_1 = require("../../utils");
16
13
  const marginfi_sdk_1 = require("../../marginfi-sdk");
17
- const __1 = require("..");
14
+ const swap_1 = require("../swap");
18
15
  const jupiter_sdk_1 = require("../../jupiter-sdk");
19
- const utils_1 = require("../../utils");
20
- const transactions_1 = require("../../types/transactions");
16
+ const types_1 = require("../../types");
21
17
  function getWSolUsage(client, solautoActions, initiatingDcaIn, cancellingDcaIn) {
22
18
  const supplyIsWsol = client.pos.supplyMint().equals(spl_token_1.NATIVE_MINT);
23
19
  const debtIsWsol = client.pos.debtMint().equals(spl_token_1.NATIVE_MINT);
@@ -57,7 +53,7 @@ async function transactionChoresBefore(client, accountsGettingCreated, solautoAc
57
53
  }
58
54
  if (client.selfManaged) {
59
55
  if ((0, utils_1.isMarginfiClient)(client) &&
60
- !(await (0, generalUtils_1.getSolanaAccountCreated)(client.umi, client.marginfiAccountPk))) {
56
+ !(await (0, utils_1.getSolanaAccountCreated)(client.umi, client.marginfiAccountPk))) {
61
57
  chores = chores.add(client.marginfiAccountInitialize(client.marginfiAccount));
62
58
  }
63
59
  // TODO: PF
@@ -67,9 +63,9 @@ async function transactionChoresBefore(client, accountsGettingCreated, solautoAc
67
63
  }
68
64
  const wSolUsage = getWSolUsage(client, solautoActions, initiatingDcaIn, undefined);
69
65
  if (wSolUsage !== undefined) {
70
- if (await (0, generalUtils_1.getSolanaAccountCreated)(client.umi, wSolUsage.wSolTokenAccount)) {
66
+ if (await (0, utils_1.getSolanaAccountCreated)(client.umi, wSolUsage.wSolTokenAccount)) {
71
67
  client.log(`Closing signer wSol TA`);
72
- chores = chores.add((0, solanaUtils_1.closeTokenAccountUmiIx)(client.signer, wSolUsage.wSolTokenAccount, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey)));
68
+ chores = chores.add((0, utils_1.closeTokenAccountUmiIx)(client.signer, wSolUsage.wSolTokenAccount, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey)));
73
69
  }
74
70
  let amountToTransfer = BigInt(0);
75
71
  if (wSolUsage.solautoAction &&
@@ -88,10 +84,10 @@ async function transactionChoresBefore(client, accountsGettingCreated, solautoAc
88
84
  const amount = amountToTransfer +
89
85
  (await client.umi.rpc.getRent(spl_token_1.ACCOUNT_SIZE)).basisPoints;
90
86
  client.log(`Transferring ${amount} lamports to signer wSol TA`);
91
- chores = chores.add((0, solanaUtils_1.systemTransferUmiIx)(client.signer, wSolUsage.wSolTokenAccount, amount));
87
+ chores = chores.add((0, utils_1.systemTransferUmiIx)(client.signer, wSolUsage.wSolTokenAccount, amount));
92
88
  }
93
89
  client.log("Creating signer wSol TA");
94
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), spl_token_1.NATIVE_MINT));
90
+ chores = chores.add((0, utils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), spl_token_1.NATIVE_MINT));
95
91
  accountsGettingCreated.push(wSolUsage.wSolTokenAccount.toString());
96
92
  }
97
93
  for (const solautoAction of solautoActions ?? []) {
@@ -105,8 +101,8 @@ async function transactionChoresBefore(client, accountsGettingCreated, solautoAc
105
101
  if (accountsGettingCreated.includes(tokenAccount.toString())) {
106
102
  continue;
107
103
  }
108
- if (!(0, generalUtils_1.getSolanaAccountCreated)(client.umi, tokenAccount)) {
109
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), (0, generated_1.isSolautoAction)("Withdraw", solautoAction)
104
+ if (!(0, utils_1.getSolanaAccountCreated)(client.umi, tokenAccount)) {
105
+ chores = chores.add((0, utils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), (0, generated_1.isSolautoAction)("Withdraw", solautoAction)
110
106
  ? client.pos.supplyMint()
111
107
  : client.pos.debtMint()));
112
108
  accountsGettingCreated.push(tokenAccount.toString());
@@ -136,26 +132,26 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
136
132
  ];
137
133
  const [referredBySupplyTa, referredByDebtTa, signerSupplyTa, signerDebtTa] = await client.umi.rpc.getAccounts(accountsNeeded.map((x) => (0, umi_1.publicKey)(x ?? web3_js_1.PublicKey.default)));
138
134
  let chores = (0, umi_1.transactionBuilder)();
139
- if (checkReferralSupplyTa && !(0, generalUtils_1.rpcAccountCreated)(referredBySupplyTa)) {
135
+ if (checkReferralSupplyTa && !(0, utils_1.rpcAccountCreated)(referredBySupplyTa)) {
140
136
  client.log("Creating referred-by supply TA");
141
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.pos.supplyMint()));
137
+ chores = chores.add((0, utils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.pos.supplyMint()));
142
138
  }
143
- if (checkReferralDebtTa && !(0, generalUtils_1.rpcAccountCreated)(referredByDebtTa)) {
139
+ if (checkReferralDebtTa && !(0, utils_1.rpcAccountCreated)(referredByDebtTa)) {
144
140
  client.log("Creating referred-by debt TA");
145
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.pos.debtMint()));
141
+ chores = chores.add((0, utils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.pos.debtMint()));
146
142
  }
147
143
  if (checkSignerSupplyTa &&
148
- !(0, generalUtils_1.rpcAccountCreated)(signerSupplyTa) &&
144
+ !(0, utils_1.rpcAccountCreated)(signerSupplyTa) &&
149
145
  !accountsGettingCreated.includes(signerSupplyTa.publicKey.toString())) {
150
146
  client.log("Creating signer supply token account");
151
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), client.pos.supplyMint()));
147
+ chores = chores.add((0, utils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), client.pos.supplyMint()));
152
148
  accountsGettingCreated.push(signerSupplyTa.publicKey.toString());
153
149
  }
154
150
  if (checkSignerDebtTa &&
155
- !(0, generalUtils_1.rpcAccountCreated)(signerDebtTa) &&
151
+ !(0, utils_1.rpcAccountCreated)(signerDebtTa) &&
156
152
  !accountsGettingCreated.includes(signerDebtTa.publicKey.toString())) {
157
153
  client.log("Creating signer debt token account");
158
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), client.pos.debtMint()));
154
+ chores = chores.add((0, utils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), client.pos.debtMint()));
159
155
  accountsGettingCreated.push(signerDebtTa.publicKey.toString());
160
156
  }
161
157
  return chores;
@@ -164,7 +160,7 @@ function transactionChoresAfter(client, solautoActions, cancellingDcaIn) {
164
160
  let chores = (0, umi_1.transactionBuilder)();
165
161
  const wSolUsage = getWSolUsage(client, solautoActions, undefined, cancellingDcaIn);
166
162
  if (wSolUsage) {
167
- chores = chores.add((0, solanaUtils_1.closeTokenAccountUmiIx)(client.signer, wSolUsage.wSolTokenAccount, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey)));
163
+ chores = chores.add((0, utils_1.closeTokenAccountUmiIx)(client.signer, wSolUsage.wSolTokenAccount, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey)));
168
164
  }
169
165
  return chores;
170
166
  }
@@ -208,16 +204,16 @@ function getSolautoActions(umi, tx) {
208
204
  }
209
205
  catch { }
210
206
  }
211
- if (x.programId === marginfi_sdk_1.MARGINFI_PROGRAM_ID) {
207
+ if ((0, utils_1.isMarginfiProgram)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.programId))) {
212
208
  try {
213
209
  const serializer = (0, marginfi_sdk_1.getLendingAccountDepositInstructionDataSerializer)();
214
- const discriminator = (0, numberUtils_1.uint8ArrayToBigInt)(serializer
210
+ const discriminator = (0, utils_1.uint8ArrayToBigInt)(serializer
215
211
  .serialize({
216
212
  amount: 0,
217
213
  })
218
214
  .slice(0, 8));
219
215
  const [data, _] = serializer.deserialize(x.data);
220
- if ((0, numberUtils_1.uint8ArrayToBigInt)(new Uint8Array(data.discriminator)) ===
216
+ if ((0, utils_1.uint8ArrayToBigInt)(new Uint8Array(data.discriminator)) ===
221
217
  discriminator) {
222
218
  solautoActions?.push({
223
219
  __kind: "Deposit",
@@ -228,13 +224,13 @@ function getSolautoActions(umi, tx) {
228
224
  catch { }
229
225
  try {
230
226
  const serializer = (0, marginfi_sdk_1.getLendingAccountBorrowInstructionDataSerializer)();
231
- const discriminator = (0, numberUtils_1.uint8ArrayToBigInt)(serializer
227
+ const discriminator = (0, utils_1.uint8ArrayToBigInt)(serializer
232
228
  .serialize({
233
229
  amount: 0,
234
230
  })
235
231
  .slice(0, 8));
236
232
  const [data, _] = serializer.deserialize(x.data);
237
- if ((0, numberUtils_1.uint8ArrayToBigInt)(new Uint8Array(data.discriminator)) ===
233
+ if ((0, utils_1.uint8ArrayToBigInt)(new Uint8Array(data.discriminator)) ===
238
234
  discriminator) {
239
235
  solautoActions?.push({
240
236
  __kind: "Borrow",
@@ -245,14 +241,14 @@ function getSolautoActions(umi, tx) {
245
241
  catch { }
246
242
  try {
247
243
  const serializer = (0, marginfi_sdk_1.getLendingAccountWithdrawInstructionDataSerializer)();
248
- const discriminator = (0, numberUtils_1.uint8ArrayToBigInt)(serializer
244
+ const discriminator = (0, utils_1.uint8ArrayToBigInt)(serializer
249
245
  .serialize({
250
246
  amount: 0,
251
247
  withdrawAll: false,
252
248
  })
253
249
  .slice(0, 8));
254
250
  const [data, _] = serializer.deserialize(x.data);
255
- if ((0, numberUtils_1.uint8ArrayToBigInt)(new Uint8Array(data.discriminator)) ===
251
+ if ((0, utils_1.uint8ArrayToBigInt)(new Uint8Array(data.discriminator)) ===
256
252
  discriminator) {
257
253
  solautoActions?.push({
258
254
  __kind: "Withdraw",
@@ -272,14 +268,14 @@ function getSolautoActions(umi, tx) {
272
268
  catch { }
273
269
  try {
274
270
  const serializer = (0, marginfi_sdk_1.getLendingAccountRepayInstructionDataSerializer)();
275
- const discriminator = (0, numberUtils_1.uint8ArrayToBigInt)(serializer
271
+ const discriminator = (0, utils_1.uint8ArrayToBigInt)(serializer
276
272
  .serialize({
277
273
  amount: 0,
278
274
  repayAll: false,
279
275
  })
280
276
  .slice(0, 8));
281
277
  const [data, _] = serializer.deserialize(x.data);
282
- if ((0, numberUtils_1.uint8ArrayToBigInt)(new Uint8Array(data.discriminator)) ===
278
+ if ((0, utils_1.uint8ArrayToBigInt)(new Uint8Array(data.discriminator)) ===
283
279
  discriminator) {
284
280
  solautoActions?.push({
285
281
  __kind: "Repay",
@@ -315,11 +311,11 @@ async function getTransactionChores(client, tx) {
315
311
  return [choresBefore, choresAfter];
316
312
  }
317
313
  async function convertReferralFeesToDestination(referralManager, tokenAccount, destinationMint) {
318
- const tokenAccountData = await (0, accountUtils_1.getTokenAccountData)(referralManager.umi, tokenAccount);
314
+ const tokenAccountData = await (0, utils_1.getTokenAccountData)(referralManager.umi, tokenAccount);
319
315
  if (!tokenAccountData || tokenAccountData.amount === BigInt(0)) {
320
316
  return undefined;
321
317
  }
322
- const jupSwapManager = new __1.JupSwapManager(referralManager.umi.identity);
318
+ const jupSwapManager = new swap_1.JupSwapManager(referralManager.umi.identity);
323
319
  const { lookupTableAddresses, setupIx, swapIx, cleanupIx } = await jupSwapManager.getJupSwapTxData({
324
320
  amount: tokenAccountData.amount,
325
321
  destinationWallet: referralManager.referralState,
@@ -332,7 +328,7 @@ async function convertReferralFeesToDestination(referralManager, tokenAccount, d
332
328
  .add(setupIx)
333
329
  .add((0, generated_1.convertReferralFees)(referralManager.umi, {
334
330
  signer: referralManager.signer,
335
- intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralManager.umi.identity.publicKey), tokenAccountData.mint)),
331
+ intermediaryTa: (0, umi_1.publicKey)((0, utils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralManager.umi.identity.publicKey), tokenAccountData.mint)),
336
332
  ixsSysvar: (0, umi_1.publicKey)(web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY),
337
333
  referralState: (0, umi_1.publicKey)(referralManager.referralState),
338
334
  referralFeesTa: (0, umi_1.publicKey)(tokenAccount),
@@ -350,7 +346,7 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
350
346
  let errName;
351
347
  const computeIxs = simulationSuccessful ? 2 : 1; // sub ixs to account for computeUnitLimit and computeUnitPrice that get added
352
348
  try {
353
- if (error instanceof transactions_1.BundleSimulationError) {
349
+ if (error instanceof types_1.BundleSimulationError) {
354
350
  errTxIdx = error.details.transactionIdx;
355
351
  errIxIdx = error.details.instructionIdx - computeIxs;
356
352
  errCode = error.details.errorCode;
@@ -365,7 +361,7 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
365
361
  : undefined;
366
362
  errName = errCode === undefined ? err[1] : undefined;
367
363
  }
368
- (0, generalUtils_1.consoleLog)("Transaction instructions:", txs.map((x) => x
364
+ (0, utils_1.consoleLog)("Transaction instructions:", txs.map((x) => x
369
365
  .getInstructions()
370
366
  .map((y) => y.programId.toString())
371
367
  .join(",")));
@@ -374,10 +370,10 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
374
370
  const errIx = errTxIdx !== undefined && errIxIdx !== undefined
375
371
  ? txs[errTxIdx].getInstructions()[Math.max(0, errIxIdx)]
376
372
  : undefined;
377
- (0, generalUtils_1.consoleLog)("Error transaction index:", errTxIdx);
378
- (0, generalUtils_1.consoleLog)("Error instruction index:", errIxIdx);
379
- (0, generalUtils_1.consoleLog)("Error code:", errCode);
380
- (0, generalUtils_1.consoleLog)("Error instruction program:", errIx?.programId.toString());
373
+ (0, utils_1.consoleLog)("Error transaction index:", errTxIdx);
374
+ (0, utils_1.consoleLog)("Error instruction index:", errIxIdx);
375
+ (0, utils_1.consoleLog)("Error code:", errCode);
376
+ (0, utils_1.consoleLog)("Error instruction program:", errIx?.programId.toString());
381
377
  const solautoError = (0, generated_1.getSolautoErrorFromCode)(errCode ?? -1, (0, generated_1.createSolautoProgram)());
382
378
  const marginfiError = (0, marginfi_sdk_1.getMarginfiErrorFromCode)(errCode ?? -1, (0, marginfi_sdk_1.createMarginfiProgram)());
383
379
  if (errCode !== undefined &&
@@ -391,7 +387,8 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
391
387
  }
392
388
  }
393
389
  else if (errCode !== undefined &&
394
- errIx?.programId === marginfi_sdk_1.MARGINFI_PROGRAM_ID) {
390
+ errIx &&
391
+ (0, utils_1.isMarginfiProgram)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(errIx.programId))) {
395
392
  programName = "Marginfi";
396
393
  programError = marginfiError;
397
394
  }
@@ -410,13 +407,13 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
410
407
  }
411
408
  }
412
409
  catch (e) {
413
- (0, generalUtils_1.consoleLog)(e);
410
+ (0, utils_1.consoleLog)(e);
414
411
  }
415
412
  const errData = {
416
413
  errorName,
417
414
  errorInfo,
418
415
  canBeIgnored,
419
416
  };
420
- (0, generalUtils_1.consoleLog)(errData);
417
+ (0, utils_1.consoleLog)(errData);
421
418
  return errData;
422
419
  }
@@ -1,8 +1,7 @@
1
1
  import { TransactionBuilder } from "@metaplex-foundation/umi";
2
- import { SolautoClient } from "../solauto/solautoClient";
3
- import { ErrorsToThrow } from "../../utils/generalUtils";
4
2
  import { PriorityFeeSetting, TransactionItemInputs, TransactionRunType } from "../../types";
5
- import { ReferralStateManager } from "..";
3
+ import { ErrorsToThrow } from "../../utils";
4
+ import { SolautoClient, ReferralStateManager } from "../solauto";
6
5
  export declare class TransactionTooLargeError extends Error {
7
6
  constructor(message: string);
8
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../../src/services/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,0BAA0B,CAAC;AAElC,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAa,MAAM,IAAI,CAAC;AAarD,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAOjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IATtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACxB,WAAW,EAAE,OAAO,CAAS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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;IA0CrC,OAAO,CAAC,YAAY;YA6CN,aAAa;IAoB3B,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,mBAAmB;YAoBb,SAAS;IAmBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IA4GzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YA8BxB,6BAA6B;YA4I7B,qBAAqB;YAgDrB,eAAe;YA0Df,eAAe;CA4D9B"}
1
+ {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../../src/services/transactions/transactionsManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAMrB,OAAO,EAEL,aAAa,EAQd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAM5E,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAOjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IATtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACxB,WAAW,EAAE,OAAO,CAAS;IAC7B,SAAS,EAAE,MAAM,CAAK;gBAGb,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO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