@haven-fi/solauto-sdk 1.0.581 → 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.
- 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/constants/switchboardConstants.d.ts.map +1 -1
- package/dist/constants/switchboardConstants.js +5 -5
- 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/priceUtils.js +1 -1
- 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} +48 -173
- package/dist/utils/switchboardUtils.d.ts +1 -1
- package/dist/utils/switchboardUtils.d.ts.map +1 -1
- package/dist/utils/switchboardUtils.js +10 -9
- package/local/createTokenAccounts.ts +1 -5
- package/local/logPositions.ts +22 -68
- package/local/shared.ts +29 -24
- package/local/txSandbox.ts +27 -0
- package/local/updateMarginfiLUT.ts +80 -4
- package/package.json +4 -7
- package/src/constants/solautoConstants.ts +4 -9
- package/src/constants/switchboardConstants.ts +10 -5
- 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} +66 -288
- package/src/utils/switchboardUtils.ts +15 -17
- 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
@@ -0,0 +1,111 @@
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
2
|
+
import { SolautoPositionEx } from "./solautoPositionEx";
|
3
|
+
import {
|
4
|
+
Bank,
|
5
|
+
fetchMarginfiAccount,
|
6
|
+
MarginfiAccount,
|
7
|
+
safeFetchAllBank,
|
8
|
+
} from "../marginfi-sdk";
|
9
|
+
import { publicKey } from "@metaplex-foundation/umi";
|
10
|
+
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
11
|
+
import {
|
12
|
+
calcMarginfiMaxLtvAndLiqThreshold,
|
13
|
+
fetchTokenPrices,
|
14
|
+
getBankLiquidityAvailableBaseUnit,
|
15
|
+
getMarginfiAccountPositionState,
|
16
|
+
toBps,
|
17
|
+
} from "../utils";
|
18
|
+
import { DEFAULT_MARGINFI_GROUP, MARGINFI_ACCOUNTS } from "../constants";
|
19
|
+
|
20
|
+
export class MarginfiSolautoPositionEx extends SolautoPositionEx {
|
21
|
+
private marginfiAccountData: MarginfiAccount | null = null;
|
22
|
+
private supplyBank: Bank | null = null;
|
23
|
+
private debtBank: Bank | null = null;
|
24
|
+
|
25
|
+
public async lendingPool(): Promise<PublicKey> {
|
26
|
+
if (this.lp) {
|
27
|
+
return this.lp;
|
28
|
+
}
|
29
|
+
|
30
|
+
if (
|
31
|
+
!this.marginfiAccountData &&
|
32
|
+
this.lpUserAccount &&
|
33
|
+
!this.lpUserAccount.equals(PublicKey.default)
|
34
|
+
) {
|
35
|
+
this.marginfiAccountData = await fetchMarginfiAccount(
|
36
|
+
this.umi,
|
37
|
+
publicKey(this.lpUserAccount),
|
38
|
+
{ commitment: "confirmed" }
|
39
|
+
);
|
40
|
+
this.lp = toWeb3JsPublicKey(this.marginfiAccountData.group);
|
41
|
+
}
|
42
|
+
|
43
|
+
if (!this.lp) {
|
44
|
+
this.lp = new PublicKey(DEFAULT_MARGINFI_GROUP);
|
45
|
+
}
|
46
|
+
|
47
|
+
return this.lp;
|
48
|
+
}
|
49
|
+
|
50
|
+
async maxLtvAndLiqThresholdBps(): Promise<[number, number]> {
|
51
|
+
if (!this.supplyBank || !this.debtBank) {
|
52
|
+
const group = (await this.lendingPool()).toString();
|
53
|
+
const supplyBank =
|
54
|
+
MARGINFI_ACCOUNTS[group][this.supplyMint().toString()].bank;
|
55
|
+
const debtBank =
|
56
|
+
MARGINFI_ACCOUNTS[group][this.debtMint().toString()].bank;
|
57
|
+
|
58
|
+
[this.supplyBank, this.debtBank] = await safeFetchAllBank(this.umi, [
|
59
|
+
publicKey(supplyBank),
|
60
|
+
publicKey(debtBank),
|
61
|
+
]);
|
62
|
+
}
|
63
|
+
|
64
|
+
const [supplyPrice] = await fetchTokenPrices([this.supplyMint()]);
|
65
|
+
const [maxLtv, liqThreshold] = calcMarginfiMaxLtvAndLiqThreshold(
|
66
|
+
this.supplyBank,
|
67
|
+
this.debtBank,
|
68
|
+
supplyPrice
|
69
|
+
);
|
70
|
+
|
71
|
+
return [toBps(maxLtv), toBps(liqThreshold)];
|
72
|
+
}
|
73
|
+
|
74
|
+
supplyLiquidityAvailable(): bigint {
|
75
|
+
return getBankLiquidityAvailableBaseUnit(this.supplyBank, false);
|
76
|
+
}
|
77
|
+
|
78
|
+
supplyLiquidityDepositable(): bigint {
|
79
|
+
return getBankLiquidityAvailableBaseUnit(this.supplyBank, true);
|
80
|
+
}
|
81
|
+
|
82
|
+
debtLiquidityAvailable(): bigint {
|
83
|
+
return getBankLiquidityAvailableBaseUnit(this.debtBank, false);
|
84
|
+
}
|
85
|
+
|
86
|
+
async refreshPositionState(): Promise<void> {
|
87
|
+
if (!this.canRefreshPositionState()) {
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
|
91
|
+
const useDesignatedMint = !this._data.position || !this._data.selfManaged;
|
92
|
+
const resp = await getMarginfiAccountPositionState(
|
93
|
+
this.umi,
|
94
|
+
{ pk: this.lpUserAccount },
|
95
|
+
await this.lendingPool(),
|
96
|
+
useDesignatedMint
|
97
|
+
? { mint: toWeb3JsPublicKey(this.state().supply.mint) }
|
98
|
+
: undefined,
|
99
|
+
useDesignatedMint
|
100
|
+
? { mint: toWeb3JsPublicKey(this.state().debt.mint) }
|
101
|
+
: undefined,
|
102
|
+
this.contextUpdates
|
103
|
+
);
|
104
|
+
|
105
|
+
if (resp) {
|
106
|
+
this.supplyBank = resp.supplyBank;
|
107
|
+
this.debtBank = resp.debtBank;
|
108
|
+
this._data.state = resp.state;
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
@@ -0,0 +1,281 @@
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
2
|
+
import {
|
3
|
+
DCASettings,
|
4
|
+
fetchSolautoPosition,
|
5
|
+
LendingPlatform,
|
6
|
+
PositionState,
|
7
|
+
SolautoPosition,
|
8
|
+
SolautoSettingsParameters,
|
9
|
+
} from "../generated";
|
10
|
+
import { Umi } from "@metaplex-foundation/umi";
|
11
|
+
import {
|
12
|
+
calcDebtUsd,
|
13
|
+
calcNetWorth,
|
14
|
+
calcNetWorthUsd,
|
15
|
+
calcSupplyUsd,
|
16
|
+
calcTotalDebt,
|
17
|
+
calcTotalSupply,
|
18
|
+
consoleLog,
|
19
|
+
ContextUpdates,
|
20
|
+
currentUnixSeconds,
|
21
|
+
debtLiquidityUsdAvailable,
|
22
|
+
maxBoostToBps,
|
23
|
+
maxRepayToBps,
|
24
|
+
positionStateWithLatestPrices,
|
25
|
+
safeGetPrice,
|
26
|
+
solautoStrategyName,
|
27
|
+
supplyLiquidityUsdDepositable,
|
28
|
+
} from "../utils";
|
29
|
+
import { RebalanceAction } from "../types";
|
30
|
+
import { getDebtAdjustment } from "../services/rebalance";
|
31
|
+
import { MIN_POSITION_STATE_FRESHNESS_SECS } from "../constants";
|
32
|
+
import {
|
33
|
+
fromWeb3JsPublicKey,
|
34
|
+
toWeb3JsPublicKey,
|
35
|
+
} from "@metaplex-foundation/umi-web3js-adapters";
|
36
|
+
|
37
|
+
export interface PositionCustomArgs {
|
38
|
+
lendingPlatform: LendingPlatform;
|
39
|
+
supplyMint?: PublicKey;
|
40
|
+
debtMint?: PublicKey;
|
41
|
+
lendingPool?: PublicKey;
|
42
|
+
lpUserAccount?: PublicKey;
|
43
|
+
}
|
44
|
+
|
45
|
+
interface SolautoPositionExData extends Partial<SolautoPosition> {
|
46
|
+
state: PositionState;
|
47
|
+
}
|
48
|
+
|
49
|
+
interface PositionExArgs {
|
50
|
+
umi: Umi;
|
51
|
+
publicKey: PublicKey;
|
52
|
+
data: SolautoPositionExData;
|
53
|
+
customArgs?: PositionCustomArgs;
|
54
|
+
contextUpdates?: ContextUpdates;
|
55
|
+
}
|
56
|
+
|
57
|
+
export abstract class SolautoPositionEx {
|
58
|
+
public umi!: Umi;
|
59
|
+
public publicKey!: PublicKey;
|
60
|
+
protected _data!: SolautoPositionExData;
|
61
|
+
protected lp?: PublicKey = undefined;
|
62
|
+
public lpUserAccount?: PublicKey = undefined;
|
63
|
+
protected contextUpdates?: ContextUpdates;
|
64
|
+
|
65
|
+
private readonly firstState!: PositionState;
|
66
|
+
|
67
|
+
constructor(args: PositionExArgs) {
|
68
|
+
this.umi = args.umi;
|
69
|
+
this.publicKey = args.publicKey;
|
70
|
+
this.contextUpdates = args.contextUpdates;
|
71
|
+
|
72
|
+
this.lp = args.customArgs?.lendingPool;
|
73
|
+
this.lpUserAccount =
|
74
|
+
args.customArgs?.lpUserAccount ??
|
75
|
+
(args.data.position
|
76
|
+
? toWeb3JsPublicKey(args.data.position!.protocolUserAccount)
|
77
|
+
: undefined);
|
78
|
+
|
79
|
+
this._data = args.data;
|
80
|
+
this.firstState = { ...args.data.state };
|
81
|
+
}
|
82
|
+
|
83
|
+
abstract lendingPool(): Promise<PublicKey>;
|
84
|
+
|
85
|
+
exists() {
|
86
|
+
return this._data.position !== undefined;
|
87
|
+
}
|
88
|
+
|
89
|
+
strategyName() {
|
90
|
+
return solautoStrategyName(
|
91
|
+
toWeb3JsPublicKey(this.state().supply.mint),
|
92
|
+
toWeb3JsPublicKey(this.state().debt.mint)
|
93
|
+
);
|
94
|
+
}
|
95
|
+
|
96
|
+
data(): SolautoPositionExData {
|
97
|
+
return this._data;
|
98
|
+
}
|
99
|
+
|
100
|
+
state(): PositionState {
|
101
|
+
return this.data().state;
|
102
|
+
}
|
103
|
+
|
104
|
+
settings(): SolautoSettingsParameters | undefined {
|
105
|
+
return this.contextUpdates?.settings ?? this.data().position?.settings;
|
106
|
+
}
|
107
|
+
|
108
|
+
dca(): DCASettings | undefined {
|
109
|
+
return this.contextUpdates?.dca ?? this.data().position?.dca;
|
110
|
+
}
|
111
|
+
|
112
|
+
supplyMint(): PublicKey {
|
113
|
+
return toWeb3JsPublicKey(this.state().supply.mint);
|
114
|
+
}
|
115
|
+
|
116
|
+
debtMint(): PublicKey {
|
117
|
+
return toWeb3JsPublicKey(this.state().debt.mint);
|
118
|
+
}
|
119
|
+
|
120
|
+
boostToBps() {
|
121
|
+
return Math.min(
|
122
|
+
this.settings()?.boostToBps ?? 0,
|
123
|
+
maxBoostToBps(this.state().maxLtvBps, this.state().liqThresholdBps)
|
124
|
+
);
|
125
|
+
}
|
126
|
+
|
127
|
+
boostFromBps() {
|
128
|
+
return this.boostToBps() - (this.settings()?.boostGap ?? 0);
|
129
|
+
}
|
130
|
+
|
131
|
+
repayToBps() {
|
132
|
+
return Math.min(
|
133
|
+
this.settings()?.repayToBps ?? 0,
|
134
|
+
maxRepayToBps(this.state().maxLtvBps, this.state().liqThresholdBps)
|
135
|
+
);
|
136
|
+
}
|
137
|
+
|
138
|
+
repayFromBps() {
|
139
|
+
return (
|
140
|
+
(this.settings()?.repayToBps ?? 0) + (this.settings()?.repayGap ?? 0)
|
141
|
+
);
|
142
|
+
}
|
143
|
+
|
144
|
+
netWorth() {
|
145
|
+
return calcNetWorth(this.state());
|
146
|
+
}
|
147
|
+
|
148
|
+
netWorthUsd() {
|
149
|
+
return calcNetWorthUsd(this.state());
|
150
|
+
}
|
151
|
+
|
152
|
+
totalSupply() {
|
153
|
+
return calcTotalSupply(this.state());
|
154
|
+
}
|
155
|
+
|
156
|
+
supplyUsd() {
|
157
|
+
return calcSupplyUsd(this.state());
|
158
|
+
}
|
159
|
+
|
160
|
+
totalDebt() {
|
161
|
+
return calcTotalDebt(this.state());
|
162
|
+
}
|
163
|
+
|
164
|
+
debtUsd() {
|
165
|
+
return calcDebtUsd(this.state());
|
166
|
+
}
|
167
|
+
|
168
|
+
supplyLiquidityUsdDepositable() {
|
169
|
+
return supplyLiquidityUsdDepositable(this.state());
|
170
|
+
}
|
171
|
+
|
172
|
+
debtLiquidityUsdAvailable() {
|
173
|
+
return debtLiquidityUsdAvailable(this.state());
|
174
|
+
}
|
175
|
+
|
176
|
+
abstract maxLtvAndLiqThresholdBps(): Promise<[number, number]>;
|
177
|
+
abstract supplyLiquidityDepositable(): bigint;
|
178
|
+
abstract supplyLiquidityAvailable(): bigint;
|
179
|
+
abstract debtLiquidityAvailable(): bigint;
|
180
|
+
|
181
|
+
sufficientLiquidityToBoost() {
|
182
|
+
const limitsUpToDate =
|
183
|
+
this.debtLiquidityUsdAvailable() !== 0 ||
|
184
|
+
this.supplyLiquidityUsdDepositable() !== 0;
|
185
|
+
|
186
|
+
if (limitsUpToDate) {
|
187
|
+
const { debtAdjustmentUsd } = getDebtAdjustment(
|
188
|
+
this.state().liqThresholdBps,
|
189
|
+
{ supplyUsd: this.supplyUsd(), debtUsd: this.debtUsd() },
|
190
|
+
{ solauto: 50, lpBorrow: 50, flashLoan: 50 }, // TODO: add better fix here instead of magic numbers
|
191
|
+
this.boostToBps()
|
192
|
+
);
|
193
|
+
|
194
|
+
const sufficientLiquidity =
|
195
|
+
this.debtLiquidityUsdAvailable() * 0.95 > debtAdjustmentUsd &&
|
196
|
+
this.supplyLiquidityUsdDepositable() * 0.95 > debtAdjustmentUsd;
|
197
|
+
|
198
|
+
if (!sufficientLiquidity) {
|
199
|
+
consoleLog("Insufficient liquidity to further boost");
|
200
|
+
}
|
201
|
+
return sufficientLiquidity;
|
202
|
+
}
|
203
|
+
|
204
|
+
return true;
|
205
|
+
}
|
206
|
+
|
207
|
+
eligibleForRebalance(bpsDistanceThreshold = 0): RebalanceAction | undefined {
|
208
|
+
if (!this.settings() || !calcSupplyUsd(this.state())) {
|
209
|
+
return undefined;
|
210
|
+
}
|
211
|
+
|
212
|
+
if (
|
213
|
+
this.state().liqUtilizationRateBps - this.boostFromBps() <=
|
214
|
+
bpsDistanceThreshold
|
215
|
+
) {
|
216
|
+
const sufficientLiquidity = this.sufficientLiquidityToBoost();
|
217
|
+
return sufficientLiquidity ? "boost" : undefined;
|
218
|
+
} else if (
|
219
|
+
this.repayFromBps() - this.state().liqUtilizationRateBps <=
|
220
|
+
bpsDistanceThreshold
|
221
|
+
) {
|
222
|
+
return "repay";
|
223
|
+
}
|
224
|
+
|
225
|
+
return undefined;
|
226
|
+
}
|
227
|
+
|
228
|
+
eligibleForRefresh(): boolean {
|
229
|
+
if (this._data.selfManaged) return false;
|
230
|
+
|
231
|
+
return (
|
232
|
+
currentUnixSeconds() - Number(this.state().lastRefreshed) >
|
233
|
+
60 * 60 * 24 * 7
|
234
|
+
);
|
235
|
+
}
|
236
|
+
|
237
|
+
protected canRefreshPositionState() {
|
238
|
+
if (
|
239
|
+
Number(this.state().lastRefreshed) >
|
240
|
+
currentUnixSeconds() - MIN_POSITION_STATE_FRESHNESS_SECS &&
|
241
|
+
!this.contextUpdates?.positionUpdates()
|
242
|
+
) {
|
243
|
+
return false;
|
244
|
+
}
|
245
|
+
return true;
|
246
|
+
}
|
247
|
+
|
248
|
+
abstract refreshPositionState(): Promise<void>;
|
249
|
+
|
250
|
+
async utilizationRateBpsDrift() {
|
251
|
+
const supplyPrice = safeGetPrice(this.state().supply.mint) ?? 0;
|
252
|
+
const debtPrice = safeGetPrice(this.state().debt.mint) ?? 0;
|
253
|
+
const oldState = await positionStateWithLatestPrices(
|
254
|
+
this.firstState,
|
255
|
+
supplyPrice,
|
256
|
+
debtPrice
|
257
|
+
);
|
258
|
+
const newState = await positionStateWithLatestPrices(
|
259
|
+
this.state(),
|
260
|
+
supplyPrice,
|
261
|
+
debtPrice
|
262
|
+
);
|
263
|
+
|
264
|
+
return newState.liqUtilizationRateBps - oldState.liqUtilizationRateBps;
|
265
|
+
}
|
266
|
+
|
267
|
+
async updateWithLatestPrices(supplyPrice?: number, debtPrice?: number) {
|
268
|
+
this._data.state = await positionStateWithLatestPrices(
|
269
|
+
this.state(),
|
270
|
+
supplyPrice,
|
271
|
+
debtPrice
|
272
|
+
);
|
273
|
+
}
|
274
|
+
|
275
|
+
async refetchPositionData() {
|
276
|
+
this._data = await fetchSolautoPosition(
|
277
|
+
this.umi,
|
278
|
+
fromWeb3JsPublicKey(this.publicKey)
|
279
|
+
);
|
280
|
+
}
|
281
|
+
}
|
@@ -0,0 +1,188 @@
|
|
1
|
+
import { Umi } from "@metaplex-foundation/umi";
|
2
|
+
import {
|
3
|
+
LendingPlatform,
|
4
|
+
PositionState,
|
5
|
+
safeFetchAllSolautoPosition,
|
6
|
+
safeFetchSolautoPosition,
|
7
|
+
SolautoSettingsParameters,
|
8
|
+
SolautoSettingsParametersInpArgs,
|
9
|
+
} from "../generated";
|
10
|
+
import { PublicKey } from "@solana/web3.js";
|
11
|
+
import { PositionCustomArgs, SolautoPositionEx } from "./solautoPositionEx";
|
12
|
+
import {
|
13
|
+
fromWeb3JsPublicKey,
|
14
|
+
toWeb3JsPublicKey,
|
15
|
+
} from "@metaplex-foundation/umi-web3js-adapters";
|
16
|
+
import { MarginfiSolautoPositionEx } from "./marginfiSolautoPositionEx";
|
17
|
+
import {
|
18
|
+
ContextUpdates,
|
19
|
+
currentUnixSeconds,
|
20
|
+
getBatches,
|
21
|
+
getLiqUtilzationRateBps,
|
22
|
+
retryWithExponentialBackoff,
|
23
|
+
toBaseUnit,
|
24
|
+
toRoundedUsdValue,
|
25
|
+
} from "../utils";
|
26
|
+
import { TOKEN_INFO } from "../constants";
|
27
|
+
|
28
|
+
export function createSolautoSettings(
|
29
|
+
settings: SolautoSettingsParametersInpArgs
|
30
|
+
): SolautoSettingsParameters {
|
31
|
+
return {
|
32
|
+
boostGap: settings.boostGap,
|
33
|
+
boostToBps: settings.boostToBps,
|
34
|
+
repayGap: settings.repayGap,
|
35
|
+
repayToBps: settings.repayToBps,
|
36
|
+
padding: [],
|
37
|
+
};
|
38
|
+
}
|
39
|
+
|
40
|
+
export async function getPositionExBulk(
|
41
|
+
umi: Umi,
|
42
|
+
publicKeys: PublicKey[]
|
43
|
+
): Promise<SolautoPositionEx[]> {
|
44
|
+
const batches = getBatches(publicKeys, 30);
|
45
|
+
|
46
|
+
const data = (
|
47
|
+
await Promise.all(
|
48
|
+
batches.map(async (pubkeys) => {
|
49
|
+
return retryWithExponentialBackoff(
|
50
|
+
async () =>
|
51
|
+
await safeFetchAllSolautoPosition(
|
52
|
+
umi,
|
53
|
+
pubkeys.map((x) => fromWeb3JsPublicKey(x))
|
54
|
+
)
|
55
|
+
);
|
56
|
+
})
|
57
|
+
)
|
58
|
+
).flat();
|
59
|
+
|
60
|
+
return data.map((x) => {
|
61
|
+
switch (x.position.lendingPlatform) {
|
62
|
+
case LendingPlatform.Marginfi:
|
63
|
+
return new MarginfiSolautoPositionEx({
|
64
|
+
umi,
|
65
|
+
publicKey: toWeb3JsPublicKey(x.publicKey),
|
66
|
+
data: x,
|
67
|
+
});
|
68
|
+
// TODO: PF
|
69
|
+
}
|
70
|
+
});
|
71
|
+
}
|
72
|
+
|
73
|
+
export async function getOrCreatePositionEx(
|
74
|
+
umi: Umi,
|
75
|
+
publicKey: PublicKey,
|
76
|
+
customArgs?: PositionCustomArgs,
|
77
|
+
contextUpdates?: ContextUpdates
|
78
|
+
): Promise<SolautoPositionEx> {
|
79
|
+
const data = await safeFetchSolautoPosition(
|
80
|
+
umi,
|
81
|
+
fromWeb3JsPublicKey(publicKey)
|
82
|
+
);
|
83
|
+
|
84
|
+
const placeholderState = createFakePositionState(
|
85
|
+
{
|
86
|
+
mint: customArgs?.supplyMint ?? PublicKey.default,
|
87
|
+
},
|
88
|
+
{ mint: customArgs?.debtMint ?? PublicKey.default },
|
89
|
+
0,
|
90
|
+
0
|
91
|
+
);
|
92
|
+
|
93
|
+
const lendingPlatform = data
|
94
|
+
? data.position.lendingPlatform
|
95
|
+
: customArgs!.lendingPlatform;
|
96
|
+
|
97
|
+
switch (lendingPlatform) {
|
98
|
+
case LendingPlatform.Marginfi:
|
99
|
+
return new MarginfiSolautoPositionEx({
|
100
|
+
umi,
|
101
|
+
publicKey,
|
102
|
+
data: data ?? {
|
103
|
+
state: placeholderState!,
|
104
|
+
},
|
105
|
+
customArgs,
|
106
|
+
contextUpdates,
|
107
|
+
});
|
108
|
+
// TODO: PF
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
interface AssetProps {
|
113
|
+
mint: PublicKey;
|
114
|
+
price?: number;
|
115
|
+
amountUsed?: number;
|
116
|
+
amountCanBeUsed?: number;
|
117
|
+
}
|
118
|
+
|
119
|
+
export function createFakePositionState(
|
120
|
+
supply: AssetProps,
|
121
|
+
debt: AssetProps,
|
122
|
+
maxLtvBps: number,
|
123
|
+
liqThresholdBps: number
|
124
|
+
): PositionState {
|
125
|
+
const supplyDecimals = TOKEN_INFO[supply.mint.toString()].decimals;
|
126
|
+
const debtDecimals = TOKEN_INFO[debt.mint.toString()].decimals;
|
127
|
+
|
128
|
+
const supplyUsd = (supply.amountUsed ?? 0) * (supply.price ?? 0);
|
129
|
+
const debtUsd = (debt.amountUsed ?? 0) * (debt.price ?? 0);
|
130
|
+
|
131
|
+
return {
|
132
|
+
liqUtilizationRateBps: getLiqUtilzationRateBps(
|
133
|
+
supplyUsd,
|
134
|
+
debtUsd,
|
135
|
+
liqThresholdBps
|
136
|
+
),
|
137
|
+
supply: {
|
138
|
+
amountUsed: {
|
139
|
+
baseUnit: toBaseUnit(supply.amountUsed ?? 0, supplyDecimals),
|
140
|
+
baseAmountUsdValue: toRoundedUsdValue(supplyUsd),
|
141
|
+
},
|
142
|
+
amountCanBeUsed: {
|
143
|
+
baseUnit: toBaseUnit(supply.amountCanBeUsed ?? 0, supplyDecimals),
|
144
|
+
baseAmountUsdValue: toRoundedUsdValue(
|
145
|
+
(supply.amountCanBeUsed ?? 0) * (supply.price ?? 0)
|
146
|
+
),
|
147
|
+
},
|
148
|
+
baseAmountMarketPriceUsd: toRoundedUsdValue(supply.price ?? 0),
|
149
|
+
borrowFeeBps: 0,
|
150
|
+
decimals: supplyDecimals,
|
151
|
+
mint: fromWeb3JsPublicKey(supply.mint),
|
152
|
+
padding1: [],
|
153
|
+
padding2: [],
|
154
|
+
padding: new Uint8Array([]),
|
155
|
+
},
|
156
|
+
debt: {
|
157
|
+
amountUsed: {
|
158
|
+
baseUnit: toBaseUnit(debt.amountUsed ?? 0, debtDecimals),
|
159
|
+
baseAmountUsdValue: toRoundedUsdValue(debtUsd),
|
160
|
+
},
|
161
|
+
amountCanBeUsed: {
|
162
|
+
baseUnit: toBaseUnit(debt.amountCanBeUsed ?? 0, debtDecimals),
|
163
|
+
baseAmountUsdValue: toRoundedUsdValue(
|
164
|
+
(debt.amountCanBeUsed ?? 0) * (debt.price ?? 0)
|
165
|
+
),
|
166
|
+
},
|
167
|
+
baseAmountMarketPriceUsd: toRoundedUsdValue(debt.price ?? 0),
|
168
|
+
borrowFeeBps: 0,
|
169
|
+
decimals: debtDecimals,
|
170
|
+
mint: fromWeb3JsPublicKey(debt.mint),
|
171
|
+
padding1: [],
|
172
|
+
padding2: [],
|
173
|
+
padding: new Uint8Array([]),
|
174
|
+
},
|
175
|
+
netWorth: {
|
176
|
+
baseUnit: supply.price
|
177
|
+
? toBaseUnit((supplyUsd - debtUsd) / supply.price, supplyDecimals)
|
178
|
+
: BigInt(0),
|
179
|
+
baseAmountUsdValue: toRoundedUsdValue(supplyUsd - debtUsd),
|
180
|
+
},
|
181
|
+
maxLtvBps,
|
182
|
+
liqThresholdBps,
|
183
|
+
lastRefreshed: BigInt(currentUnixSeconds()),
|
184
|
+
padding1: [],
|
185
|
+
padding2: [],
|
186
|
+
padding: [],
|
187
|
+
};
|
188
|
+
}
|
package/src/types/solauto.ts
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
LendingPlatform,
|
4
|
+
PositionType,
|
5
|
+
SolautoRebalanceType,
|
6
|
+
TokenType,
|
7
|
+
} from "../generated";
|
3
8
|
import { TransactionBuilder } from "@metaplex-foundation/umi";
|
9
|
+
import { RebalanceValues } from "../services/rebalance";
|
10
|
+
import { QuoteResponse } from "@jup-ag/api";
|
4
11
|
|
5
12
|
export interface SolautoPositionDetails {
|
6
13
|
publicKey?: PublicKey;
|
@@ -22,7 +29,9 @@ export enum PriorityFeeSetting {
|
|
22
29
|
VeryHigh = "VeryHigh",
|
23
30
|
}
|
24
31
|
|
25
|
-
export const priorityFeeSettingValues = Object.values(
|
32
|
+
export const priorityFeeSettingValues = Object.values(
|
33
|
+
PriorityFeeSetting
|
34
|
+
) as PriorityFeeSetting[];
|
26
35
|
|
27
36
|
export type RebalanceAction = "boost" | "repay" | "dca";
|
28
37
|
|
@@ -33,3 +42,22 @@ export interface TransactionItemInputs {
|
|
33
42
|
lookupTableAddresses?: string[];
|
34
43
|
orderPrio?: number;
|
35
44
|
}
|
45
|
+
|
46
|
+
export interface FlashLoanRequirements {
|
47
|
+
liquiditySource: TokenType;
|
48
|
+
signerFlashLoan?: boolean;
|
49
|
+
flFeeBps?: number;
|
50
|
+
}
|
51
|
+
|
52
|
+
export interface FlashLoanDetails extends FlashLoanRequirements {
|
53
|
+
baseUnitAmount: bigint;
|
54
|
+
mint: PublicKey;
|
55
|
+
}
|
56
|
+
|
57
|
+
export interface RebalanceDetails {
|
58
|
+
values: RebalanceValues;
|
59
|
+
rebalanceType: SolautoRebalanceType;
|
60
|
+
flashLoan?: FlashLoanDetails;
|
61
|
+
swapQuote: QuoteResponse;
|
62
|
+
targetLiqUtilizationRateBps?: number;
|
63
|
+
}
|
@@ -4,7 +4,7 @@ import { TOKEN_INFO, TokenInfo } from "../constants";
|
|
4
4
|
import axios from "axios";
|
5
5
|
|
6
6
|
export function consoleLog(...args: any[]): void {
|
7
|
-
if ((globalThis as any).
|
7
|
+
if ((globalThis as any).SHOW_LOGS) {
|
8
8
|
console.log(...args);
|
9
9
|
}
|
10
10
|
}
|
@@ -36,6 +36,14 @@ export function tokenInfoByTicker(ticker: string) {
|
|
36
36
|
return undefined;
|
37
37
|
}
|
38
38
|
|
39
|
+
export function getBatches<T>(items: T[], batchSize: number): T[][] {
|
40
|
+
const batches: T[][] = [];
|
41
|
+
for (let i = 0; i < items.length; i += batchSize) {
|
42
|
+
batches.push(items.slice(i, i + batchSize));
|
43
|
+
}
|
44
|
+
return batches;
|
45
|
+
}
|
46
|
+
|
39
47
|
export function generateRandomU8(): number {
|
40
48
|
return Math.floor(Math.random() * 255 + 1);
|
41
49
|
}
|
package/src/utils/index.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
export * from "./solauto/index";
|
2
1
|
export * from "./accountUtils";
|
3
2
|
export * from "./generalUtils";
|
4
3
|
export * from "./jupiterUtils";
|
5
4
|
export * from "./marginfiUtils";
|
6
5
|
export * from "./numberUtils";
|
6
|
+
export * from "./solautoUtils";
|
7
7
|
export * from "./solanaUtils";
|
8
8
|
export * from "./stringUtils";
|
9
9
|
export * from "./priceUtils";
|
10
|
-
export * from "./switchboardUtils";
|
10
|
+
export * from "./switchboardUtils";
|
package/src/utils/jitoUtils.ts
CHANGED
@@ -3,12 +3,10 @@ import {
|
|
3
3
|
PublicKey,
|
4
4
|
SimulatedTransactionResponse,
|
5
5
|
TransactionExpiredBlockheightExceededError,
|
6
|
-
VersionedMessage,
|
7
6
|
VersionedTransaction,
|
8
7
|
} from "@solana/web3.js";
|
9
8
|
import { toWeb3JsTransaction } from "@metaplex-foundation/umi-web3js-adapters";
|
10
9
|
import {
|
11
|
-
JITO_BLOCK_ENGINE,
|
12
10
|
JITO_TIP_ACCOUNTS,
|
13
11
|
} from "../constants/solautoConstants";
|
14
12
|
import {
|
@@ -17,7 +15,6 @@ import {
|
|
17
15
|
Umi,
|
18
16
|
WrappedInstruction,
|
19
17
|
TransactionMessage,
|
20
|
-
AddressLookupTableInput,
|
21
18
|
} from "@metaplex-foundation/umi";
|
22
19
|
import {
|
23
20
|
assembleFinalTransaction,
|
@@ -31,7 +28,6 @@ import {
|
|
31
28
|
retryWithExponentialBackoff,
|
32
29
|
} from "./generalUtils";
|
33
30
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
34
|
-
import axios from "axios";
|
35
31
|
import base58 from "bs58";
|
36
32
|
import { BundleSimulationError } from "../types/transactions";
|
37
33
|
import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
|