@strkfarm/sdk 2.0.0-dev.15 → 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,
@@ -27210,11 +27211,6 @@ var VesuAdapter = class _VesuAdapter extends CacheClass {
27210
27211
  if (!this.pricer) {
27211
27212
  throw new Error("Pricer is not initialized");
27212
27213
  }
27213
- const CACHE_KEY = `positions_${blockNumber}_${this.config.poolId.shortString()}_${this.config.collateral.symbol}_${this.config.debt.symbol}`;
27214
- const cacheData = this.getCache(CACHE_KEY);
27215
- if (cacheData) {
27216
- return cacheData;
27217
- }
27218
27214
  const { contract, isV2 } = this.getVesuSingletonContract(config, this.config.poolId);
27219
27215
  const output = await contract.call(isV2 ? "position" : "position_unsafe", [
27220
27216
  ...isV2 ? [] : [this.config.poolId.address],
@@ -27240,7 +27236,6 @@ var VesuAdapter = class _VesuAdapter extends CacheClass {
27240
27236
  usdValue: debtAmount.multipliedBy(token2Price.price).toNumber(),
27241
27237
  remarks: "Debt"
27242
27238
  }];
27243
- this.setCache(CACHE_KEY, value, 6e4);
27244
27239
  return value.map((v) => ({ ...v, protocol: Protocols.VESU }));
27245
27240
  }
27246
27241
  async getCollateralization(config, blockNumber = "latest") {
@@ -34427,6 +34422,16 @@ var HyperLSTStrategies = [
34427
34422
  getStrategySettings("mRe7YIELD", "mRe7YIELD", hypermRe7YIELD, false, false)
34428
34423
  ];
34429
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
+
34430
34435
  // src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx
34431
34436
  var import_jsx_runtime5 = require("react/jsx-runtime");
34432
34437
  var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy extends SVKStrategy {
@@ -34808,7 +34813,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34808
34813
  {
34809
34814
  to: Protocols.VAULT.name,
34810
34815
  from: Protocols.EXTENDED.name,
34811
- amount: extendedAmount.abs()
34816
+ amount: extendedAmount.abs(),
34817
+ cycleType: "INVESTMENT" /* INVESTMENT */
34812
34818
  },
34813
34819
  extendedAdapter,
34814
34820
  vesuAdapter
@@ -34823,11 +34829,11 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34823
34829
  }
34824
34830
  });
34825
34831
  } else {
34826
- 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 */)];
34827
34833
  }
34828
34834
  } catch (err) {
34829
34835
  logger.error(`Failed moving assets to vault: ${err}`);
34830
- 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 */)];
34831
34837
  }
34832
34838
  }
34833
34839
  if (vesuAmount.isNegative() && vesuAmount.abs().greaterThan(vesuAdapter.minimumVesuMovementAmount)) {
@@ -34836,13 +34842,14 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34836
34842
  {
34837
34843
  to: Protocols.EXTENDED.name,
34838
34844
  from: Protocols.VESU.name,
34839
- amount: vesuAmount.abs()
34845
+ amount: vesuAmount.abs(),
34846
+ cycleType: "INVESTMENT" /* INVESTMENT */
34840
34847
  },
34841
34848
  extendedAdapter,
34842
34849
  vesuAdapter
34843
34850
  );
34844
34851
  if (!vesuStatus) {
34845
- 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 */)];
34846
34853
  }
34847
34854
  transactionResults.push({
34848
34855
  status: vesuStatus,
@@ -34854,7 +34861,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34854
34861
  });
34855
34862
  } catch (err) {
34856
34863
  logger.error(`Failed moving assets to extended via vault allocator: ${err}`);
34857
- 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 */)];
34858
34865
  }
34859
34866
  }
34860
34867
  if (extendedAmountDifferenceAbs.greaterThan(extendedAdapter.minimumExtendedMovementAmount)) {
@@ -34864,7 +34871,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34864
34871
  {
34865
34872
  to: Protocols.EXTENDED.name,
34866
34873
  from: Protocols.VAULT.name,
34867
- amount: extendedAmountDifference
34874
+ amount: extendedAmountDifference,
34875
+ cycleType: "INVESTMENT" /* INVESTMENT */
34868
34876
  },
34869
34877
  extendedAdapter,
34870
34878
  vesuAdapter
@@ -34877,11 +34885,11 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34877
34885
  });
