@strkfarm/sdk 1.1.29 → 1.1.32

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.mjs CHANGED
@@ -19027,9 +19027,11 @@ import { hash, num as num6, shortString } from "starknet";
19027
19027
  // src/strategies/universal-adapters/adapter-utils.ts
19028
19028
  var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
19029
19029
  var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x7b6f98311af8aa425278570e62abf523e6462eaa01a38c1feab9b2f416492e2");
19030
+ var VESU_V2_MODIFY_POSITION_SANITIZER = ContractAddr.from("0x04Bf71F2BD9D6F8819057c9dD524F0d5fbc38317C00500d7b9a0FdCf01195066");
19030
19031
  var SIMPLE_SANITIZER_VESU_V1_DELEGATIONS = ContractAddr.from("0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a");
19031
19032
  var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
19032
19033
  var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
19034
+ var AVNU_EXCHANGE = ContractAddr.from("0x04270219d365d6b017231b52e92b3fb5d7c8378b05e9abc97724537a80e93b0f");
19033
19035
  var VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
19034
19036
  function toBigInt(value) {
19035
19037
  if (typeof value === "string") {
@@ -19174,11 +19176,11 @@ var CommonAdapter = class extends BaseAdapter {
19174
19176
  };
19175
19177
  };
19176
19178
  }
