@strkfarm/sdk 2.0.0-dev.16 → 2.0.0-dev.17

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/index.js CHANGED
@@ -49,6 +49,7 @@ __export(index_exports, {
49
49
  BaseStrategy: () => BaseStrategy,
50
50
  CommonAdapter: () => CommonAdapter,
51
51
  ContractAddr: () => ContractAddr,
52
+ CycleType: () => CycleType,
52
53
  Deployer: () => deployer_default,
53
54
  ERC20: () => ERC20,
54
55
  EXTENDED_CONTRACT: () => EXTENDED_CONTRACT,
@@ -34421,6 +34422,16 @@ var HyperLSTStrategies = [
34421
34422
  getStrategySettings("mRe7YIELD", "mRe7YIELD", hypermRe7YIELD, false, false)
34422
34423
  ];
34423
34424
 
34425
+ // src/strategies/vesu-extended-strategy/types/transaction-metadata.ts
34426
+ var CycleType = /* @__PURE__ */ ((CycleType2) => {
34427
+ CycleType2["INVESTMENT"] = "INVESTMENT";
34428
+ CycleType2["REBALANCE_PRICE_DROP"] = "REBALANCE_PRICE_DROP";
34429
+ CycleType2["REBALANCE_PRICE_RISE"] = "REBALANCE_PRICE_RISE";
34430
+ CycleType2["WITHDRAWAL"] = "WITHDRAWAL";
34431
+ CycleType2["DELTA_NEUTRAL_ADJUSTMENT"] = "DELTA_NEUTRAL_ADJUSTMENT";
34432
+ return CycleType2;
34433
+ })(CycleType || {});
34434
+
34424
34435
  // src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx
34425
34436
  var import_jsx_runtime5 = require("react/jsx-runtime");
34426
34437
  var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy extends SVKStrategy {
@@ -34802,7 +34813,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34802
34813
  {
34803
34814
  to: Protocols.VAULT.name,
34804
34815
  from: Protocols.EXTENDED.name,
34805
- amount: extendedAmount.abs()
34816
+ amount: extendedAmount.abs(),
34817
+ cycleType: "INVESTMENT" /* INVESTMENT */
34806
34818
  },
34807
34819
  extendedAdapter,
34808
34820
  vesuAdapter
@@ -34817,11 +34829,11 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34817
34829
  }
34818
34830
  });
34819
34831
  } else {
34820
- return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: extendedAmount.abs() }, "NONE")];
34832
+ return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: extendedAmount.abs() }, "NONE", "INVESTMENT" /* INVESTMENT */)];
34821
34833
  }
34822
34834
  } catch (err) {
34823
34835
  logger.error(`Failed moving assets to vault: ${err}`);
34824
- return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: extendedAmount.abs() }, "NONE")];
34836
+ return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: extendedAmount.abs() }, "NONE", "INVESTMENT" /* INVESTMENT */)];
34825
34837
  }
34826
34838
  }
34827
34839
  if (vesuAmount.isNegative() && vesuAmount.abs().greaterThan(vesuAdapter.minimumVesuMovementAmount)) {
@@ -34830,13 +34842,14 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34830
34842
  {
34831
34843
  to: Protocols.EXTENDED.name,
34832
34844
  from: Protocols.VESU.name,
34833
- amount: vesuAmount.abs()
34845
+ amount: vesuAmount.abs(),
34846
+ cycleType: "INVESTMENT" /* INVESTMENT */
34834
34847
  },
34835
34848
  extendedAdapter,
34836
34849
  vesuAdapter
34837
34850
  );
34838
34851
  if (!vesuStatus) {
34839
- return [this.createTransactionResult([], false, { from: Protocols.VESU.name, to: Protocols.EXTENDED.name, amount: vesuAmount.abs() }, "NONE")];
34852
+ return [this.createTransactionResult([], false, { from: Protocols.VESU.name, to: Protocols.EXTENDED.name, amount: vesuAmount.abs() }, "NONE", "INVESTMENT" /* INVESTMENT */)];
34840
34853
  }
34841
34854
  transactionResults.push({
34842
34855
  status: vesuStatus,
@@ -34848,7 +34861,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34848
34861
  });