34878
34886
  } else {
34879
34887
  logger.error(`Failed to move assets to extended - operation returned false status`);
34880
- 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 */)];
34881
34889
  }
34882
34890
  } catch (err) {
34883
34891
  logger.error(`Failed moving assets to extended: ${err}`);
34884
- 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 */)];
34885
34893
  }
34886
34894
  } else if (extendedAmountDifference.lessThan(0)) {
34887
34895
  try {
@@ -34889,7 +34897,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34889
34897
  {
34890
34898
  to: Protocols.VAULT.name,
34891
34899
  from: Protocols.EXTENDED.name,
34892
- amount: extendedAmountDifferenceAbs
34900
+ amount: extendedAmountDifferenceAbs,
34901
+ cycleType: "INVESTMENT" /* INVESTMENT */
34893
34902
  },
34894
34903
  extendedAdapter,
34895
34904
  vesuAdapter
@@ -34905,11 +34914,11 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34905
34914
  });
34906
34915
  } else {
34907
34916
  logger.error(`Failed to withdraw from extended - operation returned false status`);
34908
- 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 */)];
34909
34918
  }
34910
34919
  } catch (err) {
34911
34920
  logger.error(`Failed moving assets from extended to vault: ${err}`);
34912
- 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 */)];
34913
34922
  }
34914
34923
  }
34915
34924
  }
@@ -34924,14 +34933,15 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34924
34933
  {
34925
34934
  to: Protocols.VAULT.name,
34926
34935
  from: Protocols.EXTENDED.name,
34927
- amount: vesuAmountDifference
34936
+ amount: vesuAmountDifference,
34937
+ cycleType: "INVESTMENT" /* INVESTMENT */
34928
34938
  },
34929
34939
  extendedAdapter,
34930
34940
  vesuAdapter
34931
34941
  );
34932
34942
  if (!vesuStatus) {
34933
34943
  logger.error(`Failed to move assets to vesu - operation returned false status`);
34934
- 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 */)];
34935
34945
  }
34936
34946
  transactionResults.push({
34937
34947
  status: vesuStatus,
@@ -34943,20 +34953,20 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34943
34953
  });
34944
34954
  } catch (err) {
34945
34955
  logger.error(`Failed moving assets to vault: ${err}`);
34946
- 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 */)];
34947
34957
  }
34948
34958
  }
34949
34959
  }
34950
34960
  return transactionResults;
34951
34961
  } catch (err) {
34952
34962
  logger.error(`Failed moving assets to vesu: ${err}`);
34953
- 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 */)];
34954
34964
  }
34955
34965
  }
34956
34966
  /**
34957
34967
  * Helper method to create transaction result with metadata
34958
34968
  */
34959
- createTransactionResult(calls, status, params, transactionType) {
34969
+ createTransactionResult(calls, status, params, transactionType, cycleType) {
34960
34970
  if (status) {
34961
34971
  return {
34962
34972
  calls,
@@ -34966,11 +34976,12 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34966
34976
  protocolTo: params.to,
34967
34977
  transactionType,
34968
34978
  usdAmount: params.amount.abs().toFixed(),
34969
- status: "PENDING"
34979
+ status: "PENDING",
34980
+ cycleType
34970
34981
  }
34971
34982
  };
34972
34983
  }
34973
- 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 } };
34974
34985
  }
34975
34986
  async moveAssets(params, extendedAdapter, vesuAdapter) {
34976
34987
  try {
@@ -34978,7 +34989,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34978
34989
  logger.error(
34979
34990
  `Invalid amount for moveAssets: ${params.amount.toNumber()}. Amount must be positive.`
34980
34991
  );
34981
- return this.createTransactionResult([], false, params, "NONE");
34992
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
34982
34993
  }
34983
34994
  const amountAbs = params.amount.abs();
34984
34995
  if (params.from === Protocols.EXTENDED.name || params.to === Protocols.EXTENDED.name) {
@@ -34986,7 +34997,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34986
34997
  logger.warn(
34987
34998
  `Amount ${amountAbs.toNumber()} is below minimum Extended movement amount ${extendedAdapter.minimumExtendedMovementAmount}. Skipping operation.`
34988
34999
  );
34989
- return this.createTransactionResult([], false, params, "NONE");
35000
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
34990
35001
  }
34991
35002
  }
