@strkfarm/sdk 1.1.8 → 1.1.9

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.
@@ -20191,7 +20191,7 @@ ${r2}}` : "}", l2;
20191
20191
  toHexString: () => toHexString2,
20192
20192
  toStorageKey: () => toStorageKey2
20193
20193
  });
20194
- var import_utils57 = require_utils2();
20194
+ var import_utils58 = require_utils2();
20195
20195
  function isHex3(hex) {
20196
20196
  return /^0x[0-9a-f]*$/i.test(hex);
20197
20197
  }
@@ -20264,7 +20264,7 @@ ${r2}}` : "}", l2;
20264
20264
  if (adaptedValue.length % 2 !== 0) {
20265
20265
  adaptedValue = `0${adaptedValue}`;
20266
20266
  }
20267
- return (0, import_utils57.hexToBytes)(adaptedValue);
20267
+ return (0, import_utils58.hexToBytes)(adaptedValue);
20268
20268
  }
20269
20269
  function addPercent2(number2, percent) {
20270
20270
  const bigIntNum = BigInt(number2);
@@ -20283,14 +20283,14 @@ ${r2}}` : "}", l2;
20283
20283
  keccakBn: () => keccakBn2,
20284
20284
  starknetKeccak: () => starknetKeccak2
20285
20285
  });
20286
- var import_starknet23 = require_lib3();
20286
+ var import_starknet24 = require_lib3();
20287
20287
  function keccakBn2(value) {
20288
20288
  const hexWithoutPrefix = removeHexPrefix2(toHex3(BigInt(value)));
20289
20289
  const evenHex = hexWithoutPrefix.length % 2 === 0 ? hexWithoutPrefix : `0${hexWithoutPrefix}`;
20290
- return addHexPrefix2((0, import_starknet23.keccak)(hexToBytes4(addHexPrefix2(evenHex))).toString(16));
20290
+ return addHexPrefix2((0, import_starknet24.keccak)(hexToBytes4(addHexPrefix2(evenHex))).toString(16));
20291
20291
  }
20292
20292
  function keccakHex2(str) {
20293
- return addHexPrefix2((0, import_starknet23.keccak)(utf8ToArray2(str)).toString(16));
20293
+ return addHexPrefix2((0, import_starknet24.keccak)(utf8ToArray2(str)).toString(16));
20294
20294
  }
20295
20295
  function starknetKeccak2(str) {
20296
20296
  const hash2 = BigInt(keccakHex2(str));
@@ -22302,7 +22302,7 @@ ${r2}}` : "}", l2;
22302
22302
  hashDAMode: () => hashDAMode2,
22303
22303
  hashFeeField: () => hashFeeField
22304
22304
  });
22305
- var import_starknet24 = require_lib3();
22305
+ var import_starknet25 = require_lib3();
22306
22306
  var AToBI2 = (array) => array.map((it) => BigInt(it));
22307
22307
  var DATA_AVAILABILITY_MODE_BITS2 = 32n;
22308
22308
  var MAX_AMOUNT_BITS2 = 64n;
@@ -22316,7 +22316,7 @@ ${r2}}` : "}", l2;
22316
22316
  function hashFeeField(tip, bounds) {
22317
22317
  const L1Bound = (L1_GAS_NAME2 << RESOURCE_VALUE_OFFSET2) + (BigInt(bounds.l1_gas.max_amount) << MAX_PRICE_PER_UNIT_BITS2) + BigInt(bounds.l1_gas.max_price_per_unit);
22318
22318
  const L2Bound = (L2_GAS_NAME2 << RESOURCE_VALUE_OFFSET2) + (BigInt(bounds.l2_gas.max_amount) << MAX_PRICE_PER_UNIT_BITS2) + BigInt(bounds.l2_gas.max_price_per_unit);
22319
- return (0, import_starknet24.poseidonHashMany)([BigInt(tip), L1Bound, L2Bound]);
22319
+ return (0, import_starknet25.poseidonHashMany)([BigInt(tip), L1Bound, L2Bound]);
22320
22320
  }
22321
22321
  function calculateTransactionHashCommon22(txHashPrefix, version4, senderAddress, chainId, nonce, tip, paymasterData, nonceDataAvailabilityMode, feeDataAvailabilityMode, resourceBounds, additionalData = []) {
22322
22322
  const feeFieldHash = hashFeeField(tip, resourceBounds);
@@ -22326,13 +22326,13 @@ ${r2}}` : "}", l2;
22326
22326
  version4,
22327
22327
  senderAddress,
22328
22328
  feeFieldHash,
22329
- (0, import_starknet24.poseidonHashMany)(AToBI2(paymasterData)),
22329
+ (0, import_starknet25.poseidonHashMany)(AToBI2(paymasterData)),
22330
22330
  chainId,
22331
22331
  nonce,
22332
22332
  dAModeHash,
22333
22333
  ...AToBI2(additionalData)
22334
22334
  ]);
22335
- return toHex3((0, import_starknet24.poseidonHashMany)(dataToHash));
22335
+ return toHex3((0, import_starknet25.poseidonHashMany)(dataToHash));
22336
22336
  }
22337
22337
  function calculateDeployAccountTransactionHash22(contractAddress, classHash, compiledConstructorCalldata, salt, version4, chainId, nonce, nonceDataAvailabilityMode, feeDataAvailabilityMode, resourceBounds, tip, paymasterData) {
22338
22338
  return calculateTransactionHashCommon22(
@@ -22346,7 +22346,7 @@ ${r2}}` : "}", l2;
22346
22346
  nonceDataAvailabilityMode,
22347
22347
  feeDataAvailabilityMode,
22348
22348
  resourceBounds,
22349
- [(0, import_starknet24.poseidonHashMany)(AToBI2(compiledConstructorCalldata)), classHash, salt]
22349
+ [(0, import_starknet25.poseidonHashMany)(AToBI2(compiledConstructorCalldata)), classHash, salt]
22350
22350
  );
22351
22351
  }
22352
22352
  function calculateDeclareTransactionHash22(classHash, compiledClassHash, senderAddress, version4, chainId, nonce, accountDeploymentData, nonceDataAvailabilityMode, feeDataAvailabilityMode, resourceBounds, tip, paymasterData) {
@@ -22361,7 +22361,7 @@ ${r2}}` : "}", l2;
22361
22361
  nonceDataAvailabilityMode,
22362
22362
  feeDataAvailabilityMode,
22363
22363
  resourceBounds,
22364
- [(0, import_starknet24.poseidonHashMany)(AToBI2(accountDeploymentData)), classHash, compiledClassHash]
22364
+ [(0, import_starknet25.poseidonHashMany)(AToBI2(accountDeploymentData)), classHash, compiledClassHash]
22365
22365
  );
22366
22366
  }
22367
22367
  function calculateInvokeTransactionHash3(senderAddress, version4, compiledCalldata, chainId, nonce, accountDeploymentData, nonceDataAvailabilityMode, feeDataAvailabilityMode, resourceBounds, tip, paymasterData) {
@@ -22376,7 +22376,7 @@ ${r2}}` : "}", l2;
22376
22376
  nonceDataAvailabilityMode,
22377
22377
  feeDataAvailabilityMode,
22378
22378
  resourceBounds,
22379
- [(0, import_starknet24.poseidonHashMany)(AToBI2(accountDeploymentData)), (0, import_starknet24.poseidonHashMany)(AToBI2(compiledCalldata))]
22379
+ [(0, import_starknet25.poseidonHashMany)(AToBI2(accountDeploymentData)), (0, import_starknet25.poseidonHashMany)(AToBI2(compiledCalldata))]
22380
22380
  );
22381
22381
  }
22382
22382
  function isV3InvokeTx2(args) {
@@ -28650,9 +28650,11 @@ ${r2}}` : "}", l2;
28650
28650
  ERC20: () => ERC20,
28651
28651
  EkuboCLVault: () => EkuboCLVault,
28652
28652
  EkuboCLVaultStrategies: () => EkuboCLVaultStrategies,
28653
+ EkuboQuoter: () => EkuboQuoter,
28653
28654
  FatalError: () => FatalError,
28654
28655
  FlowChartColors: () => FlowChartColors,
28655
28656
  Global: () => Global,
28657
+ HyperLSTStrategies: () => HyperLSTStrategies,
28656
28658
  ILending: () => ILending,
28657
28659
  Initializable: () => Initializable,
28658
28660
  MarginType: () => MarginType,
@@ -28666,6 +28668,7 @@ ${r2}}` : "}", l2;
28666
28668
  SenseiVault: () => SenseiVault,
28667
28669
  UNIVERSAL_ADAPTERS: () => UNIVERSAL_ADAPTERS,
28668
28670
  UNIVERSAL_MANAGE_IDS: () => UNIVERSAL_MANAGE_IDS,
28671
+ UniversalLstMultiplierStrategy: () => UniversalLstMultiplierStrategy,
28669
28672
  UniversalStrategies: () => UniversalStrategies,
28670
28673
  UniversalStrategy: () => UniversalStrategy,
28671
28674
  VesuAdapter: () => VesuAdapter,
@@ -28676,6 +28679,7 @@ ${r2}}` : "}", l2;
28676
28679
  VesuRebalanceStrategies: () => VesuRebalanceStrategies,
28677
28680
  Web3Number: () => Web3Number,
28678
28681
  ZkLend: () => ZkLend,
28682
+ getContractDetails: () => getContractDetails,
28679
28683
  getMainnetConfig: () => getMainnetConfig,
28680
28684
  getNoRiskTags: () => getNoRiskTags,
28681
28685
  getRiskColor: () => getRiskColor,