34849
34862
  } catch (err) {
34850
34863
  logger.error(`Failed moving assets to extended via vault allocator: ${err}`);
34851
- return [this.createTransactionResult([], false, { from: Protocols.VESU.name, to: Protocols.EXTENDED.name, amount: vesuAmount.abs() }, "NONE")];
34864
+ return [this.createTransactionResult([], false, { from: Protocols.VESU.name, to: Protocols.EXTENDED.name, amount: vesuAmount.abs() }, "NONE", "INVESTMENT" /* INVESTMENT */)];
34852
34865
  }
34853
34866
  }
34854
34867
  if (extendedAmountDifferenceAbs.greaterThan(extendedAdapter.minimumExtendedMovementAmount)) {
@@ -34858,7 +34871,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34858
34871
  {
34859
34872
  to: Protocols.EXTENDED.name,
34860
34873
  from: Protocols.VAULT.name,
34861
- amount: extendedAmountDifference
34874
+ amount: extendedAmountDifference,
34875
+ cycleType: "INVESTMENT" /* INVESTMENT */
34862
34876
  },
34863
34877
  extendedAdapter,
34864
34878
  vesuAdapter
@@ -34871,11 +34885,11 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34871
34885
  });
34872
34886
  } else {
34873
34887
  logger.error(`Failed to move assets to extended - operation returned false status`);
34874
- return [this.createTransactionResult([], false, { from: Protocols.VAULT.name, to: Protocols.EXTENDED.name, amount: extendedAmountDifference }, "NONE")];
34888
+ return [this.createTransactionResult([], false, { from: Protocols.VAULT.name, to: Protocols.EXTENDED.name, amount: extendedAmountDifference }, "NONE", "INVESTMENT" /* INVESTMENT */)];
34875
34889
  }
34876
34890
  } catch (err) {
34877
34891
  logger.error(`Failed moving assets to extended: ${err}`);
34878
- return [this.createTransactionResult([], false, { from: Protocols.VAULT.name, to: Protocols.EXTENDED.name, amount: extendedAmountDifference }, "NONE")];
34892
+ return [this.createTransactionResult([], false, { from: Protocols.VAULT.name, to: Protocols.EXTENDED.name, amount: extendedAmountDifference }, "NONE", "INVESTMENT" /* INVESTMENT */)];
34879
34893
  }
34880
34894
  } else if (extendedAmountDifference.lessThan(0)) {
34881
34895
  try {
@@ -34883,7 +34897,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34883
34897
  {
34884
34898
  to: Protocols.VAULT.name,
34885
34899
  from: Protocols.EXTENDED.name,
34886
- amount: extendedAmountDifferenceAbs
34900
+ amount: extendedAmountDifferenceAbs,
34901
+ cycleType: "INVESTMENT" /* INVESTMENT */
34887
34902
  },
34888
34903
  extendedAdapter,
34889
34904
  vesuAdapter
@@ -34899,11 +34914,11 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34899
34914
  });
34900
34915
  } else {
34901
34916
  logger.error(`Failed to withdraw from extended - operation returned false status`);
34902
- return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: extendedAmountDifferenceAbs }, "NONE")];
34917
+ return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: extendedAmountDifferenceAbs }, "NONE", "INVESTMENT" /* INVESTMENT */)];
34903
34918
  }
34904
34919
  } catch (err) {
34905
34920
  logger.error(`Failed moving assets from extended to vault: ${err}`);
34906
- return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: extendedAmountDifferenceAbs }, "NONE")];
34921
+ return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: extendedAmountDifferenceAbs }, "NONE", "INVESTMENT" /* INVESTMENT */)];
34907
34922
  }
34908
34923
  }
34909
34924
  }
@@ -34918,14 +34933,15 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34918
34933
  {
34919
34934
  to: Protocols.VAULT.name,
34920
34935
  from: Protocols.EXTENDED.name,
34921
- amount: vesuAmountDifference
34936
+ amount: vesuAmountDifference,
34937
+ cycleType: "INVESTMENT" /* INVESTMENT */
34922
34938
  },
34923
34939
  extendedAdapter,
34924
34940
  vesuAdapter
34925
34941
  );
34926
34942
  if (!vesuStatus) {
34927
34943
  logger.error(`Failed to move assets to vesu - operation returned false status`);
34928
- return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: vesuAmountDifference }, "NONE")];
34944
+ return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: vesuAmountDifference }, "NONE", "INVESTMENT" /* INVESTMENT */)];
34929
34945
  }
34930
34946
  transactionResults.push({
34931
34947
  status: vesuStatus,
@@ -34937,20 +34953,20 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34937
34953
  });