34992
35003
  if (params.from === Protocols.VESU.name || params.to === Protocols.VESU.name) {
@@ -34994,13 +35005,13 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34994
35005
  logger.warn(
34995
35006
  `Amount ${amountAbs.toNumber()} is below minimum Vesu movement amount ${vesuAdapter.minimumVesuMovementAmount}. Skipping operation.`
34996
35007
  );
34997
- return this.createTransactionResult([], false, params, "NONE");
35008
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
34998
35009
  }
34999
35010
  }
35000
35011
  const avnuAdapter = await this.getAvnuAdapter();
35001
35012
  if (!avnuAdapter) {
35002
35013
  logger.error(`avnu adapter not found: ${avnuAdapter}`);
35003
- return this.createTransactionResult([], false, params, "NONE");
35014
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35004
35015
  }
35005
35016
  logger.info(`moveAssets params, ${JSON.stringify(params)}`);
35006
35017
  const collateralToken = vesuAdapter.config.supportedPositions[0].asset;
@@ -35019,13 +35030,13 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35019
35030
  await proofsInfo.callConstructor({ amount: params.amount })
35020
35031
  );
35021
35032
  calls.push(call);
35022
- return this.createTransactionResult(calls, true, params, "DEPOSIT");
35033
+ return this.createTransactionResult(calls, true, params, "DEPOSIT", params.cycleType);
35023
35034
  } else if (params.to === Protocols.VAULT.name && params.from === Protocols.EXTENDED.name) {
35024
35035
  const extendedLeverage = calculateExtendedLevergae();
35025
35036
  const extendedHoldings = await extendedAdapter.getExtendedDepositAmount();
35026
35037
  if (!extendedHoldings) {
35027
35038
  logger.error(`error getting extended holdings: ${extendedHoldings}`);
35028
- return this.createTransactionResult([], false, params, "NONE");
35039
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35029
35040
  }
35030
35041
  const extendedHoldingAmount = new Web3Number(
35031
35042
  extendedHoldings.availableForWithdrawal,
@@ -35042,7 +35053,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35042
35053
  "BUY" /* BUY */
35043
35054
  ) : await extendedAdapter.createOrder(
35044
35055
  extendedLeverage.toString(),
35045
- 35e-6,
35056
+ 34e-6,
35046
35057
  // just in case amount falls short then we need to create a withdrawal
35047
35058
  "BUY" /* BUY */
35048
35059
  );
@@ -35052,7 +35063,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35052
35063
  const updatedHoldings = await extendedAdapter.getExtendedDepositAmount();
35053
35064
  if (!updatedHoldings || new Web3Number(updatedHoldings.availableForWithdrawal, USDC_TOKEN_DECIMALS).lessThan(params.amount.abs())) {
35054
35065
  logger.error(`Insufficient balance after opening position. Available: ${updatedHoldings?.availableForWithdrawal}, Needed: ${params.amount.abs()}`);
35055
- return this.createTransactionResult([], false, params, "NONE");
35066
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35056
35067
  }
35057
35068
  }
