@strkfarm/sdk 2.0.0-dev.4 → 2.0.0-dev.5

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.
@@ -28609,21 +28609,35 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28609
28609
  vaultAllocator: config.vaultAllocator,
28610
28610
  id: ""
28611
28611
  });
28612
- this.tokenMarketData = new TokenMarketData(this.config.pricer, this.config.networkConfig);
28612
+ this.tokenMarketData = new TokenMarketData(
28613
+ this.config.pricer,
28614
+ this.config.networkConfig
28615
+ );
28613
28616
  }
28614
28617
  async getAPY(supportedPosition) {
28615
28618
  const CACHE_KEY = `apy_${this.config.poolId.address}_${supportedPosition.asset.symbol}`;
28616
28619
  const cacheData = this.getCache(CACHE_KEY);
28617
- console.log(`${_VesuMultiplyAdapter.name}::getAPY cacheData: ${JSON.stringify(cacheData)}`, this.vesuAdapter.config.poolId.shortString(), this.vesuAdapter.config.collateral.symbol, this.vesuAdapter.config.debt.symbol);
28620
+ console.log(
28621
+ `${_VesuMultiplyAdapter.name}::getAPY cacheData: ${JSON.stringify(
28622
+ cacheData
28623
+ )}`,
28624
+ this.vesuAdapter.config.poolId.shortString(),
28625
+ this.vesuAdapter.config.collateral.symbol,
28626
+ this.vesuAdapter.config.debt.symbol
28627
+ );
28618
28628
  if (cacheData) {
28619
28629
  return cacheData;
28620
28630
  }
28621
28631
  try {
28622
28632
  const allVesuPools = await VesuAdapter.getVesuPools();
28623
28633
  const asset = supportedPosition.asset;
28624
- const pool = allVesuPools.pools.find((p) => this.vesuAdapter.config.poolId.eqString(num9.getHexString(p.id)));
28634
+ const pool = allVesuPools.pools.find(
28635
+ (p) => this.vesuAdapter.config.poolId.eqString(num9.getHexString(p.id))
28636
+ );
28625
28637
  if (!pool) {
28626
- logger.warn(`VesuMultiplyAdapter: Pool not found for token ${asset.symbol}`);
28638
+ logger.warn(
28639
+ `VesuMultiplyAdapter: Pool not found for token ${asset.symbol}`
28640
+ );
28627
28641
  return {
28628
28642
  apy: 0,
28629
28643
  type: "base" /* BASE */
@@ -28633,7 +28647,9 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28633
28647
  (a) => a.symbol.toLowerCase() === asset.symbol.toLowerCase()
28634
28648
  )?.stats;
28635
28649
  if (!assetStats) {
28636
- logger.warn(`VesuMultiplyAdapter: Asset stats not found for token ${asset.symbol}`);
28650
+ logger.warn(
28651
+ `VesuMultiplyAdapter: Asset stats not found for token ${asset.symbol}`
28652
+ );
28637
28653
  return {
28638
28654
  apy: 0,
28639
28655
  type: "base" /* BASE */
@@ -28644,7 +28660,9 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28644
28660
  apy = Number(assetStats.borrowApr?.value || 0) / 1e18;
28645
28661
  } else {
28646
28662
  const isAssetBTC = asset.symbol.toLowerCase().includes("btc");
28647
- const baseAPY = Number(isAssetBTC ? assetStats.btcFiSupplyApr?.value + assetStats.supplyApy?.value : assetStats.supplyApy?.value || 0) / 1e18;
28663
+ const baseAPY = Number(
28664
+ isAssetBTC ? assetStats.btcFiSupplyApr?.value + assetStats.supplyApy?.value : assetStats.supplyApy?.value || 0
28665
+ ) / 1e18;
28648
28666
  const rewardAPY = Number(assetStats.defiSpringSupplyApr?.value || "0") / 1e18;
28649
28667
  const isSupported = this.tokenMarketData.isAPYSupported(asset);
28650
28668
  apy = baseAPY + rewardAPY;
@@ -28660,7 +28678,10 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28660
28678
  this.setCache(CACHE_KEY, result, 3e5);
28661
28679
  return result;
28662
28680
  } catch (error) {
28663
- logger.error(`VesuMultiplyAdapter: Error getting APY for ${supportedPosition.asset.symbol}:`, error);
28681
+ logger.error(
28682
+ `VesuMultiplyAdapter: Error getting APY for ${supportedPosition.asset.symbol}:`,
28683
+ error
28684
+ );
28664
28685
  throw error;
28665
28686
  }
28666
28687
  }
@@ -28673,12 +28694,16 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28673
28694
  try {
28674
28695
  this.vesuAdapter.networkConfig = this.config.networkConfig;
28675
28696
  this.vesuAdapter.pricer = this.config.pricer;
28676
- const positions = await this.vesuAdapter.getPositions(this.config.networkConfig);
28697
+ const positions = await this.vesuAdapter.getPositions(
28698
+ this.config.networkConfig
28699
+ );
28677
28700
  let position = positions.find(
28678
28701
  (p) => p.token.address.eq(supportedPosition.asset.address)
28679
28702
  );
28680
28703
  if (!position) {
28681
- logger.warn(`VesuMultiplyAdapter: Position not found for token ${supportedPosition.asset.symbol}`);
28704
+ logger.warn(
28705
+ `VesuMultiplyAdapter: Position not found for token ${supportedPosition.asset.symbol}`
28706
+ );
28682
28707
  return {
28683
28708
  amount: new Web3Number("0", supportedPosition.asset.decimals),
28684
28709
  remarks: "Position not found"
@@ -28691,12 +28716,18 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28691
28716
  this.setCache(CACHE_KEY, position, 6e4);
28692
28717
  return position;
28693
28718
  } catch (error) {
28694
- logger.error(`VesuMultiplyAdapter: Error getting position for ${supportedPosition.asset.symbol}:`, error);
28719
+ logger.error(
28720
+ `VesuMultiplyAdapter: Error getting position for ${supportedPosition.asset.symbol}:`,
28721
+ error
28722
+ );
28695
28723
  throw error;
28696
28724
  }
28697
28725
  }
28698
28726
  async maxBorrowableAPY() {
28699
- const collateralAPY = await this.getAPY({ asset: this.config.collateral, isDebt: false });
28727
+ const collateralAPY = await this.getAPY({
28728
+ asset: this.config.collateral,
28729
+ isDebt: false
28730
+ });
28700
28731
  const apy = collateralAPY.apy * 0.8;
28701
28732
  return apy;
28702
28733
  }
@@ -28706,9 +28737,15 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28706
28737
  try {
28707
28738
  this.vesuAdapter.networkConfig = this.config.networkConfig;
28708
28739
  this.vesuAdapter.pricer = this.config.pricer;
28709
- const positions = await this.vesuAdapter.getPositions(this.config.networkConfig);
28710
- const collateralPosition = positions.find((p) => p.token.address.eq(collateral.address));
28711
- const debtPosition = positions.find((p) => p.token.address.eq(debt.address));
28740
+ const positions = await this.vesuAdapter.getPositions(
28741
+ this.config.networkConfig
28742
+ );
28743
+ const collateralPosition = positions.find(
28744
+ (p) => p.token.address.eq(collateral.address)
28745
+ );
28746
+ const debtPosition = positions.find(
28747
+ (p) => p.token.address.eq(debt.address)
28748
+ );
28712
28749
  if (!collateralPosition || !debtPosition) {
28713
28750
  throw new Error("Could not find current positions");
28714
28751
  }
@@ -28718,13 +28755,23 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28718
28755
  debt,
28719
28756
  maxBorrowableAPY
28720
28757
  );
28721
- logger.verbose(`VesuMultiplyAdapter: Max borrowable: ${maxBorrowable.toNumber()}`);
28722
- const debtCap = await this.vesuAdapter.getDebtCap(this.config.networkConfig);
28758
+ logger.verbose(
28759
+ `VesuMultiplyAdapter: Max borrowable: ${maxBorrowable.toNumber()}`
28760
+ );
28761
+ const debtCap = await this.vesuAdapter.getDebtCap(
28762
+ this.config.networkConfig
28763
+ );
28723
28764
  logger.verbose(`VesuMultiplyAdapter: Debt cap: ${debtCap.toNumber()}`);
28724
28765
  const actualMaxBorrowable = maxBorrowable.minimum(debtCap);
28725
- logger.verbose(`VesuMultiplyAdapter: Actual max borrowable: ${actualMaxBorrowable.toNumber()}`);
28726
- const maxLTV = await this.vesuAdapter.getLTVConfig(this.config.networkConfig);
28727
- const collateralPrice = await this.config.pricer.getPrice(collateral.symbol);
28766
+ logger.verbose(
28767
+ `VesuMultiplyAdapter: Actual max borrowable: ${actualMaxBorrowable.toNumber()}`
28768
+ );
28769
+ const maxLTV = await this.vesuAdapter.getLTVConfig(
28770
+ this.config.networkConfig
28771
+ );
28772
+ const collateralPrice = await this.config.pricer.getPrice(
28773
+ collateral.symbol
28774
+ );
28728
28775
  if (collateralPrice.price === 0) {
28729
28776
  throw new Error("Collateral price is 0");
28730
28777
  }
@@ -28742,14 +28789,25 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28742
28789
  );
28743
28790
  const maxDepositAmount = amount ? amount.minimum(maxCollateralFromDebt) : maxCollateralFromDebt;
28744
28791
  const usdValue = await this.getUSDValue(collateral, maxDepositAmount);
28745
- logger.verbose(`VesuMultiplyAdapter: Max deposit::USD value: ${usdValue}, amount: ${maxDepositAmount.toNumber()}`);
28746
- const apys = await Promise.all([this.getAPY({ asset: collateral, isDebt: false }), this.getAPY({ asset: debt, isDebt: true })]);
28747
- logger.verbose(`VesuMultiplyAdapter: Apys: ${apys[0].apy}, ${apys[1].apy}`);
28792
+ logger.verbose(
28793
+ `VesuMultiplyAdapter: Max deposit::USD value: ${usdValue}, amount: ${maxDepositAmount.toNumber()}`
28794
+ );
28795
+ const apys = await Promise.all([
28796
+ this.getAPY({ asset: collateral, isDebt: false }),
28797
+ this.getAPY({ asset: debt, isDebt: true })
28798
+ ]);
28799
+ logger.verbose(
28800
+ `VesuMultiplyAdapter: Apys: ${apys[0].apy}, ${apys[1].apy}`
28801
+ );
28748
28802
  const borrowAmountUSD = actualMaxBorrowable.multipliedBy(debtPrice.price);
28749
- logger.verbose(`VesuMultiplyAdapter: Borrow amount: ${actualMaxBorrowable.toNumber()}, borrow amount USD: ${borrowAmountUSD.toNumber()}`);
28803
+ logger.verbose(
28804
+ `VesuMultiplyAdapter: Borrow amount: ${actualMaxBorrowable.toNumber()}, borrow amount USD: ${borrowAmountUSD.toNumber()}`
28805
+ );
28750
28806
  const netCollateralUSD = usdValue + borrowAmountUSD.toNumber();
28751
28807
  const netAPY = (apys[0].apy * netCollateralUSD + apys[1].apy * borrowAmountUSD.toNumber()) / usdValue;
28752
- logger.verbose(`VesuMultiplyAdapter: Max deposit amount: ${maxDepositAmount.toNumber()}, netAPY: ${netAPY}`);
28808
+ logger.verbose(
28809
+ `VesuMultiplyAdapter: Max deposit amount: ${maxDepositAmount.toNumber()}, netAPY: ${netAPY}`
28810
+ );
28753
28811
  return {
28754
28812
  tokenInfo: collateral,
28755
28813
  amount: maxDepositAmount,
@@ -28762,7 +28820,10 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28762
28820
  protocol: this.protocol
28763
28821
  };
28764
28822
  } catch (error) {
28765
- logger.error(`VesuMultiplyAdapter: Error calculating max deposit:`, error);
28823
+ logger.error(
28824
+ `VesuMultiplyAdapter: Error calculating max deposit:`,
28825
+ error
28826
+ );
28766
28827
  throw error;
28767
28828
  }
28768
28829
  }
@@ -28772,9 +28833,15 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28772
28833
  try {
28773
28834
  this.vesuAdapter.networkConfig = this.config.networkConfig;
28774
28835
  this.vesuAdapter.pricer = this.config.pricer;
28775
- const positions = await this.vesuAdapter.getPositions(this.config.networkConfig);
28776
- const collateralPosition = positions.find((p) => p.token.address.eq(collateral.address));
28777
- const debtPosition = positions.find((p) => p.token.address.eq(this.config.debt.address));
28836
+ const positions = await this.vesuAdapter.getPositions(
28837
+ this.config.networkConfig
28838
+ );
28839
+ const collateralPosition = positions.find(
28840
+ (p) => p.token.address.eq(collateral.address)
28841
+ );
28842
+ const debtPosition = positions.find(
28843
+ (p) => p.token.address.eq(this.config.debt.address)
28844
+ );
28778
28845
  if (!collateralPosition || !debtPosition) {
28779
28846
  throw new Error("Could not find current positions");
28780
28847
  }
@@ -28784,11 +28851,20 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28784
28851
  const result = maxWithdrawable.greaterThan(0) ? maxWithdrawable : new Web3Number("0", collateral.decimals);
28785
28852
  const usdValue = await this.getUSDValue(collateral, result);
28786
28853
  const debtUSD = debtPosition.usdValue;
28787
- logger.verbose(`VesuMultiplyAdapter: Debt USD: ${debtUSD}, collateral USD: ${usdValue}`);
28788
- const apys = await Promise.all([this.getAPY({ asset: collateral, isDebt: false }), this.getAPY({ asset: debt, isDebt: true })]);
28789
- logger.verbose(`VesuMultiplyAdapter: Apys: ${apys[0].apy}, ${apys[1].apy}`);
28854
+ logger.verbose(
28855
+ `VesuMultiplyAdapter: Debt USD: ${debtUSD}, collateral USD: ${usdValue}`
28856
+ );
28857
+ const apys = await Promise.all([
28858
+ this.getAPY({ asset: collateral, isDebt: false }),
28859
+ this.getAPY({ asset: debt, isDebt: true })
28860
+ ]);
28861
+ logger.verbose(
28862
+ `VesuMultiplyAdapter: Apys: ${apys[0].apy}, ${apys[1].apy}`
28863
+ );
28790
28864
  const netAPY = usdValue - debtUSD > 0 ? (apys[0].apy * usdValue + apys[1].apy * debtUSD) / (usdValue - debtUSD) : 0;
28791
- logger.verbose(`VesuMultiplyAdapter: Max withdraw amount: ${result.toNumber()}, netAPY: ${netAPY}`);
28865
+ logger.verbose(
28866
+ `VesuMultiplyAdapter: Max withdraw amount: ${result.toNumber()}, netAPY: ${netAPY}`
28867
+ );
28792
28868
  return {
28793
28869
  tokenInfo: collateral,
28794
28870
  amount: result,
@@ -28801,14 +28877,19 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28801
28877
  protocol: this.protocol
28802
28878
  };
28803
28879
  } catch (error) {
28804
- logger.error(`VesuMultiplyAdapter: Error calculating max withdraw:`, error);
28880
+ logger.error(
28881
+ `VesuMultiplyAdapter: Error calculating max withdraw:`,
28882
+ error
28883
+ );
28805
28884
  throw error;
28806
28885
  }
28807
28886
  }
