@strkfarm/sdk 1.1.28 → 1.1.31

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.
@@ -19129,9 +19129,11 @@ import { hash, num as num6, shortString } from "starknet";
19129
19129
  // src/strategies/universal-adapters/adapter-utils.ts
19130
19130
  var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
19131
19131
  var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x7b6f98311af8aa425278570e62abf523e6462eaa01a38c1feab9b2f416492e2");
19132
+ var VESU_V2_MODIFY_POSITION_SANITIZER = ContractAddr.from("0x04Bf71F2BD9D6F8819057c9dD524F0d5fbc38317C00500d7b9a0FdCf01195066");
19132
19133
  var SIMPLE_SANITIZER_VESU_V1_DELEGATIONS = ContractAddr.from("0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a");
19133
19134
  var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
19134
19135
  var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
19136
+ var AVNU_EXCHANGE = ContractAddr.from("0x04270219d365d6b017231b52e92b3fb5d7c8378b05e9abc97724537a80e93b0f");
19135
19137
  var VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
19136
19138
  function toBigInt(value) {
19137
19139
  if (typeof value === "string") {
@@ -19276,11 +19278,11 @@ var CommonAdapter = class extends BaseAdapter {
19276
19278
  };
19277
19279
  };
19278
19280
  }
19279
- getAvnuAdapter(fromToken, toToken, id) {
19281
+ getAvnuAdapter(fromToken, toToken, id, isMiddleware) {
19280
19282
  return () => ({
19281
19283
  leaf: this.constructSimpleLeafData({
19282
19284
  id,
19283
- target: AVNU_MIDDLEWARE,
19285
+ target: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
19284
19286
  method: "multi_route_swap",
19285
19287
  packedArguments: [
19286
19288
  fromToken.toBigInt(),
@@ -19288,15 +19290,15 @@ var CommonAdapter = class extends BaseAdapter {
19288
19290
  this.config.vaultAllocator.toBigInt()
19289
19291
  ]
19290
19292
  }),
19291
- callConstructor: this.getAvnuCall(fromToken, toToken).bind(this)
19293
+ callConstructor: this.getAvnuCall(fromToken, toToken, isMiddleware).bind(this)
19292
19294
  });
19293
19295
  }
19294
- getAvnuCall(fromToken, toToken) {
19296
+ getAvnuCall(fromToken, toToken, isMiddleware) {
19295
19297
  return (params) => {
19296
19298
  return {
19297
19299
  sanitizer: SIMPLE_SANITIZER,
19298
19300
  call: {
19299
- contractAddress: AVNU_MIDDLEWARE,
19301
+ contractAddress: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
19300
19302
  selector: hash2.getSelectorFromName("multi_route_swap"),
19301
19303
  calldata: [
19302
19304
  fromToken.toBigInt(),
@@ -24050,24 +24052,30 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
24050
24052
  this.VESU_MULTIPLY = ContractAddr.from("0x027fef272d0a9a3844767c851a64b36fe4f0115141d81134baade95d2b27b781");
24051
24053
  this.getModifyPosition = () => {
24052
24054
  const positionData = [0n];
24053
- const packedArguments = [
24054
- toBigInt(this.config.poolId.toString()),
24055
- // pool id
24055
+ const { addr, isV2 } = getVesuSingletonAddress(this.config.poolId);
24056
+ const commonPackedData = [
24056
24057
  toBigInt(this.config.collateral.address.toString()),
24057
24058
  // collateral
24058
24059
  toBigInt(this.config.debt.address.toString()),
24059
24060
  // debt
24060
- toBigInt(this.config.vaultAllocator.toString()),
24061
+ toBigInt(this.config.vaultAllocator.toString())
24061
24062
  // vault allocator
24063
+ ];
24064
+ const packedArguments = isV2 ? [
24065
+ ...commonPackedData
24066
+ ] : [
24067
+ toBigInt(this.config.poolId.toString()),
24068
+ // pool id
24069
+ ...commonPackedData,
24062
24070
  toBigInt(positionData.length),
24063
24071
  ...positionData
24064
24072
  ];
24065
24073
  const output = this.constructSimpleLeafData({
24066
24074
  id: this.config.id,
24067
- target: getVesuSingletonAddress(this.config.poolId).addr,
24075
+ target: addr,
24068
24076
  method: "modify_position",
24069
24077
  packedArguments
24070
- });
24078
+ }, isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER);
24071
24079
  return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
24072
24080
  };
24073
24081
  this.getModifyPositionCall = (params) => {
@@ -24108,7 +24116,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
24108
24116
  }
24109
24117
  });
24110
24118
  return {
24111
- sanitizer: SIMPLE_SANITIZER,
24119
+ sanitizer: isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER,
24112
24120
  call: {
24113
24121
  contractAddress: ContractAddr.from(contract.address),
24114
24122
  selector: hash3.getSelectorFromName("modify_position"),
@@ -24118,25 +24126,27 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
24118
24126
  }
24119
24127
  };
24120
24128
  };
24121
- this.getMultiplyAdapter = () => {
24122
- const packedArguments = [
24123
- toBigInt(this.config.poolId.toString()),
24124
- // pool id
24125
- toBigInt(this.config.collateral.address.toString()),
24126
- // collateral
24127
- toBigInt(this.config.debt.address.toString()),
24128
- // debt
24129
- toBigInt(this.config.vaultAllocator.toString())
24130
- // vault allocator
24131
- ];
24132
- const { isV2 } = getVesuSingletonAddress(this.config.poolId);
24133
- const output = this.constructSimpleLeafData({
24134
- id: this.config.id,
24135
- target: isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1,
24136
- method: "modify_lever",
24137
- packedArguments
24138
- }, SIMPLE_SANITIZER_V2);
24139
- return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
24129
+ this.getMultiplyAdapter = (id) => {
24130
+ return () => {
24131
+ const packedArguments = [
24132
+ toBigInt(this.config.poolId.toString()),
24133
+ // pool id
24134
+ toBigInt(this.config.collateral.address.toString()),
24135
+ // collateral
24136
+ toBigInt(this.config.debt.address.toString()),
24137
+ // debt
24138
+ toBigInt(this.config.vaultAllocator.toString())
24139
+ // vault allocator
24140
+ ];
24141
+ const { isV2 } = getVesuSingletonAddress(this.config.poolId);
24142
+ const output = this.constructSimpleLeafData({
24143
+ id,
24144
+ target: isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1,
24145
+ method: "modify_lever",
24146
+ packedArguments
24147
+ }, SIMPLE_SANITIZER_V2);
24148
+ return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
24149
+ };
24140
24150
  };
24141
24151
  this.getMultiplyCall = (params) => {
24142
24152
  const isIncrease = params.isIncrease;
@@ -26828,7 +26838,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
26828
26838
  id: "defispring"
26829
26839
  }] };
26830
26840
  }
26841
+ const unusedBalanceAPY = await this.getUnusedBalanceAPY();
26842
+ baseAPYs.push(...[unusedBalanceAPY.apy]);
26843
+ rewardAPYs.push(0);
26831
26844
  const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
26845
+ weights.push(unusedBalanceAPY.weight);
26832
26846
  const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
26833
26847
  const prevAUMUSD = prevAUM.multipliedBy(price.price);
26834
26848
  const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
@@ -26843,6 +26857,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
26843
26857
  id: "defispring"
26844
26858
  }] };