34938
34954
  } catch (err) {
34939
34955
  logger.error(`Failed moving assets to vault: ${err}`);
34940
- return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: vesuAmountDifference }, "NONE")];
34956
+ return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: vesuAmountDifference }, "NONE", "INVESTMENT" /* INVESTMENT */)];
34941
34957
  }
34942
34958
  }
34943
34959
  }
34944
34960
  return transactionResults;
34945
34961
  } catch (err) {
34946
34962
  logger.error(`Failed moving assets to vesu: ${err}`);
34947
- return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: new Web3Number(0, USDC_TOKEN_DECIMALS) }, "NONE")];
34963
+ return [this.createTransactionResult([], false, { from: Protocols.EXTENDED.name, to: Protocols.VAULT.name, amount: new Web3Number(0, USDC_TOKEN_DECIMALS) }, "NONE", "INVESTMENT" /* INVESTMENT */)];
34948
34964
  }
34949
34965
  }
34950
34966
  /**
34951
34967
  * Helper method to create transaction result with metadata
34952
34968
  */
34953
- createTransactionResult(calls, status, params, transactionType) {
34969
+ createTransactionResult(calls, status, params, transactionType, cycleType) {
34954
34970
  if (status) {
34955
34971
  return {
34956
34972
  calls,
@@ -34960,11 +34976,12 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34960
34976
  protocolTo: params.to,
34961
34977
  transactionType,
34962
34978
  usdAmount: params.amount.abs().toFixed(),
34963
- status: "PENDING"
34979
+ status: "PENDING",
34980
+ cycleType
34964
34981
  }
34965
34982
  };
34966
34983
  }
34967
- return { calls: [], status: false, transactionMetadata: { protocolFrom: "", protocolTo: "", transactionType: "DEPOSIT", usdAmount: "0", status: "FAILED" } };
34984
+ return { calls: [], status: false, transactionMetadata: { protocolFrom: "", protocolTo: "", transactionType: "DEPOSIT", usdAmount: "0", status: "FAILED", cycleType } };
34968
34985
  }
34969
34986
  async moveAssets(params, extendedAdapter, vesuAdapter) {
34970
34987
  try {
@@ -34972,7 +34989,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34972
34989
  logger.error(
34973
34990
  `Invalid amount for moveAssets: ${params.amount.toNumber()}. Amount must be positive.`
34974
34991
  );
34975
- return this.createTransactionResult([], false, params, "NONE");
34992
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
34976
34993
  }
34977
34994
  const amountAbs = params.amount.abs();
34978
34995
  if (params.from === Protocols.EXTENDED.name || params.to === Protocols.EXTENDED.name) {
@@ -34980,7 +34997,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34980
34997
  logger.warn(
34981
34998
  `Amount ${amountAbs.toNumber()} is below minimum Extended movement amount ${extendedAdapter.minimumExtendedMovementAmount}. Skipping operation.`
34982
34999
  );
34983
- return this.createTransactionResult([], false, params, "NONE");
35000
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
34984
35001
  }
34985
35002
  }
34986
35003
  if (params.from === Protocols.VESU.name || params.to === Protocols.VESU.name) {
@@ -34988,13 +35005,13 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34988
35005
  logger.warn(
34989
35006
  `Amount ${amountAbs.toNumber()} is below minimum Vesu movement amount ${vesuAdapter.minimumVesuMovementAmount}. Skipping operation.`
34990
35007
  );
34991
- return this.createTransactionResult([], false, params, "NONE");
35008
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
34992
35009
  }
34993
35010
  }
34994
35011
  const avnuAdapter = await this.getAvnuAdapter();
34995
35012
  if (!avnuAdapter) {
34996
35013
  logger.error(`avnu adapter not found: ${avnuAdapter}`);
34997
- return this.createTransactionResult([], false, params, "NONE");
35014
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
34998
35015
  }
34999
35016
  logger.info(`moveAssets params, ${JSON.stringify(params)}`);
35000
35017
  const collateralToken = vesuAdapter.config.supportedPositions[0].asset;
@@ -35013,13 +35030,13 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35013
35030
  await proofsInfo.callConstructor({ amount: params.amount })
35014
35031
  );
35015
35032
  calls.push(call);
