@haven-fi/solauto-sdk 1.0.51 → 1.0.53

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. package/dist/clients/solautoClient.d.ts.map +1 -1
  2. package/dist/clients/solautoClient.js +1 -7
  3. package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
  4. package/dist/clients/solautoMarginfiClient.js +3 -1
  5. package/dist/generated/accounts/referralState.d.ts.map +1 -1
  6. package/dist/generated/accounts/referralState.js +8 -9
  7. package/dist/generated/accounts/solautoPosition.d.ts.map +1 -1
  8. package/dist/generated/accounts/solautoPosition.js +8 -9
  9. package/dist/generated/errors/solauto.js +3 -3
  10. package/dist/generated/instructions/cancelDCA.js +2 -3
  11. package/dist/generated/instructions/claimReferralFees.js +2 -3
  12. package/dist/generated/instructions/closePosition.js +2 -3
  13. package/dist/generated/instructions/convertReferralFees.js +2 -3
  14. package/dist/generated/instructions/marginfiOpenPosition.d.ts +1 -0
  15. package/dist/generated/instructions/marginfiOpenPosition.d.ts.map +1 -1
  16. package/dist/generated/instructions/marginfiOpenPosition.js +22 -18
  17. package/dist/generated/instructions/marginfiProtocolInteraction.js +2 -3
  18. package/dist/generated/instructions/marginfiRebalance.js +2 -3
  19. package/dist/generated/instructions/marginfiRefreshData.js +2 -3
  20. package/dist/generated/instructions/updatePosition.js +2 -3
  21. package/dist/generated/instructions/updateReferralStates.js +2 -3
  22. package/dist/generated/programs/solauto.d.ts.map +1 -1
  23. package/dist/generated/programs/solauto.js +4 -4
  24. package/dist/generated/shared/index.js +4 -5
  25. package/dist/generated/types/automationSettings.js +1 -2
  26. package/dist/generated/types/automationSettingsInp.js +1 -2
  27. package/dist/generated/types/dCASettings.js +1 -2
  28. package/dist/generated/types/dCASettingsInp.js +1 -2
  29. package/dist/generated/types/feeType.js +3 -3
  30. package/dist/generated/types/lendingPlatform.js +3 -3
  31. package/dist/generated/types/podBool.js +1 -2
  32. package/dist/generated/types/positionData.js +1 -2
  33. package/dist/generated/types/positionState.js +1 -2
  34. package/dist/generated/types/positionTokenUsage.js +1 -2
  35. package/dist/generated/types/rebalanceData.js +1 -2
  36. package/dist/generated/types/solautoAction.js +3 -4
  37. package/dist/generated/types/solautoRebalanceType.js +3 -3
  38. package/dist/generated/types/solautoSettingsParameters.js +1 -2
  39. package/dist/generated/types/solautoSettingsParametersInp.js +1 -2
  40. package/dist/generated/types/tokenAmount.js +1 -2
  41. package/dist/generated/types/tokenBalanceAmount.js +3 -4
  42. package/dist/generated/types/updatePositionData.js +1 -2
  43. package/dist/marginfi-sdk/accounts/bank.d.ts.map +1 -1
  44. package/dist/marginfi-sdk/accounts/bank.js +8 -9
  45. package/dist/marginfi-sdk/accounts/marginfiAccount.d.ts.map +1 -1
  46. package/dist/marginfi-sdk/accounts/marginfiAccount.js +8 -9
  47. package/dist/marginfi-sdk/accounts/marginfiGroup.d.ts.map +1 -1
  48. package/dist/marginfi-sdk/accounts/marginfiGroup.js +8 -9
  49. package/dist/marginfi-sdk/errors/marginfi.js +3 -3
  50. package/dist/marginfi-sdk/instructions/lendingAccountBorrow.js +2 -3
  51. package/dist/marginfi-sdk/instructions/lendingAccountCloseBalance.js +2 -3
  52. package/dist/marginfi-sdk/instructions/lendingAccountDeposit.js +2 -3
  53. package/dist/marginfi-sdk/instructions/lendingAccountEndFlashloan.js +2 -3
  54. package/dist/marginfi-sdk/instructions/lendingAccountLiquidate.js +2 -3
  55. package/dist/marginfi-sdk/instructions/lendingAccountRepay.js +2 -3
  56. package/dist/marginfi-sdk/instructions/lendingAccountSettleEmissions.js +2 -3
  57. package/dist/marginfi-sdk/instructions/lendingAccountStartFlashloan.js +2 -3
  58. package/dist/marginfi-sdk/instructions/lendingAccountWithdraw.js +2 -3
  59. package/dist/marginfi-sdk/instructions/lendingAccountWithdrawEmissions.js +2 -3
  60. package/dist/marginfi-sdk/instructions/lendingPoolAccrueBankInterest.js +2 -3
  61. package/dist/marginfi-sdk/instructions/lendingPoolAddBank.js +2 -3
  62. package/dist/marginfi-sdk/instructions/lendingPoolAddBankWithSeed.js +2 -3
  63. package/dist/marginfi-sdk/instructions/lendingPoolCollectBankFees.js +2 -3
  64. package/dist/marginfi-sdk/instructions/lendingPoolConfigureBank.js +2 -3
  65. package/dist/marginfi-sdk/instructions/lendingPoolHandleBankruptcy.js +2 -3
  66. package/dist/marginfi-sdk/instructions/lendingPoolSetupEmissions.js +2 -3
  67. package/dist/marginfi-sdk/instructions/lendingPoolUpdateEmissionsParameters.js +2 -3
  68. package/dist/marginfi-sdk/instructions/marginfiAccountInitialize.js +2 -3
  69. package/dist/marginfi-sdk/instructions/marginfiGroupConfigure.js +2 -3
  70. package/dist/marginfi-sdk/instructions/marginfiGroupInitialize.js +2 -3
  71. package/dist/marginfi-sdk/instructions/setAccountFlag.js +2 -3
  72. package/dist/marginfi-sdk/instructions/setNewAccountAuthority.js +2 -3
  73. package/dist/marginfi-sdk/instructions/unsetAccountFlag.js +2 -3
  74. package/dist/marginfi-sdk/programs/marginfi.d.ts.map +1 -1
  75. package/dist/marginfi-sdk/programs/marginfi.js +4 -4
  76. package/dist/marginfi-sdk/shared/index.js +4 -5
  77. package/dist/marginfi-sdk/types/accountEventHeader.js +1 -2
  78. package/dist/marginfi-sdk/types/balance.js +1 -2
  79. package/dist/marginfi-sdk/types/balanceDecreaseType.js +3 -3
  80. package/dist/marginfi-sdk/types/balanceIncreaseType.js +3 -3
  81. package/dist/marginfi-sdk/types/balanceSide.js +3 -3
  82. package/dist/marginfi-sdk/types/bankConfig.js +1 -2
  83. package/dist/marginfi-sdk/types/bankConfigCompact.js +1 -2
  84. package/dist/marginfi-sdk/types/bankOperationalState.js +3 -3
  85. package/dist/marginfi-sdk/types/bankVaultType.js +3 -3
  86. package/dist/marginfi-sdk/types/groupEventHeader.js +1 -2
  87. package/dist/marginfi-sdk/types/interestRateConfig.js +1 -2
  88. package/dist/marginfi-sdk/types/interestRateConfigCompact.js +1 -2
  89. package/dist/marginfi-sdk/types/interestRateConfigOpt.js +1 -2
  90. package/dist/marginfi-sdk/types/lendingAccount.js +1 -2
  91. package/dist/marginfi-sdk/types/liquidationBalances.js +1 -2
  92. package/dist/marginfi-sdk/types/oracleConfig.js +1 -2
  93. package/dist/marginfi-sdk/types/oraclePriceType.js +3 -3
  94. package/dist/marginfi-sdk/types/oracleSetup.js +3 -3
  95. package/dist/marginfi-sdk/types/priceBias.js +3 -3
  96. package/dist/marginfi-sdk/types/requirementType.js +3 -3
  97. package/dist/marginfi-sdk/types/riskRequirementType.js +3 -3
  98. package/dist/marginfi-sdk/types/riskTier.js +3 -3
  99. package/dist/marginfi-sdk/types/wrappedI80F48.js +1 -2
  100. package/dist/transactions/transactionUtils.js +5 -6
  101. package/dist/transactions/transactionsManager.d.ts.map +1 -1
  102. package/dist/transactions/transactionsManager.js +1 -1
  103. package/dist/types/solauto.d.ts +1 -0
  104. package/dist/types/solauto.d.ts.map +1 -1
  105. package/dist/types/solauto.js +1 -1
  106. package/dist/utils/accountUtils.d.ts +0 -1
  107. package/dist/utils/accountUtils.d.ts.map +1 -1
  108. package/dist/utils/accountUtils.js +7 -8
  109. package/dist/utils/generalUtils.js +8 -9
  110. package/dist/utils/jupiterUtils.js +1 -2
  111. package/dist/utils/marginfiUtils.js +5 -6
  112. package/dist/utils/numberUtils.js +11 -12
  113. package/dist/utils/solanaUtils.js +13 -14
  114. package/dist/utils/solauto/generalUtils.d.ts +2 -2
  115. package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
  116. package/dist/utils/solauto/generalUtils.js +19 -20
  117. package/dist/utils/solauto/rebalanceUtils.js +3 -4
  118. package/package.json +3 -2
  119. package/src/clients/solautoClient.ts +1 -10
  120. package/src/clients/solautoMarginfiClient.ts +2 -0
  121. package/src/generated/instructions/marginfiOpenPosition.ts +21 -15
  122. package/src/transactions/transactionUtils.ts +2 -2
  123. package/src/types/solauto.ts +3 -1
  124. package/src/utils/solauto/generalUtils.ts +8 -9