28808
28887
  _getDepositLeaf() {
28809
28888
  const collateral = this.config.collateral;
28810
28889
  const debt = this.config.debt;
28811
- const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(this.config.poolId);
28890
+ const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(
28891
+ this.config.poolId
28892
+ );
28812
28893
  const vesuMultiply = isV2 ? this.vesuAdapter.VESU_MULTIPLY : this.vesuAdapter.VESU_MULTIPLY_V1;
28813
28894
  return [
28814
28895
  // Approval step for collateral
@@ -28872,7 +28953,9 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28872
28953
  ];
28873
28954
  }
28874
28955
  _getWithdrawLeaf() {
28875
- const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(this.config.poolId);
28956
+ const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(
28957
+ this.config.poolId
28958
+ );
28876
28959
  const vesuMultiply = isV2 ? this.vesuAdapter.VESU_MULTIPLY : this.vesuAdapter.VESU_MULTIPLY_V1;
28877
28960
  const collateral = this.config.collateral;
28878
28961
  const debt = this.config.debt;
@@ -28929,33 +29012,51 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28929
29012
  const leafConfigs = this._getDepositLeaf();
28930
29013
  const leaves = leafConfigs.map((config) => {
28931
29014
  const { target, method, packedArguments, sanitizer, id } = config;
28932
- const leaf = this.constructSimpleLeafData({
28933
- id,
28934
- target,
28935
- method,
28936
- packedArguments
28937
- }, sanitizer);
29015
+ const leaf = this.constructSimpleLeafData(
29016
+ {
29017
+ id,
29018
+ target,
29019
+ method,
29020
+ packedArguments
29021
+ },
29022
+ sanitizer
29023
+ );
28938
29024
  return leaf;
28939
29025
  });
28940
- return { leaves, callConstructor: this.getDepositCall.bind(this) };
29026
+ return {
29027
+ leaves,
29028
+ callConstructor: this.getDepositCall.bind(
29029
+ this
29030
+ )
29031
+ };
28941
29032
  }
