@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.
package/dist/index.js CHANGED
@@ -28426,21 +28426,35 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28426
28426
  vaultAllocator: config.vaultAllocator,
28427
28427
  id: ""
28428
28428
  });
28429
- this.tokenMarketData = new TokenMarketData(this.config.pricer, this.config.networkConfig);
28429
+ this.tokenMarketData = new TokenMarketData(
28430
+ this.config.pricer,
28431
+ this.config.networkConfig
28432
+ );
28430
28433
  }
28431
28434
  async getAPY(supportedPosition) {
28432
28435
  const CACHE_KEY = `apy_${this.config.poolId.address}_${supportedPosition.asset.symbol}`;
28433
28436
  const cacheData = this.getCache(CACHE_KEY);
28434
- console.log(`${_VesuMultiplyAdapter.name}::getAPY cacheData: ${JSON.stringify(cacheData)}`, this.vesuAdapter.config.poolId.shortString(), this.vesuAdapter.config.collateral.symbol, this.vesuAdapter.config.debt.symbol);
28437
+ console.log(
28438
+ `${_VesuMultiplyAdapter.name}::getAPY cacheData: ${JSON.stringify(
28439
+ cacheData
28440
+ )}`,
28441
+ this.vesuAdapter.config.poolId.shortString(),
28442
+ this.vesuAdapter.config.collateral.symbol,
28443
+ this.vesuAdapter.config.debt.symbol
28444
+ );
28435
28445
  if (cacheData) {
28436
28446
  return cacheData;
28437
28447
  }
28438
28448
  try {
28439
28449
  const allVesuPools = await VesuAdapter.getVesuPools();
28440
28450
  const asset = supportedPosition.asset;
28441
- const pool = allVesuPools.pools.find((p) => this.vesuAdapter.config.poolId.eqString(import_starknet21.num.getHexString(p.id)));
28451
+ const pool = allVesuPools.pools.find(
28452
+ (p) => this.vesuAdapter.config.poolId.eqString(import_starknet21.num.getHexString(p.id))
28453
+ );
28442
28454
  if (!pool) {
28443
- logger.warn(`VesuMultiplyAdapter: Pool not found for token ${asset.symbol}`);
28455
+ logger.warn(
28456
+ `VesuMultiplyAdapter: Pool not found for token ${asset.symbol}`
28457
+ );
28444
28458
  return {
28445
28459
  apy: 0,
28446
28460
  type: "base" /* BASE */
@@ -28450,7 +28464,9 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28450
28464
  (a) => a.symbol.toLowerCase() === asset.symbol.toLowerCase()
28451
28465
  )?.stats;
28452
28466
  if (!assetStats) {
28453
- logger.warn(`VesuMultiplyAdapter: Asset stats not found for token ${asset.symbol}`);
28467
+ logger.warn(
28468
+ `VesuMultiplyAdapter: Asset stats not found for token ${asset.symbol}`
28469
+ );
28454
28470
  return {
28455
28471
  apy: 0,
28456
28472
  type: "base" /* BASE */
@@ -28461,7 +28477,9 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28461
28477
  apy = Number(assetStats.borrowApr?.value || 0) / 1e18;
28462
28478
  } else {
28463
28479
  const isAssetBTC = asset.symbol.toLowerCase().includes("btc");
28464
- const baseAPY = Number(isAssetBTC ? assetStats.btcFiSupplyApr?.value + assetStats.supplyApy?.value : assetStats.supplyApy?.value || 0) / 1e18;
28480
+ const baseAPY = Number(
28481
+ isAssetBTC ? assetStats.btcFiSupplyApr?.value + assetStats.supplyApy?.value : assetStats.supplyApy?.value || 0
28482
+ ) / 1e18;
28465
28483
  const rewardAPY = Number(assetStats.defiSpringSupplyApr?.value || "0") / 1e18;
28466
28484
  const isSupported = this.tokenMarketData.isAPYSupported(asset);
28467
28485
  apy = baseAPY + rewardAPY;
@@ -28477,7 +28495,10 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28477
28495
  this.setCache(CACHE_KEY, result, 3e5);
28478
28496
  return result;
28479
28497
  } catch (error) {
28480
- logger.error(`VesuMultiplyAdapter: Error getting APY for ${supportedPosition.asset.symbol}:`, error);
28498
+ logger.error(
28499
+ `VesuMultiplyAdapter: Error getting APY for ${supportedPosition.asset.symbol}:`,
28500
+ error
28501
+ );
28481
28502
  throw error;
28482
28503
  }
28483
28504
  }
@@ -28490,12 +28511,16 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28490
28511
  try {
28491
28512
  this.vesuAdapter.networkConfig = this.config.networkConfig;
28492
28513
  this.vesuAdapter.pricer = this.config.pricer;
28493
- const positions = await this.vesuAdapter.getPositions(this.config.networkConfig);
28514
+ const positions = await this.vesuAdapter.getPositions(
28515
+ this.config.networkConfig
28516
+ );
28494
28517
  let position = positions.find(
28495
28518
  (p) => p.token.address.eq(supportedPosition.asset.address)
28496
28519
  );
28497
28520
  if (!position) {
28498
- logger.warn(`VesuMultiplyAdapter: Position not found for token ${supportedPosition.asset.symbol}`);
28521
+ logger.warn(
28522
+ `VesuMultiplyAdapter: Position not found for token ${supportedPosition.asset.symbol}`
28523
+ );
28499
28524
  return {
28500
28525
  amount: new Web3Number("0", supportedPosition.asset.decimals),
28501
28526
  remarks: "Position not found"
@@ -28508,12 +28533,18 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28508
28533
  this.setCache(CACHE_KEY, position, 6e4);
28509
28534
  return position;
28510
28535
  } catch (error) {
28511
- logger.error(`VesuMultiplyAdapter: Error getting position for ${supportedPosition.asset.symbol}:`, error);
28536
+ logger.error(
28537
+ `VesuMultiplyAdapter: Error getting position for ${supportedPosition.asset.symbol}:`,
28538
+ error
28539
+ );
28512
28540
  throw error;
28513
28541
  }
28514
28542
  }
28515
28543
  async maxBorrowableAPY() {
28516
- const collateralAPY = await this.getAPY({ asset: this.config.collateral, isDebt: false });
28544
+ const collateralAPY = await this.getAPY({
28545
+ asset: this.config.collateral,
28546
+ isDebt: false
28547
+ });
28517
28548
  const apy = collateralAPY.apy * 0.8;
28518
28549
  return apy;
28519
28550
  }
@@ -28523,9 +28554,15 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28523
28554
  try {
28524
28555
  this.vesuAdapter.networkConfig = this.config.networkConfig;
28525
28556
  this.vesuAdapter.pricer = this.config.pricer;
28526
- const positions = await this.vesuAdapter.getPositions(this.config.networkConfig);
28527
- const collateralPosition = positions.find((p) => p.token.address.eq(collateral.address));
28528
- const debtPosition = positions.find((p) => p.token.address.eq(debt.address));
28557
+ const positions = await this.vesuAdapter.getPositions(
28558
+ this.config.networkConfig
28559
+ );
28560
+ const collateralPosition = positions.find(
28561
+ (p) => p.token.address.eq(collateral.address)
28562
+ );
28563
+ const debtPosition = positions.find(
28564
+ (p) => p.token.address.eq(debt.address)
28565
+ );
28529
28566
  if (!collateralPosition || !debtPosition) {
28530
28567
  throw new Error("Could not find current positions");
28531
28568
  }
@@ -28535,13 +28572,23 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28535
28572
  debt,
28536
28573
  maxBorrowableAPY
28537
28574
  );
28538
- logger.verbose(`VesuMultiplyAdapter: Max borrowable: ${maxBorrowable.toNumber()}`);
28539
- const debtCap = await this.vesuAdapter.getDebtCap(this.config.networkConfig);
28575
+ logger.verbose(
28576
+ `VesuMultiplyAdapter: Max borrowable: ${maxBorrowable.toNumber()}`
28577
+ );
28578
+ const debtCap = await this.vesuAdapter.getDebtCap(
28579
+ this.config.networkConfig
28580
+ );
28540
28581
  logger.verbose(`VesuMultiplyAdapter: Debt cap: ${debtCap.toNumber()}`);
28541
28582
  const actualMaxBorrowable = maxBorrowable.minimum(debtCap);
28542
- logger.verbose(`VesuMultiplyAdapter: Actual max borrowable: ${actualMaxBorrowable.toNumber()}`);
28543
- const maxLTV = await this.vesuAdapter.getLTVConfig(this.config.networkConfig);
28544
- const collateralPrice = await this.config.pricer.getPrice(collateral.symbol);
28583
+ logger.verbose(
28584
+ `VesuMultiplyAdapter: Actual max borrowable: ${actualMaxBorrowable.toNumber()}`
28585
+ );
28586
+ const maxLTV = await this.vesuAdapter.getLTVConfig(
28587
+ this.config.networkConfig
28588
+ );
28589
+ const collateralPrice = await this.config.pricer.getPrice(
28590
+ collateral.symbol
28591
+ );
28545
28592
  if (collateralPrice.price === 0) {
28546
28593
  throw new Error("Collateral price is 0");
28547
28594
  }
@@ -28559,14 +28606,25 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28559
28606
  );
28560
28607
  const maxDepositAmount = amount ? amount.minimum(maxCollateralFromDebt) : maxCollateralFromDebt;
28561
28608
  const usdValue = await this.getUSDValue(collateral, maxDepositAmount);
28562
- logger.verbose(`VesuMultiplyAdapter: Max deposit::USD value: ${usdValue}, amount: ${maxDepositAmount.toNumber()}`);
28563
- const apys = await Promise.all([this.getAPY({ asset: collateral, isDebt: false }), this.getAPY({ asset: debt, isDebt: true })]);
28564
- logger.verbose(`VesuMultiplyAdapter: Apys: ${apys[0].apy}, ${apys[1].apy}`);
28609
+ logger.verbose(
28610
+ `VesuMultiplyAdapter: Max deposit::USD value: ${usdValue}, amount: ${maxDepositAmount.toNumber()}`
28611
+ );
28612
+ const apys = await Promise.all([
28613
+ this.getAPY({ asset: collateral, isDebt: false }),
28614
+ this.getAPY({ asset: debt, isDebt: true })
28615
+ ]);
28616
+ logger.verbose(
28617
+ `VesuMultiplyAdapter: Apys: ${apys[0].apy}, ${apys[1].apy}`
28618
+ );
28565
28619
  const borrowAmountUSD = actualMaxBorrowable.multipliedBy(debtPrice.price);
28566
- logger.verbose(`VesuMultiplyAdapter: Borrow amount: ${actualMaxBorrowable.toNumber()}, borrow amount USD: ${borrowAmountUSD.toNumber()}`);
28620
+ logger.verbose(
28621
+ `VesuMultiplyAdapter: Borrow amount: ${actualMaxBorrowable.toNumber()}, borrow amount USD: ${borrowAmountUSD.toNumber()}`
28622
+ );
28567
28623
  const netCollateralUSD = usdValue + borrowAmountUSD.toNumber();
28568
28624
  const netAPY = (apys[0].apy * netCollateralUSD + apys[1].apy * borrowAmountUSD.toNumber()) / usdValue;
28569
- logger.verbose(`VesuMultiplyAdapter: Max deposit amount: ${maxDepositAmount.toNumber()}, netAPY: ${netAPY}`);
28625
+ logger.verbose(
28626
+ `VesuMultiplyAdapter: Max deposit amount: ${maxDepositAmount.toNumber()}, netAPY: ${netAPY}`
28627
+ );
28570
28628
  return {
28571
28629
  tokenInfo: collateral,
28572
28630
  amount: maxDepositAmount,
@@ -28579,7 +28637,10 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28579
28637
  protocol: this.protocol
28580
28638
  };
28581
28639
  } catch (error) {
28582
- logger.error(`VesuMultiplyAdapter: Error calculating max deposit:`, error);
28640
+ logger.error(
28641
+ `VesuMultiplyAdapter: Error calculating max deposit:`,
28642
+ error
28643
+ );
28583
28644
  throw error;
28584
28645
  }
28585
28646
  }
@@ -28589,9 +28650,15 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28589
28650
  try {
28590
28651
  this.vesuAdapter.networkConfig = this.config.networkConfig;
28591
28652
  this.vesuAdapter.pricer = this.config.pricer;
28592
- const positions = await this.vesuAdapter.getPositions(this.config.networkConfig);
28593
- const collateralPosition = positions.find((p) => p.token.address.eq(collateral.address));
28594
- const debtPosition = positions.find((p) => p.token.address.eq(this.config.debt.address));
28653
+ const positions = await this.vesuAdapter.getPositions(
28654
+ this.config.networkConfig
28655
+ );
28656
+ const collateralPosition = positions.find(
28657
+ (p) => p.token.address.eq(collateral.address)
28658
+ );
28659
+ const debtPosition = positions.find(
28660
+ (p) => p.token.address.eq(this.config.debt.address)
28661
+ );
28595
28662
  if (!collateralPosition || !debtPosition) {
28596
28663
  throw new Error("Could not find current positions");
28597
28664
  }
@@ -28601,11 +28668,20 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28601
28668
  const result = maxWithdrawable.greaterThan(0) ? maxWithdrawable : new Web3Number("0", collateral.decimals);
28602
28669
  const usdValue = await this.getUSDValue(collateral, result);
28603
28670
  const debtUSD = debtPosition.usdValue;
28604
- logger.verbose(`VesuMultiplyAdapter: Debt USD: ${debtUSD}, collateral USD: ${usdValue}`);
28605
- const apys = await Promise.all([this.getAPY({ asset: collateral, isDebt: false }), this.getAPY({ asset: debt, isDebt: true })]);
28606
- logger.verbose(`VesuMultiplyAdapter: Apys: ${apys[0].apy}, ${apys[1].apy}`);
28671
+ logger.verbose(
28672
+ `VesuMultiplyAdapter: Debt USD: ${debtUSD}, collateral USD: ${usdValue}`
28673
+ );
28674
+ const apys = await Promise.all([
28675
+ this.getAPY({ asset: collateral, isDebt: false }),
28676
+ this.getAPY({ asset: debt, isDebt: true })
28677
+ ]);
28678
+ logger.verbose(
28679
+ `VesuMultiplyAdapter: Apys: ${apys[0].apy}, ${apys[1].apy}`
28680
+ );
28607
28681
  const netAPY = usdValue - debtUSD > 0 ? (apys[0].apy * usdValue + apys[1].apy * debtUSD) / (usdValue - debtUSD) : 0;
28608
- logger.verbose(`VesuMultiplyAdapter: Max withdraw amount: ${result.toNumber()}, netAPY: ${netAPY}`);
28682
+ logger.verbose(
28683
+ `VesuMultiplyAdapter: Max withdraw amount: ${result.toNumber()}, netAPY: ${netAPY}`
28684
+ );
28609
28685
  return {
28610
28686
  tokenInfo: collateral,
28611
28687
  amount: result,
@@ -28618,14 +28694,19 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28618
28694
  protocol: this.protocol
28619
28695
  };
28620
28696
  } catch (error) {
28621
- logger.error(`VesuMultiplyAdapter: Error calculating max withdraw:`, error);
28697
+ logger.error(
28698
+ `VesuMultiplyAdapter: Error calculating max withdraw:`,
28699
+ error
28700
+ );
28622
28701
  throw error;
28623
28702
  }
28624
28703
  }
