@haven-fi/solauto-sdk 1.0.623 → 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 +5 -26
  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 +6 -37
  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
@@ -6,18 +6,15 @@ const web3_js_1 = require("@solana/web3.js");
6
6
  const umi_1 = require("@metaplex-foundation/umi");
7
7
  const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
8
8
  const generated_1 = require("../../generated");
9
- const accountUtils_1 = require("../../utils/accountUtils");
10
- const generalAccounts_1 = require("../../constants/generalAccounts");
11
- const solanaUtils_1 = require("../../utils/solanaUtils");
12
- const solautoConstants_1 = require("../../constants/solautoConstants");
13
- const solautoUtils_1 = require("../../utils/solautoUtils");
9
+ const utils_1 = require("../../utils");
10
+ const constants_1 = require("../../constants");
14
11
  const referralStateManager_1 = require("./referralStateManager");
15
12
  const solautoPosition_1 = require("../../solautoPosition");
16
- const flProviderAggregator_1 = require("../flashLoans/flProviderAggregator");
13
+ const flashLoans_1 = require("../flashLoans");
17
14
  class SolautoClient extends referralStateManager_1.ReferralStateManager {
18
15
  constructor() {
19
16
  super(...arguments);
20
- this.contextUpdates = new solautoUtils_1.ContextUpdates();
17
+ this.contextUpdates = new utils_1.ContextUpdates();
21
18
  }
22
19
  async initialize(args) {
23
20
  await super.initialize(args);
@@ -27,7 +24,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
27
24
  (!args.supplyMint || !args.debtMint || !args.lpUserAccount)) {
28
25
  throw new Error("Self managed position is missing arguments");
29
26
  }
30
- const positionPk = (0, accountUtils_1.getSolautoPositionAccount)(this.authority, this.positionId, this.programId);
27
+ const positionPk = (0, utils_1.getSolautoPositionAccount)(this.authority, this.positionId, this.programId);
31
28
  this.pos = await (0, solautoPosition_1.getOrCreatePositionEx)(this.umi, positionPk, {
32
29
  supplyMint: args.supplyMint,
33
30
  debtMint: args.debtMint,
@@ -35,18 +32,18 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
35
32
  lpUserAccount: args.lpUserAccount,
36
33
  lendingPlatform: this.lendingPlatform,
37
34
  }, this.contextUpdates);
38
- this.positionSupplyTa = (0, accountUtils_1.getTokenAccount)(this.pos.publicKey, this.pos.supplyMint());
39
- this.signerSupplyTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.pos.supplyMint());
40
- this.positionDebtTa = (0, accountUtils_1.getTokenAccount)(this.pos.publicKey, this.pos.debtMint());
41
- this.signerDebtTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.pos.debtMint());
42
- this.solautoFeesSupplyTa = (0, accountUtils_1.getTokenAccount)(generalAccounts_1.SOLAUTO_FEES_WALLET, this.pos.supplyMint());
43
- this.solautoFeesDebtTa = (0, accountUtils_1.getTokenAccount)(generalAccounts_1.SOLAUTO_FEES_WALLET, this.pos.debtMint());
35
+ this.positionSupplyTa = (0, utils_1.getTokenAccount)(this.pos.publicKey, this.pos.supplyMint());
36
+ this.signerSupplyTa = (0, utils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.pos.supplyMint());
37
+ this.positionDebtTa = (0, utils_1.getTokenAccount)(this.pos.publicKey, this.pos.debtMint());
38
+ this.signerDebtTa = (0, utils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.pos.debtMint());
39
+ this.solautoFeesSupplyTa = (0, utils_1.getTokenAccount)(constants_1.SOLAUTO_FEES_WALLET, this.pos.supplyMint());
40
+ this.solautoFeesDebtTa = (0, utils_1.getTokenAccount)(constants_1.SOLAUTO_FEES_WALLET, this.pos.debtMint());
44
41
  this.authorityLutAddress =
45
42
  this.referralStateData?.lookupTable &&
46
43
  !(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.lookupTable).equals(web3_js_1.PublicKey.default)