@@ -31264,6 +31268,17 @@ ${r2}}` : "}", l2;
31264
31268
  const answer = _value.greaterThanOrEqualTo(_valueMe) ? _value : _valueMe;
31265
31269
  return this.construct(answer.toString(), this.decimals);
31266
31270
  }
31271
+ abs() {
31272
+ console.warn(`abs: this: ${this}`);
31273
+ return this.construct(Math.abs(this.toNumber()).toFixed(12), this.decimals);
31274
+ }
31275
+ toI129() {
31276
+ const sign2 = this.isNegative() ? 1 : 0;
31277
+ return {
31278
+ mag: BigInt(this.toWei()) * (this.isNegative() ? -1n : 1n),
31279
+ sign: sign2
31280
+ };
31281
+ }
31267
31282
  };
31268
31283
  import_bignumber.default.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: import_bignumber.default.ROUND_DOWN });
31269
31284
  _Web3Number.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: import_bignumber.default.ROUND_DOWN });
@@ -53738,6 +53753,60 @@ ${JSON.stringify(data, null, 2)}`;
53738
53753
  }
53739
53754
  };
53740
53755
 
53756
+ // src/modules/ekubo-quoter.ts
53757
+ var EkuboQuoter = class {
53758
+ // e.g. ETH/USDC'
53759
+ constructor(config3) {
53760
+ this.config = config3;
53761
+ this.ENDPOINT = "https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_FROM_ADDRESS}}/{{TOKEN_TO_ADDRESS}}";
53762
+ }
53763
+ /**
53764
+ *
53765
+ * @param fromToken
53766
+ * @param toToken
53767
+ * @param amount Can be negative too, which would mean to get exact amount out
53768
+ * @returns
53769
+ */
53770
+ async getQuote(fromToken, toToken, amount) {
53771
+ let _fromToken = amount.gt(0) ? fromToken : toToken;
53772
+ let _toToken = amount.gt(0) ? toToken : fromToken;
53773
+ const quote = await axios_default.get(this.ENDPOINT.replace("{{AMOUNT}}", amount.toWei()).replace("{{TOKEN_FROM_ADDRESS}}", _fromToken).replace("{{TOKEN_TO_ADDRESS}}", _toToken));
53774
+ console.log(`Ekubo quote from ${_fromToken} to ${_toToken} for ${amount.toString()}: ${JSON.stringify(quote.data)}`);
53775
+ return quote.data;
53776
+ }
53777
+ /**
53778
+ * Formats Ekubo response for Vesu multiple use
53779
+ * @param quote
53780
+ * @param fromTokenInfo
53781
+ * @returns
53782
+ */
53783
+ getVesuMultiplyQuote(quote, fromTokenInfo, toTokenInfo) {
53784
+ return quote.splits.map((split2) => {
53785
+ const isNegativeAmount = BigInt(split2.amount_specified) < 0n;
53786
+ const token = isNegativeAmount ? toTokenInfo : fromTokenInfo;
53787
+ return {
53788
+ route: split2.route.map((_route) => ({
53789
+ pool_key: {
53790
+ token0: ContractAddr.from(_route.pool_key.token0),
53791
+ token1: ContractAddr.from(_route.pool_key.token1),
53792
+ fee: _route.pool_key.fee,
53793
+ tick_spacing: _route.pool_key.tick_spacing.toString(),
53794
+ extension: _route.pool_key.extension
53795
+ },
53796
+ sqrt_ratio_limit: Web3Number.fromWei(_route.sqrt_ratio_limit, 18),
53797
+ // just for use, any decimal works
53798
+ skip_ahead: Web3Number.fromWei(_route.skip_ahead, 0)
53799
+ // no decimal for this
53800
+ })),
53801
+ token_amount: {
53802
+ token: token.address,
53803
+ amount: Web3Number.fromWei(split2.amount_specified, token.decimals)
53804
+ }
53805
+ };
53806
+ });
53807
+ }
53808
+ };
53809
+
53741
53810
  // src/interfaces/common.tsx
53742
53811
  var import_jsx_runtime = __toESM(require_jsx_runtime());