28942
29033
  getWithdrawAdapter() {
28943
29034
  const leafConfigs = this._getWithdrawLeaf();
28944
29035
  const leaves = leafConfigs.map((config) => {
28945
29036
  const { target, method, packedArguments, sanitizer, id } = config;
28946
- const leaf = this.constructSimpleLeafData({
28947
- id,
28948
- target,
28949
- method,
28950
- packedArguments
28951
- }, sanitizer);
29037
+ const leaf = this.constructSimpleLeafData(
29038
+ {
29039
+ id,
29040
+ target,
29041
+ method,
29042
+ packedArguments
29043
+ },
29044
+ sanitizer
29045
+ );
28952
29046
  return leaf;
28953
29047
  });
28954
- return { leaves, callConstructor: this.getWithdrawCall.bind(this) };
29048
+ return {
29049
+ leaves,
29050
+ callConstructor: this.getWithdrawCall.bind(
29051
+ this
29052
+ )
29053
+ };
28955
29054
  }
28956
29055
  async getDepositCall(params) {
28957
29056
  const collateral = this.config.collateral;
28958
- const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(this.config.poolId);
29057
+ const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(
29058
+ this.config.poolId
29059
+ );
28959
29060
  const vesuMultiply = isV2 ? this.vesuAdapter.VESU_MULTIPLY : this.vesuAdapter.VESU_MULTIPLY_V1;
28960
29061
  const uint256MarginAmount = uint25612.bnToUint256(params.amount.toWei());
28961
29062
  return [
@@ -29027,7 +29128,9 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29027
29128
  ];
29028
29129
  }