28625
28704
  _getDepositLeaf() {
28626
28705
  const collateral = this.config.collateral;
28627
28706
  const debt = this.config.debt;
28628
- const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(this.config.poolId);
28707
+ const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(
28708
+ this.config.poolId
28709
+ );
28629
28710
  const vesuMultiply = isV2 ? this.vesuAdapter.VESU_MULTIPLY : this.vesuAdapter.VESU_MULTIPLY_V1;
28630
28711
  return [
28631
28712
  // Approval step for collateral
@@ -28689,7 +28770,9 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28689
28770
  ];
28690
28771
  }
28691
28772
  _getWithdrawLeaf() {
28692
- const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(this.config.poolId);
28773
+ const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(
28774
+ this.config.poolId
28775
+ );
28693
28776
  const vesuMultiply = isV2 ? this.vesuAdapter.VESU_MULTIPLY : this.vesuAdapter.VESU_MULTIPLY_V1;
28694
28777
  const collateral = this.config.collateral;
28695
28778
  const debt = this.config.debt;
@@ -28746,33 +28829,51 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28746
28829
  const leafConfigs = this._getDepositLeaf();
28747
28830
  const leaves = leafConfigs.map((config) => {
28748
28831
  const { target, method, packedArguments, sanitizer, id } = config;
28749
- const leaf = this.constructSimpleLeafData({
28750
- id,
28751
- target,
28752
- method,
28753
- packedArguments
28754
- }, sanitizer);
28832
+ const leaf = this.constructSimpleLeafData(
28833
+ {
28834
+ id,
28835
+ target,
28836
+ method,
28837
+ packedArguments
28838
+ },
28839
+ sanitizer
28840
+ );
28755
28841
  return leaf;
28756
28842
  });
28757
- return { leaves, callConstructor: this.getDepositCall.bind(this) };
28843
+ return {
28844
+ leaves,
28845
+ callConstructor: this.getDepositCall.bind(
28846
+ this
28847
+ )
28848
+ };
28758
28849
  }
