@haven-fi/solauto-sdk 1.0.215 → 1.0.217
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/clients/referralStateManager.d.ts +6 -5
- package/dist/clients/referralStateManager.d.ts.map +1 -1
- package/dist/clients/referralStateManager.js +9 -10
- package/dist/clients/solautoClient.d.ts +8 -17
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +15 -42
- package/dist/clients/solautoMarginfiClient.d.ts +2 -2
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +20 -13
- package/dist/clients/txHandler.d.ts +1 -4
- package/dist/clients/txHandler.d.ts.map +1 -1
- package/dist/generated/instructions/marginfiRebalance.d.ts +1 -1
- package/dist/generated/instructions/marginfiRebalance.d.ts.map +1 -1
- package/dist/generated/types/index.d.ts +1 -0
- package/dist/generated/types/index.d.ts.map +1 -1
- package/dist/generated/types/index.js +1 -0
- package/dist/generated/types/rebalanceData.d.ts +3 -3
- package/dist/generated/types/rebalanceData.d.ts.map +1 -1
- package/dist/generated/types/rebalanceData.js +2 -2
- package/dist/generated/types/rebalanceDirection.d.ts +15 -0
- package/dist/generated/types/rebalanceDirection.d.ts.map +1 -0
- package/dist/generated/types/rebalanceDirection.js +22 -0
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +14 -13
- package/dist/utils/solauto/rebalanceUtils.d.ts +2 -0
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +1 -0
- package/package.json +1 -1
- package/src/clients/referralStateManager.ts +17 -15
- package/src/clients/solautoClient.ts +21 -75
- package/src/clients/solautoMarginfiClient.ts +31 -20
- package/src/clients/txHandler.ts +0 -5
- package/src/generated/instructions/marginfiRebalance.ts +1 -1
- package/src/generated/types/index.ts +1 -0
- package/src/generated/types/rebalanceData.ts +7 -5
- package/src/generated/types/rebalanceDirection.ts +25 -0
- package/src/transactions/transactionUtils.ts +19 -13
- package/src/utils/solauto/rebalanceUtils.ts +4 -0
- package/tests/transactions/solautoMarginfi.ts +4 -4
|
@@ -57,7 +57,11 @@ import {
|
|
|
57
57
|
eligibleForRebalance,
|
|
58
58
|
positionStateWithLatestPrices,
|
|
59
59
|
} from "../utils/solauto/generalUtils";
|
|
60
|
-
import {
|
|
60
|
+
import {
|
|
61
|
+
getReferralState,
|
|
62
|
+
getTokenAccount,
|
|
63
|
+
getTokenAccountData,
|
|
64
|
+
} from "../utils/accountUtils";
|
|
61
65
|
import {
|
|
62
66
|
createMarginfiProgram,
|
|
63
67
|
getLendingAccountBorrowInstructionDataSerializer,
|
|
@@ -139,19 +143,15 @@ async function transactionChoresBefore(
|
|
|
139
143
|
let chores = transactionBuilder();
|
|
140
144
|
|
|
141
145
|
if (
|
|
142
|
-
client.
|
|
143
|
-
(client.
|
|
144
|
-
client.
|
|
146
|
+
client.referralStateData === null ||
|
|
147
|
+
(client.referredBy !== undefined &&
|
|
148
|
+
client.referralStateData?.referredByState ===
|
|
145
149
|
publicKey(PublicKey.default)) ||
|
|
146
150
|
(client.authorityLutAddress !== undefined &&
|
|
147
|
-
client.
|
|
148
|
-
publicKey(PublicKey.default))
|
|
151
|
+
client.referralStateData!.lookupTable == publicKey(PublicKey.default))
|
|
149
152
|
) {
|
|
150
153
|
chores = chores.add(
|
|
151
|
-
client.
|
|
152
|
-
undefined,
|
|
153
|
-
client.authorityLutAddress
|
|
154
|
-
)
|
|
154
|
+
client.updateReferralStatesIx(undefined, client.authorityLutAddress)
|
|
155
155
|
);
|
|
156
156
|
}
|
|
157
157
|
|
|
@@ -275,7 +275,7 @@ export async function rebalanceChoresBefore(
|
|
|
275
275
|
.some((t) => t.keys.some((k) => toWeb3JsPublicKey(k.pubkey).equals(key)));
|
|
276
276
|
|
|
277
277
|
const checkReferralSupplyTa =
|
|
278
|
-
client.referredBySupplyTa && usesAccount(client.referredBySupplyTa);
|
|
278
|
+
client.referredBySupplyTa() && usesAccount(client.referredBySupplyTa()!);
|
|
279
279
|
const checkSolautoFeesTa = usesAccount(client.solautoFeesSupplyTa);
|
|
280
280
|
const checkIntermediaryMfiAccount =
|
|
281
281
|
client.lendingPlatform === LendingPlatform.Marginfi &&
|
|
@@ -286,7 +286,9 @@ export async function rebalanceChoresBefore(
|
|
|
286
286
|
const checkSignerDebtTa = usesAccount(client.signerDebtTa);
|
|
287
287
|
|
|
288
288
|
const accountsNeeded = [
|
|
289
|
-
...[
|
|
289
|
+
...[
|
|
290
|
+
checkReferralSupplyTa ? client.referredBySupplyTa() : PublicKey.default,
|
|
291
|
+
],
|
|
290
292
|
...[checkSolautoFeesTa ? client.solautoFeesSupplyTa : PublicKey.default],
|
|
291
293
|
...[
|
|
292
294
|
checkIntermediaryMfiAccount
|
|
@@ -314,7 +316,7 @@ export async function rebalanceChoresBefore(
|
|
|
314
316
|
chores = chores.add(
|
|
315
317
|
createAssociatedTokenAccountUmiIx(
|
|
316
318
|
client.signer,
|
|
317
|
-
client.
|
|
319
|
+
client.referredByState!,
|
|
318
320
|
client.supplyMint
|
|
319
321
|
)
|
|
320
322
|
);
|
|
@@ -704,6 +706,7 @@ export async function buildSolautoRebalanceTransaction(
|
|
|
704
706
|
"A",
|
|
705
707
|
jupQuote,
|
|
706
708
|
rebalanceType,
|
|
709
|
+
values,
|
|
707
710
|
flashLoan,
|
|
708
711
|
targetLiqUtilizationRateBps
|
|
709
712
|
),
|
|
@@ -714,6 +717,7 @@ export async function buildSolautoRebalanceTransaction(
|
|
|
714
717
|
"B",
|
|
715
718
|
jupQuote,
|
|
716
719
|
rebalanceType,
|
|
720
|
+
values,
|
|
717
721
|
flashLoan,
|
|
718
722
|
targetLiqUtilizationRateBps
|
|
719
723
|
),
|
|
@@ -728,6 +732,7 @@ export async function buildSolautoRebalanceTransaction(
|
|
|
728
732
|
"A",
|
|
729
733
|
jupQuote,
|
|
730
734
|
rebalanceType,
|
|
735
|
+
values,
|
|
731
736
|
undefined,
|
|
732
737
|
targetLiqUtilizationRateBps
|
|
733
738
|
),
|
|
@@ -736,6 +741,7 @@ export async function buildSolautoRebalanceTransaction(
|
|
|
736
741
|
"B",
|
|
737
742
|
jupQuote,
|
|
738
743
|
rebalanceType,
|
|
744
|
+
values,
|
|
739
745
|
undefined,
|
|
740
746
|
targetLiqUtilizationRateBps
|
|
741
747
|
),
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
toBaseUnit,
|
|
28
28
|
} from "../numberUtils";
|
|
29
29
|
import { USD_DECIMALS } from "../../constants/generalAccounts";
|
|
30
|
+
import { RebalanceAction } from "../../types";
|
|
30
31
|
|
|
31
32
|
function getAdditionalAmountToDcaIn(dca: DCASettings): number {
|
|
32
33
|
if (dca.dcaInBaseUnit === BigInt(0)) {
|
|
@@ -163,6 +164,7 @@ export interface RebalanceValues {
|
|
|
163
164
|
amountToDcaIn: number;
|
|
164
165
|
amountUsdToDcaIn: number;
|
|
165
166
|
dcaTokenType?: TokenType;
|
|
167
|
+
rebalanceAction: RebalanceAction;
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
export function getRebalanceValues(
|
|
@@ -221,6 +223,8 @@ export function getRebalanceValues(
|
|
|
221
223
|
amountToDcaIn: amountToDcaIn ?? 0,
|
|
222
224
|
amountUsdToDcaIn,
|
|
223
225
|
dcaTokenType: dca?.tokenType,
|
|
226
|
+
rebalanceAction:
|
|
227
|
+
(amountToDcaIn ?? 0) > 0 ? "dca" : increasingLeverage ? "boost" : "repay",
|
|
224
228
|
};
|
|
225
229
|
}
|
|
226
230
|
|
|
@@ -25,10 +25,10 @@ import { buildHeliusApiUrl } from "../../src/utils";
|
|
|
25
25
|
import { PriorityFeeSetting } from "../../src/types";
|
|
26
26
|
|
|
27
27
|
describe("Solauto Marginfi tests", async () => {
|
|
28
|
-
const signer = setupTest();
|
|
29
|
-
|
|
28
|
+
// const signer = setupTest();
|
|
29
|
+
const signer = setupTest("solauto-manager");
|
|
30
30
|
|
|
31
|
-
const payForTransactions =
|
|
31
|
+
const payForTransactions = false;
|
|
32
32
|
const useJitoBundle = false;
|
|
33
33
|
const positionId = 1;
|
|
34
34
|
|
|
@@ -128,7 +128,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
128
128
|
transactionItems.push(
|
|
129
129
|
new TransactionItem(
|
|
130
130
|
async (attemptNum) =>
|
|
131
|
-
await buildSolautoRebalanceTransaction(client,
|
|
131
|
+
await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
|
|
132
132
|
"rebalance"
|
|
133
133
|
)
|
|
134
134
|
);
|