@haven-fi/solauto-sdk 1.0.582 → 1.0.583

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 (260) hide show
  1. package/dist/constants/solautoConstants.d.ts +1 -0
  2. package/dist/constants/solautoConstants.d.ts.map +1 -1
  3. package/dist/constants/solautoConstants.js +4 -10
  4. package/dist/generated/accounts/solautoPosition.js +2 -2
  5. package/dist/generated/errors/solauto.d.ts +14 -2
  6. package/dist/generated/errors/solauto.d.ts.map +1 -1
  7. package/dist/generated/errors/solauto.js +27 -5
  8. package/dist/generated/instructions/claimReferralFees.d.ts +1 -1
  9. package/dist/generated/instructions/claimReferralFees.d.ts.map +1 -1
  10. package/dist/generated/instructions/closePosition.d.ts +1 -1
  11. package/dist/generated/instructions/closePosition.d.ts.map +1 -1
  12. package/dist/generated/instructions/closePosition.js +2 -2
  13. package/dist/generated/instructions/marginfiOpenPosition.d.ts +1 -3
  14. package/dist/generated/instructions/marginfiOpenPosition.d.ts.map +1 -1
  15. package/dist/generated/instructions/marginfiOpenPosition.js +0 -1
  16. package/dist/generated/instructions/marginfiRebalance.d.ts +7 -3
  17. package/dist/generated/instructions/marginfiRebalance.d.ts.map +1 -1
  18. package/dist/generated/instructions/marginfiRebalance.js +3 -1
  19. package/dist/generated/types/index.d.ts +7 -1
  20. package/dist/generated/types/index.d.ts.map +1 -1
  21. package/dist/generated/types/index.js +7 -1
  22. package/dist/generated/types/positionData.d.ts +2 -2
  23. package/dist/generated/types/positionData.d.ts.map +1 -1
  24. package/dist/generated/types/positionData.js +1 -1
  25. package/dist/generated/types/positionState.d.ts +7 -7
  26. package/dist/generated/types/positionState.d.ts.map +1 -1
  27. package/dist/generated/types/positionState.js +3 -3
  28. package/dist/generated/types/{positionTokenUsage.d.ts → positionTokenState.d.ts} +6 -8
  29. package/dist/generated/types/positionTokenState.d.ts.map +1 -0
  30. package/dist/generated/types/{positionTokenUsage.js → positionTokenState.js} +6 -7
  31. package/dist/generated/types/rebalanceData.d.ts +7 -13
  32. package/dist/generated/types/rebalanceData.d.ts.map +1 -1
  33. package/dist/generated/types/rebalanceData.js +3 -6
  34. package/dist/generated/types/rebalanceDirection.d.ts +3 -2
  35. package/dist/generated/types/rebalanceDirection.d.ts.map +1 -1
  36. package/dist/generated/types/rebalanceDirection.js +3 -2
  37. package/dist/generated/types/rebalanceInstructionData.d.ts +27 -0
  38. package/dist/generated/types/rebalanceInstructionData.d.ts.map +1 -0
  39. package/dist/generated/types/rebalanceInstructionData.js +22 -0
  40. package/dist/generated/types/rebalanceStateValues.d.ts +27 -0
  41. package/dist/generated/types/rebalanceStateValues.d.ts.map +1 -0
  42. package/dist/generated/types/rebalanceStateValues.js +22 -0
  43. package/dist/generated/types/rebalanceStep.d.ts +15 -0
  44. package/dist/generated/types/rebalanceStep.d.ts.map +1 -0
  45. package/dist/generated/types/rebalanceStep.js +22 -0
  46. package/dist/generated/types/solautoRebalanceType.d.ts +4 -5
  47. package/dist/generated/types/solautoRebalanceType.d.ts.map +1 -1
  48. package/dist/generated/types/solautoRebalanceType.js +4 -5
  49. package/dist/generated/types/solautoSettingsParameters.d.ts +2 -15
  50. package/dist/generated/types/solautoSettingsParameters.d.ts.map +1 -1
  51. package/dist/generated/types/solautoSettingsParameters.js +1 -5
  52. package/dist/generated/types/solautoSettingsParametersInp.d.ts +1 -12
  53. package/dist/generated/types/solautoSettingsParametersInp.d.ts.map +1 -1
  54. package/dist/generated/types/solautoSettingsParametersInp.js +0 -3
  55. package/dist/generated/types/swapType.d.ts +15 -0
  56. package/dist/generated/types/swapType.d.ts.map +1 -0
  57. package/dist/generated/types/swapType.js +22 -0
  58. package/dist/generated/types/tokenBalanceChange.d.ts +21 -0
  59. package/dist/generated/types/tokenBalanceChange.d.ts.map +1 -0
  60. package/dist/generated/types/tokenBalanceChange.js +19 -0
  61. package/dist/generated/types/tokenBalanceChangeType.d.ts +18 -0
  62. package/dist/generated/types/tokenBalanceChangeType.d.ts.map +1 -0
  63. package/dist/generated/types/tokenBalanceChangeType.js +25 -0
  64. package/dist/generated/types/updatePositionData.d.ts +2 -2
  65. package/dist/generated/types/updatePositionData.d.ts.map +1 -1
  66. package/dist/generated/types/updatePositionData.js +1 -1
  67. package/dist/index.d.ts +8 -6
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +5 -5
  70. package/dist/marginfi-sdk/types/interestRateConfig.d.ts +3 -1
  71. package/dist/marginfi-sdk/types/interestRateConfig.d.ts.map +1 -1
  72. package/dist/marginfi-sdk/types/interestRateConfig.js +2 -1
  73. package/dist/services/flashLoans/flProviderAggregator.d.ts +19 -0
  74. package/dist/services/flashLoans/flProviderAggregator.d.ts.map +1 -0
  75. package/dist/services/flashLoans/flProviderAggregator.js +46 -0
  76. package/dist/services/flashLoans/flProviderBase.d.ts +23 -0
  77. package/dist/services/flashLoans/flProviderBase.d.ts.map +1 -0
  78. package/dist/services/flashLoans/flProviderBase.js +37 -0
  79. package/dist/services/flashLoans/index.d.ts +4 -0
  80. package/dist/services/flashLoans/index.d.ts.map +1 -0
  81. package/dist/services/flashLoans/index.js +19 -0
  82. package/dist/services/flashLoans/marginfiFlProvider.d.ts +25 -0
  83. package/dist/services/flashLoans/marginfiFlProvider.d.ts.map +1 -0
  84. package/dist/services/flashLoans/marginfiFlProvider.js +246 -0
  85. package/dist/services/index.d.ts +6 -0
  86. package/dist/services/index.d.ts.map +1 -0
  87. package/dist/services/index.js +21 -0
  88. package/dist/services/rebalance/index.d.ts +3 -0
  89. package/dist/services/rebalance/index.d.ts.map +1 -0
  90. package/dist/services/rebalance/index.js +18 -0
  91. package/dist/services/rebalance/rebalanceSwapManager.d.ts +30 -0
  92. package/dist/services/rebalance/rebalanceSwapManager.d.ts.map +1 -0
  93. package/dist/services/rebalance/rebalanceSwapManager.js +144 -0
  94. package/dist/services/rebalance/rebalanceTxBuilder.d.ts +22 -0
  95. package/dist/services/rebalance/rebalanceTxBuilder.d.ts.map +1 -0
  96. package/dist/services/rebalance/rebalanceTxBuilder.js +200 -0
  97. package/dist/services/rebalance/rebalanceValues.d.ts +31 -0
  98. package/dist/services/rebalance/rebalanceValues.d.ts.map +1 -0
  99. package/dist/services/rebalance/rebalanceValues.js +118 -0
  100. package/dist/services/rebalance/solautoFees.d.ts +13 -0
  101. package/dist/services/rebalance/solautoFees.d.ts.map +1 -0
  102. package/dist/services/rebalance/solautoFees.js +54 -0
  103. package/dist/services/solauto/index.d.ts +5 -0
  104. package/dist/services/solauto/index.d.ts.map +1 -0
  105. package/dist/{clients → services/solauto}/referralStateManager.d.ts +4 -5
  106. package/dist/services/solauto/referralStateManager.d.ts.map +1 -0
  107. package/dist/{clients → services/solauto}/referralStateManager.js +10 -12
  108. package/dist/services/solauto/solautoClient.d.ts +59 -0
  109. package/dist/services/solauto/solautoClient.d.ts.map +1 -0
  110. package/dist/{clients → services/solauto}/solautoClient.js +78 -109
  111. package/dist/services/solauto/solautoMarginfiClient.d.ts +34 -0
  112. package/dist/services/solauto/solautoMarginfiClient.d.ts.map +1 -0
  113. package/dist/services/solauto/solautoMarginfiClient.js +322 -0
  114. package/dist/{clients → services/solauto}/txHandler.d.ts +11 -2
  115. package/dist/services/solauto/txHandler.d.ts.map +1 -0
  116. package/dist/services/solauto/txHandler.js +38 -0
  117. package/dist/services/swap/index.d.ts +2 -0
  118. package/dist/services/swap/index.d.ts.map +1 -0
  119. package/dist/{utils/solauto → services/swap}/index.js +1 -2
  120. package/dist/services/swap/jupSwapManager.d.ts +37 -0
  121. package/dist/services/swap/jupSwapManager.d.ts.map +1 -0
  122. package/dist/services/swap/jupSwapManager.js +108 -0
  123. package/dist/services/transactions/index.d.ts.map +1 -0
  124. package/dist/{transactions → services/transactions}/transactionUtils.d.ts +3 -5
  125. package/dist/services/transactions/transactionUtils.d.ts.map +1 -0
  126. package/dist/{transactions → services/transactions}/transactionUtils.js +29 -137
  127. package/dist/{transactions → services/transactions}/transactionsManager.d.ts +4 -4
  128. package/dist/services/transactions/transactionsManager.d.ts.map +1 -0
  129. package/dist/{transactions → services/transactions}/transactionsManager.js +10 -8
  130. package/dist/solautoPosition/index.d.ts +4 -0
  131. package/dist/solautoPosition/index.d.ts.map +1 -0
  132. package/dist/solautoPosition/index.js +19 -0
  133. package/dist/solautoPosition/marginfiSolautoPositionEx.d.ts +14 -0
  134. package/dist/solautoPosition/marginfiSolautoPositionEx.d.ts.map +1 -0
  135. package/dist/solautoPosition/marginfiSolautoPositionEx.js +73 -0
  136. package/dist/solautoPosition/solautoPositionEx.d.ts +67 -0
  137. package/dist/solautoPosition/solautoPositionEx.d.ts.map +1 -0
  138. package/dist/solautoPosition/solautoPositionEx.js +143 -0
  139. package/dist/solautoPosition/utils.d.ts +17 -0
  140. package/dist/solautoPosition/utils.d.ts.map +1 -0
  141. package/dist/solautoPosition/utils.js +115 -0
  142. package/dist/types/solauto.d.ts +19 -1
  143. package/dist/types/solauto.d.ts.map +1 -1
  144. package/dist/utils/generalUtils.d.ts +1 -0
  145. package/dist/utils/generalUtils.d.ts.map +1 -1
  146. package/dist/utils/generalUtils.js +9 -1
  147. package/dist/utils/index.d.ts +1 -1
  148. package/dist/utils/index.d.ts.map +1 -1
  149. package/dist/utils/index.js +1 -1
  150. package/dist/utils/jitoUtils.d.ts.map +1 -1
  151. package/dist/utils/jupiterUtils.d.ts +3 -28
  152. package/dist/utils/jupiterUtils.d.ts.map +1 -1
  153. package/dist/utils/jupiterUtils.js +2 -73
  154. package/dist/utils/marginfiUtils.d.ts +4 -3
  155. package/dist/utils/marginfiUtils.d.ts.map +1 -1
  156. package/dist/utils/marginfiUtils.js +47 -18
  157. package/dist/utils/numberUtils.d.ts +3 -6
  158. package/dist/utils/numberUtils.d.ts.map +1 -1
  159. package/dist/utils/numberUtils.js +13 -48
  160. package/dist/utils/solanaUtils.js +2 -2
  161. package/dist/utils/{solauto/generalUtils.d.ts → solautoUtils.d.ts} +9 -16
  162. package/dist/utils/solautoUtils.d.ts.map +1 -0
  163. package/dist/utils/{solauto/generalUtils.js → solautoUtils.js} +48 -173
  164. package/local/createTokenAccounts.ts +1 -5
  165. package/local/logPositions.ts +22 -68
  166. package/local/shared.ts +29 -24
  167. package/local/txSandbox.ts +27 -0
  168. package/local/updateMarginfiLUT.ts +80 -4
  169. package/package.json +3 -6
  170. package/src/constants/solautoConstants.ts +4 -9
  171. package/src/generated/accounts/solautoPosition.ts +2 -2
  172. package/src/generated/errors/solauto.ts +45 -4
  173. package/src/generated/instructions/claimReferralFees.ts +1 -1
  174. package/src/generated/instructions/closePosition.ts +3 -3
  175. package/src/generated/instructions/marginfiOpenPosition.ts +0 -7
  176. package/src/generated/instructions/marginfiRebalance.ts +12 -3
  177. package/src/generated/types/index.ts +7 -1
  178. package/src/generated/types/positionData.ts +3 -3
  179. package/src/generated/types/positionState.ts +12 -12
  180. package/src/generated/types/{positionTokenUsage.ts → positionTokenState.ts} +13 -16
  181. package/src/generated/types/rebalanceData.ts +16 -27
  182. package/src/generated/types/rebalanceDirection.ts +1 -0
  183. package/src/generated/types/rebalanceInstructionData.ts +62 -0
  184. package/src/generated/types/rebalanceStateValues.ts +59 -0
  185. package/src/generated/types/rebalanceStep.ts +25 -0
  186. package/src/generated/types/solautoRebalanceType.ts +0 -1
  187. package/src/generated/types/solautoSettingsParameters.ts +4 -25
  188. package/src/generated/types/solautoSettingsParametersInp.ts +2 -24
  189. package/src/generated/types/swapType.ts +22 -0
  190. package/src/generated/types/tokenBalanceChange.ts +46 -0
  191. package/src/generated/types/tokenBalanceChangeType.ts +28 -0
  192. package/src/generated/types/updatePositionData.ts +3 -3
  193. package/src/index.ts +8 -8
  194. package/src/marginfi-sdk/types/interestRateConfig.ts +6 -2
  195. package/src/services/flashLoans/flProviderAggregator.ts +74 -0
  196. package/src/services/flashLoans/flProviderBase.ts +88 -0
  197. package/src/services/flashLoans/index.ts +3 -0
  198. package/src/services/flashLoans/marginfiFlProvider.ts +392 -0
  199. package/src/services/index.ts +5 -0
  200. package/src/services/rebalance/index.ts +2 -0
  201. package/src/services/rebalance/rebalanceSwapManager.ts +218 -0
  202. package/src/services/rebalance/rebalanceTxBuilder.ts +330 -0
  203. package/src/services/rebalance/rebalanceValues.ts +232 -0
  204. package/src/services/rebalance/solautoFees.ts +61 -0
  205. package/src/services/solauto/index.ts +4 -0
  206. package/src/{clients → services/solauto}/referralStateManager.ts +17 -31
  207. package/src/{clients → services/solauto}/solautoClient.ts +142 -205
  208. package/src/services/solauto/solautoMarginfiClient.ts +472 -0
  209. package/src/services/solauto/txHandler.ts +69 -0
  210. package/src/services/swap/index.ts +1 -0
  211. package/src/services/swap/jupSwapManager.ts +189 -0
  212. package/src/{transactions → services/transactions}/transactionUtils.ts +40 -280
  213. package/src/{transactions → services/transactions}/transactionsManager.ts +15 -10
  214. package/src/solautoPosition/index.ts +3 -0
  215. package/src/solautoPosition/marginfiSolautoPositionEx.ts +111 -0
  216. package/src/solautoPosition/solautoPositionEx.ts +281 -0
  217. package/src/solautoPosition/utils.ts +188 -0
  218. package/src/types/solauto.ts +30 -2
  219. package/src/utils/generalUtils.ts +9 -1
  220. package/src/utils/index.ts +2 -2
  221. package/src/utils/jitoUtils.ts +0 -4
  222. package/src/utils/jupiterUtils.ts +3 -164
  223. package/src/utils/marginfiUtils.ts +77 -43
  224. package/src/utils/numberUtils.ts +18 -77
  225. package/src/utils/solanaUtils.ts +1 -1
  226. package/src/utils/{solauto/generalUtils.ts → solautoUtils.ts} +66 -288
  227. package/tests/transactions/shared.ts +135 -0
  228. package/tests/transactions/solautoMarginfi.ts +8 -198
  229. package/tests/unit/accounts.ts +3 -10
  230. package/tests/unit/lookupTables.ts +23 -2
  231. package/tests/unit/rebalanceCalculations.ts +65 -343
  232. package/dist/clients/index.d.ts +0 -5
  233. package/dist/clients/index.d.ts.map +0 -1
  234. package/dist/clients/referralStateManager.d.ts.map +0 -1
  235. package/dist/clients/solautoClient.d.ts +0 -71
  236. package/dist/clients/solautoClient.d.ts.map +0 -1
  237. package/dist/clients/solautoMarginfiClient.d.ts +0 -51
  238. package/dist/clients/solautoMarginfiClient.d.ts.map +0 -1
  239. package/dist/clients/solautoMarginfiClient.js +0 -497
  240. package/dist/clients/txHandler.d.ts.map +0 -1
  241. package/dist/clients/txHandler.js +0 -23
  242. package/dist/generated/types/positionTokenUsage.d.ts.map +0 -1
  243. package/dist/transactions/index.d.ts.map +0 -1
  244. package/dist/transactions/transactionUtils.d.ts.map +0 -1
  245. package/dist/transactions/transactionsManager.d.ts.map +0 -1
  246. package/dist/utils/solauto/generalUtils.d.ts.map +0 -1
  247. package/dist/utils/solauto/index.d.ts +0 -3
  248. package/dist/utils/solauto/index.d.ts.map +0 -1
  249. package/dist/utils/solauto/rebalanceUtils.d.ts +0 -30
  250. package/dist/utils/solauto/rebalanceUtils.d.ts.map +0 -1
  251. package/dist/utils/solauto/rebalanceUtils.js +0 -287
  252. package/src/clients/index.ts +0 -4
  253. package/src/clients/solautoMarginfiClient.ts +0 -774
  254. package/src/clients/txHandler.ts +0 -38
  255. package/src/utils/solauto/index.ts +0 -2
  256. package/src/utils/solauto/rebalanceUtils.ts +0 -562
  257. package/dist/{clients → services/solauto}/index.js +2 -2
  258. /package/dist/{transactions → services/transactions}/index.d.ts +0 -0
  259. /package/dist/{transactions → services/transactions}/index.js +0 -0
  260. /package/src/{transactions → services/transactions}/index.ts +0 -0