47
44
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.lookupTable)
48
45
  : undefined;
49
- this.flProvider = new flProviderAggregator_1.FlProviderAggregator(this.umi, this.signer, this.authority, this.pos.supplyMint(), this.pos.debtMint());
46
+ this.flProvider = new flashLoans_1.FlProviderAggregator(this.umi, this.signer, this.authority, this.pos.supplyMint(), this.pos.debtMint(), this.lpEnv);
50
47
  await this.flProvider.initialize();
51
48
  this.otherSigners.push(...this.flProvider.otherSigners());
52
49
  this.log("Position state: ", this.pos.state());
@@ -57,13 +54,13 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
57
54
  }
58
55
  referredBySupplyTa() {
59
56
  if (this.referredByState !== undefined) {
60
- return (0, accountUtils_1.getTokenAccount)(this.referredByState, this.pos.supplyMint());
57
+ return (0, utils_1.getTokenAccount)(this.referredByState, this.pos.supplyMint());
61
58
  }
62
59
  return undefined;
63
60
  }
64
61
  referredByDebtTa() {
65
62
  if (this.referredByState !== undefined) {
66
- return (0, accountUtils_1.getTokenAccount)(this.referredByState, this.pos.debtMint());
63
+ return (0, utils_1.getTokenAccount)(this.referredByState, this.pos.debtMint());
67
64
  }
68
65
  return undefined;
69
66
  }
@@ -87,7 +84,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
87
84
  }
88
85
  defaultLookupTables() {
89
86
  return [
90
- solautoConstants_1.SOLAUTO_LUT,
87
+ constants_1.SOLAUTO_LUT,
91
88
  ...(this.authorityLutAddress
92
89
  ? [this.authorityLutAddress.toString()]
93
90
  : []),
@@ -137,7 +134,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
137
134
  });
138
135
  this.authorityLutAddress = lookupTableAddress;
139
136
  tx = tx
140
- .add((0, solanaUtils_1.getWrappedInstruction)(this.signer, createLookupTableInst))
137
+ .add((0, utils_1.getWrappedInstruction)(this.signer, createLookupTableInst))
141
138
  .add(this.updateReferralStatesIx(undefined, this.authorityLutAddress));
142
139
  }
143
140
  const accountsToAdd = this.lutAccountsToAdd().filter((x) => !existingLutAccounts
@@ -147,7 +144,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
147
144
  return undefined;
148
145
  }
149
146
  tx = tx
150
- .add((0, solanaUtils_1.getWrappedInstruction)(this.signer, web3_js_1.AddressLookupTableProgram.extendLookupTable({
147
+ .add((0, utils_1.getWrappedInstruction)(this.signer, web3_js_1.AddressLookupTableProgram.extendLookupTable({
151
148
  payer: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey),
152
149
  authority: this.authority,
153
150
  lookupTable: this.authorityLutAddress,
@@ -165,7 +162,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
165
162
  async signerBalances() {
166
163
  if (!this.signerSupplyBalance || !this.signerDebtBalance) {
167
164
  [this.signerSupplyBalance, this.signerDebtBalance] =
168
- await (0, solanaUtils_1.getWalletSplBalances)(this.connection, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), [this.pos.supplyMint(), this.pos.debtMint()]);
165
+ await (0, utils_1.getWalletSplBalances)(this.connection, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), [this.pos.supplyMint(), this.pos.debtMint()]);
169
166
  }
170
167
  return {
171
168
  supplyBalance: this.signerSupplyBalance,
@@ -277,14 +274,14 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
277
274
  let tx = (0, umi_1.transactionBuilder)();
278
275
  if (!this.selfManaged) {
279
276
  if (args.__kind === "Deposit") {
280
- tx = tx.add((0, solanaUtils_1.splTokenTransferUmiIx)(this.signer, this.signerSupplyTa, this.positionSupplyTa, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), BigInt(args.fields[0])));
277
+ tx = tx.add((0, utils_1.splTokenTransferUmiIx)(this.signer, this.signerSupplyTa, this.positionSupplyTa, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), BigInt(args.fields[0])));
281
278
  }
282
279
  else if (args.__kind === "Repay") {
283
280
  if (args.fields[0].__kind === "Some") {
284
- tx = tx.add((0, solanaUtils_1.splTokenTransferUmiIx)(this.signer, this.signerDebtTa, this.positionDebtTa, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), BigInt(args.fields[0].fields[0])));
281
+ tx = tx.add((0, utils_1.splTokenTransferUmiIx)(this.signer, this.signerDebtTa, this.positionDebtTa, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), BigInt(args.fields[0].fields[0])));
285
282
  }
286
283
  else {
287
- tx = tx.add((0, solanaUtils_1.splTokenTransferUmiIx)(this.signer, this.signerDebtTa, this.positionDebtTa, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), BigInt(Math.round(Number(this.pos.state().debt.amountUsed.baseUnit) * 1.01))));
284
+ tx = tx.add((0, utils_1.splTokenTransferUmiIx)(this.signer, this.signerDebtTa, this.positionDebtTa, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), BigInt(Math.round(Number(this.pos.state().debt.amountUsed.baseUnit) * 1.01))));
288
285
  }
289
286
  }
290
287
  }
@@ -1,9 +1,8 @@
1
- import { Signer, TransactionBuilder } from "@metaplex-foundation/umi";
2
1
  import { PublicKey } from "@solana/web3.js";
3
- import { SolautoClient, SolautoClientArgs } from "./solautoClient";
4
- import { MarginfiAssetAccounts } from "../../types/accounts";
2
+ import { Signer, TransactionBuilder } from "@metaplex-foundation/umi";
3
+ import { MarginfiAssetAccounts, RebalanceDetails } from "../../types";
5
4
  import { DCASettingsInpArgs, LendingPlatform, RebalanceStep, SolautoActionArgs, SolautoSettingsParametersInpArgs } from "../../generated";
6
- import { RebalanceDetails } from "../../types";
5
+ import { SolautoClient, SolautoClientArgs } from "./solautoClient";
7
6
  export declare class SolautoMarginfiClient extends SolautoClient {
8
7
  lendingPlatform: LendingPlatform;
9
8
  marginfiProgram: PublicKey;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../../src/services/solauto/solautoMarginfiClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,kBAAkB,EAInB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAK7D,OAAO,EACL,kBAAkB,EAClB,eAAe,EAGf,aAAa,EACb,iBAAiB,EAEjB,gCAAgC,EAOjC,MAAM,iBAAiB,CAAC;AAgBzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,qBAAa,qBA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,CAAC;AAezB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEnE,qBAAa,qBAAsB,SAAQ,aAAa;IAC/C,eAAe,kBAA4B;IAE3C,eAAe,EAAG,SAAS,CAAC;IAE5B,eAAe,EAAG,SAAS,GAAG,MAAM,CAAC;IACrC,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAE1B,sBAAsB,EAAG,qBAAqB,CAAC;IAC/C,oBAAoB,EAAG,qBAAqB,CAAC;IAE7C,iBAAiB,EAAG,SAAS,CAAC;IAC9B,eAAe,EAAG,SAAS,CAAC;IAE7B,UAAU,CAAC,IAAI,EAAE,iBAAiB;IA0ExC,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAI/B,yBAAyB,CAAC,eAAe,EAAE,MAAM,GAAG,kBAAkB;IAStE,cAAc,CACZ,QAAQ,CAAC,EAAE,gCAAgC,EAC3C,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA0C9B,eAAe,IAAI,kBAAkB;IAYrC,SAAS,IAAI,kBAAkB;IAc/B,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUlE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,WAAW,CACT,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,gBAAgB,GACrB,kBAAkB;CAiGtB"}
@@ -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,E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,KAAK,EAAG,UAAU,CAAC;IAEnB,UAAU,EAAG,UAAU,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,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a;gBAEnC,MAAM,EAAE,MAAM;IAErB,QAAQ,CAAC,IAAI,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"}