26845
26859
  }
26860
+ async getUnusedBalanceAPY() {
26861
+ return {
26862
+ apy: 0,
26863
+ weight: 0
26864
+ };
26865
+ }
26846
26866
  computeAPY(apys, weights, currentAUM) {
26847
26867
  assert(apys.length === weights.length, "APYs and weights length mismatch");
26848
26868
  const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
@@ -27337,7 +27357,7 @@ function getLooperSettings(token1Symbol, token2Symbol, vaultSettings, pool1, poo
27337
27357
  vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterUSDCETH));
27338
27358
  const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
27339
27359
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
27340
- vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
27360
+ vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */, true).bind(commonAdapter));
27341
27361
  return vaultSettings;
27342
27362
  }
27343
27363
  var _riskFactor3 = [
@@ -27691,6 +27711,160 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27691
27711
  logger.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
27692
27712
  return price;
27693
27713
  }
27714
+ async getAvnuSwapMultiplyCall(params) {
27715
+ return this._getAvnuDepositSwapLegCall({
27716
+ ...params,
27717
+ minHF: 1.02
27718
+ });
27719
+ }
27720
+ async _getAvnuDepositSwapLegCall(params) {
27721
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall params: ${JSON.stringify(params)}`);
27722
+ assert(params.isDeposit, "Only deposit is supported in _getAvnuDepositSwapLegCall");
27723
+ const [vesuAdapter1] = this.getVesuAdapters();
27724
+ const legLTV = await vesuAdapter1.getLTVConfig(this.config);
27725
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall legLTV: ${legLTV}`);
27726
+ const existingPositions = await vesuAdapter1.getPositions(this.config);
27727
+ const collateralisation = await vesuAdapter1.getCollateralization(this.config);
27728
+ const existingCollateralInfo = existingPositions[0];
27729
+ const existingDebtInfo = existingPositions[1];
27730
+ logger.debug(`${this.getTag()}::_getAvnuDepositSwapLegCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
27731
+ existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
27732
+ const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
27733
+ const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
27734
+ logger.debug(`${this.getTag()}::_getAvnuDepositSwapLegCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
27735
+ const totalCollateral = existingCollateralInfo.amount.plus(params.leg1DepositAmount);
27736
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall totalCollateral: ${totalCollateral}`);
27737
+ const totalDebtAmount = totalCollateral.multipliedBy(collateralPrice).multipliedBy(legLTV).dividedBy(debtPrice).dividedBy(params.minHF);
27738
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall totalDebtAmount: ${totalDebtAmount}`);
27739
+ const debtAmount = totalDebtAmount.minus(existingDebtInfo.amount);
27740
+ if (debtAmount.lt(0)) {
27741
+ const lstDEXPrice = await this.getLSTDexPrice();
27742
+ const debtAmountInLST = debtAmount.abs().dividedBy(lstDEXPrice);
27743
+ const calls = await this.getVesuMultiplyCall({
27744
+ isDeposit: false,
27745
+ leg1DepositAmount: debtAmountInLST
27746
+ });
27747
+ assert(calls.length == 1, "Expected 1 call for unwind");
27748
+ return calls[0];
27749
+ }
27750
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall debtAmount: ${debtAmount}`);
27751
+ const STEP0 = "approve_token1" /* APPROVE_TOKEN1 */;
27752
+ const manage0Info = this.getProofs(STEP0);
27753
+ const manageCall0 = manage0Info.callConstructor({
27754
+ amount: params.leg1DepositAmount
27755
+ });
27756
+ const STEP1 = "vesu_leg1" /* VESU_LEG1 */;
27757
+ const manage1Info = this.getProofs(STEP1);
27758
+ const manageCall1 = manage1Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
27759
+ collateralAmount: params.leg1DepositAmount,
27760
+ isAddCollateral: params.isDeposit,
27761
+ debtAmount,
27762
+ isBorrow: params.isDeposit
27763
+ }));
27764
+ const proofIds = [STEP0, STEP1];
27765
+ const manageCalls = [manageCall0, manageCall1];
27766
+ if (debtAmount.gt(0)) {
27767
+ const STEP2 = "avnu_multiply_approve_deposit" /* AVNU_MULTIPLY_APPROVE_DEPOSIT */;
27768
+ const manage2Info = this.getProofs(STEP2);
27769
+ const manageCall2 = manage2Info.callConstructor({
27770
+ amount: debtAmount
27771
+ });
27772
+ const debtTokenInfo = vesuAdapter1.config.debt;
27773
+ const lstTokenInfo = this.asset();
27774
+ const avnuModule = new AvnuWrapper();
27775
+ const quote = await avnuModule.getQuotes(
27776
+ debtTokenInfo.address.address,
27777
+ lstTokenInfo.address.address,
27778
+ debtAmount.toWei(),
27779
+ this.metadata.additionalInfo.vaultAllocator.address
27780
+ );
27781
+ const minAmount = await this._getMinOutputAmountLSTBuy(debtAmount);
27782
+ const minAmountWei = minAmount.toWei();
27783
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall minAmount: ${minAmount}`);
27784
+ const swapInfo = await avnuModule.getSwapInfo(
27785
+ quote,
27786
+ this.metadata.additionalInfo.vaultAllocator.address,
27787
+ 0,
27788
+ this.address.address,
27789
+ minAmountWei
27790
+ );
27791
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall swapInfo: ${JSON.stringify(swapInfo)}`);
27792
+ const STEP3 = "avnu_multiply_swap_deposit" /* AVNU_MULTIPLY_SWAP_DEPOSIT */;
27793
+ const manage3Info = this.getProofs(STEP3);
27794
+ const manageCall3 = manage3Info.callConstructor({
27795
+ props: swapInfo
27796
+ });
27797
+ proofIds.push(STEP2);
27798
+ proofIds.push(STEP3);
27799
+ manageCalls.push(manageCall2, manageCall3);
27800
+ const newCollateral = minAmount.plus(totalCollateral);
27801
+ const newHF = newCollateral.multipliedBy(collateralPrice).multipliedBy(legLTV).dividedBy(totalDebtAmount).dividedBy(debtPrice).toNumber();
27802
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
27803
+ if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
27804
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
27805
+ const STEP4 = "approve_token1" /* APPROVE_TOKEN1 */;
27806
+ const manage4Info = this.getProofs(STEP4);
27807
+ const manageCall4 = manage4Info.callConstructor({
27808
+ amount: minAmount
27809
+ });
27810
+ const STEP5 = "vesu_leg1" /* VESU_LEG1 */;
27811
+ const manage5Info = this.getProofs(STEP5);
27812
+ const manageCall5 = manage5Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
27813
+ collateralAmount: minAmount,
27814
+ isAddCollateral: true,
27815
+ debtAmount: Web3Number.fromWei("0", this.asset().decimals),
27816
+ isBorrow: params.isDeposit
27817
+ }));
27818
+ proofIds.push(STEP4, STEP5);
27819
+ manageCalls.push(manageCall4, manageCall5);
27820
+ }
27821
+ }
27822
+ const manageCall = this.getManageCall(proofIds, manageCalls);
27823
+ return manageCall;
27824
+ }
27825
+ // todo unwind or not deposit when the yield is bad.
27826
+ async getLSTMultiplierRebalanceCall() {
27827
+ const positions = await this.getVaultPositions();
27828
+ assert(positions.length == 3, "Rebalance call is only supported for 3 positions");
27829
+ const existingCollateralInfo = positions[0];
27830
+ const existingDebtInfo = positions[1];
27831
+ const unusedBalance = positions[2];
27832
+ const [healthFactor] = await this.getVesuHealthFactors();
27833
+ const [vesuAdapter1] = this.getVesuAdapters();
27834
+ const legLTV = await vesuAdapter1.getLTVConfig(this.config);
27835
+ const collateralisation = await vesuAdapter1.getCollateralization(this.config);
27836
+ logger.debug(`${this.getTag()}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
27837
+ existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
27838
+ const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
27839
+ const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
27840
+ logger.debug(`${this.getTag()}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
27841
+ const isHFTooLow = healthFactor < this.metadata.additionalInfo.minHealthFactor;
27842
+ const isHFTooHigh = healthFactor > this.metadata.additionalInfo.targetHealthFactor + 0.05;
27843
+ if (isHFTooLow || isHFTooHigh) {
27844
+ const manageCall = await this._getAvnuDepositSwapLegCall({
27845
+ isDeposit: true,
27846
+ leg1DepositAmount: unusedBalance.amount,
27847
+ minHF: 1.02
27848
+ // todo, shouldnt use this 1.02 HF, if there isn;t more looping left.
27849
+ });
27850
+ return { shouldRebalance: true, manageCall };
27851
+ } else {
27852
+ return { shouldRebalance: false, manageCall: void 0 };
27853
+ }
27854
+ }
27855
+ //
27856
+ async _getMinOutputAmountLSTBuy(amountInUnderlying) {
27857
+ const lstTruePrice = await this.getLSTExchangeRate();
27858
+ const minOutputAmount = amountInUnderlying.dividedBy(lstTruePrice);
27859
+ return minOutputAmount;
27860
+ }
27861
+ async _getMinOutputAmountLSTSell(amountInLST) {
27862
+ const lstTruePrice = await this.getLSTExchangeRate();
27863
+ const minOutputAmount = amountInLST.multipliedBy(lstTruePrice).multipliedBy(0.995);
27864
+ return minOutputAmount;
27865
+ }
27866
+ // todo add a function to findout max borrowable amount without fucking yield
27867
+ // if the current net yield < LST yield, add a function to calculate how much to unwind.
27694
27868
  /**
27695
27869
  * Uses vesu's multiple call to create leverage on LST
27696
27870
  * Deposit amount is in LST
@@ -27742,12 +27916,40 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27742
27916
  async getLSTAPR(_address) {
27743
27917
  try {
27744
27918
  const vesuAdapter1 = this.getVesuAdapters()[0];
27745
- return await LSTAPRService.getLSTAPR(vesuAdapter1.config.debt.address);
27919
+ const apr = await LSTAPRService.getLSTAPR(vesuAdapter1.config.debt.address);
27920
+ if (!apr) {
27921
+ throw new Error("Failed to get LST APR");
27922
+ }
27923
+ return apr;
27746
27924
  } catch (error) {
27747
27925
  logger.warn(`${this.getTag()}: Failed to get LST APR: ${error}`);
27748
27926
  return 0;
27749
27927
  }
27750
27928
  }
27929
+ // todo undo this
27930
+ async netAPY() {
27931
+ const { net, splits } = await super.netAPY();
27932
+ let _net = net;
27933
+ if (this.asset().symbol == "xWBTC") {
27934
+ const debtToken = this.getVesuAdapters()[0].config.debt;
27935
+ const lstAPY = await this.getLSTAPR(debtToken.address);
27936
+ _net = lstAPY * 5;
27937
+ }
27938
+ return {
27939
+ net: _net,
27940
+ splits
27941
+ };
27942
+ }
27943
+ async getUnusedBalanceAPY() {
27944
+ const unusedBalance = await this.getUnusedBalance();
27945
+ const vesuAdapter = this.getVesuAdapters()[0];
27946
+ const underlying = vesuAdapter.config.debt;
27947
+ const lstAPY = await this.getLSTAPR(underlying.address);
27948
+ return {
27949
+ apy: lstAPY,
27950
+ weight: unusedBalance.usdValue
27951
+ };
27952
+ }
27751
27953
  async getLSTExchangeRate() {
27752
27954
  const [vesuAdapter1] = this.getVesuAdapters();
27753
27955
  const lstTokenInfo = vesuAdapter1.config.collateral;
@@ -27778,7 +27980,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27778
27980
  const proofsIDs = [];
27779
27981
  const manageCalls = [];
27780
27982
  if (params.marginAmount.greaterThan(0)) {
27781
- const STEP1_ID = "approve_token1" /* APPROVE_TOKEN1 */;
27983
+ const STEP1_ID = "multiple_approve" /* MULTIPLE_APPROVE */;
27782
27984
  const manage1Info = this.getProofs(STEP1_ID);
27783
27985
  const depositAmount = params.marginAmount;
27784
27986
  const manageCall1 = manage1Info.callConstructor({
@@ -27908,7 +28110,7 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
27908
28110
  collateral: lstToken,
27909
28111
  debt: underlyingToken,
27910
28112
  vaultAllocator: vaultSettings.vaultAllocator,
27911
- id: "multiply_vesu" /* MULTIPLY_VESU */
28113
+ id: "vesu_leg1" /* VESU_LEG1 */
27912
28114
  });
27913
28115
  const commonAdapter = new CommonAdapter({
27914
28116
  manager: vaultSettings.manager,
@@ -27917,10 +28119,10 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
27917
28119
  vaultAddress: vaultSettings.vaultAddress,
27918
28120
  vaultAllocator: vaultSettings.vaultAllocator
27919
28121
  });
27920
- const { isV2 } = getVesuSingletonAddress(pool1);
28122
+ const { isV2, addr: poolAddr } = getVesuSingletonAddress(pool1);
27921
28123
  const VESU_MULTIPLY = isV2 ? vesuAdapterLST.VESU_MULTIPLY : vesuAdapterLST.VESU_MULTIPLY_V1;
27922
- vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
27923
- vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter.bind(vesuAdapterLST));
28124
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, "multiple_approve" /* MULTIPLE_APPROVE */).bind(commonAdapter));
28125
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter("multiply_vesu" /* MULTIPLY_VESU */).bind(vesuAdapterLST));
27924
28126
  vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_on" /* SWITCH_DELEGATION_ON */).bind(vesuAdapterLST));
27925
28127
  vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_off" /* SWITCH_DELEGATION_OFF */).bind(vesuAdapterLST));
27926
28128
  vaultSettings.adapters.push(...[{
@@ -27930,12 +28132,18 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
27930
28132
  id: "common_adapter" /* COMMON */,
27931
28133
  adapter: commonAdapter
27932
28134
  }]);
28135
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(underlyingToken.address, AVNU_EXCHANGE, "avnu_multiply_approve_deposit" /* AVNU_MULTIPLY_APPROVE_DEPOSIT */).bind(commonAdapter));
28136
+ vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(underlyingToken.address, lstToken.address, "avnu_multiply_swap_deposit" /* AVNU_MULTIPLY_SWAP_DEPOSIT */, false).bind(commonAdapter));
28137
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, AVNU_EXCHANGE, "avnu_multiply_approve_withdraw" /* AVNU_MULTIPLY_APPROVE_WITHDRAW */).bind(commonAdapter));
28138
+ vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(lstToken.address, underlyingToken.address, "avnu_multiply_swap_withdraw" /* AVNU_MULTIPLY_SWAP_WITHDRAW */, false).bind(commonAdapter));
28139
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
28140
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
27933
28141
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
27934
28142
  vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
27935
28143
  vaultSettings.leafAdapters.push(vesuAdapterLST.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterLST));
27936
28144
  const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
27937
- vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
27938
- vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
28145
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_EXCHANGE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
28146
+ vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */, false).bind(commonAdapter));
27939
28147
  return vaultSettings;
27940
28148
  }
27941
28149
  var AUDIT_URL4 = "https://docs.troves.fi/p/security#starknet-vault-kit";
@@ -28036,11 +28244,11 @@ var hyperxsBTC = {
28036
28244
  minHealthFactor: 1.05
28037
28245
  };
28038
28246
  var hyperxLBTC = {
28039
- vaultAddress: ContractAddr.from("0x38e96a301428d204ab4553799aa386a0f14a5ef9b30a5830be1814e4fb8da1c"),
28040
- manager: ContractAddr.from("0x18d376446d9df1f783e17aff1f21bac3d97aa3ba378e367742cdd744468ad35"),
28041
- vaultAllocator: ContractAddr.from("0x3e98774ca0508505ba6d7f17d95ec391648f44f947b0d211241464a4f5b9b20"),
28042
- redeemRequestNFT: ContractAddr.from("0x268017b4c8b2117ca0136d9a77e3666db44b143447566f0746ca0b1c9ab1e72"),
28043
- aumOracle: ContractAddr.from("0x521a3f339c65e918e0d8a065b14baef1ea25676bb7fca1e0238ac47e20d7755"),
28247
+ vaultAddress: ContractAddr.from("0x64cf24d4883fe569926419a0569ab34497c6956a1a308fa883257f7486d7030"),
28248
+ manager: ContractAddr.from("0x203530a4022a99b8f4b406aaf33b0849d43ad7422c1d5cc14ff8c667abec6c0"),
28249
+ vaultAllocator: ContractAddr.from("0x7dbc8ccd4eabce6ea6c19e0e5c9ccca3a93bd510303b9e071cbe25fc508546e"),
28250
+ redeemRequestNFT: ContractAddr.from("0x5ee66a39af9aef3d0d48982b4a63e8bd2a5bad021916bd87fb0eae3a26800b8"),
28251
+ aumOracle: ContractAddr.from("0x23d69e4391fa72d10e625e7575d8bddbb4aff96f04503f83fdde23123bf41d0"),
28044
28252
  leafAdapters: [],
28045
28253
  adapters: [],
28046
28254
  targetHealthFactor: 1.1,
@@ -28087,6 +28295,7 @@ var HyperLSTStrategies = [
28087
28295
  ];
28088
28296
  export {
28089
28297
  AUMTypes,
28298
+ AVNU_EXCHANGE,
28090
28299
  AVNU_MIDDLEWARE,
28091
28300
  AutoCompounderSTRK,
28092
28301
  AvnuWrapper,
@@ -28125,6 +28334,7 @@ export {
28125
28334
  UniversalStrategies,
28126
28335
  UniversalStrategy,
28127
28336
  VESU_SINGLETON,
28337
+ VESU_V2_MODIFY_POSITION_SANITIZER,
28128
28338
  VesuAdapter,
28129
28339
  VesuAmountDenomination,
28130
28340
  VesuAmountType,
package/dist/index.d.ts CHANGED
@@ -961,8 +961,8 @@ declare class CommonAdapter extends BaseAdapter {
961
961
  calldata: bigint[];
962
962
  };
963
963
  };
964
- getAvnuAdapter(fromToken: ContractAddr, toToken: ContractAddr, id: string): () => AdapterLeafType<AvnuSwapCallParams>;
965
- getAvnuCall(fromToken: ContractAddr, toToken: ContractAddr): GenerateCallFn<AvnuSwapCallParams>;
964
+ getAvnuAdapter(fromToken: ContractAddr, toToken: ContractAddr, id: string, isMiddleware: boolean): () => AdapterLeafType<AvnuSwapCallParams>;
965
+ getAvnuCall(fromToken: ContractAddr, toToken: ContractAddr, isMiddleware: boolean): GenerateCallFn<AvnuSwapCallParams>;
966
966
  }
967
967
 
968
968
  interface VesuPoolsInfo {
@@ -1089,7 +1089,7 @@ declare class VesuAdapter extends BaseAdapter {
1089
1089
  };
1090
1090
  };
1091
1091
  getModifyPositionCall: (params: VesuModifyPositionCallParams) => ManageCall;
1092
- getMultiplyAdapter: () => AdapterLeafType<VesuMultiplyCallParams>;
1092
+ getMultiplyAdapter: (id: string) => LeafAdapterFn<VesuMultiplyCallParams>;
1093
1093
  getMultiplyCall: (params: VesuMultiplyCallParams) => ManageCall;
1094
1094
  getVesuModifyDelegationAdapter: (id: string) => LeafAdapterFn<VesuModifyDelegationCallParams>;
1095
1095
  getVesuModifyDelegationCall: (params: VesuModifyDelegationCallParams) => ManageCall;
@@ -1119,9 +1119,11 @@ declare class VesuAdapter extends BaseAdapter {
1119
1119
 
1120
1120
  declare const SIMPLE_SANITIZER: ContractAddr;
1121
1121
  declare const SIMPLE_SANITIZER_V2: ContractAddr;
1122
+ declare const VESU_V2_MODIFY_POSITION_SANITIZER: ContractAddr;
1122
1123
  declare const SIMPLE_SANITIZER_VESU_V1_DELEGATIONS: ContractAddr;
1123
1124
  declare const PRICE_ROUTER: ContractAddr;
1124
1125
  declare const AVNU_MIDDLEWARE: ContractAddr;
1126
+ declare const AVNU_EXCHANGE: ContractAddr;
1125
1127
  declare const VESU_SINGLETON: ContractAddr;
1126
1128
  declare function toBigInt(value: string | number): bigint;
1127
1129
 
@@ -1191,6 +1193,10 @@ declare class UniversalStrategy<S extends UniversalStrategySettings> extends Bas
1191
1193
  id: string;
1192
1194
  }[];
1193
1195
  }>;
1196
+ protected getUnusedBalanceAPY(): Promise<{
1197
+ apy: number;
1198
+ weight: number;
1199
+ }>;
1194
1200
  private computeAPY;
1195
1201
  /**
1196
1202
  * Calculates the total TVL of the strategy.
@@ -1289,6 +1295,17 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<Universal
1289
1295
  getVesuAdapters(): VesuAdapter[];
1290
1296
  protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
1291
1297
  getLSTDexPrice(): Promise<number>;
1298
+ getAvnuSwapMultiplyCall(params: {
1299
+ isDeposit: boolean;
1300
+ leg1DepositAmount: Web3Number;
1301
+ }): Promise<Call>;
1302
+ private _getAvnuDepositSwapLegCall;
1303
+ getLSTMultiplierRebalanceCall(): Promise<{
1304
+ shouldRebalance: boolean;
1305
+ manageCall: Call | undefined;
1306
+ }>;
1307
+ private _getMinOutputAmountLSTBuy;
1308
+ private _getMinOutputAmountLSTSell;
1292
1309
  /**
1293
1310
  * Uses vesu's multiple call to create leverage on LST
1294
1311
  * Deposit amount is in LST
@@ -1304,6 +1321,17 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<Universal
1304
1321
  * @returns Promise<number> The LST APR (not divided by 1e18)
1305
1322
  */
1306
1323
  getLSTAPR(_address: ContractAddr): Promise<number>;
1324
+ netAPY(): Promise<{
1325
+ net: number;
1326
+ splits: {
1327
+ apy: number;
1328
+ id: string;
1329
+ }[];
1330
+ }>;
1331
+ protected getUnusedBalanceAPY(): Promise<{
1332
+ apy: number;
1333
+ weight: number;
1334
+ }>;
1307
1335
  getLSTExchangeRate(): Promise<number>;
1308
1336
  /**
1309
1337
  *
@@ -1589,4 +1617,4 @@ declare class PasswordJsonCryptoUtil {
1589
1617
  decrypt(encryptedData: string, password: string): any;
1590
1618
  }
1591
1619
 
1592
- export { AUMTypes, AVNU_MIDDLEWARE, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type ApproveCallParams, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, BaseAdapter, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, type DecreaseLeverParams, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type FAQ, FatalError, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, HyperLSTStrategies, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, LSTAPRService, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, Network, PRICE_ROUTER, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerLST, PricerRedis, Protocols, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, type TokenAmount, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, VESU_SINGLETON, type VaultPosition, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuModifyDelegationCallParams, type VesuModifyPositionCallParams, type VesuMultiplyCallParams, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getAPIUsingHeadlessBrowser, getContractDetails, getDefaultStoreConfig, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, logger, toBigInt };
1620
+ export { AUMTypes, AVNU_EXCHANGE, AVNU_MIDDLEWARE, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type ApproveCallParams, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, BaseAdapter, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, type DecreaseLeverParams, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type FAQ, FatalError, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, HyperLSTStrategies, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, LSTAPRService, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, Network, PRICE_ROUTER, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerLST, PricerRedis, Protocols, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, type TokenAmount, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER, type VaultPosition, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuModifyDelegationCallParams, type VesuModifyPositionCallParams, type VesuMultiplyCallParams, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getAPIUsingHeadlessBrowser, getContractDetails, getDefaultStoreConfig, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, logger, toBigInt };