35016
- return this.createTransactionResult(calls, true, params, "DEPOSIT");
35033
+ return this.createTransactionResult(calls, true, params, "DEPOSIT", params.cycleType);
35017
35034
  } else if (params.to === Protocols.VAULT.name && params.from === Protocols.EXTENDED.name) {
35018
35035
  const extendedLeverage = calculateExtendedLevergae();
35019
35036
  const extendedHoldings = await extendedAdapter.getExtendedDepositAmount();
35020
35037
  if (!extendedHoldings) {
35021
35038
  logger.error(`error getting extended holdings: ${extendedHoldings}`);
35022
- return this.createTransactionResult([], false, params, "NONE");
35039
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35023
35040
  }
35024
35041
  const extendedHoldingAmount = new Web3Number(
35025
35042
  extendedHoldings.availableForWithdrawal,
@@ -35036,7 +35053,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35036
35053
  "BUY" /* BUY */
35037
35054
  ) : await extendedAdapter.createOrder(
35038
35055
  extendedLeverage.toString(),
35039
- 35e-6,
35056
+ 34e-6,
35040
35057
  // just in case amount falls short then we need to create a withdrawal
35041
35058
  "BUY" /* BUY */
35042
35059
  );
@@ -35046,7 +35063,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35046
35063
  const updatedHoldings = await extendedAdapter.getExtendedDepositAmount();
35047
35064
  if (!updatedHoldings || new Web3Number(updatedHoldings.availableForWithdrawal, USDC_TOKEN_DECIMALS).lessThan(params.amount.abs())) {
35048
35065
  logger.error(`Insufficient balance after opening position. Available: ${updatedHoldings?.availableForWithdrawal}, Needed: ${params.amount.abs()}`);
35049
- return this.createTransactionResult([], false, params, "NONE");
35066
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35050
35067
  }
35051
35068
  }
35052
35069
  const {
@@ -35060,22 +35077,22 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35060
35077
  await new Promise((resolve) => setTimeout(resolve, 5e3));
35061
35078
  const { calls, status } = await this.moveAssetsToVaultAllocator(params.amount, extendedAdapter);
35062
35079
  if (calls.length > 0 && status) {
35063
- return this.createTransactionResult(calls, true, params, "WITHDRAWAL");
35080
+ return this.createTransactionResult(calls, true, params, "WITHDRAWAL", params.cycleType);
35064
35081
  } else {
35065
- return this.createTransactionResult([], true, params, "WITHDRAWAL");
35082
+ return this.createTransactionResult([], true, params, "WITHDRAWAL", params.cycleType);
35066
35083
  }
35067
35084
  } else if (withdrawalFromExtendedStatus && !withdrawalFromExtendedTxnHash) {
35068
35085
  logger.error("withdrawal from extended successful, but funds didn't get transferred to the wallet");
35069
- return this.createTransactionResult([], true, params, "WITHDRAWAL");
35086
+ return this.createTransactionResult([], true, params, "WITHDRAWAL", params.cycleType);
35070
35087
  } else {
35071
35088
  logger.error("withdrawal from extended failed");
35072
- return this.createTransactionResult([], false, params, "NONE");
35089
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35073
35090
  }
35074
35091
  } else if (params.to === Protocols.VAULT.name && params.from === Protocols.VESU.name) {
35075
35092
  const isPriceDifferenceBetweenAvnuAndExtended = await this.checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter, vesuAdapter, avnuAdapter, "close" /* CLOSE */);
35076
35093
  if (!isPriceDifferenceBetweenAvnuAndExtended) {
35077
35094
  logger.warn(`price difference between avnu and extended doesn't fit the range for close position, ${avnuAdapter.config.maximumExtendedPriceDifferenceForSwapClosing}`);
35078
- return this.createTransactionResult([], false, params, "NONE");
35095
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35079
35096
  }
35080
35097
  const vesuAmountInBTC = new Web3Number(
35081
35098
  params.amount.dividedBy(collateralPrice.price).toFixed(WBTC_TOKEN_DECIMALS),
@@ -35096,12 +35113,12 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35096
35113
  await swapProofsInfo.callConstructor({ amount: vesuAmountInBTC })
35097
35114
  );
35098
35115
  calls.push(swapCall);
