@haven-fi/solauto-sdk 1.0.582 → 1.0.584
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.
- package/dist/constants/solautoConstants.d.ts +1 -0
- package/dist/constants/solautoConstants.d.ts.map +1 -1
- package/dist/constants/solautoConstants.js +4 -10
- package/dist/generated/accounts/solautoPosition.js +2 -2
- package/dist/generated/errors/solauto.d.ts +14 -2
- package/dist/generated/errors/solauto.d.ts.map +1 -1
- package/dist/generated/errors/solauto.js +27 -5
- package/dist/generated/instructions/claimReferralFees.d.ts +1 -1
- package/dist/generated/instructions/claimReferralFees.d.ts.map +1 -1
- package/dist/generated/instructions/closePosition.d.ts +1 -1
- package/dist/generated/instructions/closePosition.d.ts.map +1 -1
- package/dist/generated/instructions/closePosition.js +2 -2
- package/dist/generated/instructions/marginfiOpenPosition.d.ts +1 -3
- package/dist/generated/instructions/marginfiOpenPosition.d.ts.map +1 -1
- package/dist/generated/instructions/marginfiOpenPosition.js +0 -1
- package/dist/generated/instructions/marginfiRebalance.d.ts +7 -3
- package/dist/generated/instructions/marginfiRebalance.d.ts.map +1 -1
- package/dist/generated/instructions/marginfiRebalance.js +3 -1
- package/dist/generated/types/index.d.ts +7 -1
- package/dist/generated/types/index.d.ts.map +1 -1
- package/dist/generated/types/index.js +7 -1
- package/dist/generated/types/positionData.d.ts +2 -2
- package/dist/generated/types/positionData.d.ts.map +1 -1
- package/dist/generated/types/positionData.js +1 -1
- package/dist/generated/types/positionState.d.ts +7 -7
- package/dist/generated/types/positionState.d.ts.map +1 -1
- package/dist/generated/types/positionState.js +3 -3
- package/dist/generated/types/{positionTokenUsage.d.ts → positionTokenState.d.ts} +6 -8
- package/dist/generated/types/positionTokenState.d.ts.map +1 -0
- package/dist/generated/types/{positionTokenUsage.js → positionTokenState.js} +6 -7
- package/dist/generated/types/rebalanceData.d.ts +7 -13
- package/dist/generated/types/rebalanceData.d.ts.map +1 -1
- package/dist/generated/types/rebalanceData.js +3 -6
- package/dist/generated/types/rebalanceDirection.d.ts +3 -2
- package/dist/generated/types/rebalanceDirection.d.ts.map +1 -1
- package/dist/generated/types/rebalanceDirection.js +3 -2
- package/dist/generated/types/rebalanceInstructionData.d.ts +27 -0
- package/dist/generated/types/rebalanceInstructionData.d.ts.map +1 -0
- package/dist/generated/types/rebalanceInstructionData.js +22 -0
- package/dist/generated/types/rebalanceStateValues.d.ts +27 -0
- package/dist/generated/types/rebalanceStateValues.d.ts.map +1 -0
- package/dist/generated/types/rebalanceStateValues.js +22 -0
- package/dist/generated/types/rebalanceStep.d.ts +15 -0
- package/dist/generated/types/rebalanceStep.d.ts.map +1 -0
- package/dist/generated/types/rebalanceStep.js +22 -0
- package/dist/generated/types/solautoRebalanceType.d.ts +4 -5
- package/dist/generated/types/solautoRebalanceType.d.ts.map +1 -1
- package/dist/generated/types/solautoRebalanceType.js +4 -5
- package/dist/generated/types/solautoSettingsParameters.d.ts +2 -15
- package/dist/generated/types/solautoSettingsParameters.d.ts.map +1 -1
- package/dist/generated/types/solautoSettingsParameters.js +1 -5
- package/dist/generated/types/solautoSettingsParametersInp.d.ts +1 -12
- package/dist/generated/types/solautoSettingsParametersInp.d.ts.map +1 -1
- package/dist/generated/types/solautoSettingsParametersInp.js +0 -3
- package/dist/generated/types/swapType.d.ts +15 -0
- package/dist/generated/types/swapType.d.ts.map +1 -0
- package/dist/generated/types/swapType.js +22 -0
- package/dist/generated/types/tokenBalanceChange.d.ts +21 -0
- package/dist/generated/types/tokenBalanceChange.d.ts.map +1 -0
- package/dist/generated/types/tokenBalanceChange.js +19 -0
- package/dist/generated/types/tokenBalanceChangeType.d.ts +18 -0
- package/dist/generated/types/tokenBalanceChangeType.d.ts.map +1 -0
- package/dist/generated/types/tokenBalanceChangeType.js +25 -0
- package/dist/generated/types/updatePositionData.d.ts +2 -2
- package/dist/generated/types/updatePositionData.d.ts.map +1 -1
- package/dist/generated/types/updatePositionData.js +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/marginfi-sdk/types/interestRateConfig.d.ts +3 -1
- package/dist/marginfi-sdk/types/interestRateConfig.d.ts.map +1 -1
- package/dist/marginfi-sdk/types/interestRateConfig.js +2 -1
- package/dist/services/flashLoans/flProviderAggregator.d.ts +19 -0
- package/dist/services/flashLoans/flProviderAggregator.d.ts.map +1 -0
- package/dist/services/flashLoans/flProviderAggregator.js +46 -0
- package/dist/services/flashLoans/flProviderBase.d.ts +23 -0
- package/dist/services/flashLoans/flProviderBase.d.ts.map +1 -0
- package/dist/services/flashLoans/flProviderBase.js +37 -0
- package/dist/services/flashLoans/index.d.ts +4 -0
- package/dist/services/flashLoans/index.d.ts.map +1 -0
- package/dist/services/flashLoans/index.js +19 -0
- package/dist/services/flashLoans/marginfiFlProvider.d.ts +25 -0
- package/dist/services/flashLoans/marginfiFlProvider.d.ts.map +1 -0
- package/dist/services/flashLoans/marginfiFlProvider.js +246 -0
- package/dist/services/index.d.ts +6 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +21 -0
- package/dist/services/rebalance/index.d.ts +3 -0
- package/dist/services/rebalance/index.d.ts.map +1 -0
- package/dist/services/rebalance/index.js +18 -0
- package/dist/services/rebalance/rebalanceSwapManager.d.ts +30 -0
- package/dist/services/rebalance/rebalanceSwapManager.d.ts.map +1 -0
- package/dist/services/rebalance/rebalanceSwapManager.js +144 -0
- package/dist/services/rebalance/rebalanceTxBuilder.d.ts +22 -0
- package/dist/services/rebalance/rebalanceTxBuilder.d.ts.map +1 -0
- package/dist/services/rebalance/rebalanceTxBuilder.js +200 -0
- package/dist/services/rebalance/rebalanceValues.d.ts +31 -0
- package/dist/services/rebalance/rebalanceValues.d.ts.map +1 -0
- package/dist/services/rebalance/rebalanceValues.js +118 -0
- package/dist/services/rebalance/solautoFees.d.ts +13 -0
- package/dist/services/rebalance/solautoFees.d.ts.map +1 -0
- package/dist/services/rebalance/solautoFees.js +54 -0
- package/dist/services/solauto/index.d.ts +5 -0
- package/dist/services/solauto/index.d.ts.map +1 -0
- package/dist/{clients → services/solauto}/referralStateManager.d.ts +4 -5
- package/dist/services/solauto/referralStateManager.d.ts.map +1 -0
- package/dist/{clients → services/solauto}/referralStateManager.js +10 -12
- package/dist/services/solauto/solautoClient.d.ts +59 -0
- package/dist/services/solauto/solautoClient.d.ts.map +1 -0
- package/dist/{clients → services/solauto}/solautoClient.js +78 -109
- package/dist/services/solauto/solautoMarginfiClient.d.ts +34 -0
- package/dist/services/solauto/solautoMarginfiClient.d.ts.map +1 -0
- package/dist/services/solauto/solautoMarginfiClient.js +322 -0
- package/dist/{clients → services/solauto}/txHandler.d.ts +11 -2
- package/dist/services/solauto/txHandler.d.ts.map +1 -0
- package/dist/services/solauto/txHandler.js +38 -0
- package/dist/services/swap/index.d.ts +2 -0
- package/dist/services/swap/index.d.ts.map +1 -0
- package/dist/{utils/solauto → services/swap}/index.js +1 -2
- package/dist/services/swap/jupSwapManager.d.ts +37 -0
- package/dist/services/swap/jupSwapManager.d.ts.map +1 -0
- package/dist/services/swap/jupSwapManager.js +108 -0
- package/dist/services/transactions/index.d.ts.map +1 -0
- package/dist/{transactions → services/transactions}/transactionUtils.d.ts +3 -5
- package/dist/services/transactions/transactionUtils.d.ts.map +1 -0
- package/dist/{transactions → services/transactions}/transactionUtils.js +29 -137
- package/dist/{transactions → services/transactions}/transactionsManager.d.ts +4 -4
- package/dist/services/transactions/transactionsManager.d.ts.map +1 -0
- package/dist/{transactions → services/transactions}/transactionsManager.js +10 -8
- package/dist/solautoPosition/index.d.ts +4 -0
- package/dist/solautoPosition/index.d.ts.map +1 -0
- package/dist/solautoPosition/index.js +19 -0
- package/dist/solautoPosition/marginfiSolautoPositionEx.d.ts +14 -0
- package/dist/solautoPosition/marginfiSolautoPositionEx.d.ts.map +1 -0
- package/dist/solautoPosition/marginfiSolautoPositionEx.js +73 -0
- package/dist/solautoPosition/solautoPositionEx.d.ts +67 -0
- package/dist/solautoPosition/solautoPositionEx.d.ts.map +1 -0
- package/dist/solautoPosition/solautoPositionEx.js +143 -0
- package/dist/solautoPosition/utils.d.ts +17 -0
- package/dist/solautoPosition/utils.d.ts.map +1 -0
- package/dist/solautoPosition/utils.js +115 -0
- package/dist/types/solauto.d.ts +19 -1
- package/dist/types/solauto.d.ts.map +1 -1
- package/dist/utils/generalUtils.d.ts +1 -0
- package/dist/utils/generalUtils.d.ts.map +1 -1
- package/dist/utils/generalUtils.js +9 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/jitoUtils.d.ts.map +1 -1
- package/dist/utils/jupiterUtils.d.ts +3 -28
- package/dist/utils/jupiterUtils.d.ts.map +1 -1
- package/dist/utils/jupiterUtils.js +2 -73
- package/dist/utils/marginfiUtils.d.ts +4 -3
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +47 -18
- package/dist/utils/numberUtils.d.ts +3 -6
- package/dist/utils/numberUtils.d.ts.map +1 -1
- package/dist/utils/numberUtils.js +13 -48
- package/dist/utils/solanaUtils.js +2 -2
- package/dist/utils/{solauto/generalUtils.d.ts → solautoUtils.d.ts} +9 -16
- package/dist/utils/solautoUtils.d.ts.map +1 -0
- package/dist/utils/{solauto/generalUtils.js → solautoUtils.js} +49 -173
- package/local/createTokenAccounts.ts +1 -5
- package/local/logPositions.ts +22 -68
- package/local/shared.ts +29 -24
- package/local/txSandbox.ts +66 -0
- package/local/updateMarginfiLUT.ts +80 -4
- package/package.json +3 -6
- package/src/constants/solautoConstants.ts +4 -9
- package/src/generated/accounts/solautoPosition.ts +2 -2
- package/src/generated/errors/solauto.ts +45 -4
- package/src/generated/instructions/claimReferralFees.ts +1 -1
- package/src/generated/instructions/closePosition.ts +3 -3
- package/src/generated/instructions/marginfiOpenPosition.ts +0 -7
- package/src/generated/instructions/marginfiRebalance.ts +12 -3
- package/src/generated/types/index.ts +7 -1
- package/src/generated/types/positionData.ts +3 -3
- package/src/generated/types/positionState.ts +12 -12
- package/src/generated/types/{positionTokenUsage.ts → positionTokenState.ts} +13 -16
- package/src/generated/types/rebalanceData.ts +16 -27
- package/src/generated/types/rebalanceDirection.ts +1 -0
- package/src/generated/types/rebalanceInstructionData.ts +62 -0
- package/src/generated/types/rebalanceStateValues.ts +59 -0
- package/src/generated/types/rebalanceStep.ts +25 -0
- package/src/generated/types/solautoRebalanceType.ts +0 -1
- package/src/generated/types/solautoSettingsParameters.ts +4 -25
- package/src/generated/types/solautoSettingsParametersInp.ts +2 -24
- package/src/generated/types/swapType.ts +22 -0
- package/src/generated/types/tokenBalanceChange.ts +46 -0
- package/src/generated/types/tokenBalanceChangeType.ts +28 -0
- package/src/generated/types/updatePositionData.ts +3 -3
- package/src/index.ts +8 -8
- package/src/marginfi-sdk/types/interestRateConfig.ts +6 -2
- package/src/services/flashLoans/flProviderAggregator.ts +74 -0
- package/src/services/flashLoans/flProviderBase.ts +88 -0
- package/src/services/flashLoans/index.ts +3 -0
- package/src/services/flashLoans/marginfiFlProvider.ts +392 -0
- package/src/services/index.ts +5 -0
- package/src/services/rebalance/index.ts +2 -0
- package/src/services/rebalance/rebalanceSwapManager.ts +218 -0
- package/src/services/rebalance/rebalanceTxBuilder.ts +330 -0
- package/src/services/rebalance/rebalanceValues.ts +232 -0
- package/src/services/rebalance/solautoFees.ts +61 -0
- package/src/services/solauto/index.ts +4 -0
- package/src/{clients → services/solauto}/referralStateManager.ts +17 -31
- package/src/{clients → services/solauto}/solautoClient.ts +142 -205
- package/src/services/solauto/solautoMarginfiClient.ts +472 -0
- package/src/services/solauto/txHandler.ts +69 -0
- package/src/services/swap/index.ts +1 -0
- package/src/services/swap/jupSwapManager.ts +189 -0
- package/src/{transactions → services/transactions}/transactionUtils.ts +40 -280
- package/src/{transactions → services/transactions}/transactionsManager.ts +15 -10
- package/src/solautoPosition/index.ts +3 -0
- package/src/solautoPosition/marginfiSolautoPositionEx.ts +111 -0
- package/src/solautoPosition/solautoPositionEx.ts +281 -0
- package/src/solautoPosition/utils.ts +188 -0
- package/src/types/solauto.ts +30 -2
- package/src/utils/generalUtils.ts +9 -1
- package/src/utils/index.ts +2 -2
- package/src/utils/jitoUtils.ts +0 -4
- package/src/utils/jupiterUtils.ts +3 -164
- package/src/utils/marginfiUtils.ts +77 -43
- package/src/utils/numberUtils.ts +18 -77
- package/src/utils/solanaUtils.ts +1 -1
- package/src/utils/{solauto/generalUtils.ts → solautoUtils.ts} +67 -288
- package/tests/transactions/shared.ts +135 -0
- package/tests/transactions/solautoMarginfi.ts +8 -198
- package/tests/unit/accounts.ts +3 -10
- package/tests/unit/lookupTables.ts +23 -2
- package/tests/unit/rebalanceCalculations.ts +65 -343
- package/dist/clients/index.d.ts +0 -5
- package/dist/clients/index.d.ts.map +0 -1
- package/dist/clients/referralStateManager.d.ts.map +0 -1
- package/dist/clients/solautoClient.d.ts +0 -71
- package/dist/clients/solautoClient.d.ts.map +0 -1
- package/dist/clients/solautoMarginfiClient.d.ts +0 -51
- package/dist/clients/solautoMarginfiClient.d.ts.map +0 -1
- package/dist/clients/solautoMarginfiClient.js +0 -497
- package/dist/clients/txHandler.d.ts.map +0 -1
- package/dist/clients/txHandler.js +0 -23
- package/dist/generated/types/positionTokenUsage.d.ts.map +0 -1
- package/dist/transactions/index.d.ts.map +0 -1
- package/dist/transactions/transactionUtils.d.ts.map +0 -1
- package/dist/transactions/transactionsManager.d.ts.map +0 -1
- package/dist/utils/solauto/generalUtils.d.ts.map +0 -1
- package/dist/utils/solauto/index.d.ts +0 -3
- package/dist/utils/solauto/index.d.ts.map +0 -1
- package/dist/utils/solauto/rebalanceUtils.d.ts +0 -30
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +0 -1
- package/dist/utils/solauto/rebalanceUtils.js +0 -287
- package/src/clients/index.ts +0 -4
- package/src/clients/solautoMarginfiClient.ts +0 -774
- package/src/clients/txHandler.ts +0 -38
- package/src/utils/solauto/index.ts +0 -2
- package/src/utils/solauto/rebalanceUtils.ts +0 -562
- package/dist/{clients → services/solauto}/index.js +2 -2
- /package/dist/{transactions → services/transactions}/index.d.ts +0 -0
- /package/dist/{transactions → services/transactions}/index.js +0 -0
- /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 {
|
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
|
-
|
55
|
-
const
|
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
|
-
|
63
|
-
|
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
|
-
|
14
|
+
it("open - deposit - borrow - fl rebalance to 0 - withdraw - close", async () => {
|
15
|
+
await e2eTransactionTest(signer, testProgram, LendingPlatform.Marginfi, true);
|
206
16
|
});
|
207
17
|
});
|
package/tests/unit/accounts.ts
CHANGED
@@ -10,7 +10,7 @@ import {
|
|
10
10
|
import { publicKey } from "@metaplex-foundation/umi";
|
11
11
|
import { assert } from "chai";
|
12
12
|
import {
|
13
|
-
|
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
|
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) => !
|
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 {
|
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 =
|
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()))) {
|