29029
29130
  async getWithdrawCall(params) {
29030
- const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(this.config.poolId);
29131
+ const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(
29132
+ this.config.poolId
29133
+ );
29031
29134
  const vesuMultiply = isV2 ? this.vesuAdapter.VESU_MULTIPLY : this.vesuAdapter.VESU_MULTIPLY_V1;
29032
29135
  return [
29033
29136
  // Switch delegation on
@@ -29082,7 +29185,11 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29082
29185
  ];
29083
29186
  }
29084
29187
  async getMultiplyCallCalldata(params, isDeposit) {
29085
- logger.verbose(`${_VesuMultiplyAdapter.name}::getMultiplyCallCalldata params: ${JSON.stringify(params)}, isDeposit: ${isDeposit}, collateral: ${this.config.collateral.symbol}, debt: ${this.config.debt.symbol}`);
29188
+ logger.verbose(
29189
+ `${_VesuMultiplyAdapter.name}::getMultiplyCallCalldata params: ${JSON.stringify(
29190
+ params
29191
+ )}, isDeposit: ${isDeposit}, collateral: ${this.config.collateral.symbol}, debt: ${this.config.debt.symbol}`
29192
+ );
29086
29193
  const { isV2 } = getVesuSingletonAddress(this.config.poolId);
29087
29194
  const vesuMultiply = isV2 ? this.vesuAdapter.VESU_MULTIPLY : this.vesuAdapter.VESU_MULTIPLY_V1;
29088
29195
  const multiplyContract = new Contract12({
@@ -29092,42 +29199,83 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29092
29199
  });
29093
29200
  let leverSwap = [];
29094
29201
  let leverSwapLimitAmount = Web3Number.fromWei(0, this.config.debt.decimals);
29095
- const existingPositions = await this.vesuAdapter.getPositions(this.config.networkConfig);
29096
- const collateralisation = await this.vesuAdapter.getCollateralization(this.config.networkConfig);
29202
+ const existingPositions = await this.vesuAdapter.getPositions(
29203
+ this.config.networkConfig
29204
+ );
29205
+ const collateralisation = await this.vesuAdapter.getCollateralization(
29206
+ this.config.networkConfig
29207
+ );
29097
29208
  const existingCollateralInfo = existingPositions[0];
29098
29209
  const existingDebtInfo = existingPositions[1];
29099
29210
  const isDexPriceRequired = existingDebtInfo.token.symbol !== "USDC";
29100
- logger.debug(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
29101
- existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
29211
+ logger.debug(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(
29212
+ existingCollateralInfo
29213
+ )},
29214
+ existingDebtInfo: ${JSON.stringify(
29215
+ existingDebtInfo
29216
+ )}, collateralisation: ${JSON.stringify(collateralisation)}`);
29102
29217
  const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : (await this.config.pricer.getPrice(this.config.collateral.symbol)).price;
29103
29218
  const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : (await this.config.pricer.getPrice(this.config.debt.symbol)).price;
29104
- logger.debug(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
29105
- const legLTV = await this.vesuAdapter.getLTVConfig(this.config.networkConfig);
29106
- const ekuboQuoter = new EkuboQuoter(this.config.networkConfig, this.config.pricer);
29107
- const dexPrice = isDexPriceRequired ? await ekuboQuoter.getDexPrice(this.config.collateral, this.config.debt, this.config.quoteAmountToFetchPrice) : 1;
29108
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall dexPrice: ${dexPrice}, ltv: ${legLTV}`);
29219
+ logger.debug(
29220
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`
29221
+ );
29222
+ const legLTV = await this.vesuAdapter.getLTVConfig(
29223
+ this.config.networkConfig
29224
+ );
29225
+ const ekuboQuoter = new EkuboQuoter(
29226
+ this.config.networkConfig,
29227
+ this.config.pricer
29228
+ );
29229
+ const dexPrice = isDexPriceRequired ? await ekuboQuoter.getDexPrice(
29230
+ this.config.collateral,
29231
+ this.config.debt,
29232
+ this.config.quoteAmountToFetchPrice
29233
+ ) : 1;
29234
+ logger.verbose(
29235
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall dexPrice: ${dexPrice}, ltv: ${legLTV}`
29236
+ );
29109
29237
  const addedCollateral = params.amount.multipliedBy(isDeposit ? 1 : -1);
29110
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall addedCollateral: ${addedCollateral}`);
29238
+ logger.verbose(
29239
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall addedCollateral: ${addedCollateral}`
29240
+ );
29111
29241
  const numeratorPart1 = existingCollateralInfo.amount.plus(addedCollateral).multipliedBy(collateralPrice).multipliedBy(legLTV);