35099
- return this.createTransactionResult(calls, true, params, "WITHDRAWAL");
35116
+ return this.createTransactionResult(calls, true, params, "WITHDRAWAL", params.cycleType);
35100
35117
  } else if (params.to === Protocols.EXTENDED.name && params.from === Protocols.VESU.name) {
35101
35118
  const isPriceDifferenceBetweenAvnuAndExtended = await this.checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter, vesuAdapter, avnuAdapter, "close" /* CLOSE */);
35102
35119
  if (!isPriceDifferenceBetweenAvnuAndExtended) {
35103
35120
  logger.warn(`price difference between avnu and extended doesn't fit the range for close position, ${avnuAdapter.config.maximumExtendedPriceDifferenceForSwapClosing}`);
35104
- return this.createTransactionResult([], false, params, "NONE");
35121
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35105
35122
  }
35106
35123
  const vesuAmountInBTC = new Web3Number(
35107
35124
  params.amount.dividedBy(collateralPrice.price).toNumber(),
@@ -35132,23 +35149,31 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35132
35149
  await proofsInfoDeposit.callConstructor({ amount: params.amount })
35133
35150
  );
35134
35151
  calls.push(callDeposit);
35135
- return this.createTransactionResult(calls, true, params, "DEPOSIT");
35152
+ return this.createTransactionResult(calls, true, params, "DEPOSIT", params.cycleType);
35136
35153
  }
35137
35154
  logger.error(`Unsupported assets movement: ${params.from} to ${params.to}`);
35138
- return this.createTransactionResult([], false, params, "NONE");
35155
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35139
35156
  } catch (err) {
35140
35157
  logger.error(`error moving assets: ${err}`);
35141
- return this.createTransactionResult([], false, params, "NONE");
35158
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35142
35159
  }
35143
35160
  }
35144
35161
  async handleDeposit() {
35145
35162
  try {
35146
- return this.createTransactionResult([], false, { from: Protocols.VAULT.name, to: Protocols.VAULT.name, amount: new Web3Number(0, 0) }, "NONE");
35163
+ return this.createTransactionResult([], false, { from: Protocols.VAULT.name, to: Protocols.VAULT.name, amount: new Web3Number(0, 0) }, "NONE", "INVESTMENT" /* INVESTMENT */);
35147
35164
  } catch (err) {
35148
35165
  logger.error(`error handling deposit: ${err}`);
35149
- return this.createTransactionResult([], false, { from: Protocols.VAULT.name, to: Protocols.VAULT.name, amount: new Web3Number(0, 0) }, "NONE");
35166
+ return this.createTransactionResult([], false, { from: Protocols.VAULT.name, to: Protocols.VAULT.name, amount: new Web3Number(0, 0) }, "NONE", "INVESTMENT" /* INVESTMENT */);
35150
35167
  }
35151
35168
  }
35169
+ /**
35170
+ * Check if the price difference between avnu and extended is within the acceptable range to enhance the position size or close the position
35171
+ * @param extendedAdapter - the extended adapter
35172
+ * @param vesuAdapter - the vesu adapter
35173
+ * @param avnuAdapter - the avnu adapter
35174
+ * @param positionType - the position type (open or close)
35175
+ * @returns true if the price difference is within the acceptable range, false otherwise
35176
+ */
35152
35177
  async checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter, vesuAdapter, avnuAdapter, positionType) {
35153
35178
  const {
35154
35179
  ask,
@@ -35180,6 +35205,11 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35180
35205
  return result;
35181
35206
  }
35182
35207
  }
35208
+ /**
35209
+ * Handle the withdrawal of assets from the vault
35210
+ * @param amount - the amount to withdraw in USDC
35211
+ * @returns the calls to be executed and the status of the calls generated along with the metadata for the calls
35212
+ */
35183
35213
  async handleWithdraw(amount) {
35184
35214
  try {
35185
35215
  const usdcBalanceVaultAllocator = await this.getUnusedBalance();
@@ -35192,7 +35222,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35192
35222
  amount: usdcBalanceVaultAllocator.amount
35193
35223
  });
35194
35224
  calls.push(withdrawCall2);
35195
- return [this.createTransactionResult(calls, true, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "WITHDRAWAL")];
35225
+ return [this.createTransactionResult(calls, true, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "WITHDRAWAL", "WITHDRAWAL" /* WITHDRAWAL */)];
35196
35226
  }
35197
35227
  const vesuAdapter = await this.getVesuAdapter();
35198
35228
  const extendedAdapter = await this.getExtendedAdapter();