28759
28850
  getWithdrawAdapter() {
28760
28851
  const leafConfigs = this._getWithdrawLeaf();
28761
28852
  const leaves = leafConfigs.map((config) => {
28762
28853
  const { target, method, packedArguments, sanitizer, id } = config;
28763
- const leaf = this.constructSimpleLeafData({
28764
- id,
28765
- target,
28766
- method,
28767
- packedArguments
28768
- }, sanitizer);
28854
+ const leaf = this.constructSimpleLeafData(
28855
+ {
28856
+ id,
28857
+ target,
28858
+ method,
28859
+ packedArguments
28860
+ },
28861
+ sanitizer
28862
+ );
28769
28863
  return leaf;
28770
28864
  });
28771
- return { leaves, callConstructor: this.getWithdrawCall.bind(this) };
28865
+ return {
28866
+ leaves,
28867
+ callConstructor: this.getWithdrawCall.bind(
28868
+ this
28869
+ )
28870
+ };
28772
28871
  }
28773
28872
  async getDepositCall(params) {
28774
28873
  const collateral = this.config.collateral;
28775
- const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(this.config.poolId);
28874
+ const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(
28875
+ this.config.poolId
28876
+ );
28776
28877
  const vesuMultiply = isV2 ? this.vesuAdapter.VESU_MULTIPLY : this.vesuAdapter.VESU_MULTIPLY_V1;
28777
28878
  const uint256MarginAmount = import_starknet21.uint256.bnToUint256(params.amount.toWei());
28778
28879
  return [
@@ -28844,7 +28945,9 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28844
28945
  ];
28845
28946
  }