53743
53812
  var RiskType = /* @__PURE__ */ ((RiskType2) => {
@@ -67867,20 +67936,27 @@ ${JSON.stringify(data, null, 2)}`;
67867
67936
  name: "Ekubo",
67868
67937
  logo: "https://app.ekubo.org/favicon.ico"
67869
67938
  };
67870
- var _corelatedPoolRiskFactors = [
67939
+ var _lstPoolRiskFactors = [
67871
67940
  { type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
67872
67941
  { type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 1 /* HIGHLY_CORRELATED */, weight: 33, reason: "Low risk due to co-related assets" },
67873
- { type: "Market Risk" /* MARKET_RISK */, value: 1 /* VERY_LOW_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" }
67942
+ { type: "Market Risk" /* MARKET_RISK */, value: 1 /* VERY_LOW_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" },
67943
+ { type: "Depeg Risk" /* DEPEG_RISK */, value: 2 /* GENERALLY_STABLE */, weight: 33, reason: "Generally stable pegged assets" }
67944
+ ];
67945
+ var _stableCoinPoolRiskFactors = [
67946
+ { type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 1 /* BATTLE_TESTED */, weight: 34, reason: "Audited smart contracts" },
67947
+ { type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 1 /* HIGHLY_CORRELATED */, weight: 33, reason: "Low risk due to co-related assets" },
67948
+ { type: "Market Risk" /* MARKET_RISK */, value: 1 /* VERY_LOW_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" },
67949
+ { type: "Depeg Risk" /* DEPEG_RISK */, value: 1 /* HIGHLY_STABLE */, weight: 33, reason: "Highly stable assets" }
67874
67950
  ];
67875
67951
  var mediumVolatilityPoolRiskFactors = [
67876
67952
  { type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
67877
- { type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "Low risk due to co-related assets" },
67878
- { type: "Market Risk" /* MARKET_RISK */, value: 3 /* MODERATE_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" }
67953
+ { type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "Assets are not correlated, often volatile" },
67954
+ { type: "Market Risk" /* MARKET_RISK */, value: 3 /* MODERATE_VOLATILITY */, weight: 33, reason: "Assets are not correlated, relative volatile can be moderate sometimes" }
67879
67955
  ];
67880
67956
  var highVolatilityPoolRiskFactors = [
67881
67957
  { type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
67882
- { type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "Low risk due to co-related assets" },
67883
- { type: "Market Risk" /* MARKET_RISK */, value: 4 /* HIGH_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" }
67958
+ { type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "Assets are not correlated, often volatile" },
67959
+ { type: "Market Risk" /* MARKET_RISK */, value: 4 /* HIGH_VOLATILITY */, weight: 33, reason: "Assets are not correlated, relative volatile is often high" }
67884
67960
  ];
67885
67961
  var mediumRisk = {
67886
67962
  riskFactor: mediumVolatilityPoolRiskFactors,
@@ -67953,9 +68029,9 @@ ${JSON.stringify(data, null, 2)}`;
67953
68029
  auditUrl: AUDIT_URL2,
67954
68030
  maxTVL: Web3Number.fromWei("0", 18),
67955
68031
  risk: {
67956
- riskFactor: _corelatedPoolRiskFactors,
67957
- netRisk: _corelatedPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _corelatedPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
67958
- notARisks: getNoRiskTags(_corelatedPoolRiskFactors)
68032
+ riskFactor: _lstPoolRiskFactors,
68033
+ netRisk: _lstPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _lstPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
68034
+ notARisks: getNoRiskTags(_lstPoolRiskFactors)
67959
68035
  },
67960
68036
  apyMethodology: "APY based on 30-day historical performance, including fees and rewards.",
67961
68037
  additionalInfo: {
@@ -68110,7 +68186,11 @@ ${JSON.stringify(data, null, 2)}`;
68110
68186
  Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
68111
68187
  Global.getDefaultTokens().find((t) => t.symbol === "USDT")
68112
68188
  ],
68113
- risk: xSTRKSTRK.risk
68189
+ risk: {
68190
+ riskFactor: _stableCoinPoolRiskFactors,
68191
+ netRisk: _stableCoinPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _stableCoinPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
68192
+ notARisks: getNoRiskTags(_stableCoinPoolRiskFactors)
68193
+ }
68114
68194
  },
68115
68195
  {
68116
68196
  ...ETHUSDCRe7Strategy,
@@ -70288,6 +70368,7 @@ ${JSON.stringify(data, null, 2)}`;
70288
70368
 
70289
70369
  // src/strategies/universal-adapters/adapter-utils.ts
70290
70370
  var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
70371
+ var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a");
70291
70372
  var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
70292
70373
  var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
70293
70374
  function toBigInt3(value) {
@@ -70302,13 +70383,13 @@ ${JSON.stringify(data, null, 2)}`;
70302
70383
 
70303
70384
  // src/strategies/universal-adapters/baseAdapter.ts
70304
70385
  var BaseAdapter = class extends CacheClass {
70305
- constructSimpleLeafData(params) {
70386
+ constructSimpleLeafData(params, sanitizer = SIMPLE_SANITIZER) {
70306
70387
  const { id, target, method, packedArguments } = params;
70307
70388
  return {
70308
70389
  id: BigInt(num_exports.getDecimalString(shortString_exports.encodeShortString(id))),
70309
70390
  readableId: id,
70310
70391
  data: [
70311
- SIMPLE_SANITIZER.toBigInt(),
70392
+ sanitizer.toBigInt(),
70312
70393
  // sanitizer address
70313
70394
  target.toBigInt(),
70314
70395
  // contract
@@ -72743,6 +72824,483 @@ ${JSON.stringify(data, null, 2)}`;
72743
72824
  }
72744
72825
  ];
72745
72826
 
72827
+ // src/data/vesu-multiple.abi.json
72828
+ var vesu_multiple_abi_default = [
72829
+ {
72830
+ type: "impl",
72831
+ name: "LockerImpl",
72832
+ interface_name: "ekubo::interfaces::core::ILocker"
72833
+ },
72834
+ {
72835
+ type: "struct",
72836
+ name: "core::array::Span::<core::felt252>",
72837
+ members: [
72838
+ {
72839
+ name: "snapshot",
72840
+ type: "@core::array::Array::<core::felt252>"
72841
+ }
72842
+ ]
72843
+ },
72844
+ {
72845
+ type: "interface",
72846
+ name: "ekubo::interfaces::core::ILocker",
72847
+ items: [
72848
+ {
72849
+ type: "function",
72850
+ name: "locked",
72851
+ inputs: [
72852
+ {
72853
+ name: "id",
72854
+ type: "core::integer::u32"
72855
+ },
72856
+ {
72857
+ name: "data",
72858
+ type: "core::array::Span::<core::felt252>"
72859
+ }
72860
+ ],
72861
+ outputs: [
72862
+ {
72863
+ type: "core::array::Span::<core::felt252>"
72864
+ }
72865
+ ],
72866
+ state_mutability: "external"
72867
+ }
72868
+ ]
72869
+ },
72870
+ {
72871
+ type: "impl",
72872
+ name: "MultiplyImpl",
72873
+ interface_name: "vesu_periphery::multiply::IMultiply"
72874
+ },
72875
+ {
72876
+ type: "struct",
72877
+ name: "ekubo::types::keys::PoolKey",
72878
+ members: [
72879
+ {
72880
+ name: "token0",
72881
+ type: "core::starknet::contract_address::ContractAddress"
72882
+ },
72883
+ {
72884
+ name: "token1",
72885
+ type: "core::starknet::contract_address::ContractAddress"
72886
+ },
72887
+ {
72888
+ name: "fee",
72889
+ type: "core::integer::u128"
72890
+ },
72891
+ {
72892
+ name: "tick_spacing",
72893
+ type: "core::integer::u128"
72894
+ },
72895
+ {
72896
+ name: "extension",
72897
+ type: "core::starknet::contract_address::ContractAddress"
72898
+ }
72899
+ ]
72900
+ },
72901
+ {
72902
+ type: "struct",
72903
+ name: "core::integer::u256",
72904
+ members: [
72905
+ {
72906
+ name: "low",
72907
+ type: "core::integer::u128"
72908
+ },
72909
+ {
72910
+ name: "high",
72911
+ type: "core::integer::u128"
72912
+ }
72913
+ ]
72914
+ },
72915
+ {
72916
+ type: "struct",
72917
+ name: "vesu_periphery::swap::RouteNode",
72918
+ members: [
72919
+ {
72920
+ name: "pool_key",
72921
+ type: "ekubo::types::keys::PoolKey"
72922
+ },
72923
+ {
72924
+ name: "sqrt_ratio_limit",
72925
+ type: "core::integer::u256"
72926
+ },
72927
+ {
72928
+ name: "skip_ahead",
72929
+ type: "core::integer::u128"
72930
+ }
72931
+ ]
72932
+ },
72933
+ {
72934
+ type: "enum",
72935
+ name: "core::bool",
72936
+ variants: [
72937
+ {
72938
+ name: "False",
72939
+ type: "()"
72940
+ },
72941
+ {
72942
+ name: "True",
72943
+ type: "()"
72944
+ }
72945
+ ]
72946
+ },
72947
+ {
72948
+ type: "struct",
72949
+ name: "ekubo::types::i129::i129",
72950
+ members: [
72951
+ {
72952
+ name: "mag",
72953
+ type: "core::integer::u128"
72954
+ },
72955
+ {
72956
+ name: "sign",
72957
+ type: "core::bool"
72958
+ }
72959
+ ]
72960
+ },
72961
+ {
72962
+ type: "struct",
72963
+ name: "vesu_periphery::swap::TokenAmount",
72964
+ members: [
72965
+ {
72966
+ name: "token",
72967
+ type: "core::starknet::contract_address::ContractAddress"
72968
+ },
72969
+ {
72970
+ name: "amount",
72971
+ type: "ekubo::types::i129::i129"
72972
+ }
72973
+ ]
72974
+ },
72975
+ {
72976
+ type: "struct",
72977
+ name: "vesu_periphery::swap::Swap",
72978
+ members: [
72979
+ {
72980
+ name: "route",
72981
+ type: "core::array::Array::<vesu_periphery::swap::RouteNode>"
72982
+ },
72983
+ {
72984
+ name: "token_amount",
72985
+ type: "vesu_periphery::swap::TokenAmount"
72986
+ }
72987
+ ]
72988
+ },
72989
+ {
72990
+ type: "struct",
72991
+ name: "vesu_periphery::multiply::IncreaseLeverParams",
72992
+ members: [
72993
+ {
72994
+ name: "pool_id",
72995
+ type: "core::felt252"
72996
+ },
72997
+ {
72998
+ name: "collateral_asset",
72999
+ type: "core::starknet::contract_address::ContractAddress"
73000
+ },
73001
+ {
73002
+ name: "debt_asset",
73003
+ type: "core::starknet::contract_address::ContractAddress"
73004
+ },
73005
+ {
73006
+ name: "user",
73007
+ type: "core::starknet::contract_address::ContractAddress"
73008
+ },
73009
+ {
73010
+ name: "add_margin",
73011
+ type: "core::integer::u128"
73012
+ },
73013
+ {
73014
+ name: "margin_swap",
73015
+ type: "core::array::Array::<vesu_periphery::swap::Swap>"
73016
+ },
73017
+ {
73018
+ name: "margin_swap_limit_amount",
73019
+ type: "core::integer::u128"
73020
+ },
73021
+ {
73022
+ name: "lever_swap",
73023
+ type: "core::array::Array::<vesu_periphery::swap::Swap>"
73024
+ },
73025
+ {
73026
+ name: "lever_swap_limit_amount",
73027
+ type: "core::integer::u128"
73028
+ }
73029
+ ]
73030
+ },
73031
+ {
73032
+ type: "struct",
73033
+ name: "vesu_periphery::multiply::DecreaseLeverParams",
73034
+ members: [
73035
+ {
73036
+ name: "pool_id",
73037
+ type: "core::felt252"
73038
+ },
73039
+ {
73040
+ name: "collateral_asset",
73041
+ type: "core::starknet::contract_address::ContractAddress"
73042
+ },
73043
+ {
73044
+ name: "debt_asset",
73045
+ type: "core::starknet::contract_address::ContractAddress"
73046
+ },
73047
+ {
73048
+ name: "user",
73049
+ type: "core::starknet::contract_address::ContractAddress"
73050
+ },
73051
+ {
73052
+ name: "sub_margin",
73053
+ type: "core::integer::u128"
73054
+ },
73055
+ {
73056
+ name: "recipient",
73057
+ type: "core::starknet::contract_address::ContractAddress"
73058
+ },
73059
+ {
73060
+ name: "lever_swap",
73061
+ type: "core::array::Array::<vesu_periphery::swap::Swap>"
73062
+ },
73063
+ {
73064
+ name: "lever_swap_limit_amount",
73065
+ type: "core::integer::u128"
73066
+ },
73067
+ {
73068
+ name: "lever_swap_weights",
73069
+ type: "core::array::Array::<core::integer::u128>"
73070
+ },
73071
+ {
73072
+ name: "withdraw_swap",
73073
+ type: "core::array::Array::<vesu_periphery::swap::Swap>"
73074
+ },
73075
+ {
73076
+ name: "withdraw_swap_limit_amount",
73077
+ type: "core::integer::u128"
73078
+ },
73079
+ {
73080
+ name: "withdraw_swap_weights",
73081
+ type: "core::array::Array::<core::integer::u128>"
73082
+ },
73083
+ {
73084
+ name: "close_position",
73085
+ type: "core::bool"
73086
+ }
73087
+ ]
73088
+ },
73089
+ {
73090
+ type: "enum",
73091
+ name: "vesu_periphery::multiply::ModifyLeverAction",
73092
+ variants: [
73093
+ {
73094
+ name: "IncreaseLever",
73095
+ type: "vesu_periphery::multiply::IncreaseLeverParams"
73096
+ },
73097
+ {
73098
+ name: "DecreaseLever",
73099
+ type: "vesu_periphery::multiply::DecreaseLeverParams"
73100
+ }
73101
+ ]
73102
+ },
73103
+ {
73104
+ type: "struct",
73105
+ name: "vesu_periphery::multiply::ModifyLeverParams",
73106
+ members: [
73107
+ {
73108
+ name: "action",
73109
+ type: "vesu_periphery::multiply::ModifyLeverAction"
73110
+ }
73111
+ ]
73112
+ },
73113
+ {
73114
+ type: "struct",
73115
+ name: "alexandria_math::i257::i257",
73116
+ members: [
73117
+ {
73118
+ name: "abs",
73119
+ type: "core::integer::u256"
73120
+ },
73121
+ {
73122
+ name: "is_negative",
73123
+ type: "core::bool"
73124
+ }
73125
+ ]
73126
+ },
73127
+ {
73128
+ type: "struct",
73129
+ name: "vesu_periphery::multiply::ModifyLeverResponse",
73130
+ members: [
73131
+ {
73132
+ name: "collateral_delta",
73133
+ type: "alexandria_math::i257::i257"
73134
+ },
73135
+ {
73136
+ name: "debt_delta",
73137
+ type: "alexandria_math::i257::i257"
73138
+ },
73139
+ {
73140
+ name: "margin_delta",
73141
+ type: "alexandria_math::i257::i257"
73142
+ }
73143
+ ]
73144
+ },
73145
+ {
73146
+ type: "interface",
73147
+ name: "vesu_periphery::multiply::IMultiply",
73148
+ items: [
73149
+ {
73150
+ type: "function",
73151
+ name: "modify_lever",
73152
+ inputs: [
73153
+ {
73154
+ name: "modify_lever_params",
73155
+ type: "vesu_periphery::multiply::ModifyLeverParams"
73156
+ }
73157
+ ],
73158
+ outputs: [
73159
+ {
73160
+ type: "vesu_periphery::multiply::ModifyLeverResponse"
73161
+ }
73162
+ ],
73163
+ state_mutability: "external"
73164
+ }
73165
+ ]
73166
+ },
73167
+ {
73168
+ type: "struct",
73169
+ name: "ekubo::interfaces::core::ICoreDispatcher",
73170
+ members: [
73171
+ {
73172
+ name: "contract_address",
73173
+ type: "core::starknet::contract_address::ContractAddress"
73174
+ }
73175
+ ]
73176
+ },
73177
+ {
73178
+ type: "struct",
73179
+ name: "vesu::singleton::ISingletonDispatcher",
73180
+ members: [
73181
+ {
73182
+ name: "contract_address",
73183
+ type: "core::starknet::contract_address::ContractAddress"
73184
+ }
73185
+ ]
73186
+ },
73187
+ {
73188
+ type: "constructor",
73189
+ name: "constructor",
73190
+ inputs: [
73191
+ {
73192
+ name: "core",
73193
+ type: "ekubo::interfaces::core::ICoreDispatcher"
73194
+ },
73195
+ {
73196
+ name: "singleton",
73197
+ type: "vesu::singleton::ISingletonDispatcher"
73198
+ }
73199
+ ]
73200
+ },
73201
+ {
73202
+ type: "event",
73203
+ name: "vesu_periphery::multiply::Multiply::IncreaseLever",
73204
+ kind: "struct",
73205
+ members: [
73206
+ {
73207
+ name: "pool_id",
73208
+ type: "core::felt252",
73209
+ kind: "key"
73210
+ },
73211
+ {
73212
+ name: "collateral_asset",
73213
+ type: "core::starknet::contract_address::ContractAddress",
73214
+ kind: "key"
73215
+ },
73216
+ {
73217
+ name: "debt_asset",
73218
+ type: "core::starknet::contract_address::ContractAddress",
73219
+ kind: "key"
73220
+ },
73221
+ {
73222
+ name: "user",
73223
+ type: "core::starknet::contract_address::ContractAddress",
73224
+ kind: "key"
73225
+ },
73226
+ {
73227
+ name: "margin",
73228
+ type: "core::integer::u256",
73229
+ kind: "data"
73230
+ },
73231
+ {
73232
+ name: "collateral_delta",
73233
+ type: "core::integer::u256",
73234
+ kind: "data"
73235
+ },
73236
+ {
73237
+ name: "debt_delta",
73238
+ type: "core::integer::u256",
73239
+ kind: "data"
73240
+ }
73241
+ ]
73242
+ },
73243
+ {
73244
+ type: "event",
73245
+ name: "vesu_periphery::multiply::Multiply::DecreaseLever",
73246
+ kind: "struct",
73247
+ members: [
73248
+ {
73249
+ name: "pool_id",
73250
+ type: "core::felt252",
73251
+ kind: "key"
73252
+ },
73253
+ {
73254
+ name: "collateral_asset",
73255
+ type: "core::starknet::contract_address::ContractAddress",
73256
+ kind: "key"
73257
+ },
73258
+ {
73259
+ name: "debt_asset",
73260
+ type: "core::starknet::contract_address::ContractAddress",
73261
+ kind: "key"
73262
+ },
73263
+ {
73264
+ name: "user",
73265
+ type: "core::starknet::contract_address::ContractAddress",
73266
+ kind: "key"
73267
+ },
73268
+ {
73269
+ name: "margin",
73270
+ type: "core::integer::u256",
73271
+ kind: "data"
73272
+ },
73273
+ {
73274
+ name: "collateral_delta",
73275
+ type: "core::integer::u256",
73276
+ kind: "data"
73277
+ },
73278
+ {
73279
+ name: "debt_delta",
73280
+ type: "core::integer::u256",
73281
+ kind: "data"
73282
+ }
73283
+ ]
73284
+ },
73285
+ {
73286
+ type: "event",
73287
+ name: "vesu_periphery::multiply::Multiply::Event",
73288
+ kind: "enum",
73289
+ variants: [
73290
+ {
73291
+ name: "IncreaseLever",
73292
+ type: "vesu_periphery::multiply::Multiply::IncreaseLever",
73293
+ kind: "nested"
73294
+ },
73295
+ {
73296
+ name: "DecreaseLever",
73297
+ type: "vesu_periphery::multiply::Multiply::DecreaseLever",
73298
+ kind: "nested"
73299
+ }
73300
+ ]
73301
+ }
73302
+ ];
73303
+
72746
73304
  // src/strategies/universal-adapters/vesu-adapter.ts
72747
73305
  var VesuAmountType = /* @__PURE__ */ ((VesuAmountType2) => {
72748
73306
  VesuAmountType2[VesuAmountType2["Delta"] = 0] = "Delta";
@@ -72754,13 +73312,115 @@ ${JSON.stringify(data, null, 2)}`;
72754
73312
  VesuAmountDenomination2[VesuAmountDenomination2["Assets"] = 1] = "Assets";
72755
73313
  return VesuAmountDenomination2;
72756
73314
  })(VesuAmountDenomination || {});
73315
+ function getVesuMultiplyParams(isIncrease, params) {
73316
+ if (isIncrease) {
73317
+ const _params2 = params;
73318
+ return {
73319
+ action: new CairoCustomEnum({ IncreaseLever: {
73320
+ pool_id: _params2.pool_id.toBigInt(),
73321
+ collateral_asset: _params2.collateral_asset.toBigInt(),
73322
+ debt_asset: _params2.debt_asset.toBigInt(),
73323
+ user: _params2.user.toBigInt(),
73324
+ add_margin: BigInt(_params2.add_margin.toWei()),
73325
+ margin_swap: _params2.margin_swap.map((swap) => ({
73326
+ route: swap.route.map((route) => ({
73327
+ pool_key: {
73328
+ token0: route.pool_key.token0.toBigInt(),
73329
+ token1: route.pool_key.token1.toBigInt(),
73330
+ fee: route.pool_key.fee,
73331
+ tick_spacing: route.pool_key.tick_spacing,
73332
+ extension: BigInt(num_exports.hexToDecimalString(route.pool_key.extension))
73333
+ },
73334
+ sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
73335
+ skip_ahead: BigInt(100)
73336
+ })),
73337
+ token_amount: {
73338
+ token: swap.token_amount.token.toBigInt(),
73339
+ amount: swap.token_amount.amount.toI129()
73340
+ }
73341
+ })),
73342
+ margin_swap_limit_amount: BigInt(_params2.margin_swap_limit_amount.toWei()),
73343
+ lever_swap: _params2.lever_swap.map((swap) => ({
73344
+ route: swap.route.map((route) => ({
73345
+ pool_key: {
73346
+ token0: route.pool_key.token0.toBigInt(),
73347
+ token1: route.pool_key.token1.toBigInt(),
73348
+ fee: route.pool_key.fee,
73349
+ tick_spacing: route.pool_key.tick_spacing,
73350
+ extension: BigInt(num_exports.hexToDecimalString(route.pool_key.extension))
73351
+ },
73352
+ sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
73353
+ skip_ahead: BigInt(100)
73354
+ })),
73355
+ token_amount: {
73356
+ token: swap.token_amount.token.toBigInt(),
73357
+ amount: swap.token_amount.amount.toI129()
73358
+ }
73359
+ })),
73360
+ lever_swap_limit_amount: BigInt(_params2.lever_swap_limit_amount.toWei())
73361
+ } })
73362
+ };
73363
+ }
73364
+ const _params = params;
73365
+ return {
73366
+ action: new CairoCustomEnum({ DecreaseLever: {
73367
+ pool_id: _params.pool_id.toBigInt(),
73368
+ collateral_asset: _params.collateral_asset.toBigInt(),
73369
+ debt_asset: _params.debt_asset.toBigInt(),
73370
+ user: _params.user.toBigInt(),
73371
+ sub_margin: BigInt(_params.sub_margin.toWei()),
73372
+ recipient: _params.recipient.toBigInt(),
73373
+ lever_swap: _params.lever_swap.map((swap) => ({
73374
+ route: swap.route.map((route) => ({
73375
+ pool_key: {
73376
+ token0: route.pool_key.token0.toBigInt(),
73377
+ token1: route.pool_key.token1.toBigInt(),
73378
+ fee: route.pool_key.fee,
73379
+ tick_spacing: route.pool_key.tick_spacing,
73380
+ extension: ContractAddr.from(route.pool_key.extension).toBigInt()
73381
+ },
73382
+ sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
73383
+ skip_ahead: BigInt(route.skip_ahead.toWei())
73384
+ })),
73385
+ token_amount: {
73386
+ token: swap.token_amount.token.toBigInt(),
73387
+ amount: swap.token_amount.amount.toI129()
73388
+ }
73389
+ })),
73390
+ lever_swap_limit_amount: BigInt(_params.lever_swap_limit_amount.toWei()),
73391
+ lever_swap_weights: _params.lever_swap_weights.map((weight) => BigInt(weight.toWei())),
73392
+ withdraw_swap: _params.withdraw_swap.map((swap) => ({
73393
+ route: swap.route.map((route) => ({
73394
+ pool_key: {
73395
+ token0: route.pool_key.token0.toBigInt(),
73396
+ token1: route.pool_key.token1.toBigInt(),
73397
+ fee: route.pool_key.fee,
73398
+ tick_spacing: route.pool_key.tick_spacing,
73399
+ extension: ContractAddr.from(route.pool_key.extension).toBigInt()
73400
+ },
73401
+ sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
73402
+ skip_ahead: BigInt(route.skip_ahead.toWei())
73403
+ })),
73404
+ token_amount: {
73405
+ token: swap.token_amount.token.toBigInt(),
73406
+ amount: swap.token_amount.amount.toI129()
73407
+ }
73408
+ })),
73409
+ withdraw_swap_limit_amount: BigInt(_params.withdraw_swap_limit_amount.toWei()),
73410
+ withdraw_swap_weights: _params.withdraw_swap_weights.map((weight) => BigInt(weight.toWei())),
73411
+ close_position: _params.close_position
73412
+ } })
73413
+ };
73414
+ }
72757
73415
  var VesuPools = {
72758
- Genesis: ContractAddr.from("0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28")
73416
+ Genesis: ContractAddr.from("0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28"),
73417
+ Re7xSTRK: ContractAddr.from("0x052fb52363939c3aa848f8f4ac28f0a51379f8d1b971d8444de25fbd77d8f161")
72759
73418
  };
72760
73419
  var VesuAdapter = class _VesuAdapter extends BaseAdapter {
72761
73420
  constructor(config3) {
72762
73421
  super();
72763
73422
  this.VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
73423
+ this.VESU_MULTIPLY = ContractAddr.from("0x3630f1f8e5b8f5c4c4ae9b6620f8a570ae55cddebc0276c37550e7c118edf67");
72764
73424
  this.getModifyPosition = () => {
72765
73425
  const positionData = [0n];
72766
73426
  const packedArguments = [
@@ -72825,6 +73485,88 @@ ${JSON.stringify(data, null, 2)}`;
72825
73485
  }
72826
73486
  };
72827
73487
  };
73488
+ this.getMultiplyAdapter = () => {
73489
+ const packedArguments = [
73490
+ toBigInt3(this.config.poolId.toString()),
73491
+ // pool id
73492
+ toBigInt3(this.config.collateral.address.toString()),
73493
+ // collateral
73494
+ toBigInt3(this.config.debt.address.toString()),
73495
+ // debt
73496
+ toBigInt3(this.config.vaultAllocator.toString())
73497
+ // vault allocator
73498
+ ];
73499
+ const output = this.constructSimpleLeafData({
73500
+ id: this.config.id,
73501
+ target: this.VESU_MULTIPLY,
73502
+ method: "modify_lever",
73503
+ packedArguments
73504
+ }, SIMPLE_SANITIZER_V2);
73505
+ return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
73506
+ };
73507
+ this.getMultiplyCall = (params) => {
73508
+ const isIncrease = params.isIncrease;
73509
+ const multiplyParams = isIncrease ? params.increaseParams : params.decreaseParams;
73510
+ if (!multiplyParams) {
73511
+ throw new Error("Multiply params are not provided");
73512
+ }
73513
+ const multiplyContract = new Contract({ abi: vesu_multiple_abi_default, address: this.VESU_MULTIPLY.toString(), providerOrAccount: new RpcProvider2({ nodeUrl: "" }) });
73514
+ const call = multiplyContract.populate("modify_lever", {
73515
+ modify_lever_params: getVesuMultiplyParams(isIncrease, {
73516
+ ...multiplyParams,
73517
+ user: this.config.vaultAllocator,
73518
+ pool_id: this.config.poolId,
73519
+ collateral_asset: this.config.collateral.address,
73520
+ debt_asset: this.config.debt.address,
73521
+ recipient: this.config.vaultAllocator
73522
+ })
73523
+ });
73524
+ return {
73525
+ sanitizer: SIMPLE_SANITIZER_V2,
73526
+ call: {
73527
+ contractAddress: this.VESU_MULTIPLY,
73528
+ selector: hash_exports.getSelectorFromName("modify_lever"),
73529
+ calldata: [
73530
+ ...call.calldata
73531
+ ]
73532
+ }
73533
+ };
73534
+ };
73535
+ this.getVesuModifyDelegationAdapter = (id) => {
73536
+ return () => {
73537
+ const packedArguments = [
73538
+ toBigInt3(this.config.poolId.toString()),
73539
+ // pool id
73540
+ toBigInt3(this.VESU_MULTIPLY.toString())
73541
+ // vault allocator
73542
+ ];
73543
+ const output = this.constructSimpleLeafData({
73544
+ id,
73545
+ target: this.VESU_SINGLETON,
73546
+ method: "modify_delegation",
73547
+ packedArguments
73548
+ }, SIMPLE_SANITIZER_V2);
73549
+ return { leaf: output, callConstructor: this.getVesuModifyDelegationCall.bind(this) };
73550
+ };
73551
+ };
73552
+ this.getVesuModifyDelegationCall = (params) => {
73553
+ const singletonContract = new Contract({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider2({ nodeUrl: "" }) });
73554
+ const call = singletonContract.populate("modify_delegation", {
73555
+ pool_id: this.config.poolId.toBigInt(),
73556
+ delegatee: this.VESU_MULTIPLY.toBigInt(),
73557
+ delegation: params.delegation
73558
+ });
73559
+ return {
73560
+ sanitizer: SIMPLE_SANITIZER_V2,
73561
+ call: {
73562
+ contractAddress: this.VESU_SINGLETON,
73563
+ selector: hash_exports.getSelectorFromName("modify_delegation"),
73564
+ calldata: [
73565
+ ...call.calldata
73566
+ ]
73567
+ }
73568
+ };
73569
+ };
72828
73570
  this.getDefispringRewardsAdapter = (id) => {
72829
73571
  return () => {
72830
73572
  const packedArguments = [];
@@ -75245,10 +75987,10 @@ ${JSON.stringify(data, null, 2)}`;
75245
75987
 
75246
75988
  // src/strategies/universal-strategy.tsx
75247
75989
  var import_jsx_runtime4 = __toESM(require_jsx_runtime());
75248
- var AUMTypes = /* @__PURE__ */ ((AUMTypes2) => {
75249
- AUMTypes2["FINALISED"] = "finalised";
75250
- AUMTypes2["DEFISPRING"] = "defispring";
75251
- return AUMTypes2;
75990
+ var AUMTypes = /* @__PURE__ */ ((AUMTypes3) => {
75991
+ AUMTypes3["FINALISED"] = "finalised";
75992
+ AUMTypes3["DEFISPRING"] = "defispring";
75993
+ return AUMTypes3;
75252
75994
  })(AUMTypes || {});
75253
75995
  var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
75254
75996
  constructor(config3, pricer, metadata) {
@@ -75376,24 +76118,33 @@ ${JSON.stringify(data, null, 2)}`;
75376
76118
  * @returns {Promise<number>} The weighted average APY across all pools
75377
76119
  */
75378
76120
  async netAPY() {
75379
- const [vesuAdapter1, vesuAdapter2] = this.getVesuAdapters();
75380
- const pools = await VesuAdapter.getVesuPools();
75381
- const pool1 = pools.pools.find((p) => vesuAdapter1.config.poolId.eqString(num_exports.getHexString(p.id)));
75382
- const pool2 = pools.pools.find((p) => vesuAdapter2.config.poolId.eqString(num_exports.getHexString(p.id)));
75383
- if (!pool1 || !pool2) {
76121
+ const prevAUM = await this.getPrevAUM();
76122
+ const vesuAdapters = this.getVesuAdapters();
76123
+ const allVesuPools = await VesuAdapter.getVesuPools();
76124
+ const pools = vesuAdapters.map((vesuAdapter) => {
76125
+ return allVesuPools.pools.find((p) => vesuAdapter.config.poolId.eqString(num_exports.getHexString(p.id)));
76126
+ });
76127
+ logger2.verbose(`${this.metadata.name}::netAPY: vesu-pools: ${JSON.stringify(pools)}`);
76128
+ if (pools.some((p) => !p)) {
75384
76129
  throw new Error("Pool not found");
75385
76130
  }
75386
76131
  ;
75387
- const collateralAsset1 = pool1.assets.find((a) => a.symbol === vesuAdapter1.config.collateral.symbol)?.stats;
75388
- const debtAsset1 = pool1.assets.find((a) => a.symbol === vesuAdapter1.config.debt.symbol)?.stats;
75389
- const collateralAsset2 = pool2.assets.find((a) => a.symbol === vesuAdapter2.config.collateral.symbol)?.stats;
75390
- const debtAsset2 = pool2.assets.find((a) => a.symbol === vesuAdapter2.config.debt.symbol)?.stats;
75391
- const collateral1APY = Number(collateralAsset1.supplyApy.value) / 1e18;
75392
- const debt1APY = Number(debtAsset1.borrowApr.value) / 1e18;
75393
- const collateral2APY = Number(collateralAsset2.supplyApy.value) / 1e18;
75394
- const debt2APY = Number(debtAsset2.borrowApr.value) / 1e18;
75395
- const positions = await this.getVaultPositions();
76132
+ const positions = await this.getVesuPositions();
75396
76133
  logger2.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
76134
+ const baseAPYs = [];
76135
+ const rewardAPYs = [];
76136
+ for (const [index, pool] of pools.entries()) {
76137
+ const vesuAdapter = vesuAdapters[index];
76138
+ const collateralAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.collateral.symbol)?.stats;
76139
+ const debtAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.debt.symbol)?.stats;
76140
+ const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
76141
+ const lstAPY = Number(collateralAsset.lstApr?.value || 0) / 1e18;
76142
+ baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
76143
+ rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr.value || "0") / 1e18, 0]);
76144
+ }
76145
+ logger2.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
76146
+ logger2.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
76147
+ assert3(baseAPYs.length == positions.length, "APYs and positions length mismatch");
75397
76148
  if (positions.every((p) => p.amount.isZero())) {
75398
76149
  return { net: 0, splits: [{
75399
76150
  apy: 0,
@@ -75404,11 +76155,10 @@ ${JSON.stringify(data, null, 2)}`;
75404
76155
  }] };
75405
76156
  }
75406
76157
  const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
75407
- const baseAPYs = [collateral1APY, debt1APY, collateral2APY, debt2APY];
75408
- assert3(positions.length == baseAPYs.length, "Positions and APYs length mismatch");
75409
- const rewardAPYs = [Number(collateralAsset1.defiSpringSupplyApr.value) / 1e18, 0, Number(collateralAsset2.defiSpringSupplyApr.value) / 1e18, 0];
75410
- const baseAPY = this.computeAPY(baseAPYs, weights);
75411
- const rewardAPY = this.computeAPY(rewardAPYs, weights);
76158
+ const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
76159
+ const prevAUMUSD = prevAUM.multipliedBy(price.price);
76160
+ const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
76161
+ const rewardAPY = this.computeAPY(rewardAPYs, weights, prevAUMUSD);
75412
76162
  const netAPY = baseAPY + rewardAPY;
75413
76163
  logger2.verbose(`${this.metadata.name}::netAPY: net: ${netAPY}, baseAPY: ${baseAPY}, rewardAPY: ${rewardAPY}`);
75414
76164
  return { net: netAPY, splits: [{
@@ -75419,11 +76169,11 @@ ${JSON.stringify(data, null, 2)}`;
75419
76169
  id: "defispring"
75420
76170
  }] };
75421
76171
  }