29112
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}`);
29242
+ logger.verbose(
29243
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}`
29244
+ );
29113
29245
  const numeratorPart2 = existingDebtInfo.amount.multipliedBy(debtPrice).multipliedBy(this.config.targetHealthFactor);
29114
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart2: ${numeratorPart2}`);
29246
+ logger.verbose(
29247
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart2: ${numeratorPart2}`
29248
+ );
29115
29249
  const denominatorPart = this.config.targetHealthFactor - legLTV / dexPrice;
29116
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall denominatorPart: ${denominatorPart}`);
29250
+ logger.verbose(
29251
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall denominatorPart: ${denominatorPart}`
29252
+ );
29117
29253
  const x_debt_usd = numeratorPart1.minus(numeratorPart2).dividedBy(denominatorPart);
29118
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall x_debt_usd: ${x_debt_usd}`);
29119
- logger.debug(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}, numeratorPart2: ${numeratorPart2}, denominatorPart: ${denominatorPart}`);
29120
- let debtAmount = new Web3Number(x_debt_usd.dividedBy(debtPrice).toFixed(this.config.debt.decimals), this.config.debt.decimals);
29254
+ logger.verbose(
29255
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall x_debt_usd: ${x_debt_usd}`
29256
+ );
29257
+ logger.debug(
29258
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}, numeratorPart2: ${numeratorPart2}, denominatorPart: ${denominatorPart}`
29259
+ );
29260
+ let debtAmount = new Web3Number(
29261
+ x_debt_usd.dividedBy(debtPrice).toFixed(this.config.debt.decimals),
29262
+ this.config.debt.decimals
29263
+ );
29121
29264
  const marginAmount = addedCollateral;
29122
29265
  const collateralToken = this.config.collateral;
29123
29266
  const debtToken = this.config.debt;
29124
- const debtAmountInCollateralUnits = new Web3Number(debtAmount.multipliedBy(debtPrice).dividedBy(collateralPrice).multipliedBy(10 ** collateralToken.decimals).toFixed(0), collateralToken.decimals);
29267
+ const debtAmountInCollateralUnits = new Web3Number(
29268
+ debtAmount.multipliedBy(debtPrice).dividedBy(collateralPrice).multipliedBy(10 ** collateralToken.decimals).toFixed(0),
29269
+ collateralToken.decimals
29270
+ );
29125
29271
  const isIncrease = debtAmount.greaterThanOrEqualTo(0);
29126
29272
  if (isIncrease && debtAmount.lessThan(0)) {
29127
29273
  } else if (!isIncrease && debtAmount.greaterThan(0)) {
29128
29274
  debtAmount = Web3Number.fromWei(0, this.config.debt.decimals);
29129
29275
  }
29130
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall debtAmount: ${debtAmount}, marginAmount: ${marginAmount}`);
29276
+ logger.verbose(
29277
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall debtAmount: ${debtAmount}, marginAmount: ${marginAmount}`
29278
+ );
29131
29279
  if (!debtAmount.isZero()) {
29132
29280
  try {
29133
29281
  const swapQuote = await ekuboQuoter.getQuote(
@@ -29137,26 +29285,49 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29137
29285
  // negative for exact amount out
29138
29286
  );
29139
29287
  if (swapQuote.price_impact < 0.01) {
29140
- leverSwap = ekuboQuoter.getVesuMultiplyQuote(swapQuote, debtToken, collateralToken);
29288
+ leverSwap = debtAmount.isNegative() ? ekuboQuoter.getVesuMultiplyQuote(
29289
+ swapQuote,
29290
+ collateralToken,
29291
+ debtToken
29292
+ ) : ekuboQuoter.getVesuMultiplyQuote(
29293
+ swapQuote,
29294
+ debtToken,
29295
+ collateralToken
29296
+ );
29141
29297
  const MAX_SLIPPAGE = 2e-3;
29142
29298
  if (debtAmount.greaterThan(0)) {
29143
29299
  leverSwapLimitAmount = debtAmount.multipliedBy(1 + MAX_SLIPPAGE);
29144
29300
  } else if (debtAmount.lessThan(0)) {
29145
29301
  leverSwapLimitAmount = debtAmount.abs().multipliedBy(1 - MAX_SLIPPAGE);
29146
29302
  } else {
29147
- leverSwapLimitAmount = Web3Number.fromWei(0, this.config.debt.decimals);
29303
+ leverSwapLimitAmount = Web3Number.fromWei(
29304
+ 0,
29305
+ this.config.debt.decimals
29306
+ );
29148
29307
  }
29149
29308
  await new Promise((resolve) => setTimeout(resolve, 1e4));
29150
29309
  } else {
29151
- throw new Error(`VesuMultiplyAdapter: Price impact too high (${swapQuote.price_impact}), skipping swap`);
29310
+ throw new Error(
29311
+ `VesuMultiplyAdapter: Price impact too high (${swapQuote.price_impact}), skipping swap`
29312
+ );
29152
29313
  }
29153
29314
  } catch (error) {
29154
- throw new Error(`VesuMultiplyAdapter: Failed to get swap quote: ${error}`);
29315
+ throw new Error(
29316
+ `VesuMultiplyAdapter: Failed to get swap quote: ${error}`
29317
+ );
29155
29318
  }
29156
29319
  }
29157
- const multiplyParams = await this.getLeverParams(isIncrease, params, leverSwap, leverSwapLimitAmount);
29320
+ const multiplyParams = await this.getLeverParams(
29321
+ isIncrease,
29322
+ params,
29323
+ leverSwap,
29324
+ leverSwapLimitAmount
29325
+ );
29158
29326
  const call = multiplyContract.populate("modify_lever", {
29159
- modify_lever_params: this.formatMultiplyParams(isIncrease, multiplyParams)
29327
+ modify_lever_params: this.formatMultiplyParams(
29328
+ isIncrease,
29329
+ multiplyParams
29330
+ )
29160
29331
  });