28846
28947
  async getWithdrawCall(params) {
28847
- const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(this.config.poolId);
28948
+ const { addr: vesuSingleton, isV2 } = getVesuSingletonAddress(
28949
+ this.config.poolId
28950
+ );
28848
28951
  const vesuMultiply = isV2 ? this.vesuAdapter.VESU_MULTIPLY : this.vesuAdapter.VESU_MULTIPLY_V1;
28849
28952
  return [
28850
28953
  // Switch delegation on
@@ -28899,7 +29002,11 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28899
29002
  ];
28900
29003
  }
28901
29004
  async getMultiplyCallCalldata(params, isDeposit) {
28902
- logger.verbose(`${_VesuMultiplyAdapter.name}::getMultiplyCallCalldata params: ${JSON.stringify(params)}, isDeposit: ${isDeposit}, collateral: ${this.config.collateral.symbol}, debt: ${this.config.debt.symbol}`);
29005
+ logger.verbose(
29006
+ `${_VesuMultiplyAdapter.name}::getMultiplyCallCalldata params: ${JSON.stringify(
29007
+ params
29008
+ )}, isDeposit: ${isDeposit}, collateral: ${this.config.collateral.symbol}, debt: ${this.config.debt.symbol}`
29009
+ );
28903
29010
  const { isV2 } = getVesuSingletonAddress(this.config.poolId);
28904
29011
  const vesuMultiply = isV2 ? this.vesuAdapter.VESU_MULTIPLY : this.vesuAdapter.VESU_MULTIPLY_V1;
28905
29012
  const multiplyContract = new import_starknet21.Contract({
@@ -28909,42 +29016,83 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28909
29016
  });
28910
29017
  let leverSwap = [];
28911
29018
  let leverSwapLimitAmount = Web3Number.fromWei(0, this.config.debt.decimals);
28912
- const existingPositions = await this.vesuAdapter.getPositions(this.config.networkConfig);
28913
- const collateralisation = await this.vesuAdapter.getCollateralization(this.config.networkConfig);
29019
+ const existingPositions = await this.vesuAdapter.getPositions(
29020
+ this.config.networkConfig
29021
+ );
29022
+ const collateralisation = await this.vesuAdapter.getCollateralization(
29023
+ this.config.networkConfig
29024
+ );
28914
29025
  const existingCollateralInfo = existingPositions[0];
28915
29026
  const existingDebtInfo = existingPositions[1];
28916
29027
  const isDexPriceRequired = existingDebtInfo.token.symbol !== "USDC";
28917
- logger.debug(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
28918
- existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
29028
+ logger.debug(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(
29029
+ existingCollateralInfo
29030
+ )},
29031
+ existingDebtInfo: ${JSON.stringify(
29032
+ existingDebtInfo
29033
+ )}, collateralisation: ${JSON.stringify(collateralisation)}`);
28919
29034
  const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : (await this.config.pricer.getPrice(this.config.collateral.symbol)).price;
28920
29035
  const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : (await this.config.pricer.getPrice(this.config.debt.symbol)).price;
28921
- logger.debug(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
28922
- const legLTV = await this.vesuAdapter.getLTVConfig(this.config.networkConfig);
28923
- const ekuboQuoter = new EkuboQuoter(this.config.networkConfig, this.config.pricer);
28924
- const dexPrice = isDexPriceRequired ? await ekuboQuoter.getDexPrice(this.config.collateral, this.config.debt, this.config.quoteAmountToFetchPrice) : 1;
28925
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall dexPrice: ${dexPrice}, ltv: ${legLTV}`);
29036
+ logger.debug(
29037
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`
29038
+ );
29039
+ const legLTV = await this.vesuAdapter.getLTVConfig(
29040
+ this.config.networkConfig
29041
+ );
29042
+ const ekuboQuoter = new EkuboQuoter(
29043
+ this.config.networkConfig,
29044
+ this.config.pricer
29045
+ );
29046
+ const dexPrice = isDexPriceRequired ? await ekuboQuoter.getDexPrice(
29047
+ this.config.collateral,
29048
+ this.config.debt,
29049
+ this.config.quoteAmountToFetchPrice
29050
+ ) : 1;
29051
+ logger.verbose(
29052
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall dexPrice: ${dexPrice}, ltv: ${legLTV}`
29053
+ );
28926
29054
  const addedCollateral = params.amount.multipliedBy(isDeposit ? 1 : -1);
28927
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall addedCollateral: ${addedCollateral}`);
29055
+ logger.verbose(
29056
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall addedCollateral: ${addedCollateral}`
29057
+ );
28928
29058
  const numeratorPart1 = existingCollateralInfo.amount.plus(addedCollateral).multipliedBy(collateralPrice).multipliedBy(legLTV);
