@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.
Files changed (39) hide show
  1. package/dist/clients/referralStateManager.d.ts +6 -5
  2. package/dist/clients/referralStateManager.d.ts.map +1 -1
  3. package/dist/clients/referralStateManager.js +9 -10
  4. package/dist/clients/solautoClient.d.ts +8 -17
  5. package/dist/clients/solautoClient.d.ts.map +1 -1
  6. package/dist/clients/solautoClient.js +15 -42
  7. package/dist/clients/solautoMarginfiClient.d.ts +2 -2
  8. package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
  9. package/dist/clients/solautoMarginfiClient.js +20 -13
  10. package/dist/clients/txHandler.d.ts +1 -4
  11. package/dist/clients/txHandler.d.ts.map +1 -1
  12. package/dist/generated/instructions/marginfiRebalance.d.ts +1 -1
  13. package/dist/generated/instructions/marginfiRebalance.d.ts.map +1 -1
  14. package/dist/generated/types/index.d.ts +1 -0
  15. package/dist/generated/types/index.d.ts.map +1 -1
  16. package/dist/generated/types/index.js +1 -0
  17. package/dist/generated/types/rebalanceData.d.ts +3 -3
  18. package/dist/generated/types/rebalanceData.d.ts.map +1 -1
  19. package/dist/generated/types/rebalanceData.js +2 -2
  20. package/dist/generated/types/rebalanceDirection.d.ts +15 -0
  21. package/dist/generated/types/rebalanceDirection.d.ts.map +1 -0
  22. package/dist/generated/types/rebalanceDirection.js +22 -0
  23. package/dist/transactions/transactionUtils.d.ts.map +1 -1
  24. package/dist/transactions/transactionUtils.js +14 -13
  25. package/dist/utils/solauto/rebalanceUtils.d.ts +2 -0
  26. package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
  27. package/dist/utils/solauto/rebalanceUtils.js +1 -0
  28. package/package.json +1 -1
  29. package/src/clients/referralStateManager.ts +17 -15
  30. package/src/clients/solautoClient.ts +21 -75
  31. package/src/clients/solautoMarginfiClient.ts +31 -20
  32. package/src/clients/txHandler.ts +0 -5
  33. package/src/generated/instructions/marginfiRebalance.ts +1 -1
  34. package/src/generated/types/index.ts +1 -0
  35. package/src/generated/types/rebalanceData.ts +7 -5
  36. package/src/generated/types/rebalanceDirection.ts +25 -0
  37. package/src/transactions/transactionUtils.ts +19 -13
  38. package/src/utils/solauto/rebalanceUtils.ts +4 -0
  39. 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 { getReferralState, getTokenAccount, getTokenAccountData } from "../utils/accountUtils";
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.referralStateManager.referralStateData === null ||
143
- (client.referralStateManager.referredBy !== undefined &&
144
- client.referralStateManager.referralStateData?.referredByState ===
146
+ client.referralStateData === null ||
147
+ (client.referredBy !== undefined &&
148
+ client.referralStateData?.referredByState ===
145
149
  publicKey(PublicKey.default)) ||
146
150
  (client.authorityLutAddress !== undefined &&
147
- client.referralStateManager.referralStateData!.lookupTable ==
148
- publicKey(PublicKey.default))
151
+ client.referralStateData!.lookupTable == publicKey(PublicKey.default))
149
152
  ) {
150
153
  chores = chores.add(
151
- client.referralStateManager.updateReferralStatesIx(
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
- ...[checkReferralSupplyTa ? client.referredBySupplyTa : PublicKey.default],
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.referralStateManager.referredByState!,
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
- // const signer = setupTest("solauto-manager");
28
+ // const signer = setupTest();
29
+ const signer = setupTest("solauto-manager");
30
30
 
31
- const payForTransactions = true;
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, 7000, attemptNum),
131
+ await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
132
132
  "rebalance"
133
133
  )
134
134
  );