29161
29332
  return call.calldata;
29162
29333
  }
@@ -29170,7 +29341,10 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29170
29341
  add_margin: params.amount,
29171
29342
  // multiplied by collateral decimals in format
29172
29343
  margin_swap: [],
29173
- margin_swap_limit_amount: Web3Number.fromWei(0, this.config.collateral.decimals),
29344
+ margin_swap_limit_amount: Web3Number.fromWei(
29345
+ 0,
29346
+ this.config.collateral.decimals
29347
+ ),
29174
29348
  lever_swap: leverSwap,
29175
29349
  lever_swap_limit_amount: leverSwapLimitAmount
29176
29350
  } : {
@@ -29184,7 +29358,10 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29184
29358
  lever_swap_limit_amount: leverSwapLimitAmount,
29185
29359
  lever_swap_weights: [],
29186
29360
  withdraw_swap: [],
29187
- withdraw_swap_limit_amount: Web3Number.fromWei(0, this.config.collateral.decimals),
29361
+ withdraw_swap_limit_amount: Web3Number.fromWei(
29362
+ 0,
29363
+ this.config.collateral.decimals
29364
+ ),
29188
29365
  withdraw_swap_weights: [],
29189
29366
  close_position: false
29190
29367
  };
@@ -29200,12 +29377,16 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29200
29377
  });
29201
29378
  let leverSwap = [];
29202
29379
  let leverSwapLimitAmount = Web3Number.fromWei(0, this.config.debt.decimals);
29203
- const existingPositions = await this.vesuAdapter.getPositions(this.config.networkConfig);
29380
+ const existingPositions = await this.vesuAdapter.getPositions(
29381
+ this.config.networkConfig
29382
+ );
29204
29383
  const existingCollateralInfo = existingPositions[0];
29205
29384
  const existingDebtInfo = existingPositions[1];
29206
29385
  const collateralToken = this.config.collateral;
29207
29386
  const debtToken = this.config.debt;
29208
- const collateralPrice = await this.config.pricer.getPrice(collateralToken.symbol);
29387
+ const collateralPrice = await this.config.pricer.getPrice(
29388
+ collateralToken.symbol
29389
+ );
29209
29390
  const debtPrice = await this.config.pricer.getPrice(debtToken.symbol);