28929
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}`);
29059
+ logger.verbose(
29060
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}`
29061
+ );
28930
29062
  const numeratorPart2 = existingDebtInfo.amount.multipliedBy(debtPrice).multipliedBy(this.config.targetHealthFactor);
28931
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart2: ${numeratorPart2}`);
29063
+ logger.verbose(
29064
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart2: ${numeratorPart2}`
29065
+ );
28932
29066
  const denominatorPart = this.config.targetHealthFactor - legLTV / dexPrice;
28933
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall denominatorPart: ${denominatorPart}`);
29067
+ logger.verbose(
29068
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall denominatorPart: ${denominatorPart}`
29069
+ );
28934
29070
  const x_debt_usd = numeratorPart1.minus(numeratorPart2).dividedBy(denominatorPart);
28935
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall x_debt_usd: ${x_debt_usd}`);
28936
- logger.debug(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}, numeratorPart2: ${numeratorPart2}, denominatorPart: ${denominatorPart}`);
28937
- let debtAmount = new Web3Number(x_debt_usd.dividedBy(debtPrice).toFixed(this.config.debt.decimals), this.config.debt.decimals);
29071
+ logger.verbose(
29072
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall x_debt_usd: ${x_debt_usd}`
29073
+ );
29074
+ logger.debug(
29075
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}, numeratorPart2: ${numeratorPart2}, denominatorPart: ${denominatorPart}`
29076
+ );
29077
+ let debtAmount = new Web3Number(
29078
+ x_debt_usd.dividedBy(debtPrice).toFixed(this.config.debt.decimals),
29079
+ this.config.debt.decimals
29080
+ );
28938
29081
  const marginAmount = addedCollateral;
28939
29082
  const collateralToken = this.config.collateral;
28940
29083
  const debtToken = this.config.debt;
28941
- const debtAmountInCollateralUnits = new Web3Number(debtAmount.multipliedBy(debtPrice).dividedBy(collateralPrice).multipliedBy(10 ** collateralToken.decimals).toFixed(0), collateralToken.decimals);
29084
+ const debtAmountInCollateralUnits = new Web3Number(
29085
+ debtAmount.multipliedBy(debtPrice).dividedBy(collateralPrice).multipliedBy(10 ** collateralToken.decimals).toFixed(0),
29086
+ collateralToken.decimals
29087
+ );
28942
29088
  const isIncrease = debtAmount.greaterThanOrEqualTo(0);
28943
29089
  if (isIncrease && debtAmount.lessThan(0)) {
28944
29090
  } else if (!isIncrease && debtAmount.greaterThan(0)) {
28945
29091
  debtAmount = Web3Number.fromWei(0, this.config.debt.decimals);
28946
29092
  }
28947
- logger.verbose(`${_VesuMultiplyAdapter.name}::getVesuMultiplyCall debtAmount: ${debtAmount}, marginAmount: ${marginAmount}`);
29093
+ logger.verbose(
29094
+ `${_VesuMultiplyAdapter.name}::getVesuMultiplyCall debtAmount: ${debtAmount}, marginAmount: ${marginAmount}`
29095
+ );
28948
29096
  if (!debtAmount.isZero()) {
28949
29097
  try {
28950
29098
  const swapQuote = await ekuboQuoter.getQuote(
@@ -28954,26 +29102,49 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28954
29102
  // negative for exact amount out
28955
29103
  );
28956
29104
  if (swapQuote.price_impact < 0.01) {
28957
- leverSwap = ekuboQuoter.getVesuMultiplyQuote(swapQuote, debtToken, collateralToken);
29105
+ leverSwap = debtAmount.isNegative() ? ekuboQuoter.getVesuMultiplyQuote(
29106
+ swapQuote,
29107
+ collateralToken,
29108
+ debtToken
29109
+ ) : ekuboQuoter.getVesuMultiplyQuote(
29110
+ swapQuote,
29111
+ debtToken,
29112
+ collateralToken
29113
+ );
28958
29114
  const MAX_SLIPPAGE = 2e-3;
28959
29115
  if (debtAmount.greaterThan(0)) {
28960
29116
  leverSwapLimitAmount = debtAmount.multipliedBy(1 + MAX_SLIPPAGE);
28961
29117
  } else if (debtAmount.lessThan(0)) {
28962
29118
  leverSwapLimitAmount = debtAmount.abs().multipliedBy(1 - MAX_SLIPPAGE);
28963
29119
  } else {
28964
- leverSwapLimitAmount = Web3Number.fromWei(0, this.config.debt.decimals);
29120
+ leverSwapLimitAmount = Web3Number.fromWei(
29121
+ 0,
29122
+ this.config.debt.decimals
29123
+ );
28965
29124
  }
28966
29125
  await new Promise((resolve) => setTimeout(resolve, 1e4));
28967
29126
  } else {
28968
- throw new Error(`VesuMultiplyAdapter: Price impact too high (${swapQuote.price_impact}), skipping swap`);
29127
+ throw new Error(
29128
+ `VesuMultiplyAdapter: Price impact too high (${swapQuote.price_impact}), skipping swap`
29129
+ );
28969
29130
  }
28970
29131
  } catch (error) {
28971
- throw new Error(`VesuMultiplyAdapter: Failed to get swap quote: ${error}`);
29132
+ throw new Error(
29133
+ `VesuMultiplyAdapter: Failed to get swap quote: ${error}`
29134
+ );
28972
29135
  }
28973
29136
  }
28974
- const multiplyParams = await this.getLeverParams(isIncrease, params, leverSwap, leverSwapLimitAmount);
29137
+ const multiplyParams = await this.getLeverParams(
29138
+ isIncrease,
29139
+ params,
29140
+ leverSwap,
29141
+ leverSwapLimitAmount
29142
+ );
28975
29143
  const call = multiplyContract.populate("modify_lever", {
28976
- modify_lever_params: this.formatMultiplyParams(isIncrease, multiplyParams)
29144
+ modify_lever_params: this.formatMultiplyParams(
29145
+ isIncrease,
29146
+ multiplyParams
29147
+ )
28977
29148
  });