75422
- computeAPY(apys, weights) {
76172
+ computeAPY(apys, weights, currentAUM) {
75423
76173
  assert3(apys.length === weights.length, "APYs and weights length mismatch");
75424
76174
  const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
75425
- const totalWeight = weights.reduce((acc, weight) => acc + weight, 0);
75426
- return weightedSum / totalWeight;
76175
+ logger2.verbose(`${this.getTag()} computeAPY: apys: ${JSON.stringify(apys)}, weights: ${JSON.stringify(weights)}, weightedSum: ${weightedSum}, currentAUM: ${currentAUM}`);
76176
+ return weightedSum / currentAUM.toNumber();
75427
76177
  }
75428
76178
  /**
75429
76179
  * Calculates the total TVL of the strategy.
@@ -75455,24 +76205,48 @@ ${JSON.stringify(data, null, 2)}`;
75455
76205
  usdValue
75456
76206
  };
75457
76207
  }
75458
- async getAUM() {
76208
+ async getVesuAUM(adapter) {
76209
+ const legAUM = await adapter.getPositions(this.config);
76210
+ const underlying = this.asset();
76211
+ let vesuAum = Web3Number.fromWei("0", underlying.decimals);
76212
+ if (legAUM[0].token.address.eq(underlying.address)) {
76213
+ vesuAum = vesuAum.plus(legAUM[0].amount);
76214
+ } else {
76215
+ const tokenPrice = await this.pricer.getPrice(legAUM[1].token.symbol);
76216
+ vesuAum = vesuAum.plus(legAUM[1].usdValue / tokenPrice.price);
76217
+ }
76218
+ if (legAUM[1].token.address.eq(underlying.address)) {
76219
+ vesuAum = vesuAum.minus(legAUM[1].amount);
76220
+ } else {
76221
+ const tokenPrice = await this.pricer.getPrice(legAUM[1].token.symbol);
76222
+ vesuAum = vesuAum.minus(legAUM[1].usdValue / tokenPrice.price);
76223
+ }
76224
+ ;
76225
+ logger2.verbose(`${this.getTag()} Vesu AUM: ${vesuAum}, legCollateral: ${legAUM[0].amount.toNumber()}, legDebt: ${legAUM[1].amount.toNumber()}`);
76226
+ return vesuAum;
76227
+ }
76228
+ async getPrevAUM() {
75459
76229
  const currentAUM = await this.contract.call("aum", []);
75460
- const lastReportTime = await this.contract.call("last_report_timestamp", []);
76230
+ const prevAum = Web3Number.fromWei(currentAUM.toString(), this.asset().decimals);
76231
+ logger2.verbose(`${this.getTag()} Prev AUM: ${prevAum}`);
76232
+ return prevAum;
76233
+ }
76234
+ async getAUM() {
76235
+ const prevAum = await this.getPrevAUM();
75461
76236
  const token1Price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
75462
- const [vesuAdapter1, vesuAdapter2] = this.getVesuAdapters();
75463
- const leg1AUM = await vesuAdapter1.getPositions(this.config);
75464
- const leg2AUM = await vesuAdapter2.getPositions(this.config);
76237
+ const vesuAdapters = this.getVesuAdapters();
76238
+ let vesuAum = Web3Number.fromWei("0", this.asset().decimals);
76239
+ for (const adapter of vesuAdapters) {
76240
+ vesuAum = vesuAum.plus(await this.getVesuAUM(adapter));
76241
+ }
75465
76242
  const balance = await this.getUnusedBalance();
75466
76243
  logger2.verbose(`${this.getTag()} unused balance: ${balance.amount.toNumber()}`);
75467
- const vesuAum = leg1AUM[0].amount.plus(leg2AUM[0].usdValue / token1Price.price).minus(leg1AUM[1].usdValue / token1Price.price).minus(leg2AUM[1].amount);
75468
- logger2.verbose(`${this.getTag()} Vesu AUM: leg1: ${leg1AUM[0].amount.toNumber()}, ${leg1AUM[1].amount.toNumber()}, leg2: ${leg2AUM[0].amount.toNumber()}, ${leg2AUM[1].amount.toNumber()}`);
75469
76244
  const zeroAmt = Web3Number.fromWei("0", this.asset().decimals);
75470
76245
  const net = {
75471
76246
  tokenInfo: this.asset(),
75472
76247
  amount: zeroAmt,
75473
76248
  usdValue: 0
75474
76249
  };
75475
- const prevAum = Web3Number.fromWei(currentAUM.toString(), this.asset().decimals);
75476
76250
  if (vesuAum.isZero()) {
75477
76251
  return { net, splits: [{
75478
76252
  aum: zeroAmt,
@@ -75484,16 +76258,7 @@ ${JSON.stringify(data, null, 2)}`;
75484
76258
  }
75485
76259
  const aumToken = vesuAum.plus(balance.amount);
75486
76260
  logger2.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
75487
- const netAPY = await this.netAPY();
75488
- const defispringAPY = (netAPY.splits.find((s) => s.id === "defispring")?.apy || 0) * 0.8;
75489
- if (!defispringAPY) throw new Error("DefiSpring APY not found");
75490
- const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
75491
- const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
75492
- const rewardAssets = prevAum.multipliedBy(growthRate);
75493
- logger2.verbose(`${this.getTag()} DefiSpring AUM time difference: ${timeDiff}`);
75494
- logger2.verbose(`${this.getTag()} Current AUM: ${currentAUM}`);
75495
- logger2.verbose(`${this.getTag()} Net APY: ${JSON.stringify(netAPY)}`);
75496
- logger2.verbose(`${this.getTag()} rewards AUM: ${rewardAssets}`);
76261
+ const rewardAssets = await this.getRewardsAUM(prevAum);
75497
76262
  const newAUM = aumToken.plus(rewardAssets);
75498
76263
  logger2.verbose(`${this.getTag()} New AUM: ${newAUM}`);
75499
76264
  net.amount = newAUM;
@@ -75507,6 +76272,21 @@ ${JSON.stringify(data, null, 2)}`;
75507
76272
  }];
75508
76273
  return { net, splits, prevAum };
75509
76274
  }
76275
+ // account for future rewards (e.g. defispring rewards)
76276
+ async getRewardsAUM(prevAum) {
76277
+ const lastReportTime = await this.contract.call("last_report_timestamp", []);
76278
+ const netAPY = await this.netAPY();
76279
+ const defispringAPY = (netAPY.splits.find((s) => s.id === "defispring")?.apy || 0) * 0.8;
76280
+ if (!defispringAPY) throw new Error("DefiSpring APY not found");
76281
+ const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
76282
+ const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
76283
+ const rewardAssets = prevAum.multipliedBy(growthRate);
76284
+ logger2.verbose(`${this.getTag()} DefiSpring AUM time difference: ${timeDiff}`);
76285
+ logger2.verbose(`${this.getTag()} Current AUM: ${prevAum.toString()}`);
76286
+ logger2.verbose(`${this.getTag()} Net APY: ${JSON.stringify(netAPY)}`);
76287
+ logger2.verbose(`${this.getTag()} rewards AUM: ${rewardAssets}`);
76288
+ return rewardAssets;
76289
+ }
75510
76290
  getVesuAdapters() {
75511
76291
  const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
75512
76292
  const vesuAdapter2 = this.getAdapter("vesu_leg2_adapter" /* VESU_LEG2 */);