35058
35069
  const {
@@ -35066,22 +35077,22 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35066
35077
  await new Promise((resolve) => setTimeout(resolve, 5e3));
35067
35078
  const { calls, status } = await this.moveAssetsToVaultAllocator(params.amount, extendedAdapter);
35068
35079
  if (calls.length > 0 && status) {
35069
- return this.createTransactionResult(calls, true, params, "WITHDRAWAL");
35080
+ return this.createTransactionResult(calls, true, params, "WITHDRAWAL", params.cycleType);
35070
35081
  } else {
35071
- return this.createTransactionResult([], true, params, "WITHDRAWAL");
35082
+ return this.createTransactionResult([], true, params, "WITHDRAWAL", params.cycleType);
35072
35083
  }
35073
35084
  } else if (withdrawalFromExtendedStatus && !withdrawalFromExtendedTxnHash) {
35074
35085
  logger.error("withdrawal from extended successful, but funds didn't get transferred to the wallet");
35075
- return this.createTransactionResult([], true, params, "WITHDRAWAL");
35086
+ return this.createTransactionResult([], true, params, "WITHDRAWAL", params.cycleType);
35076
35087
  } else {
35077
35088
  logger.error("withdrawal from extended failed");
35078
- return this.createTransactionResult([], false, params, "NONE");
35089
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35079
35090
  }
35080
35091
  } else if (params.to === Protocols.VAULT.name && params.from === Protocols.VESU.name) {
35081
35092
  const isPriceDifferenceBetweenAvnuAndExtended = await this.checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter, vesuAdapter, avnuAdapter, "close" /* CLOSE */);
35082
35093
  if (!isPriceDifferenceBetweenAvnuAndExtended) {
35083
35094
  logger.warn(`price difference between avnu and extended doesn't fit the range for close position, ${avnuAdapter.config.maximumExtendedPriceDifferenceForSwapClosing}`);
35084
- return this.createTransactionResult([], false, params, "NONE");
35095
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35085
35096
  }
35086
35097
  const vesuAmountInBTC = new Web3Number(
35087
35098
  params.amount.dividedBy(collateralPrice.price).toFixed(WBTC_TOKEN_DECIMALS),
@@ -35102,12 +35113,12 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35102
35113
  await swapProofsInfo.callConstructor({ amount: vesuAmountInBTC })
35103
35114
  );
35104
35115
  calls.push(swapCall);
35105
- return this.createTransactionResult(calls, true, params, "WITHDRAWAL");
35116
+ return this.createTransactionResult(calls, true, params, "WITHDRAWAL", params.cycleType);
35106
35117
  } else if (params.to === Protocols.EXTENDED.name && params.from === Protocols.VESU.name) {
35107
35118
  const isPriceDifferenceBetweenAvnuAndExtended = await this.checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter, vesuAdapter, avnuAdapter, "close" /* CLOSE */);
35108
35119
  if (!isPriceDifferenceBetweenAvnuAndExtended) {
35109
35120
  logger.warn(`price difference between avnu and extended doesn't fit the range for close position, ${avnuAdapter.config.maximumExtendedPriceDifferenceForSwapClosing}`);
35110
- return this.createTransactionResult([], false, params, "NONE");
35121
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35111
35122
  }
35112
35123
  const vesuAmountInBTC = new Web3Number(
35113
35124
  params.amount.dividedBy(collateralPrice.price).toNumber(),
@@ -35138,23 +35149,31 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35138
35149
  await proofsInfoDeposit.callConstructor({ amount: params.amount })
35139
35150
  );
35140
35151
  calls.push(callDeposit);
35141
- return this.createTransactionResult(calls, true, params, "DEPOSIT");
35152
+ return this.createTransactionResult(calls, true, params, "DEPOSIT", params.cycleType);
35142
35153
  }
35143
35154
  logger.error(`Unsupported assets movement: ${params.from} to ${params.to}`);
35144
- return this.createTransactionResult([], false, params, "NONE");
35155
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35145
35156
  } catch (err) {
35146
35157
  logger.error(`error moving assets: ${err}`);
35147
- return this.createTransactionResult([], false, params, "NONE");
35158
+ return this.createTransactionResult([], false, params, "NONE", params.cycleType);
35148
35159
  }
35149
35160
  }
35150
35161
  async handleDeposit() {
35151
35162
  try {
35152
- 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 */);
35153
35164
  } catch (err) {
35154
35165
  logger.error(`error handling deposit: ${err}`);
35155
- 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 */);
35156
35167
  }