@@ -1,207 +1,17 @@
1
1
  import { describe, it } from "mocha";
2
- import { none, publicKey, some } from "@metaplex-foundation/umi";
3
2
  import { setupTest } from "../shared";
4
- import { SolautoMarginfiClient } from "../../src/clients/solautoMarginfiClient";
5
- import {
6
- PositionType,
7
- safeFetchSolautoPosition,
8
- solautoAction,
9
- SolautoSettingsParametersInpArgs,
10
- } from "../../src/generated";
11
- import { buildSolautoRebalanceTransaction } from "../../src/transactions/transactionUtils";
12
- import {
13
- bytesToI80F48,
14
- getLiqUtilzationRateBps,
15
- getMaxLiqUtilizationRateBps,
16
- maxBoostToBps,
17
- maxRepayFromBps,
18
- maxRepayToBps,
19
- toBaseUnit,
20
- } from "../../src/utils/numberUtils";
21
- import { NATIVE_MINT } from "@solana/spl-token";
22
- import {
23
- TransactionItem,
24
- TransactionsManager,
25
- } from "../../src/transactions/transactionsManager";
26
- import { PublicKey } from "@solana/web3.js";
27
- import {
28
- ALL_SUPPORTED_TOKENS,
29
- DEFAULT_MARGINFI_GROUP,
30
- MARGINFI_ACCOUNTS,
31
- POPCAT,
32
- PRICES,
33
- SOLAUTO_PROD_PROGRAM,
34
- SOLAUTO_TEST_PROGRAM,
35
- USDC,
36
- USDT,
37
- } from "../../src/constants";
38
- import {
39
- buildHeliusApiUrl,
40
- buildIronforgeApiUrl,
41
- fetchTokenPrices,
42
- getAllPositionsByAuthority,
43
- getJupTokenPrices,
44
- getQnComputeUnitPriceEstimate,
45
- getSolautoManagedPositions,
46
- getSolautoPositionAccount,
47
- getSwitchboardPrices,
48
- retryWithExponentialBackoff,
49
- } from "../../src/utils";
50
- import { PriorityFeeSetting } from "../../src/types";
51
- import { SWITCHBOARD_PRICE_FEED_IDS } from "../../src/constants/switchboardConstants";
3
+ import { LendingPlatform } from "../../src";
4
+ import { e2eTransactionTest } from "./shared";
52
5
 