28978
29149
  return call.calldata;
28979
29150
  }
@@ -28987,7 +29158,10 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
28987
29158
  add_margin: params.amount,
28988
29159
  // multiplied by collateral decimals in format
28989
29160
  margin_swap: [],
28990
- margin_swap_limit_amount: Web3Number.fromWei(0, this.config.collateral.decimals),
29161
+ margin_swap_limit_amount: Web3Number.fromWei(
29162
+ 0,
29163
+ this.config.collateral.decimals
29164
+ ),
28991
29165
  lever_swap: leverSwap,
28992
29166
  lever_swap_limit_amount: leverSwapLimitAmount
28993
29167
  } : {
@@ -29001,7 +29175,10 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29001
29175
  lever_swap_limit_amount: leverSwapLimitAmount,
29002
29176
  lever_swap_weights: [],
29003
29177
  withdraw_swap: [],
29004
- withdraw_swap_limit_amount: Web3Number.fromWei(0, this.config.collateral.decimals),
29178
+ withdraw_swap_limit_amount: Web3Number.fromWei(
29179
+ 0,
29180
+ this.config.collateral.decimals
29181
+ ),
29005
29182
  withdraw_swap_weights: [],
29006
29183
  close_position: false
29007
29184
  };
@@ -29017,12 +29194,16 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29017
29194
  });
29018
29195
  let leverSwap = [];
29019
29196
  let leverSwapLimitAmount = Web3Number.fromWei(0, this.config.debt.decimals);
29020
- const existingPositions = await this.vesuAdapter.getPositions(this.config.networkConfig);
29197
+ const existingPositions = await this.vesuAdapter.getPositions(
29198
+ this.config.networkConfig
29199
+ );
29021
29200
  const existingCollateralInfo = existingPositions[0];
29022
29201
  const existingDebtInfo = existingPositions[1];
29023
29202
  const collateralToken = this.config.collateral;
29024
29203
  const debtToken = this.config.debt;
29025
- const collateralPrice = await this.config.pricer.getPrice(collateralToken.symbol);
29204
+ const collateralPrice = await this.config.pricer.getPrice(
29205
+ collateralToken.symbol
29206
+ );
29026
29207
  const debtPrice = await this.config.pricer.getPrice(debtToken.symbol);