19177
- getAvnuAdapter(fromToken, toToken, id) {
19179
+ getAvnuAdapter(fromToken, toToken, id, isMiddleware) {
19178
19180
  return () => ({
19179
19181
  leaf: this.constructSimpleLeafData({
19180
19182
  id,
19181
- target: AVNU_MIDDLEWARE,
19183
+ target: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
19182
19184
  method: "multi_route_swap",
19183
19185
  packedArguments: [
19184
19186
  fromToken.toBigInt(),
@@ -19186,15 +19188,15 @@ var CommonAdapter = class extends BaseAdapter {
19186
19188
  this.config.vaultAllocator.toBigInt()
19187
19189
  ]
19188
19190
  }),
19189
- callConstructor: this.getAvnuCall(fromToken, toToken).bind(this)
19191
+ callConstructor: this.getAvnuCall(fromToken, toToken, isMiddleware).bind(this)
19190
19192
  });
19191
19193
  }
19192
- getAvnuCall(fromToken, toToken) {
19194
+ getAvnuCall(fromToken, toToken, isMiddleware) {
19193
19195
  return (params) => {
19194
19196
  return {
19195
19197
  sanitizer: SIMPLE_SANITIZER,
19196
19198
  call: {
19197
- contractAddress: AVNU_MIDDLEWARE,
19199
+ contractAddress: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
19198
19200
  selector: hash2.getSelectorFromName("multi_route_swap"),
19199
19201
  calldata: [
19200
19202
  fromToken.toBigInt(),
@@ -23948,24 +23950,30 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
23948
23950
  this.VESU_MULTIPLY = ContractAddr.from("0x027fef272d0a9a3844767c851a64b36fe4f0115141d81134baade95d2b27b781");
23949
23951
  this.getModifyPosition = () => {
23950
23952
  const positionData = [0n];
23951
- const packedArguments = [
23952
- toBigInt(this.config.poolId.toString()),
23953
- // pool id
23953
+ const { addr, isV2 } = getVesuSingletonAddress(this.config.poolId);
23954
+ const commonPackedData = [
23954
23955
  toBigInt(this.config.collateral.address.toString()),
23955
23956
  // collateral
23956
23957
  toBigInt(this.config.debt.address.toString()),
23957
23958
  // debt
23958
- toBigInt(this.config.vaultAllocator.toString()),
23959
+ toBigInt(this.config.vaultAllocator.toString())
23959
23960
  // vault allocator
23961
+ ];
23962
+ const packedArguments = isV2 ? [
23963
+ ...commonPackedData
23964
+ ] : [
23965
+ toBigInt(this.config.poolId.toString()),
23966
+ // pool id
23967
+ ...commonPackedData,
23960
23968
  toBigInt(positionData.length),
23961
23969
  ...positionData
23962
23970
  ];
23963
23971
  const output = this.constructSimpleLeafData({
23964
23972
  id: this.config.id,
23965
- target: getVesuSingletonAddress(this.config.poolId).addr,
23973
+ target: addr,
23966
23974
  method: "modify_position",
23967
23975
  packedArguments
23968
- });
23976
+ }, isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER);
23969
23977
  return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
23970
23978
  };
23971
23979
  this.getModifyPositionCall = (params) => {
@@ -24006,7 +24014,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
24006
24014
  }
24007
24015
  });
24008
24016
  return {
24009
- sanitizer: SIMPLE_SANITIZER,
24017
+ sanitizer: isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER,
24010
24018
  call: {
24011
24019
  contractAddress: ContractAddr.from(contract.address),
24012
24020
  selector: hash3.getSelectorFromName("modify_position"),
@@ -24016,25 +24024,27 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
24016
24024
  }
24017
24025
  };
24018
24026
  };
24019
- this.getMultiplyAdapter = () => {
24020
- const packedArguments = [
24021
- toBigInt(this.config.poolId.toString()),
24022
- // pool id
24023
- toBigInt(this.config.collateral.address.toString()),
24024
- // collateral
24025
- toBigInt(this.config.debt.address.toString()),
24026
- // debt
24027
- toBigInt(this.config.vaultAllocator.toString())
24028
- // vault allocator
24029
- ];
24030
- const { isV2 } = getVesuSingletonAddress(this.config.poolId);
24031
- const output = this.constructSimpleLeafData({
24032
- id: this.config.id,
24033
- target: isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1,
24034
- method: "modify_lever",
24035
- packedArguments
24036
- }, SIMPLE_SANITIZER_V2);
24037
- return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
24027
+ this.getMultiplyAdapter = (id) => {
24028
+ return () => {
24029
+ const packedArguments = [
24030
+ toBigInt(this.config.poolId.toString()),
24031
+ // pool id
24032
+ toBigInt(this.config.collateral.address.toString()),
24033
+ // collateral
24034
+ toBigInt(this.config.debt.address.toString()),
24035
+ // debt
24036
+ toBigInt(this.config.vaultAllocator.toString())
24037
+ // vault allocator
24038
+ ];
24039
+ const { isV2 } = getVesuSingletonAddress(this.config.poolId);
24040
+ const output = this.constructSimpleLeafData({
24041
+ id,
24042
+ target: isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1,
24043
+ method: "modify_lever",
24044
+ packedArguments
24045
+ }, SIMPLE_SANITIZER_V2);
24046
+ return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
24047
+ };
24038
24048
  };
24039
24049
  this.getMultiplyCall = (params) => {
24040
24050
  const isIncrease = params.isIncrease;
@@ -27245,7 +27255,7 @@ function getLooperSettings(token1Symbol, token2Symbol, vaultSettings, pool1, poo
27245
27255
  vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterUSDCETH));
27246
27256
  const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
27247
27257
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
27248
- vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
27258
+ vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */, true).bind(commonAdapter));
27249
27259
  return vaultSettings;
27250
27260
  }
27251
27261
  var _riskFactor3 = [
@@ -27600,8 +27610,159 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27600
27610
  return price;
27601
27611
  }
27602
27612
  async getAvnuSwapMultiplyCall(params) {
27603
- return [];
27613
+ return this._getAvnuDepositSwapLegCall({
27614
+ ...params,
27615
+ minHF: 1.02
27616
+ });
27617
+ }
27618
+ async _getAvnuDepositSwapLegCall(params) {
27619
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall params: ${JSON.stringify(params)}`);
27620
+ assert(params.isDeposit, "Only deposit is supported in _getAvnuDepositSwapLegCall");
27621
+ const [vesuAdapter1] = this.getVesuAdapters();
27622
+ const legLTV = await vesuAdapter1.getLTVConfig(this.config);
27623
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall legLTV: ${legLTV}`);
27624
+ const existingPositions = await vesuAdapter1.getPositions(this.config);
27625
+ const collateralisation = await vesuAdapter1.getCollateralization(this.config);
27626
+ const existingCollateralInfo = existingPositions[0];
27627
+ const existingDebtInfo = existingPositions[1];
27628
+ logger.debug(`${this.getTag()}::_getAvnuDepositSwapLegCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
27629
+ existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
27630
+ const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
27631
+ const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
27632
+ logger.debug(`${this.getTag()}::_getAvnuDepositSwapLegCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
27633
+ const totalCollateral = existingCollateralInfo.amount.plus(params.leg1DepositAmount);
27634
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall totalCollateral: ${totalCollateral}`);
27635
+ const totalDebtAmount = totalCollateral.multipliedBy(collateralPrice).multipliedBy(legLTV).dividedBy(debtPrice).dividedBy(params.minHF);
27636
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall totalDebtAmount: ${totalDebtAmount}`);
27637
+ const debtAmount = totalDebtAmount.minus(existingDebtInfo.amount);
27638
+ if (debtAmount.lt(0)) {
27639
+ const lstDEXPrice = await this.getLSTDexPrice();
27640
+ const debtAmountInLST = debtAmount.abs().dividedBy(lstDEXPrice);
27641
+ const calls = await this.getVesuMultiplyCall({
27642
+ isDeposit: false,
27643
+ leg1DepositAmount: debtAmountInLST
27644
+ });
27645
+ assert(calls.length == 1, "Expected 1 call for unwind");
27646
+ return calls[0];
27647
+ }
27648
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall debtAmount: ${debtAmount}`);
27649
+ const STEP0 = "approve_token1" /* APPROVE_TOKEN1 */;
27650
+ const manage0Info = this.getProofs(STEP0);
27651
+ const manageCall0 = manage0Info.callConstructor({
27652
+ amount: params.leg1DepositAmount
27653
+ });
27654
+ const STEP1 = "vesu_leg1" /* VESU_LEG1 */;
27655
+ const manage1Info = this.getProofs(STEP1);
27656
+ const manageCall1 = manage1Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
27657
+ collateralAmount: params.leg1DepositAmount,
27658
+ isAddCollateral: params.isDeposit,
27659
+ debtAmount,
27660
+ isBorrow: params.isDeposit
27661
+ }));
27662
+ const proofIds = [STEP0, STEP1];
27663
+ const manageCalls = [manageCall0, manageCall1];
27664
+ if (debtAmount.gt(0)) {
27665
+ const STEP2 = "avnu_multiply_approve_deposit" /* AVNU_MULTIPLY_APPROVE_DEPOSIT */;
27666
+ const manage2Info = this.getProofs(STEP2);
27667
+ const manageCall2 = manage2Info.callConstructor({
27668
+ amount: debtAmount
27669
+ });
27670
+ const debtTokenInfo = vesuAdapter1.config.debt;
27671
+ const lstTokenInfo = this.asset();
27672
+ const avnuModule = new AvnuWrapper();
27673
+ const quote = await avnuModule.getQuotes(
27674
+ debtTokenInfo.address.address,
27675
+ lstTokenInfo.address.address,
27676
+ debtAmount.toWei(),
27677
+ this.metadata.additionalInfo.vaultAllocator.address
27678
+ );
27679
+ const minAmount = await this._getMinOutputAmountLSTBuy(debtAmount);
27680
+ const minAmountWei = minAmount.toWei();
27681
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall minAmount: ${minAmount}`);
27682
+ const swapInfo = await avnuModule.getSwapInfo(
27683
+ quote,
27684
+ this.metadata.additionalInfo.vaultAllocator.address,
27685
+ 0,
27686
+ this.address.address,
27687
+ minAmountWei
27688
+ );
27689
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall swapInfo: ${JSON.stringify(swapInfo)}`);
27690
+ const STEP3 = "avnu_multiply_swap_deposit" /* AVNU_MULTIPLY_SWAP_DEPOSIT */;
27691
+ const manage3Info = this.getProofs(STEP3);
27692
+ const manageCall3 = manage3Info.callConstructor({
27693
+ props: swapInfo
27694
+ });
27695
+ proofIds.push(STEP2);
27696
+ proofIds.push(STEP3);
27697
+ manageCalls.push(manageCall2, manageCall3);
27698
+ const newCollateral = minAmount.plus(totalCollateral);
27699
+ const newHF = newCollateral.multipliedBy(collateralPrice).multipliedBy(legLTV).dividedBy(totalDebtAmount).dividedBy(debtPrice).toNumber();
27700
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
27701
+ if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
27702
+ logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
27703
+ const STEP4 = "approve_token1" /* APPROVE_TOKEN1 */;
27704
+ const manage4Info = this.getProofs(STEP4);
27705
+ const manageCall4 = manage4Info.callConstructor({
27706
+ amount: minAmount
27707
+ });
27708
+ const STEP5 = "vesu_leg1" /* VESU_LEG1 */;
27709
+ const manage5Info = this.getProofs(STEP5);
27710
+ const manageCall5 = manage5Info.callConstructor(VesuAdapter.getDefaultModifyPositionCallParams({
27711
+ collateralAmount: minAmount,
27712
+ isAddCollateral: true,
27713
+ debtAmount: Web3Number.fromWei("0", this.asset().decimals),
27714
+ isBorrow: params.isDeposit
27715
+ }));
27716
+ proofIds.push(STEP4, STEP5);
27717
+ manageCalls.push(manageCall4, manageCall5);
27718
+ }
27719
+ }
27720
+ const manageCall = this.getManageCall(proofIds, manageCalls);
27721
+ return manageCall;
27604
27722
  }
27723
+ // todo unwind or not deposit when the yield is bad.
27724
+ async getLSTMultiplierRebalanceCall() {
27725
+ const positions = await this.getVaultPositions();
27726
+ assert(positions.length == 3, "Rebalance call is only supported for 3 positions");
27727
+ const existingCollateralInfo = positions[0];
27728
+ const existingDebtInfo = positions[1];
27729
+ const unusedBalance = positions[2];
27730
+ const [healthFactor] = await this.getVesuHealthFactors();
27731
+ const [vesuAdapter1] = this.getVesuAdapters();
27732
+ const legLTV = await vesuAdapter1.getLTVConfig(this.config);
27733
+ const collateralisation = await vesuAdapter1.getCollateralization(this.config);
27734
+ logger.debug(`${this.getTag()}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
27735
+ existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
27736
+ const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
27737
+ const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
27738
+ logger.debug(`${this.getTag()}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
27739
+ const isHFTooLow = healthFactor < this.metadata.additionalInfo.minHealthFactor;
27740
+ const isHFTooHigh = healthFactor > this.metadata.additionalInfo.targetHealthFactor + 0.05;
27741
+ if (isHFTooLow || isHFTooHigh) {
27742
+ const manageCall = await this._getAvnuDepositSwapLegCall({
27743
+ isDeposit: true,
27744
+ leg1DepositAmount: unusedBalance.amount,
27745
+ minHF: 1.02
27746
+ // todo, shouldnt use this 1.02 HF, if there isn;t more looping left.
27747
+ });
27748
+ return { shouldRebalance: true, manageCall };
27749
+ } else {
27750
+ return { shouldRebalance: false, manageCall: void 0 };
27751
+ }
27752
+ }
27753
+ //
27754
+ async _getMinOutputAmountLSTBuy(amountInUnderlying) {
27755
+ const lstTruePrice = await this.getLSTExchangeRate();
27756
+ const minOutputAmount = amountInUnderlying.dividedBy(lstTruePrice);
27757
+ return minOutputAmount;
27758
+ }
27759
+ async _getMinOutputAmountLSTSell(amountInLST) {
27760
+ const lstTruePrice = await this.getLSTExchangeRate();
27761
+ const minOutputAmount = amountInLST.multipliedBy(lstTruePrice).multipliedBy(0.995);
27762
+ return minOutputAmount;
27763
+ }
27764
+ // todo add a function to findout max borrowable amount without fucking yield
27765
+ // if the current net yield < LST yield, add a function to calculate how much to unwind.
27605
27766
  /**
27606
27767
  * Uses vesu's multiple call to create leverage on LST
27607
27768
  * Deposit amount is in LST
@@ -27653,7 +27814,11 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27653
27814
  async getLSTAPR(_address) {
27654
27815
  try {
27655
27816
  const vesuAdapter1 = this.getVesuAdapters()[0];
27656
- return await LSTAPRService2.getLSTAPR(vesuAdapter1.config.debt.address);
27817
+ const apr = await LSTAPRService.getLSTAPR(vesuAdapter1.config.debt.address);
27818
+ if (!apr) {
27819
+ throw new Error("Failed to get LST APR");
27820
+ }
27821
+ return apr;
27657
27822
  } catch (error) {
27658
27823
  logger.warn(`${this.getTag()}: Failed to get LST APR: ${error}`);
27659
27824
  return 0;
@@ -27664,7 +27829,9 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27664
27829
  const { net, splits } = await super.netAPY();
27665
27830
  let _net = net;
27666
27831
  if (this.asset().symbol == "xWBTC") {
27667
- _net *= 5;
27832
+ const debtToken = this.getVesuAdapters()[0].config.debt;
27833
+ const lstAPY = await this.getLSTAPR(debtToken.address);
27834
+ _net = lstAPY * 5;
27668
27835
  }
27669
27836
  return {
27670
27837
  net: _net,
@@ -27711,7 +27878,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
27711
27878
  const proofsIDs = [];
27712
27879
  const manageCalls = [];
27713
27880
  if (params.marginAmount.greaterThan(0)) {
27714
- const STEP1_ID = "approve_token1" /* APPROVE_TOKEN1 */;
27881
+ const STEP1_ID = "multiple_approve" /* MULTIPLE_APPROVE */;
27715
27882
  const manage1Info = this.getProofs(STEP1_ID);
27716
27883
  const depositAmount = params.marginAmount;
27717
27884
  const manageCall1 = manage1Info.callConstructor({
@@ -27821,12 +27988,22 @@ function VaultDescription(lstSymbol, underlyingSymbol) {
27821
27988
  highlightTextWithLinks("conversion rate oracle", [{ highlight: "conversion rate oracle", link: "https://docs.pragma.build/starknet/development#conversion-rate" }]),
27822
27989
  "which is resilient to liquidity issues and price volatility, hence reducing the risk of liquidation. However, overtime, if left un-monitored, debt can increase enough to trigger a liquidation. But no worries, our continuous monitoring systems look for situations with reduced health factor and balance collateral/debt to bring it back to safe levels. With Troves, you can have a peaceful sleep."
27823
27990
  ] }),
27824
- /* @__PURE__ */ jsx5("div", { style: { backgroundColor: "#222", padding: "10px", borderRadius: "8px", marginBottom: "20px", border: "1px solid #444" }, children: /* @__PURE__ */ jsxs4("p", { style: { fontSize: "13px", color: "#ccc" }, children: [
27825
- /* @__PURE__ */ jsx5("strong", { children: "Withdrawals:" }),
27826
- " Requests can take up to ",
27827
- /* @__PURE__ */ jsx5("strong", { children: "1-2 hours" }),
27828
- " to process as the vault unwinds and settles routing."
27829
- ] }) })
27991
+ /* @__PURE__ */ jsxs4("div", { style: { backgroundColor: "#222", padding: "10px", borderRadius: "8px", marginBottom: "20px", border: "1px solid #444" }, children: [
27992
+ /* @__PURE__ */ jsxs4("p", { style: { fontSize: "13px", color: "#ccc" }, children: [
27993
+ /* @__PURE__ */ jsx5("strong", { children: "Withdrawals:" }),
27994
+ " Requests can take up to ",
27995
+ /* @__PURE__ */ jsx5("strong", { children: "1-2 hours" }),
27996
+ " to process as the vault unwinds and settles routing."
27997
+ ] }),
27998
+ /* @__PURE__ */ jsxs4("p", { style: { fontSize: "13px", color: "#ccc" }, children: [
27999
+ /* @__PURE__ */ jsx5("strong", { children: "Debt limits:" }),
28000
+ " Pools on Vesu have debt caps that are gradually increased over time. Until caps are raised, deposited LSTs remain in the vault, generating a shared net return for all depositors."
28001
+ ] }),
28002
+ /* @__PURE__ */ jsxs4("p", { style: { fontSize: "13px", color: "#ccc" }, children: [
28003
+ /* @__PURE__ */ jsx5("strong", { children: "APY assumptions:" }),
28004
+ " APY shown is the max possible value given current LST and borrowing rates. True APY will be subject to the actual leverage, based on above point. More insights on exact APY will be added soon."
28005
+ ] })
28006
+ ] })
27830
28007
  ] });
27831
28008
  }
27832
28009
  function getDescription2(tokenSymbol, underlyingSymbol) {
@@ -27841,7 +28018,7 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
27841
28018
  collateral: lstToken,
27842
28019
  debt: underlyingToken,
27843
28020
  vaultAllocator: vaultSettings.vaultAllocator,
27844
- id: "multiply_vesu" /* MULTIPLY_VESU */
28021
+ id: "vesu_leg1" /* VESU_LEG1 */
27845
28022
  });
27846
28023
  const commonAdapter = new CommonAdapter({
27847
28024
  manager: vaultSettings.manager,
@@ -27850,10 +28027,10 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
27850
28027
  vaultAddress: vaultSettings.vaultAddress,
27851
28028
  vaultAllocator: vaultSettings.vaultAllocator
27852
28029
  });
27853
- const { isV2 } = getVesuSingletonAddress(pool1);
28030
+ const { isV2, addr: poolAddr } = getVesuSingletonAddress(pool1);
27854
28031
  const VESU_MULTIPLY = isV2 ? vesuAdapterLST.VESU_MULTIPLY : vesuAdapterLST.VESU_MULTIPLY_V1;
27855
- vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
27856
- vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter.bind(vesuAdapterLST));
28032
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, "multiple_approve" /* MULTIPLE_APPROVE */).bind(commonAdapter));
28033
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter("multiply_vesu" /* MULTIPLY_VESU */).bind(vesuAdapterLST));
27857
28034
  vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_on" /* SWITCH_DELEGATION_ON */).bind(vesuAdapterLST));
27858
28035
  vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_off" /* SWITCH_DELEGATION_OFF */).bind(vesuAdapterLST));
27859
28036
  vaultSettings.adapters.push(...[{
@@ -27863,12 +28040,18 @@ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
27863
28040
  id: "common_adapter" /* COMMON */,
27864
28041
  adapter: commonAdapter
27865
28042
  }]);
28043
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(underlyingToken.address, AVNU_EXCHANGE, "avnu_multiply_approve_deposit" /* AVNU_MULTIPLY_APPROVE_DEPOSIT */).bind(commonAdapter));
28044
+ vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(underlyingToken.address, lstToken.address, "avnu_multiply_swap_deposit" /* AVNU_MULTIPLY_SWAP_DEPOSIT */, false).bind(commonAdapter));
28045
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, AVNU_EXCHANGE, "avnu_multiply_approve_withdraw" /* AVNU_MULTIPLY_APPROVE_WITHDRAW */).bind(commonAdapter));
28046
+ vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(lstToken.address, underlyingToken.address, "avnu_multiply_swap_withdraw" /* AVNU_MULTIPLY_SWAP_WITHDRAW */, false).bind(commonAdapter));
28047
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
28048
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
27866
28049
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
27867
28050
  vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
27868
28051
  vaultSettings.leafAdapters.push(vesuAdapterLST.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterLST));
27869
28052
  const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
27870
- vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
27871
- vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
28053
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_EXCHANGE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
28054
+ vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */, false).bind(commonAdapter));
27872
28055
  return vaultSettings;
27873
28056
  }
27874
28057
  var AUDIT_URL4 = "https://docs.troves.fi/p/security#starknet-vault-kit";
@@ -27969,11 +28152,11 @@ var hyperxsBTC = {
27969
28152
  minHealthFactor: 1.05
27970
28153
  };
27971
28154
  var hyperxLBTC = {
27972
- vaultAddress: ContractAddr.from("0x38e96a301428d204ab4553799aa386a0f14a5ef9b30a5830be1814e4fb8da1c"),
27973
- manager: ContractAddr.from("0x18d376446d9df1f783e17aff1f21bac3d97aa3ba378e367742cdd744468ad35"),
27974
- vaultAllocator: ContractAddr.from("0x3e98774ca0508505ba6d7f17d95ec391648f44f947b0d211241464a4f5b9b20"),
27975
- redeemRequestNFT: ContractAddr.from("0x268017b4c8b2117ca0136d9a77e3666db44b143447566f0746ca0b1c9ab1e72"),
27976
- aumOracle: ContractAddr.from("0x521a3f339c65e918e0d8a065b14baef1ea25676bb7fca1e0238ac47e20d7755"),
28155
+ vaultAddress: ContractAddr.from("0x64cf24d4883fe569926419a0569ab34497c6956a1a308fa883257f7486d7030"),
28156
+ manager: ContractAddr.from("0x203530a4022a99b8f4b406aaf33b0849d43ad7422c1d5cc14ff8c667abec6c0"),
28157
+ vaultAllocator: ContractAddr.from("0x7dbc8ccd4eabce6ea6c19e0e5c9ccca3a93bd510303b9e071cbe25fc508546e"),
28158
+ redeemRequestNFT: ContractAddr.from("0x5ee66a39af9aef3d0d48982b4a63e8bd2a5bad021916bd87fb0eae3a26800b8"),
28159
+ aumOracle: ContractAddr.from("0x23d69e4391fa72d10e625e7575d8bddbb4aff96f04503f83fdde23123bf41d0"),
27977
28160
  leafAdapters: [],
27978
28161
  adapters: [],
27979
28162
  targetHealthFactor: 1.1,
@@ -27981,7 +28164,7 @@ var hyperxLBTC = {
27981
28164
  };
27982
28165
  function getInvestmentSteps(lstSymbol, underlyingSymbol) {
27983
28166
  return [
27984
- `Deposit ${underlyingSymbol} into the vault`,
28167
+ `Deposit ${lstSymbol} into the vault`,
27985
28168
  `The vault manager loops the ${underlyingSymbol} to buy ${lstSymbol}`,
27986
28169
  `The vault manager collateralizes the ${lstSymbol} on Vesu`,
27987
28170
  `The vault manager borrows more ${underlyingSymbol} to loop further`,
@@ -28070,7 +28253,7 @@ var PricerLST2 = class extends Pricer {
28070
28253
  };
28071
28254
 
28072
28255
  // src/modules/lst-apr.ts
28073
- var LSTAPRService2 = class {
28256
+ var LSTAPRService = class {
28074
28257
  // 5 minutes
28075
28258
  /**
28076
28259
  * Fetches LST stats from Endur API with caching
@@ -28165,10 +28348,10 @@ var LSTAPRService2 = class {
28165
28348
  logger.verbose(`LSTAPRService: Cache cleared`);
28166
28349
  }
28167
28350
  };
28168
- LSTAPRService2.ENDUR_API_URL = "https://app.endur.fi/api/lst/stats";
28169
- LSTAPRService2.cache = null;
28170
- LSTAPRService2.cacheTimestamp = 0;
28171
- LSTAPRService2.CACHE_DURATION = 5 * 60 * 1e3;
28351
+ LSTAPRService.ENDUR_API_URL = "https://app.endur.fi/api/lst/stats";
28352
+ LSTAPRService.cache = null;
28353
+ LSTAPRService.cacheTimestamp = 0;
28354
+ LSTAPRService.CACHE_DURATION = 5 * 60 * 1e3;
28172
28355
 
28173
28356
  // src/notifs/telegram.ts
28174
28357
  import TelegramBot from "node-telegram-bot-api";
@@ -28679,6 +28862,7 @@ var Deployer = {
28679
28862
  var deployer_default = Deployer;
28680
28863
  export {
28681
28864
  AUMTypes,
28865
+ AVNU_EXCHANGE,
28682
28866
  AVNU_MIDDLEWARE,
28683
28867
  AutoCompounderSTRK,
28684
28868
  AvnuWrapper,
@@ -28697,7 +28881,7 @@ export {
28697
28881
  HyperLSTStrategies,
28698
28882
  ILending,
28699
28883
  Initializable,
28700
- LSTAPRService2 as LSTAPRService,
28884
+ LSTAPRService,
28701
28885
  MarginType,
28702
28886
  Network,
28703
28887
  PRICE_ROUTER,
@@ -28724,6 +28908,7 @@ export {
28724
28908
  UniversalStrategies,
28725
28909
  UniversalStrategy,
28726
28910
  VESU_SINGLETON,
28911
+ VESU_V2_MODIFY_POSITION_SANITIZER,
28727
28912
  VesuAdapter,
28728
28913
  VesuAmountDenomination,
28729
28914
  VesuAmountType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.1.29",
3
+ "version": "1.1.32",
4
4
  "description": "STRKFarm TS SDK (Meant for our internal use, but feel free to use it)",
5
5
  "typings": "dist/index.d.ts",
6
6
  "types": "dist/index.d.ts",
@@ -4,9 +4,11 @@ import { ContractAddr } from "@/dataTypes";
4
4
  export const SIMPLE_SANITIZER = ContractAddr.from('0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4');
5
5
  // Without flashloan options
6
6
  export const SIMPLE_SANITIZER_V2 = ContractAddr.from('0x7b6f98311af8aa425278570e62abf523e6462eaa01a38c1feab9b2f416492e2');
7
+ export const VESU_V2_MODIFY_POSITION_SANITIZER = ContractAddr.from('0x04Bf71F2BD9D6F8819057c9dD524F0d5fbc38317C00500d7b9a0FdCf01195066');
7
8
  export const SIMPLE_SANITIZER_VESU_V1_DELEGATIONS = ContractAddr.from('0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a');
8
9
  export const PRICE_ROUTER = ContractAddr.from('0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837');
9
10
  export const AVNU_MIDDLEWARE = ContractAddr.from('0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d');
11
+ export const AVNU_EXCHANGE = ContractAddr.from('0x04270219d365d6b017231b52e92b3fb5d7c8378b05e9abc97724537a80e93b0f');
10
12
 
11
13
  export const VESU_SINGLETON = ContractAddr.from('0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160');
12
14
  export function toBigInt(value: string | number): bigint {
@@ -1,7 +1,7 @@
1
1
  import { ContractAddr, Web3Number } from "@/dataTypes";
2
2
  import { LeafData } from "@/utils";
3
3
  import { Call, hash, num, shortString, uint256 } from "starknet";
4
- import { AVNU_MIDDLEWARE, SIMPLE_SANITIZER, toBigInt } from "./adapter-utils";
4
+ import { AVNU_EXCHANGE, AVNU_MIDDLEWARE, SIMPLE_SANITIZER, toBigInt } from "./adapter-utils";
5
5
  import { AdapterLeafType, BaseAdapter, GenerateCallFn, LeafAdapterFn, ManageCall } from "./baseAdapter";
6
6
  import { SwapInfo } from "@/modules";
7
7
 
@@ -129,11 +129,11 @@ export class CommonAdapter extends BaseAdapter {
129
129
  }
130
130
  }
131
131
 
132
- getAvnuAdapter(fromToken: ContractAddr, toToken: ContractAddr, id: string): () => AdapterLeafType<AvnuSwapCallParams> {
132
+ getAvnuAdapter(fromToken: ContractAddr, toToken: ContractAddr, id: string, isMiddleware: boolean): () => AdapterLeafType<AvnuSwapCallParams> {
133
133
  return () => ({
134
134
  leaf: this.constructSimpleLeafData({
135
135
  id: id,
136
- target: AVNU_MIDDLEWARE,
136
+ target: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
137
137
  method: 'multi_route_swap',
138
138
  packedArguments: [
139
139
  fromToken.toBigInt(),
@@ -141,16 +141,16 @@ export class CommonAdapter extends BaseAdapter {
141
141
  this.config.vaultAllocator.toBigInt(),
142
142
  ]
143
143
  }),
144
- callConstructor: this.getAvnuCall(fromToken, toToken).bind(this)
144
+ callConstructor: this.getAvnuCall(fromToken, toToken, isMiddleware).bind(this)
145
145
  });
146
146
  }
147
147
 
148
- getAvnuCall(fromToken: ContractAddr, toToken: ContractAddr): GenerateCallFn<AvnuSwapCallParams> {
148
+ getAvnuCall(fromToken: ContractAddr, toToken: ContractAddr, isMiddleware: boolean): GenerateCallFn<AvnuSwapCallParams> {
149
149
  return (params: AvnuSwapCallParams): ManageCall => {
150
150
  return {
151
151
  sanitizer: SIMPLE_SANITIZER,
152
152
  call: {
153
- contractAddress: AVNU_MIDDLEWARE,
153
+ contractAddress: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
154
154
  selector: hash.getSelectorFromName('multi_route_swap'),
155
155
  calldata: [
156
156
  fromToken.toBigInt(), // sell_token_address
@@ -1,6 +1,6 @@
1
1
  import { LeafData, logger } from "@/utils"
2
2
  import { CairoCustomEnum, Contract, hash, num, RpcProvider, shortString, uint256, Uint256 } from "starknet";
3
- import { SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, toBigInt, VESU_SINGLETON } from "./adapter-utils";
3
+ import { SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, toBigInt, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER } from "./adapter-utils";
4
4
  import { ContractAddr, Web3Number } from "@/dataTypes";
5
5
  import { AdapterLeafType, BaseAdapter, GenerateCallFn, LeafAdapterFn, ManageCall } from "./baseAdapter";
6
6
  import VesuSingletonAbi from '../../data/vesu-singleton.abi.json';
@@ -239,20 +239,26 @@ export class VesuAdapter extends BaseAdapter {
239
239
 
240
240
  getModifyPosition = (): AdapterLeafType<VesuModifyPositionCallParams> => {
241
241
  const positionData: bigint[] = [0n];
242
- const packedArguments: bigint[] = [
243
- toBigInt(this.config.poolId.toString()), // pool id
242
+ const { addr, isV2 } = getVesuSingletonAddress(this.config.poolId);
243
+ const commonPackedData: bigint[] = [
244
244
  toBigInt(this.config.collateral.address.toString()), // collateral
245
245
  toBigInt(this.config.debt.address.toString()), // debt
246
246
  toBigInt(this.config.vaultAllocator.toString()), // vault allocator
247
+ ];
248
+ const packedArguments: bigint[] = isV2 ? [
249
+ ...commonPackedData
250
+ ] : [
251
+ toBigInt(this.config.poolId.toString()), // pool id
252
+ ...commonPackedData,
247
253
  toBigInt(positionData.length),
248
254
  ...positionData
249
255
  ];
250
256
  const output = this.constructSimpleLeafData({
251
257
  id: this.config.id,
252
- target: getVesuSingletonAddress(this.config.poolId).addr,
258
+ target: addr,
253
259
  method: 'modify_position',
254
260
  packedArguments
255
- });
261
+ }, isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER);
256
262
 
257
263
  return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
258
264
  }
@@ -328,7 +334,7 @@ export class VesuAdapter extends BaseAdapter {
328
334
  }
329
335
  });
330
336
  return {
331
- sanitizer: SIMPLE_SANITIZER,
337
+ sanitizer: isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER,
332
338
  call: {
333
339
  contractAddress: ContractAddr.from(contract.address),
334
340
  selector: hash.getSelectorFromName('modify_position'),
@@ -339,22 +345,24 @@ export class VesuAdapter extends BaseAdapter {
339
345
  }
340
346
  }
341
347
 
342
- getMultiplyAdapter = (): AdapterLeafType<VesuMultiplyCallParams> => {
343
- const packedArguments: bigint[] = [
344
- toBigInt(this.config.poolId.toString()), // pool id
345
- toBigInt(this.config.collateral.address.toString()), // collateral
346
- toBigInt(this.config.debt.address.toString()), // debt
347
- toBigInt(this.config.vaultAllocator.toString()), // vault allocator
348
- ];
349
- const { isV2 } = getVesuSingletonAddress(this.config.poolId);
350
- const output = this.constructSimpleLeafData({
351
- id: this.config.id,
352
- target: isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1,
353
- method: 'modify_lever',
354
- packedArguments
355
- }, SIMPLE_SANITIZER_V2);
348
+ getMultiplyAdapter = (id: string): LeafAdapterFn<VesuMultiplyCallParams> => {
349
+ return () => {
350
+ const packedArguments: bigint[] = [
351
+ toBigInt(this.config.poolId.toString()), // pool id
352
+ toBigInt(this.config.collateral.address.toString()), // collateral
353
+ toBigInt(this.config.debt.address.toString()), // debt
354
+ toBigInt(this.config.vaultAllocator.toString()), // vault allocator
355
+ ];
356
+ const { isV2 } = getVesuSingletonAddress(this.config.poolId);
357
+ const output = this.constructSimpleLeafData({
358
+ id: id,
359
+ target: isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1,
360
+ method: 'modify_lever',
361
+ packedArguments
362
+ }, SIMPLE_SANITIZER_V2);
356
363
 
357
- return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
364
+ return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
365
+ }
358
366
  }
359
367
 
360
368
  getMultiplyCall = (params: VesuMultiplyCallParams): ManageCall => {