29210
29391
  const { deltadebtAmountUnits: debtAmountToRepay } = calculateDebtReductionAmountForWithdrawal(
29211
29392
  existingDebtInfo.amount,
@@ -29219,8 +29400,14 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29219
29400
  if (!debtAmountToRepay) {
29220
29401
  throw new Error("error calculating debt amount to repay");
29221
29402
  }
29222
- const ekuboQuoter = new EkuboQuoter(this.config.networkConfig, this.config.pricer);
29223
- const debtInDebtUnits = new Web3Number(debtAmountToRepay, debtToken.decimals).dividedBy(debtPrice.price).multipliedBy(10 ** debtToken.decimals);
29403
+ const ekuboQuoter = new EkuboQuoter(
29404
+ this.config.networkConfig,
29405
+ this.config.pricer
29406
+ );
29407
+ const debtInDebtUnits = new Web3Number(
29408
+ debtAmountToRepay,
29409
+ debtToken.decimals
29410
+ ).dividedBy(debtPrice.price).multipliedBy(10 ** debtToken.decimals);
29224
29411
  const swapQuote = await ekuboQuoter.getQuote(
29225
29412
  debtToken.address.address,
29226
29413
  collateralToken.address.address,
@@ -29228,12 +29415,23 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29228
29415
  );
29229
29416
  const MAX_SLIPPAGE = 2e-3;
29230
29417
  if (swapQuote.price_impact < 25e-4) {
29231
- leverSwap = ekuboQuoter.getVesuMultiplyQuote(swapQuote, collateralToken, debtToken);
29418
+ leverSwap = ekuboQuoter.getVesuMultiplyQuote(
29419
+ swapQuote,
29420
+ collateralToken,
29421
+ debtToken
29422
+ );
29232
29423
  } else {
29233
- logger.error(`VesuMultiplyAdapter: Price impact too high (${swapQuote.price_impact}), skipping swap`);
29424
+ logger.error(
29425
+ `VesuMultiplyAdapter: Price impact too high (${swapQuote.price_impact}), skipping swap`
29426
+ );
29234
29427
  }
29235
29428
  leverSwapLimitAmount = new Web3Number(debtAmountToRepay, debtToken.decimals).abs().multipliedBy(1 + MAX_SLIPPAGE);
29236
- const multiplyParams = await this.getLeverParams(false, params, leverSwap, leverSwapLimitAmount);
29429
+ const multiplyParams = await this.getLeverParams(
29430
+ false,
29431
+ params,
29432
+ leverSwap,
29433
+ leverSwapLimitAmount
29434
+ );
29237
29435
  const call = multiplyContract.populate("modify_lever", {
29238
29436
  modify_lever_params: this.formatMultiplyParams(false, multiplyParams)
29239
29437
  });
@@ -29243,100 +29441,132 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29243
29441
  if (isIncrease) {
29244
29442
  const _params2 = params;
29245
29443
  return {
29246
- action: new CairoCustomEnum3({ IncreaseLever: {
29247
- pool_id: _params2.pool_id.toBigInt(),
29248
- collateral_asset: _params2.collateral_asset.toBigInt(),
29249
- debt_asset: _params2.debt_asset.toBigInt(),
29250
- user: _params2.user.toBigInt(),
29251
- add_margin: BigInt(_params2.add_margin.toWei()),
29252
- margin_swap: _params2.margin_swap.map((swap) => ({
29444
+ action: new CairoCustomEnum3({
29445
+ IncreaseLever: {
29446
+ pool_id: _params2.pool_id.toBigInt(),
29447
+ collateral_asset: _params2.collateral_asset.toBigInt(),
29448
+ debt_asset: _params2.debt_asset.toBigInt(),
29449
+ user: _params2.user.toBigInt(),
29450
+ add_margin: BigInt(_params2.add_margin.toWei()),
29451
+ margin_swap: _params2.margin_swap.map((swap) => ({
29452
+ route: swap.route.map((route) => ({
29453
+ pool_key: {
29454
+ token0: route.pool_key.token0.toBigInt(),
29455
+ token1: route.pool_key.token1.toBigInt(),
29456
+ fee: route.pool_key.fee,
29457
+ tick_spacing: route.pool_key.tick_spacing,
29458
+ extension: BigInt(
29459
+ num9.hexToDecimalString(route.pool_key.extension)
29460
+ )
29461
+ },
29462
+ sqrt_ratio_limit: uint25612.bnToUint256(
29463
+ route.sqrt_ratio_limit.toWei()
29464
+ ),
29465
+ skip_ahead: BigInt(100)
29466
+ })),
29467
+ token_amount: {
29468
+ token: swap.token_amount.token.toBigInt(),
29469
+ amount: swap.token_amount.amount.toI129()
29470
+ }
29471
+ })),
29472
+ margin_swap_limit_amount: BigInt(
29473
+ _params2.margin_swap_limit_amount.toWei()
29474
+ ),
29475
+ lever_swap: _params2.lever_swap.map((swap) => ({
29476
+ route: swap.route.map((route) => ({
29477
+ pool_key: {
29478
+ token0: route.pool_key.token0.toBigInt(),
29479
+ token1: route.pool_key.token1.toBigInt(),
29480
+ fee: route.pool_key.fee,
29481
+ tick_spacing: route.pool_key.tick_spacing,
29482
+ extension: BigInt(
29483
+ num9.hexToDecimalString(route.pool_key.extension)
29484
+ )
29485
+ },
29486
+ sqrt_ratio_limit: uint25612.bnToUint256(
29487
+ route.sqrt_ratio_limit.toWei()
29488
+ ),
29489
+ skip_ahead: BigInt(0)
29490
+ })),
29491
+ token_amount: {
29492
+ token: swap.token_amount.token.toBigInt(),
29493
+ amount: swap.token_amount.amount.toI129()
29494
+ }
29495
+ })),
29496
+ lever_swap_limit_amount: BigInt(
29497
+ _params2.lever_swap_limit_amount.toWei()
29498
+ )
29499
+ }
29500
+ })
29501
+ };
29502
+ }
29503
+ const _params = params;
29504
+ return {
29505
+ action: new CairoCustomEnum3({
29506
+ DecreaseLever: {
29507
+ pool_id: _params.pool_id.toBigInt(),
29508
+ collateral_asset: _params.collateral_asset.toBigInt(),
29509
+ debt_asset: _params.debt_asset.toBigInt(),
29510
+ user: _params.user.toBigInt(),
29511
+ sub_margin: BigInt(_params.sub_margin.toWei()),
29512
+ recipient: _params.recipient.toBigInt(),
29513
+ lever_swap: _params.lever_swap.map((swap) => ({
29253
29514
  route: swap.route.map((route) => ({
29254
29515
  pool_key: {
29255
29516
  token0: route.pool_key.token0.toBigInt(),
29256
29517
  token1: route.pool_key.token1.toBigInt(),
29257
29518
  fee: route.pool_key.fee,
29258
29519
  tick_spacing: route.pool_key.tick_spacing,
29259
- extension: BigInt(num9.hexToDecimalString(route.pool_key.extension))
29520
+ extension: ContractAddr.from(
29521
+ route.pool_key.extension
29522
+ ).toBigInt()
29260
29523
  },
29261
- sqrt_ratio_limit: uint25612.bnToUint256(route.sqrt_ratio_limit.toWei()),
29262
- skip_ahead: BigInt(100)
29524
+ sqrt_ratio_limit: uint25612.bnToUint256(
29525
+ route.sqrt_ratio_limit.toWei()
29526
+ ),
29527
+ skip_ahead: BigInt(route.skip_ahead.toWei())
29263
29528
  })),
29264
29529
  token_amount: {
29265
29530
  token: swap.token_amount.token.toBigInt(),
29266
29531
  amount: swap.token_amount.amount.toI129()
29267
29532
  }
29268
29533
  })),
29269
- margin_swap_limit_amount: BigInt(_params2.margin_swap_limit_amount.toWei()),
29270
- lever_swap: _params2.lever_swap.map((swap) => ({
29534
+ lever_swap_limit_amount: BigInt(
29535
+ _params.lever_swap_limit_amount.toWei()
29536
+ ),
29537
+ lever_swap_weights: _params.lever_swap_weights.map(
29538
+ (weight) => BigInt(weight.toWei())
29539
+ ),
29540
+ withdraw_swap: _params.withdraw_swap.map((swap) => ({
29271
29541
  route: swap.route.map((route) => ({
29272
29542
  pool_key: {
29273
29543
  token0: route.pool_key.token0.toBigInt(),
29274
29544
  token1: route.pool_key.token1.toBigInt(),
29275
29545
  fee: route.pool_key.fee,
29276
29546
  tick_spacing: route.pool_key.tick_spacing,
29277
- extension: BigInt(num9.hexToDecimalString(route.pool_key.extension))
29547
+ extension: ContractAddr.from(
29548
+ route.pool_key.extension
29549
+ ).toBigInt()
29278
29550
  },
29279
- sqrt_ratio_limit: uint25612.bnToUint256(route.sqrt_ratio_limit.toWei()),
29280
- skip_ahead: BigInt(0)
29551
+ sqrt_ratio_limit: uint25612.bnToUint256(
29552
+ route.sqrt_ratio_limit.toWei()
29553
+ ),
29554
+ skip_ahead: BigInt(route.skip_ahead.toWei())
29281
29555
  })),
29282
29556
  token_amount: {
29283
29557
  token: swap.token_amount.token.toBigInt(),
29284
29558
  amount: swap.token_amount.amount.toI129()
29285
29559
  }
29286
29560
  })),
29287
- lever_swap_limit_amount: BigInt(_params2.lever_swap_limit_amount.toWei())
29288
- } })
29289
- };
29290
- }
29291
- const _params = params;
29292
- return {
29293
- action: new CairoCustomEnum3({ DecreaseLever: {
29294
- pool_id: _params.pool_id.toBigInt(),
29295
- collateral_asset: _params.collateral_asset.toBigInt(),
29296
- debt_asset: _params.debt_asset.toBigInt(),
29297
- user: _params.user.toBigInt(),
29298
- sub_margin: BigInt(_params.sub_margin.toWei()),
29299
- recipient: _params.recipient.toBigInt(),
29300
- lever_swap: _params.lever_swap.map((swap) => ({
29301
- route: swap.route.map((route) => ({
29302
- pool_key: {
29303
- token0: route.pool_key.token0.toBigInt(),
29304
- token1: route.pool_key.token1.toBigInt(),
29305
- fee: route.pool_key.fee,
29306
- tick_spacing: route.pool_key.tick_spacing,
29307
- extension: ContractAddr.from(route.pool_key.extension).toBigInt()
29308
- },
29309
- sqrt_ratio_limit: uint25612.bnToUint256(route.sqrt_ratio_limit.toWei()),
29310
- skip_ahead: BigInt(route.skip_ahead.toWei())
29311
- })),
29312
- token_amount: {
29313
- token: swap.token_amount.token.toBigInt(),
29314
- amount: swap.token_amount.amount.toI129()
29315
- }
29316
- })),
29317
- lever_swap_limit_amount: BigInt(_params.lever_swap_limit_amount.toWei()),
29318
- lever_swap_weights: _params.lever_swap_weights.map((weight) => BigInt(weight.toWei())),
29319
- withdraw_swap: _params.withdraw_swap.map((swap) => ({
29320
- route: swap.route.map((route) => ({
29321
- pool_key: {
29322
- token0: route.pool_key.token0.toBigInt(),
29323
- token1: route.pool_key.token1.toBigInt(),
29324
- fee: route.pool_key.fee,
29325
- tick_spacing: route.pool_key.tick_spacing,
29326
- extension: ContractAddr.from(route.pool_key.extension).toBigInt()
29327
- },
29328
- sqrt_ratio_limit: uint25612.bnToUint256(route.sqrt_ratio_limit.toWei()),
29329
- skip_ahead: BigInt(route.skip_ahead.toWei())
29330
- })),
29331
- token_amount: {
29332
- token: swap.token_amount.token.toBigInt(),
29333
- amount: swap.token_amount.amount.toI129()
29334
- }
29335
- })),
29336
- withdraw_swap_limit_amount: BigInt(_params.withdraw_swap_limit_amount.toWei()),
29337
- withdraw_swap_weights: _params.withdraw_swap_weights.map((weight) => BigInt(weight.toWei())),
29338
- close_position: _params.close_position
29339
- } })
29561
+ withdraw_swap_limit_amount: BigInt(
29562
+ _params.withdraw_swap_limit_amount.toWei()
29563
+ ),
29564
+ withdraw_swap_weights: _params.withdraw_swap_weights.map(
29565
+ (weight) => BigInt(weight.toWei())
29566
+ ),
29567
+ close_position: _params.close_position
29568
+ }
29569
+ })
29340
29570
  };
29341
29571
  }
29342
29572
  async getHealthFactor() {
@@ -29345,11 +29575,15 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29345
29575
  }
29346
29576
  async getNetAPY() {
29347
29577
  const positions = await this.getPositions();
29348
- logger.verbose(`${this.name}::getNetAPY: positions: ${JSON.stringify(positions)}`);
29578
+ logger.verbose(
29579
+ `${this.name}::getNetAPY: positions: ${JSON.stringify(positions)}`
29580
+ );
29349
29581
  const allZero = positions.every((p) => p.usdValue === 0);
29350
29582
  if (allZero) {
29351
29583
  const collateralUSD = 1e3;
29352
- const maxLTV = await this.vesuAdapter.getLTVConfig(this.config.networkConfig);
29584
+ const maxLTV = await this.vesuAdapter.getLTVConfig(
29585
+ this.config.networkConfig
29586
+ );
29353
29587
  const targetHF = this.config.targetHealthFactor;
29354
29588
  const maxDebt = HealthFactorMath.getMaxDebtAmountOnLooping(
29355
29589
  new Web3Number(collateralUSD, this.config.collateral.decimals),
@@ -29739,6 +29973,7 @@ var ExtendedAdapter = class _ExtendedAdapter extends BaseAdapter {
29739
29973
  logger.error("error initializing client");
29740
29974
  return null;
29741
29975
  }
29976
+ await new Promise((resolve) => setTimeout(resolve, 5e3));
29742
29977
  const orderhistory = await this.getOrderHistory(marketName);
29743
29978
  if (!orderhistory || orderhistory.length === 0) {
29744
29979
  logger.error(`error getting order: ${orderId}`);
@@ -34119,7 +34354,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34119
34354
  const withdrawalFromExtended = await extendedAdapter.withdrawFromExtended(params.amount);
34120
34355
  if (withdrawalFromExtended) {
34121
34356
  const extendedHoldings2 = await extendedAdapter.getExtendedDepositAmount();
34122
- logger.info(`extendedHoldings after withdrawal ${extendedHoldings2}`);
34357
+ logger.info(`extendedHoldings after withdrawal ${extendedHoldings2?.availableForWithdrawal}`);
34123
34358
  await new Promise((resolve) => setTimeout(resolve, 1e4));
34124
34359
  const calls = await this.moveAssetsToVaultAllocator(params.amount, extendedAdapter);
34125
34360
  if (calls.length > 0) {