35157
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
+ */
35158
35177
  async checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter, vesuAdapter, avnuAdapter, positionType) {
35159
35178
  const {
35160
35179
  ask,
@@ -35186,6 +35205,11 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35186
35205
  return result;
35187
35206
  }
35188
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
+ */
35189
35213
  async handleWithdraw(amount) {
35190
35214
  try {
35191
35215
  const usdcBalanceVaultAllocator = await this.getUnusedBalance();
@@ -35198,7 +35222,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35198
35222
  amount: usdcBalanceVaultAllocator.amount
35199
35223
  });
35200
35224
  calls.push(withdrawCall2);
35201
- 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 */)];
35202
35226
  }
35203
35227
  const vesuAdapter = await this.getVesuAdapter();
35204
35228
  const extendedAdapter = await this.getExtendedAdapter();
@@ -35207,7 +35231,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35207
35231
  logger.error(
35208
35232
  `vesu or extended adapter not found: vesuAdapter=${vesuAdapter}, extendedAdapter=${extendedAdapter}`
35209
35233
  );
35210
- 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 */)];
35211
35235
  }
35212
35236
  let transactionResults = [];
35213
35237
  const { collateralTokenAmount } = await vesuAdapter.vesuAdapter.getAssetPrices();
@@ -35218,7 +35242,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35218
35242
  if (!extendedPositon) {
35219
35243
  status = false;
35220
35244
  logger.error("error getting extended position", extendedPositon);
35221
- 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 */)];
35222
35246
  }
35223
35247
  const amountDistributionForWithdrawal = await calculateAmountDistributionForWithdrawal(
35224
35248
  usdcBalanceDifference,
@@ -35231,7 +35255,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35231
35255
  logger.error(
35232
35256
  `error calculating amount distribution for withdrawal: ${amountDistributionForWithdrawal}`
35233
35257
  );
35234
- 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 */)];
35235
35259
  }
35236
35260
  const { vesu_amount, extended_amount } = amountDistributionForWithdrawal;
35237
35261
  if (status && vesu_amount.greaterThan(0)) {
@@ -35239,7 +35263,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35239
35263
  {
35240
35264
  amount: vesu_amount,
35241
35265
  from: Protocols.VESU.name,
35242
- to: Protocols.VAULT.name
35266
+ to: Protocols.VAULT.name,
35267
+ cycleType: "WITHDRAWAL" /* WITHDRAWAL */
35243
35268
  },
35244
35269
  extendedAdapter,
35245
35270
  vesuAdapter
@@ -35256,7 +35281,8 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35256
35281
  {
35257
35282
  amount: extended_amount,
35258
35283
  from: Protocols.EXTENDED.name,
35259
- to: Protocols.VAULT.name
35284
+ to: Protocols.VAULT.name,
35285
+ cycleType: "WITHDRAWAL" /* WITHDRAWAL */
35260
35286
  },
35261
35287
  extendedAdapter,
35262
35288
  vesuAdapter
@@ -35270,7 +35296,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35270
35296
  });
35271
35297
  } else {
35272
35298
  logger.error("error moving assets to vault: extendedStatus: ${extendedStatus}");
35273
- 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 */)];
35274
35300
  }
35275
35301
  }
35276
35302
  const withdrawCall = await this.getBringLiquidityCall({
@@ -35285,13 +35311,14 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
35285
35311
  protocolTo: Protocols.NONE.name,
35286
35312
  transactionType: "WITHDRAWAL",
35287
35313
  usdAmount: amount.toFixed(),
35288
- status: "PENDING"
35314
+ status: "PENDING",
35315
+ cycleType: "WITHDRAWAL" /* WITHDRAWAL */
35289
35316
  }
35290
35317
  });
35291
35318
  return transactionResults;
35292
35319
  } catch (err) {
35293
35320
  logger.error(`error handling withdrawal: ${err}`);
35294
- 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 */)];
35295
35322
  }
35296
35323
  }
35297
35324
  async getAUM() {
@@ -39807,6 +39834,7 @@ var deployer_default = Deployer;
39807
39834
  BaseStrategy,
39808
39835
  CommonAdapter,
39809
39836
  ContractAddr,
39837
+ CycleType,
39810
39838
  Deployer,
39811
39839
  ERC20,
39812
39840
  EXTENDED_CONTRACT,