@@ -27,7 +27,7 @@ import {
27
27
  getAllMarginfiAccountsByAuthority,
28
28
  getMarginfiAccountPositionState,
29
29
  } from "../marginfiUtils";
30
- import { SolautoPositionDetails } from "../../types/solauto";
30
+ import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
31
31
 
32
32
  function newPeriodsPassed(
33
33
  automation: AutomationSettings,
@@ -118,20 +118,20 @@ export function getSolautoFeesBps(
118
118
  };
119
119
  }
120
120
 
121
- export function eligibileForRebalance(
121
+ export function eligibleForRebalance(
122
122
  positionState: PositionState,
123
123
  positionSettings: SolautoSettingsParameters,
124
124
  positionDca: DCASettings
125
- ): boolean {
125
+ ): RebalanceAction | undefined {
126
126
  if (
127
127
  positionDca.automation.targetPeriods > 0 &&
128
128
  eligibleForNextAutomationPeriod(positionDca.automation)
129
129
  ) {
130
- return true;
130
+ return 'dca';
131
131
  }
132
132
 
133
133
  if (positionState.supply.amountUsed.baseUnit === BigInt(0)) {
134
- return false;
134
+ return undefined;
135
135
  }
136
136
 
137
137
  const boostToBps =
@@ -148,15 +148,14 @@ export function eligibileForRebalance(
148
148
  const boostFrom = boostToBps - positionSettings.boostGap;
149
149
 
150
150
  if (positionState.liqUtilizationRateBps <= boostFrom) {
151
- return true;
151
+ return 'boost';
152
152
  } else if (
153
153
  positionState.liqUtilizationRateBps >= repayFrom
154
154
  ) {
155
- console.log(`Requires repay ${positionState.liqUtilizationRateBps} > ${repayFrom}`);
156
- return true;
155
+ return 'repay';
157
156
  }
158
157
 
159
- return false;
158
+ return undefined;
160
159
  }
161
160
 
162
161
  export function eligibleForRefresh(