@@ -35201,7 +35231,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35201
35231
  logger.error(
35202
35232
  `vesu or extended adapter not found: vesuAdapter=${vesuAdapter}, extendedAdapter=${extendedAdapter}`
35203
35233
  );
35204
- return [this.createTransactionResult(calls, status, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "NONE")];
35234
+ return [this.createTransactionResult(calls, status, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "NONE", "WITHDRAWAL" /* WITHDRAWAL */)];
35205
35235
  }
35206
35236
  let transactionResults = [];
35207
35237
  const { collateralTokenAmount } = await vesuAdapter.vesuAdapter.getAssetPrices();
@@ -35212,7 +35242,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35212
35242
  if (!extendedPositon) {
35213
35243
  status = false;
35214
35244
  logger.error("error getting extended position", extendedPositon);
35215
- return [this.createTransactionResult(calls, status, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "NONE")];
35245
+ return [this.createTransactionResult(calls, status, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "NONE", "WITHDRAWAL" /* WITHDRAWAL */)];
35216
35246
  }
35217
35247
  const amountDistributionForWithdrawal = await calculateAmountDistributionForWithdrawal(
35218
35248
  usdcBalanceDifference,
@@ -35225,7 +35255,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35225
35255
  logger.error(
35226
35256
  `error calculating amount distribution for withdrawal: ${amountDistributionForWithdrawal}`
35227
35257
  );
35228
- return [this.createTransactionResult(calls, status, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "NONE")];
35258
+ return [this.createTransactionResult(calls, status, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "NONE", "WITHDRAWAL" /* WITHDRAWAL */)];
35229
35259
  }
35230
35260
  const { vesu_amount, extended_amount } = amountDistributionForWithdrawal;
35231
35261
  if (status && vesu_amount.greaterThan(0)) {
@@ -35233,7 +35263,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35233
35263
  {
35234
35264
  amount: vesu_amount,
35235
35265
  from: Protocols.VESU.name,
35236
- to: Protocols.VAULT.name
35266
+ to: Protocols.VAULT.name,
35267
+ cycleType: "WITHDRAWAL" /* WITHDRAWAL */
35237
35268
  },
35238
35269
  extendedAdapter,
35239
35270
  vesuAdapter
@@ -35250,7 +35281,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35250
35281
  {
35251
35282
  amount: extended_amount,
35252
35283
  from: Protocols.EXTENDED.name,
35253
- to: Protocols.VAULT.name
35284
+ to: Protocols.VAULT.name,
35285
+ cycleType: "WITHDRAWAL" /* WITHDRAWAL */
35254
35286
  },
35255
35287
  extendedAdapter,
35256
35288
  vesuAdapter
@@ -35264,7 +35296,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35264
35296
  });
35265
35297
  } else {
35266
35298
  logger.error("error moving assets to vault: extendedStatus: ${extendedStatus}");
35267
- return [this.createTransactionResult([], status, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "NONE")];
35299
+ return [this.createTransactionResult([], status, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "NONE", "WITHDRAWAL" /* WITHDRAWAL */)];
35268
35300
  }
35269
35301
  }
35270
35302
  const withdrawCall = await this.getBringLiquidityCall({
@@ -35279,13 +35311,14 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35279
35311
  protocolTo: Protocols.NONE.name,
35280
35312
  transactionType: "WITHDRAWAL",
35281
35313
  usdAmount: amount.toFixed(),
35282
- status: "PENDING"
35314
+ status: "PENDING",
35315
+ cycleType: "WITHDRAWAL" /* WITHDRAWAL */
35283
35316
  }
35284
35317
  });
35285
35318
  return transactionResults;
35286
35319
  } catch (err) {
35287
35320
  logger.error(`error handling withdrawal: ${err}`);
35288
- return [this.createTransactionResult([], false, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "NONE")];
35321
+ return [this.createTransactionResult([], false, { from: Protocols.VAULT.name, to: Protocols.NONE.name, amount }, "NONE", "WITHDRAWAL" /* WITHDRAWAL */)];
35289
35322
  }
35290
35323
  }
35291
35324
  async getAUM() {
@@ -39801,6 +39834,7 @@ var deployer_default = Deployer;
39801
39834
  BaseStrategy,
39802
39835
  CommonAdapter,
39803
39836
  ContractAddr,
39837
+ CycleType,
39804
39838
  Deployer,
39805
39839
  ERC20,
39806
39840
  EXTENDED_CONTRACT,