@@ -75516,11 +76296,23 @@ ${JSON.stringify(data, null, 2)}`;
75516
76296
  vesuAdapter2.networkConfig = this.config;
75517
76297
  return [vesuAdapter1, vesuAdapter2];
75518
76298
  }
76299
+ async getVesuPositions() {
76300
+ const adapters = this.getVesuAdapters();
76301
+ const positions = [];
76302
+ for (const adapter of adapters) {
76303
+ positions.push(...await adapter.getPositions(this.config));
76304
+ }
76305
+ return positions;
76306
+ }
75519
76307
  async getVaultPositions() {
75520
- const [vesuAdapter1, vesuAdapter2] = this.getVesuAdapters();
75521
- const leg1Positions = await vesuAdapter1.getPositions(this.config);
75522
- const leg2Positions = await vesuAdapter2.getPositions(this.config);
75523
- return [...leg1Positions, ...leg2Positions];
76308
+ const vesuPositions = await this.getVesuPositions();
76309
+ const unusedBalance = await this.getUnusedBalance();
76310
+ return [...vesuPositions, {
76311
+ amount: unusedBalance.amount,
76312
+ usdValue: unusedBalance.usdValue,
76313
+ token: this.asset(),
76314
+ remarks: "Unused Balance"
76315
+ }];
75524
76316
  }
75525
76317
  getSetManagerCall(strategist, root = this.getMerkleRoot()) {
75526
76318
  return this.managerContract.populate("set_manage_root", [strategist.address, num_exports.getHexString(root)]);
@@ -75658,7 +76450,7 @@ ${JSON.stringify(data, null, 2)}`;
75658
76450
  return new Web3Number(newAmount.toFixed(8), debtTokenAmount.decimals);