53
6
  describe("Solauto Marginfi tests", async () => {
54
- // const signer = setupTest();
55
- const signer = setupTest("solauto-manager");
56
-
57
- const payForTransactions = false;
58
- const testProgram = false;
59
- const positionId = 1;
7
+ const signer = setupTest();
8
+ const testProgram = true;
60
9
 
61
10
  it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
62
- const client = new SolautoMarginfiClient(
63
- buildIronforgeApiUrl(process.env.IRONFORGE_API_KEY!),
64
- true,
65
- testProgram ? SOLAUTO_TEST_PROGRAM : SOLAUTO_PROD_PROGRAM
66
- );
67
-
68
- const supply = NATIVE_MINT;
69
- const supplyDecimals = 6;
70
- const debtDecimals = 6;
71
-
72
- await client.initialize({
73
- signer,
74
- positionId,
75
- authority: new PublicKey("EBhRj7jbF2EVE21i19JSuCX1BAbnZFYhoKW64HnaZ3kf"),
76
- // new: true,
77
- // marginfiAccount: new PublicKey(
78
- // ""
79
- // ),
80
- // marginfiGroup: new PublicKey(""),
81
- // supplyMint: new PublicKey(""),
82
- // debtMint: new PublicKey(USDC),
83
- });
84
-
85
- const transactionItems: TransactionItem[] = [];
86
- // const settingParams: SolautoSettingsParametersInpArgs = {
87
- // boostToBps: maxBoostToBps(
88
- // client.solautoPositionState?.maxLtvBps ?? 0,
89
- // client.solautoPositionState?.liqThresholdBps ?? 0
90
- // ),
91
- // boostGap: 50,
92
- // repayToBps: maxRepayToBps(
93
- // client.solautoPositionState?.maxLtvBps ?? 0,
94
- // client.solautoPositionState?.liqThresholdBps ?? 0
95
- // ),
96
- // repayGap: 50,
97
- // automation: none(),
98
- // targetBoostToBps: none(),
99
- // };
100
-
101
- const settingParams: SolautoSettingsParametersInpArgs = {
102
- boostToBps: client.solautoPositionSettings().boostToBps - 150,
103
- boostGap: 50,
104
- repayToBps: client.solautoPositionSettings().repayToBps - 150,
105
- repayGap: 50,
106
- automation: none(),
107
- targetBoostToBps: none(),
108
- };
109
-
110
- // if (client.solautoPositionData === null) {
111
- // transactionItems.push(
112
- // new TransactionItem(async () => {
113
- // return {
114
- // tx: client.openPosition(settingParams),
115
- // };
116
- // }, "open position")
117
- // );
118
-
119
- // const initialSupplyUsd = 150;
120
- // transactionItems.push(
121
- // new TransactionItem(async () => {
122
- // // const [supplyPrice] = await fetchTokenPrices([supply]);
123
- // return {
124
- // tx: client.protocolInteraction(
125
- // solautoAction("Deposit", [toBaseUnit(300, supplyDecimals)])
126
- // ),
127
- // };
128
- // }, "deposit")
129
- // );
130
- // }
131
-
132
- // const maxLtvBps = client.solautoPositionState!.maxLtvBps;
133
- // const liqThresholdBps = client.solautoPositionState!.liqThresholdBps;
134
- // const maxRepayFrom = maxRepayFromBps(maxLtvBps, liqThresholdBps);
135
- // const maxRepayTo = maxRepayToBps(maxLtvBps, liqThresholdBps);
136
- // const maxBoostTo = maxBoostToBps(maxLtvBps, liqThresholdBps);
137
- // transactionItems.push(
138
- // new TransactionItem(
139
- // async () => ({
140
- // tx: client.updatePositionIx({
141
- // positionId: client.positionId,
142
- // settingParams: some({
143
- // ...settingParams,
144
- // }),
145
- // dca: null,
146
- // }),
147
- // }),
148
- // "update position"
149
- // )
150
- // );
151
-
152
- transactionItems.push(
153
- new TransactionItem(
154
- async (attemptNum) =>
155
- await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
156
- "rebalance"
157
- )
158
- );
159
-
160
- // transactionItems.push(
161
- // new TransactionItem(
162
- // async () => ({ tx: client.refresh() }),
163
- // "refresh"
164
- // )
165
- // );
166
-
167
- // transactionItems.push(
168
- // new TransactionItem(
169
- // async (attemptNum) =>
170
- // await buildSolautoRebalanceTransaction(client, 0, attemptNum),
171
- // "rebalance"
172
- // )
173
- // );
174
-
175
- // transactionItems.push(
176
- // new TransactionItem(
177
- // async () => ({
178
- // tx: client.protocolInteraction(
179
- // solautoAction("Withdraw", [{ __kind: "All" }])
180
- // ),
181
- // }),
182
- // "withdraw"
183
- // )
184
- // );
185
-
186
- // transactionItems.push(
187
- // new TransactionItem(
188
- // async () => ({
189
- // tx: client.closePositionIx(),
190
- // }),
191
- // "close position"
192
- // )
193
- // );
194
-
195
- const statuses = await new TransactionsManager(
196
- client,
197
- undefined,
198
- !payForTransactions ? "only-simulate" : "normal",
199
- PriorityFeeSetting.Min,
200
- true,
201
- undefined,
202
- { totalRetries: 5 }
203
- ).clientSend(transactionItems);
11
+ await e2eTransactionTest(signer, testProgram, LendingPlatform.Marginfi, false);
12
+ });
204
13
 
205
- console.log(statuses);
14
+ it("open - deposit - borrow - fl rebalance to 0 - withdraw - close", async () => {
15
+ await e2eTransactionTest(signer, testProgram, LendingPlatform.Marginfi, true);
206
16
  });
207
17
  });
@@ -10,7 +10,7 @@ import {
10
10
  import { publicKey } from "@metaplex-foundation/umi";
11
11
  import { assert } from "chai";
12
12
  import {
13
- getAllMarginfiAccountsByAuthority,
13
+ getEmptyMarginfiAccountsByAuthority,
14
14
  getTokenAccount,
15
15
  } from "../../src/utils";
16
16
  import {
@@ -19,7 +19,6 @@ import {
19
19
  SOLAUTO_MANAGER,
20
20
  } from "../../src/constants";
21
21
  import { PublicKey } from "@solana/web3.js";
22
- import { safeFetchAllMarginfiAccount } from "../../src/marginfi-sdk";
23
22
  import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
24
23
 
25
24
  async function hasTokenAccounts(wallet: PublicKey) {
@@ -54,21 +53,15 @@ describe("Assert Solauto fee token accounts are created", async () => {
54
53
  buildHeliusApiUrl(process.env.HELIUS_API_KEY!)
55
54
  );
56
55
 
57
- const ismAccounts = await getAllMarginfiAccountsByAuthority(
56
+ const ismAccounts = await getEmptyMarginfiAccountsByAuthority(
58
57
  umi,
59
58
  SOLAUTO_MANAGER,
60
- undefined,
61
- false
62
- );
63
- const ismData = await safeFetchAllMarginfiAccount(
64
- umi,
65
- ismAccounts.map((x) => publicKey(x.marginfiAccount))
66
59
  );
67
60
  const supportedMarginfiGroups = Object.keys(MARGINFI_ACCOUNTS).map(
68
61
  (x) => new PublicKey(x)
69
62
  );
70
63
  const missingIsmAccounts = supportedMarginfiGroups.filter(
71
- (group) => !ismData.find((x) => group.equals(toWeb3JsPublicKey(x.group)))
64
+ (group) => !ismAccounts.find((x) => group.equals(toWeb3JsPublicKey(x.group)))
72
65
  );
73
66
 
74
67
  console.log("Missing ISM accounts", missingIsmAccounts);
@@ -1,11 +1,19 @@
1
1
  import { describe, it } from "mocha";
2
- import { clusterApiUrl, Connection, PublicKey } from "@solana/web3.js";
2
+ import { PublicKey } from "@solana/web3.js";
3
3
  import {
4
4
  MARGINFI_ACCOUNTS,
5
5
  MARGINFI_ACCOUNTS_LOOKUP_TABLE,
6
6
  } from "../../src/constants/marginfiAccounts";
7
+ import {
8
+ buildIronforgeApiUrl,
9
+ getEmptyMarginfiAccountsByAuthority,
10
+ getSolanaRpcConnection,
11
+ SOLAUTO_MANAGER,
12
+ } from "../../src";
7
13
 
8
- const conn = new Connection(clusterApiUrl("mainnet-beta"), "confirmed");
14
+ const [conn, umi] = getSolanaRpcConnection(
15
+ buildIronforgeApiUrl(process.env.IRONFORGE_API_KEY!)
16
+ );
9
17
 
10
18
  describe("Assert lookup tables up-to-date", async () => {
11
19
  it("marginfi accounts LUT should have everything", async () => {
@@ -16,6 +24,11 @@ describe("Assert lookup tables up-to-date", async () => {
16
24
  throw new Error("Lookup table not found");
17
25
  }
18
26
 
27
+ const ismAccounts = await getEmptyMarginfiAccountsByAuthority(
28
+ umi,
29
+ SOLAUTO_MANAGER
30
+ );
31
+
19
32
  const existingAccounts =
20
33
  lookupTable.value?.state.addresses.map((x) => x.toString()) ?? [];
21
34
 
@@ -25,6 +38,13 @@ describe("Assert lookup tables up-to-date", async () => {
25
38
  continue;
26
39
  }
27
40
 
41
+ const groupIsmAccounts = ismAccounts
42
+ .filter((x) => x.group.toString() === group)
43
+ .map((x) => x.publicKey.toString());
44
+ if (groupIsmAccounts.length === 0) {
45
+ throw new Error(`Missing ISM account for group: ${group}`);
46
+ }
47
+
28
48
  const accounts = MARGINFI_ACCOUNTS[group][key];
29
49
  const addresses = [
30
50
  group,
@@ -32,6 +52,7 @@ describe("Assert lookup tables up-to-date", async () => {
32
52
  accounts.liquidityVault,
33
53
  accounts.vaultAuthority,
34
54
  accounts.priceOracle,
55
+ ...groupIsmAccounts,
35
56
  ];
36
57
 
37
58
  if (addresses.find((x) => !existingAccounts.includes(x.toString()))) {