29027
29208
  const { deltadebtAmountUnits: debtAmountToRepay } = calculateDebtReductionAmountForWithdrawal(
29028
29209
  existingDebtInfo.amount,
@@ -29036,8 +29217,14 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29036
29217
  if (!debtAmountToRepay) {
29037
29218
  throw new Error("error calculating debt amount to repay");
29038
29219
  }
29039
- const ekuboQuoter = new EkuboQuoter(this.config.networkConfig, this.config.pricer);
29040
- const debtInDebtUnits = new Web3Number(debtAmountToRepay, debtToken.decimals).dividedBy(debtPrice.price).multipliedBy(10 ** debtToken.decimals);
29220
+ const ekuboQuoter = new EkuboQuoter(
29221
+ this.config.networkConfig,
29222
+ this.config.pricer
29223
+ );
29224
+ const debtInDebtUnits = new Web3Number(
29225
+ debtAmountToRepay,
29226
+ debtToken.decimals
29227
+ ).dividedBy(debtPrice.price).multipliedBy(10 ** debtToken.decimals);
29041
29228
  const swapQuote = await ekuboQuoter.getQuote(
29042
29229
  debtToken.address.address,
29043
29230
  collateralToken.address.address,
@@ -29045,12 +29232,23 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29045
29232
  );
29046
29233
  const MAX_SLIPPAGE = 2e-3;
29047
29234
  if (swapQuote.price_impact < 25e-4) {
29048
- leverSwap = ekuboQuoter.getVesuMultiplyQuote(swapQuote, collateralToken, debtToken);
29235
+ leverSwap = ekuboQuoter.getVesuMultiplyQuote(
29236
+ swapQuote,
29237
+ collateralToken,
29238
+ debtToken
29239
+ );
29049
29240
  } else {
29050
- logger.error(`VesuMultiplyAdapter: Price impact too high (${swapQuote.price_impact}), skipping swap`);
29241
+ logger.error(
29242
+ `VesuMultiplyAdapter: Price impact too high (${swapQuote.price_impact}), skipping swap`
29243
+ );
29051
29244
  }
29052
29245
  leverSwapLimitAmount = new Web3Number(debtAmountToRepay, debtToken.decimals).abs().multipliedBy(1 + MAX_SLIPPAGE);
29053
- const multiplyParams = await this.getLeverParams(false, params, leverSwap, leverSwapLimitAmount);
29246
+ const multiplyParams = await this.getLeverParams(
29247
+ false,
29248
+ params,
29249
+ leverSwap,
29250
+ leverSwapLimitAmount
29251
+ );
29054
29252
  const call = multiplyContract.populate("modify_lever", {
29055
29253
  modify_lever_params: this.formatMultiplyParams(false, multiplyParams)
29056
29254
  });
@@ -29060,100 +29258,132 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29060
29258
  if (isIncrease) {
29061
29259
  const _params2 = params;
29062
29260
  return {
29063
- action: new import_starknet21.CairoCustomEnum({ IncreaseLever: {
29064
- pool_id: _params2.pool_id.toBigInt(),
29065
- collateral_asset: _params2.collateral_asset.toBigInt(),
29066
- debt_asset: _params2.debt_asset.toBigInt(),
29067
- user: _params2.user.toBigInt(),
29068
- add_margin: BigInt(_params2.add_margin.toWei()),
29069
- margin_swap: _params2.margin_swap.map((swap) => ({
29261
+ action: new import_starknet21.CairoCustomEnum({
29262
+ IncreaseLever: {
29263
+ pool_id: _params2.pool_id.toBigInt(),
29264
+ collateral_asset: _params2.collateral_asset.toBigInt(),
29265
+ debt_asset: _params2.debt_asset.toBigInt(),
29266
+ user: _params2.user.toBigInt(),
29267
+ add_margin: BigInt(_params2.add_margin.toWei()),
29268
+ margin_swap: _params2.margin_swap.map((swap) => ({
29269
+ route: swap.route.map((route) => ({
29270
+ pool_key: {
29271
+ token0: route.pool_key.token0.toBigInt(),
29272
+ token1: route.pool_key.token1.toBigInt(),
29273
+ fee: route.pool_key.fee,
29274
+ tick_spacing: route.pool_key.tick_spacing,
29275
+ extension: BigInt(
29276
+ import_starknet21.num.hexToDecimalString(route.pool_key.extension)
29277
+ )
29278
+ },
29279
+ sqrt_ratio_limit: import_starknet21.uint256.bnToUint256(
29280
+ route.sqrt_ratio_limit.toWei()
29281
+ ),
29282
+ skip_ahead: BigInt(100)
29283
+ })),
29284
+ token_amount: {
29285
+ token: swap.token_amount.token.toBigInt(),
29286
+ amount: swap.token_amount.amount.toI129()
29287
+ }
29288
+ })),
29289
+ margin_swap_limit_amount: BigInt(
29290
+ _params2.margin_swap_limit_amount.toWei()
29291
+ ),
29292
+ lever_swap: _params2.lever_swap.map((swap) => ({
29293
+ route: swap.route.map((route) => ({
29294
+ pool_key: {
29295
+ token0: route.pool_key.token0.toBigInt(),
29296
+ token1: route.pool_key.token1.toBigInt(),
29297
+ fee: route.pool_key.fee,
29298
+ tick_spacing: route.pool_key.tick_spacing,
29299
+ extension: BigInt(
29300
+ import_starknet21.num.hexToDecimalString(route.pool_key.extension)
29301
+ )
29302
+ },
29303
+ sqrt_ratio_limit: import_starknet21.uint256.bnToUint256(
29304
+ route.sqrt_ratio_limit.toWei()
29305
+ ),
29306
+ skip_ahead: BigInt(0)
29307
+ })),
29308
+ token_amount: {
29309
+ token: swap.token_amount.token.toBigInt(),
29310
+ amount: swap.token_amount.amount.toI129()
29311
+ }
29312
+ })),
29313
+ lever_swap_limit_amount: BigInt(
29314
+ _params2.lever_swap_limit_amount.toWei()
29315
+ )
29316
+ }
29317
+ })
29318
+ };
29319
+ }
29320
+ const _params = params;
29321
+ return {
29322
+ action: new import_starknet21.CairoCustomEnum({
29323
+ DecreaseLever: {
29324
+ pool_id: _params.pool_id.toBigInt(),
29325
+ collateral_asset: _params.collateral_asset.toBigInt(),
29326
+ debt_asset: _params.debt_asset.toBigInt(),
29327
+ user: _params.user.toBigInt(),
29328
+ sub_margin: BigInt(_params.sub_margin.toWei()),
29329
+ recipient: _params.recipient.toBigInt(),
29330
+ lever_swap: _params.lever_swap.map((swap) => ({
29070
29331
  route: swap.route.map((route) => ({
29071
29332
  pool_key: {
29072
29333
  token0: route.pool_key.token0.toBigInt(),
29073
29334
  token1: route.pool_key.token1.toBigInt(),
29074
29335
  fee: route.pool_key.fee,
29075
29336
  tick_spacing: route.pool_key.tick_spacing,
29076
- extension: BigInt(import_starknet21.num.hexToDecimalString(route.pool_key.extension))
29337
+ extension: ContractAddr.from(
29338
+ route.pool_key.extension
29339
+ ).toBigInt()
29077
29340
  },
29078
- sqrt_ratio_limit: import_starknet21.uint256.bnToUint256(route.sqrt_ratio_limit.toWei()),
29079
- skip_ahead: BigInt(100)
29341
+ sqrt_ratio_limit: import_starknet21.uint256.bnToUint256(
29342
+ route.sqrt_ratio_limit.toWei()
29343
+ ),
29344
+ skip_ahead: BigInt(route.skip_ahead.toWei())
29080
29345
  })),
29081
29346
  token_amount: {
29082
29347
  token: swap.token_amount.token.toBigInt(),
29083
29348
  amount: swap.token_amount.amount.toI129()
29084
29349
  }
29085
29350
  })),
29086
- margin_swap_limit_amount: BigInt(_params2.margin_swap_limit_amount.toWei()),
29087
- lever_swap: _params2.lever_swap.map((swap) => ({
29351
+ lever_swap_limit_amount: BigInt(
29352
+ _params.lever_swap_limit_amount.toWei()
29353
+ ),
29354
+ lever_swap_weights: _params.lever_swap_weights.map(
29355
+ (weight) => BigInt(weight.toWei())
29356
+ ),
29357
+ withdraw_swap: _params.withdraw_swap.map((swap) => ({
29088
29358
  route: swap.route.map((route) => ({
29089
29359
  pool_key: {
29090
29360
  token0: route.pool_key.token0.toBigInt(),
29091
29361
  token1: route.pool_key.token1.toBigInt(),
29092
29362
  fee: route.pool_key.fee,
29093
29363
  tick_spacing: route.pool_key.tick_spacing,
29094
- extension: BigInt(import_starknet21.num.hexToDecimalString(route.pool_key.extension))
29364
+ extension: ContractAddr.from(
29365
+ route.pool_key.extension
29366
+ ).toBigInt()
29095
29367
  },
29096
- sqrt_ratio_limit: import_starknet21.uint256.bnToUint256(route.sqrt_ratio_limit.toWei()),
29097
- skip_ahead: BigInt(0)
29368
+ sqrt_ratio_limit: import_starknet21.uint256.bnToUint256(
29369
+ route.sqrt_ratio_limit.toWei()
29370
+ ),
29371
+ skip_ahead: BigInt(route.skip_ahead.toWei())
29098
29372
  })),
29099
29373
  token_amount: {
29100
29374
  token: swap.token_amount.token.toBigInt(),
29101
29375
  amount: swap.token_amount.amount.toI129()
29102
29376
  }
29103
29377
  })),
29104
- lever_swap_limit_amount: BigInt(_params2.lever_swap_limit_amount.toWei())
29105
- } })
29106
- };
29107
- }
29108
- const _params = params;
29109
- return {
29110
- action: new import_starknet21.CairoCustomEnum({ DecreaseLever: {
29111
- pool_id: _params.pool_id.toBigInt(),
29112
- collateral_asset: _params.collateral_asset.toBigInt(),
29113
- debt_asset: _params.debt_asset.toBigInt(),
29114
- user: _params.user.toBigInt(),
29115
- sub_margin: BigInt(_params.sub_margin.toWei()),
29116
- recipient: _params.recipient.toBigInt(),
29117
- lever_swap: _params.lever_swap.map((swap) => ({
29118
- route: swap.route.map((route) => ({
29119
- pool_key: {
29120
- token0: route.pool_key.token0.toBigInt(),
29121
- token1: route.pool_key.token1.toBigInt(),
29122
- fee: route.pool_key.fee,
29123
- tick_spacing: route.pool_key.tick_spacing,
29124
- extension: ContractAddr.from(route.pool_key.extension).toBigInt()
29125
- },
29126
- sqrt_ratio_limit: import_starknet21.uint256.bnToUint256(route.sqrt_ratio_limit.toWei()),
29127
- skip_ahead: BigInt(route.skip_ahead.toWei())
29128
- })),
29129
- token_amount: {
29130
- token: swap.token_amount.token.toBigInt(),
29131
- amount: swap.token_amount.amount.toI129()
29132
- }
29133
- })),
29134
- lever_swap_limit_amount: BigInt(_params.lever_swap_limit_amount.toWei()),
29135
- lever_swap_weights: _params.lever_swap_weights.map((weight) => BigInt(weight.toWei())),
29136
- withdraw_swap: _params.withdraw_swap.map((swap) => ({
29137
- route: swap.route.map((route) => ({
29138
- pool_key: {
29139
- token0: route.pool_key.token0.toBigInt(),
29140
- token1: route.pool_key.token1.toBigInt(),
29141
- fee: route.pool_key.fee,
29142
- tick_spacing: route.pool_key.tick_spacing,
29143
- extension: ContractAddr.from(route.pool_key.extension).toBigInt()
29144
- },
29145
- sqrt_ratio_limit: import_starknet21.uint256.bnToUint256(route.sqrt_ratio_limit.toWei()),
29146
- skip_ahead: BigInt(route.skip_ahead.toWei())
29147
- })),
29148
- token_amount: {
29149
- token: swap.token_amount.token.toBigInt(),
29150
- amount: swap.token_amount.amount.toI129()
29151
- }
29152
- })),
29153
- withdraw_swap_limit_amount: BigInt(_params.withdraw_swap_limit_amount.toWei()),
29154
- withdraw_swap_weights: _params.withdraw_swap_weights.map((weight) => BigInt(weight.toWei())),
29155
- close_position: _params.close_position
29156
- } })
29378
+ withdraw_swap_limit_amount: BigInt(
29379
+ _params.withdraw_swap_limit_amount.toWei()
29380
+ ),
29381
+ withdraw_swap_weights: _params.withdraw_swap_weights.map(
29382
+ (weight) => BigInt(weight.toWei())
29383
+ ),
29384
+ close_position: _params.close_position
29385
+ }
29386
+ })
29157
29387
  };
29158
29388
  }
29159
29389
  async getHealthFactor() {
@@ -29162,11 +29392,15 @@ var VesuMultiplyAdapter = class _VesuMultiplyAdapter extends BaseAdapter {
29162
29392
  }
29163
29393
  async getNetAPY() {
29164
29394
  const positions = await this.getPositions();
29165
- logger.verbose(`${this.name}::getNetAPY: positions: ${JSON.stringify(positions)}`);
29395
+ logger.verbose(
29396
+ `${this.name}::getNetAPY: positions: ${JSON.stringify(positions)}`
29397
+ );
29166
29398
  const allZero = positions.every((p) => p.usdValue === 0);
29167
29399
  if (allZero) {
29168
29400
  const collateralUSD = 1e3;
29169
- const maxLTV = await this.vesuAdapter.getLTVConfig(this.config.networkConfig);
29401
+ const maxLTV = await this.vesuAdapter.getLTVConfig(
29402
+ this.config.networkConfig
29403
+ );
29170
29404
  const targetHF = this.config.targetHealthFactor;
29171
29405
  const maxDebt = HealthFactorMath.getMaxDebtAmountOnLooping(
29172
29406
  new Web3Number(collateralUSD, this.config.collateral.decimals),
@@ -29892,6 +30126,7 @@ var ExtendedAdapter = class _ExtendedAdapter extends BaseAdapter {
29892
30126
  logger.error("error initializing client");
29893
30127
  return null;
29894
30128
  }
30129
+ await new Promise((resolve) => setTimeout(resolve, 5e3));
29895
30130
  const orderhistory = await this.getOrderHistory(marketName);
29896
30131
  if (!orderhistory || orderhistory.length === 0) {
29897
30132
  logger.error(`error getting order: ${orderId}`);
@@ -34272,7 +34507,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34272
34507
  const withdrawalFromExtended = await extendedAdapter.withdrawFromExtended(params.amount);
34273
34508
  if (withdrawalFromExtended) {
34274
34509
  const extendedHoldings2 = await extendedAdapter.getExtendedDepositAmount();
34275
- logger.info(`extendedHoldings after withdrawal ${extendedHoldings2}`);
34510
+ logger.info(`extendedHoldings after withdrawal ${extendedHoldings2?.availableForWithdrawal}`);
34276
34511
  await new Promise((resolve) => setTimeout(resolve, 1e4));
34277
34512
  const calls = await this.moveAssetsToVaultAllocator(params.amount, extendedAdapter);
34278
34513
  if (calls.length > 0) {