75659
76451
  }
75660
76452
  }
75661
- async getVesuMultiplyCall(params) {
76453
+ async getVesuModifyPositionCall(params) {
75662
76454
  const [vesuAdapter1, vesuAdapter2] = this.getVesuAdapters();
75663
76455
  const leg1LTV = await vesuAdapter1.getLTVConfig(this.config);
75664
76456
  const leg2LTV = await vesuAdapter2.getLTVConfig(this.config);
@@ -76158,6 +76950,335 @@ ${JSON.stringify(data, null, 2)}`;
76158
76950
  investmentSteps
76159
76951
  }
76160
76952
  ];
76953
+
76954
+ // src/strategies/universal-lst-muliplier-strategy.tsx
76955
+ var import_jsx_runtime5 = __toESM(require_jsx_runtime());
76956
+ var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
76957
+ constructor(config3, pricer, metadata) {
76958
+ super(config3, pricer, metadata);
76959
+ this.quoteAmountToFetchPrice = new Web3Number(1, 18);
76960
+ const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
76961
+ const underlyingToken = this.getLSTUnderlyingTokenInfo();
76962
+ if (underlyingToken.address.eq(STRKToken.address)) {
76963
+ this.quoteAmountToFetchPrice = new Web3Number(100, 18);
76964
+ } else {
76965
+ this.quoteAmountToFetchPrice = new Web3Number(0.01, this.asset().decimals);
76966
+ }
76967
+ }
76968
+ // only one leg is used
76969
+ // todo support lending assets of underlying as well
76970
+ getVesuAdapters() {
76971
+ const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
76972
+ vesuAdapter1.pricer = this.pricer;
76973
+ vesuAdapter1.networkConfig = this.config;
76974
+ return [vesuAdapter1];
76975
+ }
76976
+ // not applicable for this strategy
76977
+ // No rewards on collateral or borrowing of LST assets
76978
+ async getRewardsAUM(prevAum) {
76979
+ return Web3Number.fromWei("0", this.asset().decimals);
76980
+ }
76981
+ async getLSTDexPrice() {
76982
+ const ekuboQuoter = new EkuboQuoter(this.config);
76983
+ const lstTokenInfo = this.asset();
76984
+ const lstUnderlyingTokenInfo = this.getLSTUnderlyingTokenInfo();
76985
+ const quote = await ekuboQuoter.getQuote(
76986
+ lstTokenInfo.address.address,
76987
+ lstUnderlyingTokenInfo.address.address,
76988
+ this.quoteAmountToFetchPrice
76989
+ );
76990
+ const outputAmount = Web3Number.fromWei(quote.total_calculated, lstUnderlyingTokenInfo.decimals);
76991
+ const price = outputAmount.toNumber() / this.quoteAmountToFetchPrice.toNumber();
76992
+ logger2.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
76993
+ return price;
76994
+ }
76995
+ /**
76996
+ * Uses vesu's multiple call to create leverage on LST
76997
+ * Deposit amount is in LST
76998
+ * @param params
76999
+ */
77000
+ async getVesuMultiplyCall(params) {
77001
+ const [vesuAdapter1] = this.getVesuAdapters();
77002
+ const legLTV = await vesuAdapter1.getLTVConfig(this.config);
77003
+ const existingPositions = await vesuAdapter1.getPositions(this.config);
77004
+ const collateralisation = await vesuAdapter1.getCollateralization(this.config);
77005
+ const existingCollateralInfo = existingPositions[0];
77006
+ const existingDebtInfo = existingPositions[1];
77007
+ logger2.debug(`${this.getTag()}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
77008
+ existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
77009
+ const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
77010
+ const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
77011
+ logger2.debug(`${this.getTag()}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
77012
+ const addedCollateral = params.leg1DepositAmount.multipliedBy(params.isDeposit ? 1 : -1);
77013
+ const DEXPrice = await this.getLSTDexPrice();
77014
+ logger2.verbose(`${this.getTag()}::getVesuMultiplyCall addedCollateral: ${addedCollateral}`);
77015
+ const numeratorPart1 = existingCollateralInfo.amount.plus(addedCollateral).multipliedBy(collateralPrice).multipliedBy(legLTV);
77016
+ const numeratorPart2 = existingDebtInfo.amount.multipliedBy(debtPrice).multipliedBy(this.metadata.additionalInfo.targetHealthFactor);
77017
+ const denominatorPart = this.metadata.additionalInfo.targetHealthFactor - legLTV / DEXPrice;
77018
+ const x_debt_usd = numeratorPart1.minus(numeratorPart2).dividedBy(denominatorPart);
77019
+ logger2.verbose(`${this.getTag()}::getVesuMultiplyCall x_debt_usd: ${x_debt_usd}`);
77020
+ logger2.debug(`${this.getTag()}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}, numeratorPart2: ${numeratorPart2}, denominatorPart: ${denominatorPart}`);
77021
+ const debtAmount = x_debt_usd.dividedBy(debtPrice);
77022
+ const marginAmount = addedCollateral;
77023
+ logger2.verbose(`${this.getTag()}::getVesuMultiplyCall debtAmount: ${debtAmount}, marginAmount: ${marginAmount}`);
77024
+ return this.getModifyLeverCall({
77025
+ marginAmount,
77026
+ debtAmount,
77027
+ isIncrease: debtAmount.greaterThan(0)
77028
+ });
77029
+ }
77030
+ getLSTUnderlyingTokenInfo() {
77031
+ const [vesuAdapter1] = this.getVesuAdapters();
77032
+ return vesuAdapter1.config.debt;
77033
+ }
77034
+ async getLSTExchangeRate() {
77035
+ const [vesuAdapter1] = this.getVesuAdapters();
77036
+ const lstTokenInfo = vesuAdapter1.config.collateral;
77037
+ const lstABI = new Contract({
77038
+ abi: erc4626_abi_default,
77039
+ address: lstTokenInfo.address.address,
77040
+ providerOrAccount: this.config.provider
77041
+ });
77042
+ const price = await lstABI.call("convert_to_assets", [uint256_exports.bnToUint256(new Web3Number(1, lstTokenInfo.decimals).toWei())]);
77043
+ const exchangeRate = Number(uint256_exports.uint256ToBN(price).toString()) / Math.pow(10, lstTokenInfo.decimals);
77044
+ logger2.verbose(`${this.getTag()}:: LST Exchange Rate: ${exchangeRate}`);
77045
+ return exchangeRate;
77046
+ }
77047
+ /**
77048
+ *
77049
+ * @param params marginAmount is in LST, debtAmount is in underlying
77050
+ */
77051
+ async getModifyLeverCall(params) {
77052
+ assert3(!params.marginAmount.isZero() || !params.debtAmount.isZero(), "Deposit/debt must be non-0");
77053
+ const [vesuAdapter1] = this.getVesuAdapters();
77054
+ const lstTokenInfo = this.asset();
77055
+ const lstUnderlyingTokenInfo = vesuAdapter1.config.debt;
77056
+ const proofsIDs = [];
77057
+ const manageCalls = [];
77058
+ if (params.marginAmount.greaterThan(0)) {
77059
+ const STEP1_ID = "approve_token1" /* APPROVE_TOKEN1 */;
77060
+ const manage1Info = this.getProofs(STEP1_ID);
77061
+ const depositAmount = params.marginAmount;
77062
+ const manageCall1 = manage1Info.callConstructor({
77063
+ amount: depositAmount
77064
+ });
77065
+ proofsIDs.push(STEP1_ID);
77066
+ manageCalls.push(manageCall1);
77067
+ }
77068
+ const ekuboQuoter = new EkuboQuoter(this.config);
77069
+ const lstPrice = await this.getLSTExchangeRate();
77070
+ const marginSwap = [];
77071
+ const MAX_SLIPPAGE = 0.01;
77072
+ const fromToken = params.isIncrease ? lstUnderlyingTokenInfo : lstTokenInfo;
77073
+ const toToken = params.isIncrease ? lstTokenInfo : lstUnderlyingTokenInfo;
77074
+ const leverSwapQuote = await ekuboQuoter.getQuote(
77075
+ fromToken.address.address,
77076
+ toToken.address.address,
77077
+ params.debtAmount
77078
+ // negative for exact amount out
77079
+ );
77080
+ assert3(leverSwapQuote.price_impact < MAX_SLIPPAGE, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
77081
+ const leverSwap = ekuboQuoter.getVesuMultiplyQuote(leverSwapQuote, fromToken, toToken);
77082
+ const minExpectedDebt = params.debtAmount.dividedBy(lstPrice).multipliedBy(1 - MAX_SLIPPAGE);
77083
+ const maxUsedCollateral = params.debtAmount.abs().dividedBy(lstPrice).multipliedBy(1 + MAX_SLIPPAGE);
77084
+ const STEP2_ID = "switch_delegation_on" /* SWITCH_DELEGATION_ON */;
77085
+ const manage2Info = this.getProofs(STEP2_ID);
77086
+ const manageCall2 = manage2Info.callConstructor({
77087
+ delegation: true
77088
+ });
77089
+ const STEP3_ID = "multiply_vesu" /* MULTIPLY_VESU */;
77090
+ const manage3Info = this.getProofs(STEP3_ID);
77091
+ const multiplyParams = params.isIncrease ? {
77092
+ isIncrease: true,
77093
+ increaseParams: {
77094
+ add_margin: params.marginAmount,
77095
+ margin_swap: marginSwap,
77096
+ margin_swap_limit_amount: Web3Number.fromWei(0, this.asset().decimals),
77097
+ lever_swap: leverSwap,
77098
+ lever_swap_limit_amount: minExpectedDebt
77099
+ }
77100
+ } : {
77101
+ isIncrease: false,
77102
+ decreaseParams: {
77103
+ sub_margin: params.marginAmount.multipliedBy(-1),
77104
+ lever_swap: leverSwap,
77105
+ lever_swap_limit_amount: maxUsedCollateral,
77106
+ // only required for close position
77107
+ lever_swap_weights: [],
77108
+ // no need to swap collateral to anything, and any residuals return our contract anyways.
77109
+ withdraw_swap: [],
77110
+ withdraw_swap_limit_amount: Web3Number.fromWei(0, this.asset().decimals),
77111
+ withdraw_swap_weights: [],
77112
+ close_position: false
77113
+ }
77114
+ };
77115
+ const manageCall3 = manage3Info.callConstructor(multiplyParams);
77116
+ const STEP4_ID = "switch_delegation_off" /* SWITCH_DELEGATION_OFF */;
77117
+ const manage4Info = this.getProofs(STEP4_ID);
77118
+ const manageCall4 = manage4Info.callConstructor({
77119
+ delegation: false
77120
+ });
77121
+ proofsIDs.push(STEP2_ID, STEP3_ID, STEP4_ID);
77122
+ manageCalls.push(manageCall2, manageCall3, manageCall4);
77123
+ return [this.getManageCall(proofsIDs, manageCalls)];
77124
+ }
77125
+ };
77126
+ function VaultDescription() {
77127
+ const containerStyle = {
77128
+ maxWidth: "800px",
77129
+ margin: "0 auto",
77130
+ backgroundColor: "#111",
77131
+ color: "#eee",
77132
+ fontFamily: "Arial, sans-serif",
77133
+ borderRadius: "12px"
77134
+ };
77135
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: containerStyle, children: [
77136
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h1", { style: { fontSize: "18px", marginBottom: "10px" }, children: "Meta Vault \u2014 Automated Yield Router" }),
77137
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: { fontSize: "14px", lineHeight: "1.5", marginBottom: "16px" }, children: "This Levered Endur LST vault is a tokenized leveraged Vault, auto-compounding strategy that continuously allocates your deposited asset to the best available yield source in the ecosystem. Depositors receive vault shares that represent a proportional claim on the underlying assets and accrued yield. Allocation shifts are handled programmatically based on on-chain signals and risk filters, minimizing idle capital and maximizing net APY." }),
77138
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { backgroundColor: "#222", padding: "10px", borderRadius: "8px", marginBottom: "20px", border: "1px solid #444" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { style: { fontSize: "13px", color: "#ccc" }, children: [
77139
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { children: "Withdrawals:" }),
77140
+ " Requests can take up to ",
77141
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { children: "1-2 hours" }),
77142
+ " to process as the vault unwinds and settles routing."
77143
+ ] }) })
77144
+ ] });
77145
+ }
77146
+ function getDescription2(tokenSymbol) {
77147
+ return VaultDescription();
77148
+ }
77149
+ function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
77150
+ vaultSettings.leafAdapters = [];
77151
+ const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
77152
+ const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
77153
+ const vesuAdapterLST = new VesuAdapter({
77154
+ poolId: pool1,
77155
+ collateral: lstToken,
77156
+ debt: underlyingToken,
77157
+ vaultAllocator: vaultSettings.vaultAllocator,
77158
+ id: "multiply_vesu" /* MULTIPLY_VESU */
77159
+ });
77160
+ const commonAdapter = new CommonAdapter({
77161
+ manager: vaultSettings.manager,
77162
+ asset: lstToken.address,
77163
+ id: "",
77164
+ vaultAddress: vaultSettings.vaultAddress,
77165
+ vaultAllocator: vaultSettings.vaultAllocator
77166
+ });
77167
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vesuAdapterLST.VESU_MULTIPLY, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
77168
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter.bind(vesuAdapterLST));
77169
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_on" /* SWITCH_DELEGATION_ON */).bind(vesuAdapterLST));
77170
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_off" /* SWITCH_DELEGATION_OFF */).bind(vesuAdapterLST));
77171
+ vaultSettings.adapters.push(...[{
77172
+ id: "vesu_leg1_adapter" /* VESU_LEG1 */,
77173
+ adapter: vesuAdapterLST
77174
+ }, {
77175
+ id: "common_adapter" /* COMMON */,
77176
+ adapter: commonAdapter
77177
+ }]);
77178
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
77179
+ vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
77180
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterLST));
77181
+ const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
77182
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
77183
+ vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
77184
+ return vaultSettings;
77185
+ }
77186
+ function getFAQs2(lstSymbol, underlyingSymbol) {
77187
+ return [
77188
+ {
77189
+ question: `What is the Hyper ${lstSymbol} Vault?`,
77190
+ answer: `The Hyper ${lstSymbol} Vault is a tokenized strategy that automatically loops your ${underlyingSymbol} or ${lstSymbol} to create up to 4x leverage to hence yield in a very low risk manner.`
77191
+ },
77192
+ {
77193
+ question: "How does yield allocation work?",
77194
+ answer: `The strategy uses deposited ${lstSymbol} to collateralize it on Vesu, borrow more ${underlyingSymbol} to loop further. Instead of manually doing this, using flash loan, this leverage is created in a single gas efficient step. Our continuous monitoring systems gauge current yield and available liquidity in real time to make sure yield is optimal. For instance, if the looping becomes in-efficient in future, the strategy will rebalance to reduce leverage or simply hold ${lstSymbol} to continue earning yield.`
77195
+ },
77196
+ {
77197
+ question: "Which protocols/dApp are used??",
77198
+ answer: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
77199
+ "Currently, the LST is from ",
77200
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { children: "Endur" }),
77201
+ " while ",
77202
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { children: "Vesu" }),
77203
+ " is used to collateralize the looped position."
77204
+ ] })
77205
+ },
77206
+ {
77207
+ question: "Can I get liquidated?",
77208
+ answer: "The strategy uses highly correlated assets which drastically reduces 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."
77209
+ },
77210
+ {
77211
+ question: "What do I receive when I deposit?",
77212
+ answer: "Depositors receive vault tokens representing their proportional share of the vault. These tokens entitle holders to both the principal and accrued yield."
77213
+ },
77214
+ {
77215
+ question: "How long do withdrawals take?",
77216
+ answer: "Withdrawals may take up to 1-2 hours to process, as the vault unwinds and settles liquidity routing across integrated protocols. In case of large withdrawals, to avoid slippage, we may slowly unwind the position, which could make the withdrawals longer."
77217
+ },
77218
+ {
77219
+ question: "Is the Hyper xSTRK Vault non-custodial?",
77220
+ answer: "Yes. The Hyper xSTRK Vault operates entirely on-chain. Users always maintain control of their vault tokens, and the strategy is fully transparent."
77221
+ },
77222
+ {
77223
+ question: "Is the Vault audited?",
77224
+ answer: "Yes. The Hyper xSTRK Vault is audited by Zellic. Look for safety icon beside the strategy name for more details."
77225
+ },
77226
+ {
77227
+ question: "Are there any fees?",
77228
+ answer: "Troves charges a performance of 10% on the yield generated. The APY shown is net of this fee. This fee is only applied to the profits earned, ensuring that users retain their initial capital."
77229
+ }
77230
+ ];
77231
+ }
77232
+ var _riskFactor4 = [
77233
+ { type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 25, reason: "Audited by Zellic" },
77234
+ { type: "Liquidation Risk" /* LIQUIDATION_RISK */, value: 1 /* VERY_LOW_PROBABILITY */, weight: 50, reason: "The collateral and debt are highly correlated" },
77235
+ { type: "Technical Risk" /* TECHNICAL_RISK */, value: 1 /* STABLE_INFRASTRUCTURE */, weight: 50, reason: "Liquidation can only happen if vault is left un-monitored for weeks, which is highly unlikely. We actively monitor all services on a daily basis." }
77236
+ ];
77237
+ var hyperxSTRK = {
77238
+ vaultAddress: ContractAddr.from("0x46c7a54c82b1fe374353859f554a40b8bd31d3e30f742901579e7b57b1b5960"),
77239
+ manager: ContractAddr.from("0x5d499cd333757f461a0bedaca3dfc4d77320c773037e0aa299f22a6dbfdc03a"),
77240
+ vaultAllocator: ContractAddr.from("0x511d07953a09bc7c505970891507c5a2486d2ea22752601a14db092186d7caa"),
77241
+ redeemRequestNFT: ContractAddr.from("0x51e40b839dc0c2feca923f863072673b94abfa2483345be3b30b457a90d095"),
77242
+ aumOracle: ContractAddr.from("0x48cf709870a1a0d453d37de108e0c41b8b89819ef54f95abc0e2e1f98bbe937"),
77243
+ leafAdapters: [],
77244
+ adapters: [],
77245
+ targetHealthFactor: 1.1,
77246
+ minHealthFactor: 1.05
77247
+ };
77248
+ function getInvestmentSteps(lstSymbol, underlyingSymbol) {
77249
+ return [
77250
+ `Deposit ${underlyingSymbol} into the vault`,
77251
+ `The vault manager loops the ${underlyingSymbol} to buy ${lstSymbol}`,
77252
+ `The vault manager collateralizes the ${lstSymbol} on Vesu`,
77253
+ `The vault manager borrows more ${underlyingSymbol} to loop further`,
77254
+ `Claim BTCFi STRK rewards weekly to swap to ${lstSymbol} and reinvest`,
77255
+ `If required, adjust leverage or re-allocate assets within LST pool on Vesu to optimize yield`
77256
+ ];
77257
+ }
77258
+ function getStrategySettings(lstSymbol, underlyingSymbol, addresses) {
77259
+ return {
77260
+ name: `Hyper ${lstSymbol}`,
77261
+ description: getDescription2(lstSymbol),
77262
+ address: addresses.vaultAddress,
77263
+ launchBlock: 0,
77264
+ type: "Other",
77265
+ depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === lstSymbol)],
77266
+ additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, addresses, VesuPools.Re7xSTRK),
77267
+ risk: {
77268
+ riskFactor: _riskFactor4,
77269
+ netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
77270
+ notARisks: getNoRiskTags(_riskFactor4)
77271
+ },
77272
+ protocols: [Protocols.ENDUR, Protocols.VESU],
77273
+ maxTVL: Web3Number.fromWei(0, 18),
77274
+ contractDetails: getContractDetails(addresses),
77275
+ faqs: getFAQs2(lstSymbol, underlyingSymbol),
77276
+ investmentSteps: getInvestmentSteps(lstSymbol, underlyingSymbol)
77277
+ };
77278
+ }
77279
+ var HyperLSTStrategies = [
77280
+ getStrategySettings("xSTRK", "STRK", hyperxSTRK)
77281
+ ];
76161
77282
  return __toCommonJS(index_browser_exports);
76162
77283
  })();
76163
77284
  /*! Bundled license information: