@strkfarm/sdk 2.0.0-dev.34 → 2.0.0-dev.35

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.
@@ -22065,6 +22065,7 @@ import { CairoCustomEnum as CairoCustomEnum2, Contract as Contract10, hash as ha
22065
22065
 
22066
22066
  // src/strategies/universal-adapters/adapter-utils.ts
22067
22067
  var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
22068
+ var SVK_SIMPLE_SANITIZER = ContractAddr.from("0x03dcde04343257c3ce14574676cb9c5b2eda16e332c1b8caf5dc4c95ac568d2f");
22068
22069
  var EXTENDED_SANITIZER = ContractAddr.from("0x65891708362b24dcf4c40c8e218cce6e82d1d6b3a3404c9ab00a48f08e2c110");
22069
22070
  var AVNU_LEGACY_SANITIZER = ContractAddr.from("0x0656fBE853f116DD53956176a553eDe8fE65632252f8aceB50C1B9B6c8237309");
22070
22071
  var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x7b6f98311af8aa425278570e62abf523e6462eaa01a38c1feab9b2f416492e2");
@@ -35928,7 +35929,14 @@ var VesuModifyPositionAdapter = class _VesuModifyPositionAdapter extends BaseAda
35928
35929
  }
35929
35930
  const normalizedDebtAmount = this._normalizeDebtAmountFromHelper(
35930
35931
  helperOutput
35931
- );
35932
+ ).minus(state.currentDebt);
35933
+ if (normalizedDebtAmount.lessThan(0)) {
35934
+ logger.warn(`VesuModifyPositionAdapter: deposit debt delta is negative (${normalizedDebtAmount.toNumber()}), clamping to zero`);
35935
+ return {
35936
+ collateral: this._toSigned(collateralToAdd, false),
35937
+ debt: this._toSigned(Web3Number.fromWei(0, this.config.debt.decimals), false)
35938
+ };
35939
+ }
35932
35940
  return {
35933
35941
  collateral: this._toSigned(collateralToAdd, false),
35934
35942
  debt: this._toSigned(normalizedDebtAmount, false)
@@ -35946,8 +35954,8 @@ var VesuModifyPositionAdapter = class _VesuModifyPositionAdapter extends BaseAda
35946
35954
  state.debtPrice,
35947
35955
  this.config.debt
35948
35956
  );
35949
- if (!helperOutput || helperOutput.greaterThan(0)) {
35950
- throw new Error(`Failed to calculate default withdraw debt delta: ${helperOutput?.toNumber()}`);
35957
+ if (!helperOutput || helperOutput.lessThan(0)) {
35958
+ throw new Error(`Failed to calculate max debt amount for withdraw: ${helperOutput?.toNumber()}`);
35951
35959
  }
35952
35960
  const normalizedDebtAmount = this._normalizeDebtAmountFromHelper(
35953
35961
  helperOutput
@@ -36144,6 +36152,24 @@ var VesuModifyPositionAdapter = class _VesuModifyPositionAdapter extends BaseAda
36144
36152
  this._prepareVesuAdapter();
36145
36153
  return this._vesuAdapter.getHealthFactor();
36146
36154
  }
36155
+ /**
36156
+ * Simulates a deposit of `depositAmount` collateral and returns how much
36157
+ * debt (STRK) would be incrementally borrowed to reach the target LTV.
36158
+ * Used upstream to size the AVNU swap call in the same transaction batch.
36159
+ */
36160
+ async getExpectedDepositDebtDelta(depositAmount) {
36161
+ const defaults = await this._buildDefaultDepositDeltas({ amount: depositAmount });
36162
+ return defaults.debt.amount;
36163
+ }
36164
+ /**
36165
+ * Simulates a withdrawal of `withdrawAmount` collateral and returns the
36166
+ * incremental debt delta needed to keep the target health factor.
36167
+ * Positive means borrow, negative means repay.
36168
+ */
36169
+ async getExpectedWithdrawDebtDelta(withdrawAmount) {
36170
+ const defaults = await this._buildDefaultWithdrawDeltas({ amount: withdrawAmount });
36171
+ return defaults.debt.amount;
36172
+ }
36147
36173
  };
36148
36174
 
36149
36175
  // src/strategies/universal-adapters/extended-adapter.ts
@@ -36205,6 +36231,25 @@ var ExtendedAdapter = class _ExtendedAdapter extends BaseAdapter {
36205
36231
  return { success: false, data: [] };
36206
36232
  }
36207
36233
  }
36234
+ /** Account funding payment history via `GET /api/v1/account/funding-payments` (USDC amounts). */
36235
+ async getFundingPayments(side, startTime, limit) {
36236
+ try {
36237
+ const response = await this.client.getUserFundingPayments(
36238
+ this.config.extendedMarketName,
36239
+ side,
36240
+ startTime ?? Date.now() - 30 * 24 * 60 * 60 * 1e3,
36241
+ limit ?? 200
36242
+ );
36243
+ if (response.status !== "OK") {
36244
+ logger.error("error getting funding payments", response.data);
36245
+ return { success: false, data: [] };
36246
+ }
36247
+ return { success: true, data: response.data ?? [] };
36248
+ } catch (err) {
36249
+ logger.error("error getting funding payments", err);
36250
+ return { success: false, data: [] };
36251
+ }
36252
+ }
36208
36253
  async getPosition(supportedPosition) {
36209
36254
  const holdings = await this.getExtendedDepositAmount();
36210
36255
  if (!holdings) {
@@ -38844,349 +38889,110 @@ var universal_vault_abi_default = [
38844
38889
  }
38845
38890
  ];
38846
38891
 
38847
- // src/strategies/universal-adapters/svk-troves-adapter.ts
38848
- var DEFAULT_TROVES_STRATEGIES_API = "https://app.troves.fi/api/strategies";
38849
- function parseTrovesApyField(raw) {
38850
- if (typeof raw === "number" && Number.isFinite(raw)) {
38851
- return raw;
38852
- }
38853
- if (typeof raw === "string") {
38854
- const n = Number.parseFloat(raw);
38855
- if (Number.isFinite(n)) {
38856
- return n;
38857
- }
38858
- }
38859
- return 0;
38860
- }
38861
- var SvkTrovesAdapter = class _SvkTrovesAdapter extends BaseAdapter {
38862
- constructor(config) {
38863
- super(config, _SvkTrovesAdapter.name, Protocols.TROVES);
38864
- this.config = config;
38865
- }
38866
- /** Owner used for share balance + `due_assets_from_owner`. */
38867
- _positionOwner() {
38868
- return this.config.positionOwner ?? this.config.vaultAllocator;
38869
- }
38870
- /**
38871
- * Proof readable IDs must stay ≤ 31 chars (Cairo short string). We derive a short ASCII suffix from
38872
- * `strategyVault` address so multiple SVK adapters in one tree stay distinct.
38873
- */
38874
- _proofSuffix() {
38875
- return this.config.strategyVault.address.replace(/^0x/, "").slice(-6);
38876
- }
38877
- _depositApproveProofReadableId() {
38878
- return `appr_dep_svk_${this._proofSuffix()}`;
38879
- }
38880
- _depositCallProofReadableId() {
38881
- return `dep_svk_${this._proofSuffix()}`;
38882
- }
38883
- _withdrawCallProofReadableId() {
38884
- return `wtdrw_svk_${this._proofSuffix()}`;
38885
- }
38886
- async getAPY(supportedPosition) {
38887
- const CACHE_KEY = `svk_apy_${this.config.trovesStrategyId}`;
38888
- const cached = this.getCache(CACHE_KEY);
38889
- if (cached) {
38890
- return cached;
38891
- }
38892
- const url = this.config.trovesStrategiesApiUrl ?? DEFAULT_TROVES_STRATEGIES_API;
38893
- try {
38894
- const res = await fetch(url);
38895
- if (!res.ok) {
38896
- logger.warn(`${_SvkTrovesAdapter.name}::getAPY: HTTP ${res.status} from ${url}`);
38897
- const fallback = { apy: 0, type: "base" /* BASE */ };
38898
- this.setCache(CACHE_KEY, fallback, 3e5);
38899
- return fallback;
38900
- }
38901
- const body = await res.json();
38902
- const row = body.strategies?.find((s) => s.id === this.config.trovesStrategyId);
38903
- if (!row) {
38904
- logger.warn(
38905
- `${_SvkTrovesAdapter.name}::getAPY: strategy id not found: ${this.config.trovesStrategyId}`
38906
- );
38907
- const fallback = { apy: 0, type: "base" /* BASE */ };
38908
- this.setCache(CACHE_KEY, fallback, 3e5);
38909
- return fallback;
38910
- }
38911
- const apy = parseTrovesApyField(row.apy);
38912
- const result = { apy, type: "base" /* BASE */ };
38913
- this.setCache(CACHE_KEY, result, 3e5);
38914
- return result;
38915
- } catch (error) {
38916
- logger.error(`${_SvkTrovesAdapter.name}::getAPY:`, error);
38917
- throw error;
38918
- }
38919
- }
38920
- async getPosition(supportedPosition) {
38921
- const CACHE_KEY = `svk_pos_${this.config.strategyVault.address}_${this._positionOwner().address}`;
38922
- const cached = this.getCache(CACHE_KEY);
38923
- if (cached) {
38924
- return cached;
38925
- }
38926
- try {
38927
- const vault = new Contract14({
38928
- abi: universal_vault_abi_default,
38929
- address: this.config.strategyVault.address,
38930
- providerOrAccount: this.config.networkConfig.provider
38931
- });
38932
- const owner = this._positionOwner();
38933
- const decimals = supportedPosition.asset.decimals;
38934
- const shares = await vault.balance_of(owner.address);
38935
- const shareU256 = uint25619.bnToUint256(shares);
38936
- const liquidAssetsRaw = await vault.convert_to_assets(shareU256);
38937
- const liquid = Web3Number.fromWei(liquidAssetsRaw.toString(), decimals);
38938
- let pending = Web3Number.fromWei("0", decimals);
38939
- try {
38940
- const dueRaw = await vault.call("due_assets_from_owner", [owner.address]);
38941
- pending = Web3Number.fromWei(dueRaw.toString(), decimals);
38942
- } catch (e) {
38943
- logger.warn(
38944
- `${_SvkTrovesAdapter.name}::getPosition: due_assets_from_owner failed (treating as 0): ${e.message}`
38945
- );
38946
- }
38947
- const total = liquid.plus(pending);
38948
- const remarks = `Troves ${this.config.trovesStrategyId} holdings`;
38949
- const result = {
38950
- amount: total,
38951
- remarks
38952
- };
38953
- this.setCache(CACHE_KEY, result, 6e4);
38954
- return result;
38955
- } catch (error) {
38956
- logger.error(`${_SvkTrovesAdapter.name}::getPosition:`, error);
38957
- throw error;
38958
- }
38959
- }
38960
- async maxDeposit(amount) {
38961
- const baseToken = this.config.baseToken;
38962
- if (!amount) {
38963
- return {
38964
- tokenInfo: baseToken,
38965
- amount: new Web3Number("999999999999999999999999999", baseToken.decimals),
38966
- usdValue: 1e27,
38967
- remarks: "Max deposit (unbounded placeholder)",
38968
- apy: await this.getAPY({ asset: baseToken, isDebt: false }),
38969
- protocol: this.protocol
38970
- };
38971
- }
38972
- const usdValue = await this.getUSDValue(baseToken, amount);
38973
- return {
38974
- tokenInfo: baseToken,
38975
- amount,
38976
- usdValue,
38977
- remarks: "Deposit amount",
38978
- apy: await this.getAPY({ asset: baseToken, isDebt: false }),
38979
- protocol: this.protocol
38980
- };
38981
- }
38982
- async maxWithdraw() {
38983
- const baseToken = this.config.baseToken;
38984
- const current = await this.getPosition({ asset: baseToken, isDebt: false });
38985
- const pos = current ?? { amount: new Web3Number("0", baseToken.decimals), remarks: "" };
38986
- const usdValue = await this.getUSDValue(baseToken, pos.amount);
38987
- return {
38988
- tokenInfo: baseToken,
38989
- amount: pos.amount,
38990
- usdValue,
38991
- remarks: "Max withdraw (liquid + pending redemption, underlying units)",
38992
- apy: await this.getAPY({ asset: baseToken, isDebt: false }),
38993
- protocol: this.protocol
38994
- };
38995
- }
38996
- _getDepositLeaf() {
38997
- const baseToken = this.config.baseToken;
38998
- const strategyVault = this.config.strategyVault;
38999
- const receiver = this.config.vaultAllocator;
39000
- return [
38892
+ // src/data/redeem-request-nft.abi.json
38893
+ var redeem_request_nft_abi_default = [
38894
+ {
38895
+ type: "impl",
38896
+ name: "RedeemRequestImpl",
38897
+ interface_name: "vault::redeem_request::interface::IRedeemRequest"
38898
+ },
38899
+ {
38900
+ type: "struct",
38901
+ name: "core::integer::u256",
38902
+ members: [
39001
38903
  {
39002
- target: baseToken.address,
39003
- method: "approve",
39004
- packedArguments: [strategyVault.toBigInt()],
39005
- sanitizer: SIMPLE_SANITIZER,
39006
- id: this._depositApproveProofReadableId()
38904
+ name: "low",
38905
+ type: "core::integer::u128"
39007
38906
  },
39008
38907
  {
39009
- target: strategyVault,
39010
- method: "deposit",
39011
- packedArguments: [receiver.toBigInt()],
39012
- sanitizer: SIMPLE_SANITIZER,
39013
- id: this._depositCallProofReadableId()
39014
- }
39015
- ];
39016
- }
39017
- _getWithdrawLeaf() {
39018
- const strategyVault = this.config.strategyVault;
39019
- const recv = this.config.vaultAllocator;
39020
- const owner = this.config.vaultAllocator;
39021
- return [
39022
- {
39023
- target: strategyVault,
39024
- method: "withdraw",
39025
- packedArguments: [recv.toBigInt(), owner.toBigInt()],
39026
- sanitizer: SIMPLE_SANITIZER,
39027
- id: this._withdrawCallProofReadableId()
38908
+ name: "high",
38909
+ type: "core::integer::u128"
39028
38910
  }
39029
- ];
39030
- }
39031
- getDepositAdapter() {
39032
- const leafConfigs = this._getDepositLeaf();
39033
- const leaves = leafConfigs.map((config) => {
39034
- const { target, method, packedArguments, sanitizer, id } = config;
39035
- return this.constructSimpleLeafData({ id, target, method, packedArguments }, sanitizer);
39036
- });
39037
- return { leaves, callConstructor: this.getDepositCall.bind(this) };
39038
- }
39039
- getWithdrawAdapter() {
39040
- const leafConfigs = this._getWithdrawLeaf();
39041
- const leaves = leafConfigs.map((config) => {
39042
- const { target, method, packedArguments, sanitizer, id } = config;
39043
- return this.constructSimpleLeafData({ id, target, method, packedArguments }, sanitizer);
39044
- });
39045
- return { leaves, callConstructor: this.getWithdrawCall.bind(this) };
39046
- }
39047
- async getDepositCall(params) {
39048
- const baseToken = this.config.baseToken;
39049
- const strategyVault = this.config.strategyVault;
39050
- const amount = params.amount;
39051
- const uint256Amount = uint25619.bnToUint256(amount.toWei());
39052
- const receiver = this.config.vaultAllocator;
39053
- return [
38911
+ ]
38912
+ },
38913
+ {
38914
+ type: "struct",
38915
+ name: "vault::redeem_request::interface::RedeemRequestInfo",
38916
+ members: [
39054
38917
  {
39055
- proofReadableId: this._depositApproveProofReadableId(),
39056
- sanitizer: SIMPLE_SANITIZER,
39057
- call: {
39058
- contractAddress: baseToken.address,
39059
- selector: hash11.getSelectorFromName("approve"),
39060
- calldata: [
39061
- strategyVault.toBigInt(),
39062
- toBigInt(uint256Amount.low.toString()),
39063
- toBigInt(uint256Amount.high.toString())
39064
- ]
39065
- }
38918
+ name: "epoch",
38919
+ type: "core::integer::u256"
39066
38920
  },
39067
38921
  {
39068
- proofReadableId: this._depositCallProofReadableId(),
39069
- sanitizer: SIMPLE_SANITIZER,
39070
- call: {
39071
- contractAddress: strategyVault,
39072
- selector: hash11.getSelectorFromName("deposit"),
39073
- calldata: [
39074
- toBigInt(uint256Amount.low.toString()),
39075
- toBigInt(uint256Amount.high.toString()),
39076
- receiver.toBigInt()
39077
- ]
39078
- }
39079
- }
39080
- ];
39081
- }
39082
- async getWithdrawCall(params) {
39083
- const strategyVault = this.config.strategyVault;
39084
- const amount = params.amount;
39085
- const uint256Amount = uint25619.bnToUint256(amount.toWei());
39086
- const recv = this.config.vaultAllocator;
39087
- const owner = this.config.vaultAllocator;
39088
- return [
39089
- {
39090
- proofReadableId: this._withdrawCallProofReadableId(),
39091
- sanitizer: SIMPLE_SANITIZER,
39092
- call: {
39093
- contractAddress: strategyVault,
39094
- selector: hash11.getSelectorFromName("withdraw"),
39095
- calldata: [
39096
- toBigInt(uint256Amount.low.toString()),
39097
- toBigInt(uint256Amount.high.toString()),
39098
- recv.toBigInt(),
39099
- owner.toBigInt()
39100
- ]
39101
- }
38922
+ name: "nominal",
38923
+ type: "core::integer::u256"
39102
38924
  }
39103
- ];
39104
- }
39105
- getHealthFactor() {
39106
- return Promise.resolve(10);
39107
- }
39108
- };
39109
-
39110
- // src/strategies/universal-strategy.tsx
39111
- import { CallData, Contract as Contract15, num as num12, uint256 as uint25620 } from "starknet";
39112
-
39113
- // src/data/vault-manager.abi.json
39114
- var vault_manager_abi_default = [
39115
- {
39116
- type: "impl",
39117
- name: "UpgradeableImpl",
39118
- interface_name: "openzeppelin_upgrades::interface::IUpgradeable"
38925
+ ]
39119
38926
  },
39120
38927
  {
39121
38928
  type: "interface",
39122
- name: "openzeppelin_upgrades::interface::IUpgradeable",
38929
+ name: "vault::redeem_request::interface::IRedeemRequest",
39123
38930
  items: [
39124
38931
  {
39125
38932
  type: "function",
39126
- name: "upgrade",
39127
- inputs: [
38933
+ name: "vault",
38934
+ inputs: [],
38935
+ outputs: [
39128
38936
  {
39129
- name: "new_class_hash",
39130
- type: "core::starknet::class_hash::ClassHash"
38937
+ type: "core::starknet::contract_address::ContractAddress"
39131
38938
  }
39132
38939
  ],
39133
- outputs: [],
39134
- state_mutability: "external"
39135
- }
39136
- ]
39137
- },
39138
- {
39139
- type: "impl",
39140
- name: "ManagerFlashloanReceiverImpl",
39141
- interface_name: "vault_allocator::integration_interfaces::vesu::IFlashloanReceiver"
39142
- },
39143
- {
39144
- type: "struct",
39145
- name: "core::integer::u256",
39146
- members: [
39147
- {
39148
- name: "low",
39149
- type: "core::integer::u128"
38940
+ state_mutability: "view"
39150
38941
  },
39151
38942
  {
39152
- name: "high",
39153
- type: "core::integer::u128"
39154
- }
39155
- ]
39156
- },
39157
- {
39158
- type: "struct",
39159
- name: "core::array::Span::<core::felt252>",
39160
- members: [
38943
+ type: "function",
38944
+ name: "id_to_info",
38945
+ inputs: [
38946
+ {
38947
+ name: "id",
38948
+ type: "core::integer::u256"
38949
+ }
38950
+ ],
38951
+ outputs: [
38952
+ {
38953
+ type: "vault::redeem_request::interface::RedeemRequestInfo"
38954
+ }
38955
+ ],
38956
+ state_mutability: "view"
38957
+ },
39161
38958
  {
39162
- name: "snapshot",
39163
- type: "@core::array::Array::<core::felt252>"
39164
- }
39165
- ]
39166
- },
39167
- {
39168
- type: "interface",
39169
- name: "vault_allocator::integration_interfaces::vesu::IFlashloanReceiver",
39170
- items: [
38959
+ type: "function",
38960
+ name: "id_len",
38961
+ inputs: [],
38962
+ outputs: [
38963
+ {
38964
+ type: "core::integer::u256"
38965
+ }
38966
+ ],
38967
+ state_mutability: "view"
38968
+ },
39171
38969
  {
39172
38970
  type: "function",
39173
- name: "on_flash_loan",
38971
+ name: "mint",
39174
38972
  inputs: [
39175
38973
  {
39176
- name: "sender",
38974
+ name: "to",
39177
38975
  type: "core::starknet::contract_address::ContractAddress"
39178
38976
  },
39179
38977
  {
39180
- name: "asset",
39181
- type: "core::starknet::contract_address::ContractAddress"
39182
- },
38978
+ name: "redeem_request_info",
38979
+ type: "vault::redeem_request::interface::RedeemRequestInfo"
38980
+ }
38981
+ ],
38982
+ outputs: [
39183
38983
  {
39184
- name: "amount",
39185
38984
  type: "core::integer::u256"
39186
- },
38985
+ }
38986
+ ],
38987
+ state_mutability: "external"
38988
+ },
38989
+ {
38990
+ type: "function",
38991
+ name: "burn",
38992
+ inputs: [
39187
38993
  {
39188
- name: "data",
39189
- type: "core::array::Span::<core::felt252>"
38994
+ name: "id",
38995
+ type: "core::integer::u256"
39190
38996
  }
39191
38997
  ],
39192
38998
  outputs: [],
@@ -39196,26 +39002,39 @@ var vault_manager_abi_default = [
39196
39002
  },
39197
39003
  {
39198
39004
  type: "impl",
39199
- name: "ManagerImpl",
39200
- interface_name: "vault_allocator::manager::interface::IManager"
39005
+ name: "UpgradeableImpl",
39006
+ interface_name: "openzeppelin_interfaces::upgrades::IUpgradeable"
39201
39007
  },
39202
39008
  {
39203
- type: "struct",
39204
- name: "core::array::Span::<core::array::Span::<core::felt252>>",
39205
- members: [
39009
+ type: "interface",
39010
+ name: "openzeppelin_interfaces::upgrades::IUpgradeable",
39011
+ items: [
39206
39012
  {
39207
- name: "snapshot",
39208
- type: "@core::array::Array::<core::array::Span::<core::felt252>>"
39013
+ type: "function",
39014
+ name: "upgrade",
39015
+ inputs: [
39016
+ {
39017
+ name: "new_class_hash",
39018
+ type: "core::starknet::class_hash::ClassHash"
39019
+ }
39020
+ ],
39021
+ outputs: [],
39022
+ state_mutability: "external"
39209
39023
  }
39210
39024
  ]
39211
39025
  },
39026
+ {
39027
+ type: "impl",
39028
+ name: "ERC721MixinImpl",
39029
+ interface_name: "openzeppelin_interfaces::token::erc721::ERC721ABI"
39030
+ },
39212
39031
  {
39213
39032
  type: "struct",
39214
- name: "core::array::Span::<core::starknet::contract_address::ContractAddress>",
39033
+ name: "core::array::Span::<core::felt252>",
39215
39034
  members: [
39216
39035
  {
39217
39036
  name: "snapshot",
39218
- type: "@core::array::Array::<core::starknet::contract_address::ContractAddress>"
39037
+ type: "@core::array::Array::<core::felt252>"
39219
39038
  }
39220
39039
  ]
39221
39040
  },
@@ -39233,25 +39052,53 @@ var vault_manager_abi_default = [
39233
39052
  }
39234
39053
  ]
39235
39054
  },
39055
+ {
39056
+ type: "struct",
39057
+ name: "core::byte_array::ByteArray",
39058
+ members: [
39059
+ {
39060
+ name: "data",
39061
+ type: "core::array::Array::<core::bytes_31::bytes31>"
39062
+ },
39063
+ {
39064
+ name: "pending_word",
39065
+ type: "core::felt252"
39066
+ },
39067
+ {
39068
+ name: "pending_word_len",
39069
+ type: "core::integer::u32"
39070
+ }
39071
+ ]
39072
+ },
39236
39073
  {
39237
39074
  type: "interface",
39238
- name: "vault_allocator::manager::interface::IManager",
39075
+ name: "openzeppelin_interfaces::token::erc721::ERC721ABI",
39239
39076
  items: [
39240
39077
  {
39241
39078
  type: "function",
39242
- name: "vesu_singleton",
39243
- inputs: [],
39244
- outputs: [
39079
+ name: "balance_of",
39080
+ inputs: [
39245
39081
  {
39082
+ name: "account",
39246
39083
  type: "core::starknet::contract_address::ContractAddress"
39247
39084
  }
39248
39085
  ],
39086
+ outputs: [
39087
+ {
39088
+ type: "core::integer::u256"
39089
+ }
39090
+ ],
39249
39091
  state_mutability: "view"
39250
39092
  },
39251
39093
  {
39252
39094
  type: "function",
39253
- name: "vault_allocator",
39254
- inputs: [],
39095
+ name: "owner_of",
39096
+ inputs: [
39097
+ {
39098
+ name: "token_id",
39099
+ type: "core::integer::u256"
39100
+ }
39101
+ ],
39255
39102
  outputs: [
39256
39103
  {
39257
39104
  type: "core::starknet::contract_address::ContractAddress"
@@ -39261,15 +39108,23 @@ var vault_manager_abi_default = [
39261
39108
  },
39262
39109
  {
39263
39110
  type: "function",
39264
- name: "set_manage_root",
39111
+ name: "safe_transfer_from",
39265
39112
  inputs: [
39266
39113
  {
39267
- name: "target",
39114
+ name: "from",
39268
39115
  type: "core::starknet::contract_address::ContractAddress"
39269
39116
  },
39270
39117
  {
39271
- name: "root",
39272
- type: "core::felt252"
39118
+ name: "to",
39119
+ type: "core::starknet::contract_address::ContractAddress"
39120
+ },
39121
+ {
39122
+ name: "token_id",
39123
+ type: "core::integer::u256"
39124
+ },
39125
+ {
39126
+ name: "data",
39127
+ type: "core::array::Span::<core::felt252>"
39273
39128
  }
39274
39129
  ],
39275
39130
  outputs: [],
@@ -39277,137 +39132,150 @@ var vault_manager_abi_default = [
39277
39132
  },
39278
39133
  {
39279
39134
  type: "function",
39280
- name: "manage_root",
39135
+ name: "transfer_from",
39281
39136
  inputs: [
39282
39137
  {
39283
- name: "target",
39138
+ name: "from",
39284
39139
  type: "core::starknet::contract_address::ContractAddress"
39285
- }
39286
- ],
39287
- outputs: [
39140
+ },
39288
39141
  {
39289
- type: "core::felt252"
39142
+ name: "to",
39143
+ type: "core::starknet::contract_address::ContractAddress"
39144
+ },
39145
+ {
39146
+ name: "token_id",
39147
+ type: "core::integer::u256"
39290
39148
  }
39291
39149
  ],
39292
- state_mutability: "view"
39150
+ outputs: [],
39151
+ state_mutability: "external"
39293
39152
  },
39294
39153
  {
39295
39154
  type: "function",
39296
- name: "pause",
39297
- inputs: [],
39155
+ name: "approve",
39156
+ inputs: [
39157
+ {
39158
+ name: "to",
39159
+ type: "core::starknet::contract_address::ContractAddress"
39160
+ },
39161
+ {
39162
+ name: "token_id",
39163
+ type: "core::integer::u256"
39164
+ }
39165
+ ],
39298
39166
  outputs: [],
39299
39167
  state_mutability: "external"
39300
39168
  },
39301
39169
  {
39302
39170
  type: "function",
39303
- name: "unpause",
39304
- inputs: [],
39171
+ name: "set_approval_for_all",
39172
+ inputs: [
39173
+ {
39174
+ name: "operator",
39175
+ type: "core::starknet::contract_address::ContractAddress"
39176
+ },
39177
+ {
39178
+ name: "approved",
39179
+ type: "core::bool"
39180
+ }
39181
+ ],
39305
39182
  outputs: [],
39306
39183
  state_mutability: "external"
39307
39184
  },
39308
39185
  {
39309
39186
  type: "function",
39310
- name: "manage_vault_with_merkle_verification",
39187
+ name: "get_approved",
39311
39188
  inputs: [
39312
39189
  {
39313
- name: "proofs",
39314
- type: "core::array::Span::<core::array::Span::<core::felt252>>"
39315
- },
39316
- {
39317
- name: "decoder_and_sanitizers",
39318
- type: "core::array::Span::<core::starknet::contract_address::ContractAddress>"
39319
- },
39320
- {
39321
- name: "targets",
39322
- type: "core::array::Span::<core::starknet::contract_address::ContractAddress>"
39323
- },
39324
- {
39325
- name: "selectors",
39326
- type: "core::array::Span::<core::felt252>"
39327
- },
39190
+ name: "token_id",
39191
+ type: "core::integer::u256"
39192
+ }
39193
+ ],
39194
+ outputs: [
39328
39195
  {
39329
- name: "calldatas",
39330
- type: "core::array::Span::<core::array::Span::<core::felt252>>"
39196
+ type: "core::starknet::contract_address::ContractAddress"
39331
39197
  }
39332
39198
  ],
39333
- outputs: [],
39334
- state_mutability: "external"
39199
+ state_mutability: "view"
39335
39200
  },
39336
39201
  {
39337
39202
  type: "function",
39338
- name: "flash_loan",
39203
+ name: "is_approved_for_all",
39339
39204
  inputs: [
39340
39205
  {
39341
- name: "recipient",
39206
+ name: "owner",
39342
39207
  type: "core::starknet::contract_address::ContractAddress"
39343
39208
  },
39344
39209
  {
39345
- name: "asset",
39210
+ name: "operator",
39346
39211
  type: "core::starknet::contract_address::ContractAddress"
39347
- },
39348
- {
39349
- name: "amount",
39350
- type: "core::integer::u256"
39351
- },
39212
+ }
39213
+ ],
39214
+ outputs: [
39352
39215
  {
39353
- name: "is_legacy",
39354
39216
  type: "core::bool"
39355
- },
39356
- {
39357
- name: "data",
39358
- type: "core::array::Span::<core::felt252>"
39359
39217
  }
39360
39218
  ],
39361
- outputs: [],
39362
- state_mutability: "external"
39219
+ state_mutability: "view"
39363
39220
  },
39364
39221
  {
39365
39222
  type: "function",
39366
- name: "get_leaf_hash",
39223
+ name: "supports_interface",
39367
39224
  inputs: [
39368
39225
  {
39369
- name: "decoder_and_sanitizer",
39370
- type: "core::starknet::contract_address::ContractAddress"
39371
- },
39372
- {
39373
- name: "target",
39374
- type: "core::starknet::contract_address::ContractAddress"
39375
- },
39376
- {
39377
- name: "selector",
39226
+ name: "interface_id",
39378
39227
  type: "core::felt252"
39379
- },
39228
+ }
39229
+ ],
39230
+ outputs: [
39380
39231
  {
39381
- name: "packed_argument_addresses",
39382
- type: "core::array::Span::<core::felt252>"
39232
+ type: "core::bool"
39383
39233
  }
39384
39234
  ],
39235
+ state_mutability: "view"
39236
+ },
39237
+ {
39238
+ type: "function",
39239
+ name: "name",
39240
+ inputs: [],
39385
39241
  outputs: [
39386
39242
  {
39387
- type: "core::felt252"
39243
+ type: "core::byte_array::ByteArray"
39388
39244
  }
39389
39245
  ],
39390
39246
  state_mutability: "view"
39391
- }
39392
- ]
39393
- },
39394
- {
39395
- type: "impl",
39396
- name: "AccessControlImpl",
39397
- interface_name: "openzeppelin_access::accesscontrol::interface::IAccessControl"
39398
- },
39399
- {
39400
- type: "interface",
39401
- name: "openzeppelin_access::accesscontrol::interface::IAccessControl",
39402
- items: [
39247
+ },
39403
39248
  {
39404
39249
  type: "function",
39405
- name: "has_role",
39250
+ name: "symbol",
39251
+ inputs: [],
39252
+ outputs: [
39253
+ {
39254
+ type: "core::byte_array::ByteArray"
39255
+ }
39256
+ ],
39257
+ state_mutability: "view"
39258
+ },
39259
+ {
39260
+ type: "function",
39261
+ name: "token_uri",
39406
39262
  inputs: [
39407
39263
  {
39408
- name: "role",
39409
- type: "core::felt252"
39410
- },
39264
+ name: "token_id",
39265
+ type: "core::integer::u256"
39266
+ }
39267
+ ],
39268
+ outputs: [
39269
+ {
39270
+ type: "core::byte_array::ByteArray"
39271
+ }
39272
+ ],
39273
+ state_mutability: "view"
39274
+ },
39275
+ {
39276
+ type: "function",
39277
+ name: "balanceOf",
39278
+ inputs: [
39411
39279
  {
39412
39280
  name: "account",
39413
39281
  type: "core::starknet::contract_address::ContractAddress"
@@ -39415,38 +39283,46 @@ var vault_manager_abi_default = [
39415
39283
  ],
39416
39284
  outputs: [
39417
39285
  {
39418
- type: "core::bool"
39286
+ type: "core::integer::u256"
39419
39287
  }
39420
39288
  ],
39421
39289
  state_mutability: "view"
39422
39290
  },
39423
39291
  {
39424
39292
  type: "function",
39425
- name: "get_role_admin",
39293
+ name: "ownerOf",
39426
39294
  inputs: [
39427
39295
  {
39428
- name: "role",
39429
- type: "core::felt252"
39296
+ name: "tokenId",
39297
+ type: "core::integer::u256"
39430
39298
  }
39431
39299
  ],
39432
39300
  outputs: [
39433
39301
  {
39434
- type: "core::felt252"
39302
+ type: "core::starknet::contract_address::ContractAddress"
39435
39303
  }
39436
39304
  ],
39437
39305
  state_mutability: "view"
39438
39306
  },
39439
39307
  {
39440
39308
  type: "function",
39441
- name: "grant_role",
39309
+ name: "safeTransferFrom",
39442
39310
  inputs: [
39443
39311
  {
39444
- name: "role",
39445
- type: "core::felt252"
39312
+ name: "from",
39313
+ type: "core::starknet::contract_address::ContractAddress"
39446
39314
  },
39447
39315
  {
39448
- name: "account",
39316
+ name: "to",
39449
39317
  type: "core::starknet::contract_address::ContractAddress"
39318
+ },
39319
+ {
39320
+ name: "tokenId",
39321
+ type: "core::integer::u256"
39322
+ },
39323
+ {
39324
+ name: "data",
39325
+ type: "core::array::Span::<core::felt252>"
39450
39326
  }
39451
39327
  ],
39452
39328
  outputs: [],
@@ -39454,15 +39330,19 @@ var vault_manager_abi_default = [
39454
39330
  },
39455
39331
  {
39456
39332
  type: "function",
39457
- name: "revoke_role",
39333
+ name: "transferFrom",
39458
39334
  inputs: [
39459
39335
  {
39460
- name: "role",
39461
- type: "core::felt252"
39336
+ name: "from",
39337
+ type: "core::starknet::contract_address::ContractAddress"
39462
39338
  },
39463
39339
  {
39464
- name: "account",
39340
+ name: "to",
39465
39341
  type: "core::starknet::contract_address::ContractAddress"
39342
+ },
39343
+ {
39344
+ name: "tokenId",
39345
+ type: "core::integer::u256"
39466
39346
  }
39467
39347
  ],
39468
39348
  outputs: [],
@@ -39470,188 +39350,246 @@ var vault_manager_abi_default = [
39470
39350
  },
39471
39351
  {
39472
39352
  type: "function",
39473
- name: "renounce_role",
39353
+ name: "setApprovalForAll",
39474
39354
  inputs: [
39475
39355
  {
39476
- name: "role",
39477
- type: "core::felt252"
39356
+ name: "operator",
39357
+ type: "core::starknet::contract_address::ContractAddress"
39478
39358
  },
39479
39359
  {
39480
- name: "account",
39481
- type: "core::starknet::contract_address::ContractAddress"
39360
+ name: "approved",
39361
+ type: "core::bool"
39482
39362
  }
39483
39363
  ],
39484
39364
  outputs: [],
39485
39365
  state_mutability: "external"
39366
+ },
39367
+ {
39368
+ type: "function",
39369
+ name: "getApproved",
39370
+ inputs: [
39371
+ {
39372
+ name: "tokenId",
39373
+ type: "core::integer::u256"
39374
+ }
39375
+ ],
39376
+ outputs: [
39377
+ {
39378
+ type: "core::starknet::contract_address::ContractAddress"
39379
+ }
39380
+ ],
39381
+ state_mutability: "view"
39382
+ },
39383
+ {
39384
+ type: "function",
39385
+ name: "isApprovedForAll",
39386
+ inputs: [
39387
+ {
39388
+ name: "owner",
39389
+ type: "core::starknet::contract_address::ContractAddress"
39390
+ },
39391
+ {
39392
+ name: "operator",
39393
+ type: "core::starknet::contract_address::ContractAddress"
39394
+ }
39395
+ ],
39396
+ outputs: [
39397
+ {
39398
+ type: "core::bool"
39399
+ }
39400
+ ],
39401
+ state_mutability: "view"
39402
+ },
39403
+ {
39404
+ type: "function",
39405
+ name: "tokenURI",
39406
+ inputs: [
39407
+ {
39408
+ name: "tokenId",
39409
+ type: "core::integer::u256"
39410
+ }
39411
+ ],
39412
+ outputs: [
39413
+ {
39414
+ type: "core::byte_array::ByteArray"
39415
+ }
39416
+ ],
39417
+ state_mutability: "view"
39486
39418
  }
39487
39419
  ]
39488
39420
  },
39489
39421
  {
39490
39422
  type: "impl",
39491
- name: "PausableImpl",
39492
- interface_name: "openzeppelin_security::interface::IPausable"
39423
+ name: "ERC721EnumerableImpl",
39424
+ interface_name: "openzeppelin_interfaces::token::erc721::IERC721Enumerable"
39493
39425
  },
39494
39426
  {
39495
39427
  type: "interface",
39496
- name: "openzeppelin_security::interface::IPausable",
39428
+ name: "openzeppelin_interfaces::token::erc721::IERC721Enumerable",
39497
39429
  items: [
39498
39430
  {
39499
39431
  type: "function",
39500
- name: "is_paused",
39432
+ name: "total_supply",
39501
39433
  inputs: [],
39502
39434
  outputs: [
39503
39435
  {
39504
- type: "core::bool"
39436
+ type: "core::integer::u256"
39505
39437
  }
39506
39438
  ],
39507
39439
  state_mutability: "view"
39508
- }
39509
- ]
39510
- },
39511
- {
39512
- type: "constructor",
39513
- name: "constructor",
39514
- inputs: [
39515
- {
39516
- name: "owner",
39517
- type: "core::starknet::contract_address::ContractAddress"
39518
- },
39519
- {
39520
- name: "vault_allocator",
39521
- type: "core::starknet::contract_address::ContractAddress"
39522
39440
  },
39523
39441
  {
39524
- name: "vesu_singleton",
39525
- type: "core::starknet::contract_address::ContractAddress"
39442
+ type: "function",
39443
+ name: "token_by_index",
39444
+ inputs: [
39445
+ {
39446
+ name: "index",
39447
+ type: "core::integer::u256"
39448
+ }
39449
+ ],
39450
+ outputs: [
39451
+ {
39452
+ type: "core::integer::u256"
39453
+ }
39454
+ ],
39455
+ state_mutability: "view"
39456
+ },
39457
+ {
39458
+ type: "function",
39459
+ name: "token_of_owner_by_index",
39460
+ inputs: [
39461
+ {
39462
+ name: "owner",
39463
+ type: "core::starknet::contract_address::ContractAddress"
39464
+ },
39465
+ {
39466
+ name: "index",
39467
+ type: "core::integer::u256"
39468
+ }
39469
+ ],
39470
+ outputs: [
39471
+ {
39472
+ type: "core::integer::u256"
39473
+ }
39474
+ ],
39475
+ state_mutability: "view"
39526
39476
  }
39527
39477
  ]
39528
39478
  },
39529
39479
  {
39530
- type: "event",
39531
- name: "openzeppelin_introspection::src5::SRC5Component::Event",
39532
- kind: "enum",
39533
- variants: []
39534
- },
39535
- {
39536
- type: "event",
39537
- name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGranted",
39538
- kind: "struct",
39539
- members: [
39540
- {
39541
- name: "role",
39542
- type: "core::felt252",
39543
- kind: "data"
39544
- },
39480
+ type: "constructor",
39481
+ name: "constructor",
39482
+ inputs: [
39545
39483
  {
39546
- name: "account",
39547
- type: "core::starknet::contract_address::ContractAddress",
39548
- kind: "data"
39484
+ name: "owner",
39485
+ type: "core::starknet::contract_address::ContractAddress"
39549
39486
  },
39550
39487
  {
39551
- name: "sender",
39552
- type: "core::starknet::contract_address::ContractAddress",
39553
- kind: "data"
39488
+ name: "vault",
39489
+ type: "core::starknet::contract_address::ContractAddress"
39554
39490
  }
39555
39491
  ]
39556
39492
  },
39557
39493
  {
39558
39494
  type: "event",
39559
- name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGrantedWithDelay",
39495
+ name: "openzeppelin_token::erc721::erc721::ERC721Component::Transfer",
39560
39496
  kind: "struct",
39561
39497
  members: [
39562
39498
  {
39563
- name: "role",
39564
- type: "core::felt252",
39565
- kind: "data"
39566
- },
39567
- {
39568
- name: "account",
39499
+ name: "from",
39569
39500
  type: "core::starknet::contract_address::ContractAddress",
39570
- kind: "data"
39501
+ kind: "key"
39571
39502
  },
39572
39503
  {
39573
- name: "sender",
39504
+ name: "to",
39574
39505
  type: "core::starknet::contract_address::ContractAddress",
39575
- kind: "data"
39506
+ kind: "key"
39576
39507
  },
39577
39508
  {
39578
- name: "delay",
39579
- type: "core::integer::u64",
39580
- kind: "data"
39509
+ name: "token_id",
39510
+ type: "core::integer::u256",
39511
+ kind: "key"
39581
39512
  }
39582
39513
  ]
39583
39514
  },
39584
39515
  {
39585
39516
  type: "event",
39586
- name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleRevoked",
39517
+ name: "openzeppelin_token::erc721::erc721::ERC721Component::Approval",
39587
39518
  kind: "struct",
39588
39519
  members: [
39589
39520
  {
39590
- name: "role",
39591
- type: "core::felt252",
39592
- kind: "data"
39521
+ name: "owner",
39522
+ type: "core::starknet::contract_address::ContractAddress",
39523
+ kind: "key"
39593
39524
  },
39594
39525
  {
39595
- name: "account",
39526
+ name: "approved",
39596
39527
  type: "core::starknet::contract_address::ContractAddress",
39597
- kind: "data"
39528
+ kind: "key"
39598
39529
  },
39599
39530
  {
39600
- name: "sender",
39601
- type: "core::starknet::contract_address::ContractAddress",
39602
- kind: "data"
39531
+ name: "token_id",
39532
+ type: "core::integer::u256",
39533
+ kind: "key"
39603
39534
  }
39604
39535
  ]
39605
39536
  },
39606
39537
  {
39607
39538
  type: "event",
39608
- name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleAdminChanged",
39539
+ name: "openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll",
39609
39540
  kind: "struct",
39610
39541
  members: [
39611
39542
  {
39612
- name: "role",
39613
- type: "core::felt252",
39614
- kind: "data"
39543
+ name: "owner",
39544
+ type: "core::starknet::contract_address::ContractAddress",
39545
+ kind: "key"
39615
39546
  },
39616
39547
  {
39617
- name: "previous_admin_role",
39618
- type: "core::felt252",
39619
- kind: "data"
39548
+ name: "operator",
39549
+ type: "core::starknet::contract_address::ContractAddress",
39550
+ kind: "key"
39620
39551
  },
39621
39552
  {
39622
- name: "new_admin_role",
39623
- type: "core::felt252",
39553
+ name: "approved",
39554
+ type: "core::bool",
39624
39555
  kind: "data"
39625
39556
  }
39626
39557
  ]
39627
39558
  },
39628
39559
  {
39629
39560
  type: "event",
39630
- name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::Event",
39561
+ name: "openzeppelin_token::erc721::erc721::ERC721Component::Event",
39631
39562
  kind: "enum",
39632
39563
  variants: [
39633
39564
  {
39634
- name: "RoleGranted",
39635
- type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGranted",
39636
- kind: "nested"
39637
- },
39638
- {
39639
- name: "RoleGrantedWithDelay",
39640
- type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGrantedWithDelay",
39565
+ name: "Transfer",
39566
+ type: "openzeppelin_token::erc721::erc721::ERC721Component::Transfer",
39641
39567
  kind: "nested"
39642
39568
  },
39643
39569
  {
39644
- name: "RoleRevoked",
39645
- type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleRevoked",
39570
+ name: "Approval",
39571
+ type: "openzeppelin_token::erc721::erc721::ERC721Component::Approval",
39646
39572
  kind: "nested"
39647
39573
  },
39648
39574
  {
39649
- name: "RoleAdminChanged",
39650
- type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleAdminChanged",
39575
+ name: "ApprovalForAll",
39576
+ type: "openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll",
39651
39577
  kind: "nested"
39652
39578
  }
39653
39579
  ]
39654
39580
  },
39581
+ {
39582
+ type: "event",
39583
+ name: "openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Event",
39584
+ kind: "enum",
39585
+ variants: []
39586
+ },
39587
+ {
39588
+ type: "event",
39589
+ name: "openzeppelin_introspection::src5::SRC5Component::Event",
39590
+ kind: "enum",
39591
+ variants: []
39592
+ },
39655
39593
  {
39656
39594
  type: "event",
39657
39595
  name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
@@ -39678,390 +39616,1352 @@ var vault_manager_abi_default = [
39678
39616
  },
39679
39617
  {
39680
39618
  type: "event",
39681
- name: "openzeppelin_security::pausable::PausableComponent::Paused",
39682
- kind: "struct",
39683
- members: [
39684
- {
39685
- name: "account",
39686
- type: "core::starknet::contract_address::ContractAddress",
39687
- kind: "data"
39688
- }
39689
- ]
39690
- },
39691
- {
39692
- type: "event",
39693
- name: "openzeppelin_security::pausable::PausableComponent::Unpaused",
39694
- kind: "struct",
39695
- members: [
39696
- {
39697
- name: "account",
39698
- type: "core::starknet::contract_address::ContractAddress",
39699
- kind: "data"
39700
- }
39701
- ]
39702
- },
39703
- {
39704
- type: "event",
39705
- name: "openzeppelin_security::pausable::PausableComponent::Event",
39619
+ name: "vault::redeem_request::redeem_request::RedeemRequest::Event",
39706
39620
  kind: "enum",
39707
39621
  variants: [
39708
39622
  {
39709
- name: "Paused",
39710
- type: "openzeppelin_security::pausable::PausableComponent::Paused",
39711
- kind: "nested"
39623
+ name: "ERC721Event",
39624
+ type: "openzeppelin_token::erc721::erc721::ERC721Component::Event",
39625
+ kind: "flat"
39712
39626
  },
39713
39627
  {
39714
- name: "Unpaused",
39715
- type: "openzeppelin_security::pausable::PausableComponent::Unpaused",
39716
- kind: "nested"
39717
- }
39718
- ]
39719
- },
39720
- {
39721
- type: "event",
39722
- name: "vault_allocator::manager::manager::Manager::Event",
39723
- kind: "enum",
39724
- variants: [
39628
+ name: "ERC721EnumerableEvent",
39629
+ type: "openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Event",
39630
+ kind: "flat"
39631
+ },
39725
39632
  {
39726
39633
  name: "SRC5Event",
39727
39634
  type: "openzeppelin_introspection::src5::SRC5Component::Event",
39728
- kind: "nested"
39729
- },
39730
- {
39731
- name: "AccessControlEvent",
39732
- type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::Event",
39733
- kind: "nested"
39635
+ kind: "flat"
39734
39636
  },
39735
39637
  {
39736
39638
  name: "UpgradeableEvent",
39737
39639
  type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
39738
- kind: "nested"
39739
- },
39740
- {
39741
- name: "PausableEvent",
39742
- type: "openzeppelin_security::pausable::PausableComponent::Event",
39743
- kind: "nested"
39640
+ kind: "flat"
39744
39641
  }
39745
39642
  ]
39746
39643
  }
39747
39644
  ];
39748
39645
 
39749
- // src/strategies/types.ts
39750
- var LSTPriceType = /* @__PURE__ */ ((LSTPriceType2) => {
39751
- LSTPriceType2["ENDUR_PRICE"] = "ENDUR_PRICE";
39752
- LSTPriceType2["AVNU_PRICE"] = "AVNU_PRICE";
39753
- return LSTPriceType2;
39754
- })(LSTPriceType || {});
39755
-
39756
- // src/strategies/universal-strategy.tsx
39757
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
39758
- var AUMTypes = /* @__PURE__ */ ((AUMTypes2) => {
39759
- AUMTypes2["FINALISED"] = "finalised";
39760
- AUMTypes2["DEFISPRING"] = "defispring";
39761
- return AUMTypes2;
39762
- })(AUMTypes || {});
39763
- var PositionTypeAvnuExtended = /* @__PURE__ */ ((PositionTypeAvnuExtended2) => {
39764
- PositionTypeAvnuExtended2["OPEN"] = "open";
39765
- PositionTypeAvnuExtended2["CLOSE"] = "close";
39766
- return PositionTypeAvnuExtended2;
39767
- })(PositionTypeAvnuExtended || {});
39768
- var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
39769
- constructor(config, pricer, metadata) {
39770
- super(config);
39771
- this.pricer = pricer;
39772
- assert(
39773
- metadata.depositTokens.length === 1,
39774
- "VesuRebalance only supports 1 deposit token"
39775
- );
39776
- this.metadata = metadata;
39777
- this.address = metadata.address;
39778
- this.contract = new Contract15({
39779
- abi: universal_vault_abi_default,
39780
- address: this.address.address,
39781
- providerOrAccount: this.config.provider
39782
- });
39783
- this.managerContract = new Contract15({
39784
- abi: vault_manager_abi_default,
39785
- address: this.metadata.additionalInfo.manager.address,
39786
- providerOrAccount: this.config.provider
39787
- });
39646
+ // src/strategies/universal-adapters/svk-troves-adapter.ts
39647
+ var DEFAULT_TROVES_STRATEGIES_API = "https://app.troves.fi/api/strategies";
39648
+ function parseTrovesApyField(raw) {
39649
+ if (typeof raw === "number" && Number.isFinite(raw)) {
39650
+ return raw;
39788
39651
  }
39789
- getMerkleTree() {
39790
- if (this.merkleTree) return this.merkleTree;
39791
- const leaves = this.metadata.additionalInfo.leafAdapters.map((adapter, index) => {
39792
- return adapter();
39793
- });
39794
- const standardTree = StandardMerkleTree.of(leaves.flatMap((l) => l.leaves));
39795
- this.merkleTree = standardTree;
39796
- return standardTree;
39652
+ if (typeof raw === "string") {
39653
+ const n = Number.parseFloat(raw);
39654
+ if (Number.isFinite(n)) {
39655
+ return n;
39656
+ }
39797
39657
  }
39798
- getMerkleRoot() {
39799
- return this.getMerkleTree().root;
39658
+ return 0;
39659
+ }
39660
+ var SvkTrovesAdapter = class _SvkTrovesAdapter extends BaseAdapter {
39661
+ constructor(config) {
39662
+ super(config, _SvkTrovesAdapter.name, Protocols.TROVES);
39663
+ this.config = config;
39800
39664
  }
39801
- getProofs(id) {
39802
- const tree = this.getMerkleTree();
39803
- let proofs = [];
39804
- for (const [i, v] of tree.entries()) {
39805
- if (v.readableId == id) {
39806
- proofs = tree.getProof(i);
39807
- }
39808
- }
39809
- if (proofs.length === 0) {
39810
- throw new Error(`Proof not found for ID: ${id}`);
39665
+ /** Owner used for share balance + `due_assets_from_owner`. */
39666
+ _positionOwner() {
39667
+ return this.config.positionOwner ?? this.config.vaultAllocator;
39668
+ }
39669
+ /**
39670
+ * Proof readable IDs must stay ≤ 31 chars (Cairo short string). We derive a short ASCII suffix from
39671
+ * `strategyVault` address so multiple SVK adapters in one tree stay distinct.
39672
+ */
39673
+ _proofSuffix() {
39674
+ return this.config.strategyVault.address.replace(/^0x/, "").slice(-6);
39675
+ }
39676
+ _depositApproveProofReadableId() {
39677
+ return `appr_dep_svk_${this._proofSuffix()}`;
39678
+ }
39679
+ _depositCallProofReadableId() {
39680
+ return `dep_svk_${this._proofSuffix()}`;
39681
+ }
39682
+ _withdrawCallProofReadableId() {
39683
+ return `wtdrw_svk_${this._proofSuffix()}`;
39684
+ }
39685
+ async getAPY(supportedPosition) {
39686
+ const CACHE_KEY = `svk_apy_${this.config.trovesStrategyId}`;
39687
+ const cached = this.getCache(CACHE_KEY);
39688
+ if (cached) {
39689
+ return cached;
39811
39690
  }
39812
- const leafAdapter = this.metadata.additionalInfo.leafAdapters.find((adapter) => adapter().leaves[0]?.readableId === id);
39813
- if (!leafAdapter) {
39814
- throw new Error(`Leaf adapter not found for ID: ${id}`);
39691
+ const url = this.config.trovesStrategiesApiUrl ?? DEFAULT_TROVES_STRATEGIES_API;
39692
+ try {
39693
+ const res = await fetch(url);
39694
+ if (!res.ok) {
39695
+ logger.warn(`${_SvkTrovesAdapter.name}::getAPY: HTTP ${res.status} from ${url}`);
39696
+ const fallback = { apy: 0, type: "base" /* BASE */ };
39697
+ this.setCache(CACHE_KEY, fallback, 3e5);
39698
+ return fallback;
39699
+ }
39700
+ const body = await res.json();
39701
+ const row = body.strategies?.find((s) => s.id === this.config.trovesStrategyId);
39702
+ if (!row) {
39703
+ logger.warn(
39704
+ `${_SvkTrovesAdapter.name}::getAPY: strategy id not found: ${this.config.trovesStrategyId}`
39705
+ );
39706
+ const fallback = { apy: 0, type: "base" /* BASE */ };
39707
+ this.setCache(CACHE_KEY, fallback, 3e5);
39708
+ return fallback;
39709
+ }
39710
+ const apy = parseTrovesApyField(row.apy);
39711
+ const result = { apy, type: "base" /* BASE */ };
39712
+ this.setCache(CACHE_KEY, result, 3e5);
39713
+ return result;
39714
+ } catch (error) {
39715
+ logger.error(`${_SvkTrovesAdapter.name}::getAPY:`, error);
39716
+ throw error;
39815
39717
  }
39816
- const leafInfo = leafAdapter();
39817
- return {
39818
- proofs,
39819
- callConstructor: leafInfo.callConstructor.bind(leafInfo)
39820
- };
39821
39718
  }
39822
- getAdapter(id) {
39823
- const adapter = this.metadata.additionalInfo.adapters.find((adapter2) => adapter2.id === id);
39824
- if (!adapter) {
39825
- throw new Error(`Adapter not found for ID: ${id}`);
39719
+ async getPosition(supportedPosition) {
39720
+ const CACHE_KEY = `svk_pos_${this.config.strategyVault.address}_${this._positionOwner().address}`;
39721
+ const cached = this.getCache(CACHE_KEY);
39722
+ if (cached) {
39723
+ return cached;
39724
+ }
39725
+ try {
39726
+ const vault = new Contract14({
39727
+ abi: universal_vault_abi_default,
39728
+ address: this.config.strategyVault.address,
39729
+ providerOrAccount: this.config.networkConfig.provider
39730
+ });
39731
+ const owner = this._positionOwner();
39732
+ const decimals = supportedPosition.asset.decimals;
39733
+ const shares = await vault.balance_of(owner.address);
39734
+ const shareU256 = uint25619.bnToUint256(shares);
39735
+ const liquidAssetsRaw = await vault.convert_to_assets(shareU256);
39736
+ const liquid = Web3Number.fromWei(liquidAssetsRaw.toString(), decimals);
39737
+ let pending = Web3Number.fromWei("0", decimals);
39738
+ try {
39739
+ const dueRaw = await vault.call("due_assets_from_owner", [owner.address]);
39740
+ pending = Web3Number.fromWei(dueRaw.toString(), decimals);
39741
+ } catch (e) {
39742
+ logger.warn(
39743
+ `${_SvkTrovesAdapter.name}::getPosition: due_assets_from_owner failed (treating as 0): ${e.message}`
39744
+ );
39745
+ }
39746
+ const total = liquid.plus(pending);
39747
+ const remarks = `Troves ${this.config.trovesStrategyId} holdings`;
39748
+ const result = {
39749
+ amount: total,
39750
+ remarks
39751
+ };
39752
+ this.setCache(CACHE_KEY, result, 6e4);
39753
+ return result;
39754
+ } catch (error) {
39755
+ logger.error(`${_SvkTrovesAdapter.name}::getPosition:`, error);
39756
+ throw error;
39826
39757
  }
39827
- return adapter.adapter;
39828
- }
39829
- asset() {
39830
- return this.metadata.depositTokens[0];
39831
39758
  }
39832
- async depositCall(amountInfo, receiver) {
39833
- assert(
39834
- amountInfo.tokenInfo.address.eq(this.asset().address),
39835
- "Deposit token mismatch"
39836
- );
39837
- const assetContract = new Contract15({
39759
+ async getPendingAssetsFromOwner(owner = this._positionOwner(), decimals = this.config.baseToken.decimals) {
39760
+ const vault = new Contract14({
39838
39761
  abi: universal_vault_abi_default,
39839
- address: this.asset().address.address,
39840
- providerOrAccount: this.config.provider
39762
+ address: this.config.strategyVault.address,
39763
+ providerOrAccount: this.config.networkConfig.provider
39841
39764
  });
39842
- const call1 = assetContract.populate("approve", [
39843
- this.address.address,
39844
- uint25620.bnToUint256(amountInfo.amount.toWei())
39845
- ]);
39846
- const call2 = this.contract.populate("deposit", [
39847
- uint25620.bnToUint256(amountInfo.amount.toWei()),
39848
- receiver.address
39849
- ]);
39850
- return [call1, call2];
39765
+ try {
39766
+ const dueRaw = await vault.call("due_assets_from_owner", [owner.address]);
39767
+ return Web3Number.fromWei(dueRaw.toString(), decimals);
39768
+ } catch (e) {
39769
+ logger.warn(
39770
+ `${_SvkTrovesAdapter.name}::getPendingAssetsFromOwner: due_assets_from_owner failed (treating as 0): ${e.message}`
39771
+ );
39772
+ return Web3Number.fromWei("0", decimals);
39773
+ }
39851
39774
  }
39852
- async withdrawCall(amountInfo, receiver, owner) {
39853
- assert(
39854
- amountInfo.tokenInfo.address.eq(this.asset().address),
39855
- "Withdraw token mismatch"
39856
- );
39857
- const shares = await this.contract.call("convert_to_shares", [uint25620.bnToUint256(amountInfo.amount.toWei())]);
39858
- const call = this.contract.populate("request_redeem", [
39859
- uint25620.bnToUint256(shares.toString()),
39860
- receiver.address,
39861
- owner.address
39862
- ]);
39863
- return [call];
39775
+ /**
39776
+ * Get pending assets from owner by scanning redeem request NFTs.
39777
+ * This method iterates backwards through NFT IDs to find all pending redemptions for a specific owner.
39778
+ *
39779
+ * @param redeemRequestNFT - The redeem request NFT contract address
39780
+ * @param owner - The owner address to check for pending redemptions (defaults to positionOwner)
39781
+ * @param decimals - Token decimals for conversion (defaults to baseToken decimals)
39782
+ * @returns Total pending assets from all NFTs owned by the specified address
39783
+ */
39784
+ async getPendingAssetsFromOwnerNFTMethod(redeemRequestNFT, owner = this._positionOwner(), decimals = this.config.baseToken.decimals) {
39785
+ try {
39786
+ const nftContract = new Contract14({
39787
+ abi: redeem_request_nft_abi_default,
39788
+ address: redeemRequestNFT.address,
39789
+ providerOrAccount: this.config.networkConfig.provider
39790
+ });
39791
+ const idLenRaw = await nftContract.id_len();
39792
+ const latestId = BigInt(idLenRaw.toString());
39793
+ if (latestId === 0n) {
39794
+ logger.info(
39795
+ `${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: No NFTs minted yet`
39796
+ );
39797
+ return Web3Number.fromWei("0", decimals);
39798
+ }
39799
+ const matchingIds = [];
39800
+ let currentId = latestId - 1n;
39801
+ while (currentId >= 0n) {
39802
+ try {
39803
+ const idU256 = uint25619.bnToUint256(currentId);
39804
+ const ownerRaw = await nftContract.owner_of(idU256);
39805
+ const nftOwnerAddr = ContractAddr.from(ownerRaw.toString());
39806
+ if (nftOwnerAddr.eq(owner)) {
39807
+ matchingIds.push(currentId);
39808
+ logger.debug(
39809
+ `${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Found matching NFT ID ${currentId} for owner ${owner.address}`
39810
+ );
39811
+ }
39812
+ currentId--;
39813
+ } catch (e) {
39814
+ logger.info(
39815
+ `${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Reached last pending NFT at id ${currentId}`
39816
+ );
39817
+ break;
39818
+ }
39819
+ }
39820
+ if (matchingIds.length === 0) {
39821
+ logger.info(
39822
+ `${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: No matching NFTs found for owner ${owner.address}`
39823
+ );
39824
+ return Web3Number.fromWei("0", decimals);
39825
+ }
39826
+ let totalNominal = 0n;
39827
+ for (const nftId of matchingIds) {
39828
+ try {
39829
+ const idU256 = uint25619.bnToUint256(nftId);
39830
+ const infoRaw = await nftContract.id_to_info(idU256);
39831
+ const nominal = BigInt(infoRaw.nominal.toString());
39832
+ totalNominal += nominal;
39833
+ logger.debug(
39834
+ `${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: NFT ID ${nftId} has nominal ${nominal}`
39835
+ );
39836
+ } catch (e) {
39837
+ logger.warn(
39838
+ `${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Failed to get info for NFT ID ${nftId}: ${e.message}`
39839
+ );
39840
+ }
39841
+ }
39842
+ logger.info(
39843
+ `${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Found ${matchingIds.length} NFTs with total nominal ${totalNominal}`
39844
+ );
39845
+ return Web3Number.fromWei(totalNominal.toString(), decimals);
39846
+ } catch (error) {
39847
+ logger.error(
39848
+ `${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: ${error.message}`
39849
+ );
39850
+ return Web3Number.fromWei("0", decimals);
39851
+ }
39864
39852
  }
39865
- async getUserTVL(user, blockIdentifier = "latest") {
39866
- const shares = await this.contract.call("balanceOf", [user.address], { blockIdentifier });
39867
- const assets = await this.contract.call(
39868
- "convert_to_assets",
39869
- [uint25620.bnToUint256(shares)],
39870
- { blockIdentifier }
39871
- );
39872
- const amount = Web3Number.fromWei(
39873
- assets.toString(),
39874
- this.metadata.depositTokens[0].decimals
39875
- );
39876
- const blockNumber = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : void 0;
39877
- let price = await this.pricer.getPrice(
39878
- this.metadata.depositTokens[0].symbol,
39879
- blockNumber
39880
- );
39881
- const usdValue = Number(amount.toFixed(6)) * price.price;
39853
+ async maxDeposit(amount) {
39854
+ const baseToken = this.config.baseToken;
39855
+ if (!amount) {
39856
+ return {
39857
+ tokenInfo: baseToken,
39858
+ amount: new Web3Number("999999999999999999999999999", baseToken.decimals),
39859
+ usdValue: 1e27,
39860
+ remarks: "Max deposit (unbounded placeholder)",
39861
+ apy: await this.getAPY({ asset: baseToken, isDebt: false }),
39862
+ protocol: this.protocol
39863
+ };
39864
+ }
39865
+ const usdValue = await this.getUSDValue(baseToken, amount);
39882
39866
  return {
39883
- tokenInfo: this.asset(),
39867
+ tokenInfo: baseToken,
39884
39868
  amount,
39885
- usdValue
39869
+ usdValue,
39870
+ remarks: "Deposit amount",
39871
+ apy: await this.getAPY({ asset: baseToken, isDebt: false }),
39872
+ protocol: this.protocol
39886
39873
  };
39887
39874
  }
39888
- async getVesuAPYs() {
39889
- const vesuAdapters = this.getVesuAdapters();
39890
- const allVesuPools = await VesuAdapter.getVesuPools();
39891
- const pools = vesuAdapters.map((vesuAdapter) => {
39892
- return allVesuPools.pools.find((p) => vesuAdapter.config.poolId.eqString(num12.getHexString(p.id)));
39893
- });
39894
- logger.verbose(`${this.metadata.name}::netAPY: vesu-pools: ${JSON.stringify(pools)}`);
39895
- if (pools.some((p) => !p)) {
39896
- throw new Error("Pool not found");
39897
- }
39898
- ;
39899
- const positions = await this.getVesuPositions();
39900
- logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
39901
- const baseAPYs = [];
39902
- const rewardAPYs = [];
39903
- for (const [index, pool] of pools.entries()) {
39904
- const vesuAdapter = vesuAdapters[index];
39905
- const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
39906
- const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
39907
- const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
39908
- const lstAPY = await this.getLSTAPR(vesuAdapter.config.collateral.address);
39909
- logger.verbose(`${this.metadata.name}::netAPY: ${vesuAdapter.config.collateral.symbol} LST APR from Endur: ${lstAPY}`);
39910
- baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
39911
- rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
39912
- }
39913
- logger.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
39914
- logger.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
39915
- assert(baseAPYs.length == positions.length, "APYs and positions length mismatch");
39875
+ async maxWithdraw() {
39876
+ const baseToken = this.config.baseToken;
39877
+ const current = await this.getPosition({ asset: baseToken, isDebt: false });
39878
+ const pos = current ?? { amount: new Web3Number("0", baseToken.decimals), remarks: "" };
39879
+ const usdValue = await this.getUSDValue(baseToken, pos.amount);
39916
39880
  return {
39917
- baseAPYs,
39918
- rewardAPYs,
39919
- positions
39881
+ tokenInfo: baseToken,
39882
+ amount: pos.amount,
39883
+ usdValue,
39884
+ remarks: "Max withdraw (liquid + pending redemption, underlying units)",
39885
+ apy: await this.getAPY({ asset: baseToken, isDebt: false }),
39886
+ protocol: this.protocol
39920
39887
  };
39921
39888
  }
39922
- /**
39923
- * Calculates the weighted average APY across all pools based on USD value.
39924
- * @returns {Promise<number>} The weighted average APY across all pools
39925
- */
39926
- async netAPY() {
39927
- if (this.metadata.isPreview) {
39928
- return { net: 0, splits: [{
39929
- apy: 0,
39930
- id: "base"
39931
- }, {
39932
- apy: 0,
39933
- id: "defispring"
39934
- }] };
39935
- }
39936
- const { positions, baseAPYs, rewardAPYs } = await this.getVesuAPYs();
39937
- const unusedBalanceAPY = await this.getUnusedBalanceAPY();
39938
- baseAPYs.push(...[unusedBalanceAPY.apy]);
39939
- rewardAPYs.push(0);
39940
- const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
39941
- weights.push(unusedBalanceAPY.weight);
39942
- const prevAUM = await this.getPrevAUM();
39943
- const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
39944
- const prevAUMUSD = prevAUM.multipliedBy(price.price);
39945
- return this.returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD);
39946
- }
39947
- async returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD) {
39948
- if (weights.every((p) => p == 0)) {
39949
- return { net: 0, splits: [{
39950
- apy: 0,
39951
- id: "base"
39952
- }, {
39953
- apy: 0,
39954
- id: "defispring"
39955
- }] };
39956
- }
39957
- const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
39958
- const rewardAPY = this.computeAPY(rewardAPYs, weights, prevAUMUSD);
39959
- const netAPY = baseAPY + rewardAPY;
39960
- logger.verbose(`${this.metadata.name}::netAPY: net: ${netAPY}, baseAPY: ${baseAPY}, rewardAPY: ${rewardAPY}`);
39961
- return { net: netAPY, splits: [{
39962
- apy: baseAPY,
39963
- id: "base"
39964
- }, {
39965
- apy: rewardAPY,
39966
- id: "defispring"
39967
- }] };
39889
+ _getDepositLeaf() {
39890
+ const baseToken = this.config.baseToken;
39891
+ const strategyVault = this.config.strategyVault;
39892
+ const receiver = this.config.vaultAllocator;
39893
+ return [
39894
+ {
39895
+ target: baseToken.address,
39896
+ method: "approve",
39897
+ packedArguments: [strategyVault.toBigInt()],
39898
+ sanitizer: SIMPLE_SANITIZER,
39899
+ id: this._depositApproveProofReadableId()
39900
+ },
39901
+ {
39902
+ target: strategyVault,
39903
+ method: "deposit",
39904
+ packedArguments: [receiver.toBigInt()],
39905
+ sanitizer: SIMPLE_SANITIZER,
39906
+ id: this._depositCallProofReadableId()
39907
+ }
39908
+ ];
39968
39909
  }
39969
- async getUnusedBalanceAPY() {
39970
- return {
39971
- apy: 0,
39972
- weight: 0
39973
- };
39910
+ _getWithdrawLeaf() {
39911
+ const strategyVault = this.config.strategyVault;
39912
+ const recv = this.config.vaultAllocator;
39913
+ const owner = this.config.vaultAllocator;
39914
+ return [
39915
+ {
39916
+ target: strategyVault,
39917
+ method: "request_redeem",
39918
+ packedArguments: [recv.toBigInt(), owner.toBigInt()],
39919
+ sanitizer: SVK_SIMPLE_SANITIZER,
39920
+ id: this._withdrawCallProofReadableId()
39921
+ }
39922
+ ];
39974
39923
  }
39975
- computeAPY(apys, weights, currentAUM) {
39976
- assert(apys.length === weights.length, "APYs and weights length mismatch");
39977
- const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
39978
- logger.verbose(`${this.getTag()} computeAPY: apys: ${JSON.stringify(apys)}, weights: ${JSON.stringify(weights)}, weightedSum: ${weightedSum}, currentAUM: ${currentAUM}`);
39979
- return weightedSum / currentAUM.toNumber();
39924
+ getDepositAdapter() {
39925
+ const leafConfigs = this._getDepositLeaf();
39926
+ const leaves = leafConfigs.map((config) => {
39927
+ const { target, method, packedArguments, sanitizer, id } = config;
39928
+ return this.constructSimpleLeafData({ id, target, method, packedArguments }, sanitizer);
39929
+ });
39930
+ return { leaves, callConstructor: this.getDepositCall.bind(this) };
39980
39931
  }
39981
- /**
39982
- * Calculates user realized APY based on trueSharesBasedAPY method.
39983
- * Returns the APY as a number.
39984
- */
39985
- async getUserRealizedAPY(blockIdentifier = "latest", sinceBlocks = 6e5) {
39986
- logger.verbose(
39987
- `${this.getTag()}: getUserRealizedAPY => starting with blockIdentifier=${blockIdentifier}, sinceBlocks=${sinceBlocks}`
39988
- );
39989
- let blockNow = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : (await this.config.provider.getBlockLatestAccepted()).block_number;
39990
- const blockNowTime = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? (await this.config.provider.getBlockWithTxs(blockIdentifier)).timestamp : (/* @__PURE__ */ new Date()).getTime() / 1e3;
39991
- const blockBefore = Math.max(
39992
- blockNow - sinceBlocks,
39993
- this.metadata.launchBlock
39994
- );
39995
- const assetsNowRaw = await this.contract.call("total_assets", [], {
39996
- blockIdentifier
39932
+ getWithdrawAdapter() {
39933
+ const leafConfigs = this._getWithdrawLeaf();
39934
+ const leaves = leafConfigs.map((config) => {
39935
+ const { target, method, packedArguments, sanitizer, id } = config;
39936
+ return this.constructSimpleLeafData({ id, target, method, packedArguments }, sanitizer);
39997
39937
  });
39998
- const amountNow = Web3Number.fromWei(
39999
- assetsNowRaw.toString(),
40000
- this.metadata.depositTokens[0].decimals
40001
- );
40002
- const supplyNowRaw = await this.contract.call("total_supply", [], {
40003
- blockIdentifier
39938
+ return { leaves, callConstructor: this.getWithdrawCall.bind(this) };
39939
+ }
39940
+ async getDepositCall(params) {
39941
+ const baseToken = this.config.baseToken;
39942
+ const strategyVault = this.config.strategyVault;
39943
+ const amount = params.amount;
39944
+ const uint256Amount = uint25619.bnToUint256(amount.toWei());
39945
+ const receiver = this.config.vaultAllocator;
39946
+ return [
39947
+ {
39948
+ proofReadableId: this._depositApproveProofReadableId(),
39949
+ sanitizer: SIMPLE_SANITIZER,
39950
+ call: {
39951
+ contractAddress: baseToken.address,
39952
+ selector: hash11.getSelectorFromName("approve"),
39953
+ calldata: [
39954
+ strategyVault.toBigInt(),
39955
+ toBigInt(uint256Amount.low.toString()),
39956
+ toBigInt(uint256Amount.high.toString())
39957
+ ]
39958
+ }
39959
+ },
39960
+ {
39961
+ proofReadableId: this._depositCallProofReadableId(),
39962
+ sanitizer: SIMPLE_SANITIZER,
39963
+ call: {
39964
+ contractAddress: strategyVault,
39965
+ selector: hash11.getSelectorFromName("deposit"),
39966
+ calldata: [
39967
+ toBigInt(uint256Amount.low.toString()),
39968
+ toBigInt(uint256Amount.high.toString()),
39969
+ receiver.toBigInt()
39970
+ ]
39971
+ }
39972
+ }
39973
+ ];
39974
+ }
39975
+ async getWithdrawCall(params) {
39976
+ const strategyVault = this.config.strategyVault;
39977
+ const amount = params.amount;
39978
+ const uint256Amount = uint25619.bnToUint256(amount.toWei());
39979
+ const recv = this.config.vaultAllocator;
39980
+ const owner = this.config.vaultAllocator;
39981
+ const vault = new Contract14({
39982
+ abi: universal_vault_abi_default,
39983
+ address: strategyVault.address,
39984
+ providerOrAccount: this.config.networkConfig.provider
40004
39985
  });
40005
- const supplyNow = Web3Number.fromWei(supplyNowRaw.toString(), 18);
40006
- const assetsBeforeRaw = await this.contract.call(
40007
- "total_assets",
40008
- [],
40009
- { blockIdentifier: blockBefore }
40010
- );
40011
- const amountBefore = Web3Number.fromWei(
40012
- assetsBeforeRaw.toString(),
40013
- this.metadata.depositTokens[0].decimals
40014
- );
40015
- const supplyBeforeRaw = await this.contract.call(
40016
- "total_supply",
40017
- [],
40018
- { blockIdentifier: blockBefore }
40019
- );
40020
- const supplyBefore = Web3Number.fromWei(supplyBeforeRaw.toString(), 18);
40021
- const blockBeforeInfo = await this.config.provider.getBlockWithTxs(
40022
- blockBefore
40023
- );
40024
- const assetsPerShareNow = amountNow.multipliedBy(1e18).dividedBy(supplyNow.toString());
40025
- const assetsPerShareBf = amountBefore.multipliedBy(1e18).dividedBy(supplyBefore.toString());
40026
- const timeDiffSeconds = blockNowTime - blockBeforeInfo.timestamp;
40027
- logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsNow: ${amountNow.toString()}`);
40028
- logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsBefore: ${amountBefore.toString()}`);
40029
- logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsPerShareNow: ${assetsPerShareNow.toString()}`);
40030
- logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsPerShareBf: ${assetsPerShareBf.toString()}`);
40031
- logger.verbose(`${this.getTag()} [getUserRealizedAPY] Supply before: ${supplyBefore.toString()}`);
40032
- logger.verbose(`${this.getTag()} [getUserRealizedAPY] Supply now: ${supplyNow.toString()}`);
40033
- logger.verbose(`${this.getTag()} [getUserRealizedAPY] Time diff in seconds: ${timeDiffSeconds}`);
40034
- const apyForGivenBlocks = Number(
40035
- assetsPerShareNow.minus(assetsPerShareBf).multipliedBy(1e4).dividedBy(assetsPerShareBf)
40036
- ) / 1e4;
40037
- return apyForGivenBlocks * (365 * 24 * 3600) / timeDiffSeconds;
39986
+ const sharesRaw = await vault.convert_to_shares(uint256Amount);
39987
+ const sharesU256 = uint25619.bnToUint256(sharesRaw.toString());
39988
+ return [
39989
+ {
39990
+ proofReadableId: this._withdrawCallProofReadableId(),
39991
+ sanitizer: SVK_SIMPLE_SANITIZER,
39992
+ call: {
39993
+ contractAddress: strategyVault,
39994
+ selector: hash11.getSelectorFromName("request_redeem"),
39995
+ calldata: [
39996
+ toBigInt(sharesU256.low.toString()),
39997
+ toBigInt(sharesU256.high.toString()),
39998
+ recv.toBigInt(),
39999
+ owner.toBigInt()
40000
+ ]
40001
+ }
40002
+ }
40003
+ ];
40038
40004
  }
40039
- /**
40040
- * Calculates the total TVL of the strategy.
40041
- * @returns Object containing the total amount in token units and USD value
40042
- */
40043
- async getTVL() {
40044
- const assets = await this.contract.total_assets();
40045
- const amount = Web3Number.fromWei(
40046
- assets.toString(),
40047
- this.metadata.depositTokens[0].decimals
40048
- );
40049
- let price = await this.pricer.getPrice(
40050
- this.metadata.depositTokens[0].symbol
40051
- );
40052
- const usdValue = Number(amount.toFixed(6)) * price.price;
40053
- return {
40054
- tokenInfo: this.asset(),
40055
- amount,
40056
- usdValue
40057
- };
40005
+ getHealthFactor() {
40006
+ return Promise.resolve(10);
40058
40007
  }
40059
- async getUnusedBalance() {
40060
- const balance = await new ERC20(this.config).balanceOf(this.asset().address, this.metadata.additionalInfo.vaultAllocator, this.asset().decimals);
40061
- const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
40062
- const usdValue = Number(balance.toFixed(6)) * price.price;
40063
- return {
40064
- tokenInfo: this.asset(),
40008
+ };
40009
+
40010
+ // src/strategies/universal-strategy.tsx
40011
+ import { CallData, Contract as Contract15, num as num12, uint256 as uint25620 } from "starknet";
40012
+
40013
+ // src/data/vault-manager.abi.json
40014
+ var vault_manager_abi_default = [
40015
+ {
40016
+ type: "impl",
40017
+ name: "UpgradeableImpl",
40018
+ interface_name: "openzeppelin_upgrades::interface::IUpgradeable"
40019
+ },
40020
+ {
40021
+ type: "interface",
40022
+ name: "openzeppelin_upgrades::interface::IUpgradeable",
40023
+ items: [
40024
+ {
40025
+ type: "function",
40026
+ name: "upgrade",
40027
+ inputs: [
40028
+ {
40029
+ name: "new_class_hash",
40030
+ type: "core::starknet::class_hash::ClassHash"
40031
+ }
40032
+ ],
40033
+ outputs: [],
40034
+ state_mutability: "external"
40035
+ }
40036
+ ]
40037
+ },
40038
+ {
40039
+ type: "impl",
40040
+ name: "ManagerFlashloanReceiverImpl",
40041
+ interface_name: "vault_allocator::integration_interfaces::vesu::IFlashloanReceiver"
40042
+ },
40043
+ {
40044
+ type: "struct",
40045
+ name: "core::integer::u256",
40046
+ members: [
40047
+ {
40048
+ name: "low",
40049
+ type: "core::integer::u128"
40050
+ },
40051
+ {
40052
+ name: "high",
40053
+ type: "core::integer::u128"
40054
+ }
40055
+ ]
40056
+ },
40057
+ {
40058
+ type: "struct",
40059
+ name: "core::array::Span::<core::felt252>",
40060
+ members: [
40061
+ {
40062
+ name: "snapshot",
40063
+ type: "@core::array::Array::<core::felt252>"
40064
+ }
40065
+ ]
40066
+ },
40067
+ {
40068
+ type: "interface",
40069
+ name: "vault_allocator::integration_interfaces::vesu::IFlashloanReceiver",
40070
+ items: [
40071
+ {
40072
+ type: "function",
40073
+ name: "on_flash_loan",
40074
+ inputs: [
40075
+ {
40076
+ name: "sender",
40077
+ type: "core::starknet::contract_address::ContractAddress"
40078
+ },
40079
+ {
40080
+ name: "asset",
40081
+ type: "core::starknet::contract_address::ContractAddress"
40082
+ },
40083
+ {
40084
+ name: "amount",
40085
+ type: "core::integer::u256"
40086
+ },
40087
+ {
40088
+ name: "data",
40089
+ type: "core::array::Span::<core::felt252>"
40090
+ }
40091
+ ],
40092
+ outputs: [],
40093
+ state_mutability: "external"
40094
+ }
40095
+ ]
40096
+ },
40097
+ {
40098
+ type: "impl",
40099
+ name: "ManagerImpl",
40100
+ interface_name: "vault_allocator::manager::interface::IManager"
40101
+ },
40102
+ {
40103
+ type: "struct",
40104
+ name: "core::array::Span::<core::array::Span::<core::felt252>>",
40105
+ members: [
40106
+ {
40107
+ name: "snapshot",
40108
+ type: "@core::array::Array::<core::array::Span::<core::felt252>>"
40109
+ }
40110
+ ]
40111
+ },
40112
+ {
40113
+ type: "struct",
40114
+ name: "core::array::Span::<core::starknet::contract_address::ContractAddress>",
40115
+ members: [
40116
+ {
40117
+ name: "snapshot",
40118
+ type: "@core::array::Array::<core::starknet::contract_address::ContractAddress>"
40119
+ }
40120
+ ]
40121
+ },
40122
+ {
40123
+ type: "enum",
40124
+ name: "core::bool",
40125
+ variants: [
40126
+ {
40127
+ name: "False",
40128
+ type: "()"
40129
+ },
40130
+ {
40131
+ name: "True",
40132
+ type: "()"
40133
+ }
40134
+ ]
40135
+ },
40136
+ {
40137
+ type: "interface",
40138
+ name: "vault_allocator::manager::interface::IManager",
40139
+ items: [
40140
+ {
40141
+ type: "function",
40142
+ name: "vesu_singleton",
40143
+ inputs: [],
40144
+ outputs: [
40145
+ {
40146
+ type: "core::starknet::contract_address::ContractAddress"
40147
+ }
40148
+ ],
40149
+ state_mutability: "view"
40150
+ },
40151
+ {
40152
+ type: "function",
40153
+ name: "vault_allocator",
40154
+ inputs: [],
40155
+ outputs: [
40156
+ {
40157
+ type: "core::starknet::contract_address::ContractAddress"
40158
+ }
40159
+ ],
40160
+ state_mutability: "view"
40161
+ },
40162
+ {
40163
+ type: "function",
40164
+ name: "set_manage_root",
40165
+ inputs: [
40166
+ {
40167
+ name: "target",
40168
+ type: "core::starknet::contract_address::ContractAddress"
40169
+ },
40170
+ {
40171
+ name: "root",
40172
+ type: "core::felt252"
40173
+ }
40174
+ ],
40175
+ outputs: [],
40176
+ state_mutability: "external"
40177
+ },
40178
+ {
40179
+ type: "function",
40180
+ name: "manage_root",
40181
+ inputs: [
40182
+ {
40183
+ name: "target",
40184
+ type: "core::starknet::contract_address::ContractAddress"
40185
+ }
40186
+ ],
40187
+ outputs: [
40188
+ {
40189
+ type: "core::felt252"
40190
+ }
40191
+ ],
40192
+ state_mutability: "view"
40193
+ },
40194
+ {
40195
+ type: "function",
40196
+ name: "pause",
40197
+ inputs: [],
40198
+ outputs: [],
40199
+ state_mutability: "external"
40200
+ },
40201
+ {
40202
+ type: "function",
40203
+ name: "unpause",
40204
+ inputs: [],
40205
+ outputs: [],
40206
+ state_mutability: "external"
40207
+ },
40208
+ {
40209
+ type: "function",
40210
+ name: "manage_vault_with_merkle_verification",
40211
+ inputs: [
40212
+ {
40213
+ name: "proofs",
40214
+ type: "core::array::Span::<core::array::Span::<core::felt252>>"
40215
+ },
40216
+ {
40217
+ name: "decoder_and_sanitizers",
40218
+ type: "core::array::Span::<core::starknet::contract_address::ContractAddress>"
40219
+ },
40220
+ {
40221
+ name: "targets",
40222
+ type: "core::array::Span::<core::starknet::contract_address::ContractAddress>"
40223
+ },
40224
+ {
40225
+ name: "selectors",
40226
+ type: "core::array::Span::<core::felt252>"
40227
+ },
40228
+ {
40229
+ name: "calldatas",
40230
+ type: "core::array::Span::<core::array::Span::<core::felt252>>"
40231
+ }
40232
+ ],
40233
+ outputs: [],
40234
+ state_mutability: "external"
40235
+ },
40236
+ {
40237
+ type: "function",
40238
+ name: "flash_loan",
40239
+ inputs: [
40240
+ {
40241
+ name: "recipient",
40242
+ type: "core::starknet::contract_address::ContractAddress"
40243
+ },
40244
+ {
40245
+ name: "asset",
40246
+ type: "core::starknet::contract_address::ContractAddress"
40247
+ },
40248
+ {
40249
+ name: "amount",
40250
+ type: "core::integer::u256"
40251
+ },
40252
+ {
40253
+ name: "is_legacy",
40254
+ type: "core::bool"
40255
+ },
40256
+ {
40257
+ name: "data",
40258
+ type: "core::array::Span::<core::felt252>"
40259
+ }
40260
+ ],
40261
+ outputs: [],
40262
+ state_mutability: "external"
40263
+ },
40264
+ {
40265
+ type: "function",
40266
+ name: "get_leaf_hash",
40267
+ inputs: [
40268
+ {
40269
+ name: "decoder_and_sanitizer",
40270
+ type: "core::starknet::contract_address::ContractAddress"
40271
+ },
40272
+ {
40273
+ name: "target",
40274
+ type: "core::starknet::contract_address::ContractAddress"
40275
+ },
40276
+ {
40277
+ name: "selector",
40278
+ type: "core::felt252"
40279
+ },
40280
+ {
40281
+ name: "packed_argument_addresses",
40282
+ type: "core::array::Span::<core::felt252>"
40283
+ }
40284
+ ],
40285
+ outputs: [
40286
+ {
40287
+ type: "core::felt252"
40288
+ }
40289
+ ],
40290
+ state_mutability: "view"
40291
+ }
40292
+ ]
40293
+ },
40294
+ {
40295
+ type: "impl",
40296
+ name: "AccessControlImpl",
40297
+ interface_name: "openzeppelin_access::accesscontrol::interface::IAccessControl"
40298
+ },
40299
+ {
40300
+ type: "interface",
40301
+ name: "openzeppelin_access::accesscontrol::interface::IAccessControl",
40302
+ items: [
40303
+ {
40304
+ type: "function",
40305
+ name: "has_role",
40306
+ inputs: [
40307
+ {
40308
+ name: "role",
40309
+ type: "core::felt252"
40310
+ },
40311
+ {
40312
+ name: "account",
40313
+ type: "core::starknet::contract_address::ContractAddress"
40314
+ }
40315
+ ],
40316
+ outputs: [
40317
+ {
40318
+ type: "core::bool"
40319
+ }
40320
+ ],
40321
+ state_mutability: "view"
40322
+ },
40323
+ {
40324
+ type: "function",
40325
+ name: "get_role_admin",
40326
+ inputs: [
40327
+ {
40328
+ name: "role",
40329
+ type: "core::felt252"
40330
+ }
40331
+ ],
40332
+ outputs: [
40333
+ {
40334
+ type: "core::felt252"
40335
+ }
40336
+ ],
40337
+ state_mutability: "view"
40338
+ },
40339
+ {
40340
+ type: "function",
40341
+ name: "grant_role",
40342
+ inputs: [
40343
+ {
40344
+ name: "role",
40345
+ type: "core::felt252"
40346
+ },
40347
+ {
40348
+ name: "account",
40349
+ type: "core::starknet::contract_address::ContractAddress"
40350
+ }
40351
+ ],
40352
+ outputs: [],
40353
+ state_mutability: "external"
40354
+ },
40355
+ {
40356
+ type: "function",
40357
+ name: "revoke_role",
40358
+ inputs: [
40359
+ {
40360
+ name: "role",
40361
+ type: "core::felt252"
40362
+ },
40363
+ {
40364
+ name: "account",
40365
+ type: "core::starknet::contract_address::ContractAddress"
40366
+ }
40367
+ ],
40368
+ outputs: [],
40369
+ state_mutability: "external"
40370
+ },
40371
+ {
40372
+ type: "function",
40373
+ name: "renounce_role",
40374
+ inputs: [
40375
+ {
40376
+ name: "role",
40377
+ type: "core::felt252"
40378
+ },
40379
+ {
40380
+ name: "account",
40381
+ type: "core::starknet::contract_address::ContractAddress"
40382
+ }
40383
+ ],
40384
+ outputs: [],
40385
+ state_mutability: "external"
40386
+ }
40387
+ ]
40388
+ },
40389
+ {
40390
+ type: "impl",
40391
+ name: "PausableImpl",
40392
+ interface_name: "openzeppelin_security::interface::IPausable"
40393
+ },
40394
+ {
40395
+ type: "interface",
40396
+ name: "openzeppelin_security::interface::IPausable",
40397
+ items: [
40398
+ {
40399
+ type: "function",
40400
+ name: "is_paused",
40401
+ inputs: [],
40402
+ outputs: [
40403
+ {
40404
+ type: "core::bool"
40405
+ }
40406
+ ],
40407
+ state_mutability: "view"
40408
+ }
40409
+ ]
40410
+ },
40411
+ {
40412
+ type: "constructor",
40413
+ name: "constructor",
40414
+ inputs: [
40415
+ {
40416
+ name: "owner",
40417
+ type: "core::starknet::contract_address::ContractAddress"
40418
+ },
40419
+ {
40420
+ name: "vault_allocator",
40421
+ type: "core::starknet::contract_address::ContractAddress"
40422
+ },
40423
+ {
40424
+ name: "vesu_singleton",
40425
+ type: "core::starknet::contract_address::ContractAddress"
40426
+ }
40427
+ ]
40428
+ },
40429
+ {
40430
+ type: "event",
40431
+ name: "openzeppelin_introspection::src5::SRC5Component::Event",
40432
+ kind: "enum",
40433
+ variants: []
40434
+ },
40435
+ {
40436
+ type: "event",
40437
+ name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGranted",
40438
+ kind: "struct",
40439
+ members: [
40440
+ {
40441
+ name: "role",
40442
+ type: "core::felt252",
40443
+ kind: "data"
40444
+ },
40445
+ {
40446
+ name: "account",
40447
+ type: "core::starknet::contract_address::ContractAddress",
40448
+ kind: "data"
40449
+ },
40450
+ {
40451
+ name: "sender",
40452
+ type: "core::starknet::contract_address::ContractAddress",
40453
+ kind: "data"
40454
+ }
40455
+ ]
40456
+ },
40457
+ {
40458
+ type: "event",
40459
+ name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGrantedWithDelay",
40460
+ kind: "struct",
40461
+ members: [
40462
+ {
40463
+ name: "role",
40464
+ type: "core::felt252",
40465
+ kind: "data"
40466
+ },
40467
+ {
40468
+ name: "account",
40469
+ type: "core::starknet::contract_address::ContractAddress",
40470
+ kind: "data"
40471
+ },
40472
+ {
40473
+ name: "sender",
40474
+ type: "core::starknet::contract_address::ContractAddress",
40475
+ kind: "data"
40476
+ },
40477
+ {
40478
+ name: "delay",
40479
+ type: "core::integer::u64",
40480
+ kind: "data"
40481
+ }
40482
+ ]
40483
+ },
40484
+ {
40485
+ type: "event",
40486
+ name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleRevoked",
40487
+ kind: "struct",
40488
+ members: [
40489
+ {
40490
+ name: "role",
40491
+ type: "core::felt252",
40492
+ kind: "data"
40493
+ },
40494
+ {
40495
+ name: "account",
40496
+ type: "core::starknet::contract_address::ContractAddress",
40497
+ kind: "data"
40498
+ },
40499
+ {
40500
+ name: "sender",
40501
+ type: "core::starknet::contract_address::ContractAddress",
40502
+ kind: "data"
40503
+ }
40504
+ ]
40505
+ },
40506
+ {
40507
+ type: "event",
40508
+ name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleAdminChanged",
40509
+ kind: "struct",
40510
+ members: [
40511
+ {
40512
+ name: "role",
40513
+ type: "core::felt252",
40514
+ kind: "data"
40515
+ },
40516
+ {
40517
+ name: "previous_admin_role",
40518
+ type: "core::felt252",
40519
+ kind: "data"
40520
+ },
40521
+ {
40522
+ name: "new_admin_role",
40523
+ type: "core::felt252",
40524
+ kind: "data"
40525
+ }
40526
+ ]
40527
+ },
40528
+ {
40529
+ type: "event",
40530
+ name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::Event",
40531
+ kind: "enum",
40532
+ variants: [
40533
+ {
40534
+ name: "RoleGranted",
40535
+ type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGranted",
40536
+ kind: "nested"
40537
+ },
40538
+ {
40539
+ name: "RoleGrantedWithDelay",
40540
+ type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGrantedWithDelay",
40541
+ kind: "nested"
40542
+ },
40543
+ {
40544
+ name: "RoleRevoked",
40545
+ type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleRevoked",
40546
+ kind: "nested"
40547
+ },
40548
+ {
40549
+ name: "RoleAdminChanged",
40550
+ type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleAdminChanged",
40551
+ kind: "nested"
40552
+ }
40553
+ ]
40554
+ },
40555
+ {
40556
+ type: "event",
40557
+ name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
40558
+ kind: "struct",
40559
+ members: [
40560
+ {
40561
+ name: "class_hash",
40562
+ type: "core::starknet::class_hash::ClassHash",
40563
+ kind: "data"
40564
+ }
40565
+ ]
40566
+ },
40567
+ {
40568
+ type: "event",
40569
+ name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
40570
+ kind: "enum",
40571
+ variants: [
40572
+ {
40573
+ name: "Upgraded",
40574
+ type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
40575
+ kind: "nested"
40576
+ }
40577
+ ]
40578
+ },
40579
+ {
40580
+ type: "event",
40581
+ name: "openzeppelin_security::pausable::PausableComponent::Paused",
40582
+ kind: "struct",
40583
+ members: [
40584
+ {
40585
+ name: "account",
40586
+ type: "core::starknet::contract_address::ContractAddress",
40587
+ kind: "data"
40588
+ }
40589
+ ]
40590
+ },
40591
+ {
40592
+ type: "event",
40593
+ name: "openzeppelin_security::pausable::PausableComponent::Unpaused",
40594
+ kind: "struct",
40595
+ members: [
40596
+ {
40597
+ name: "account",
40598
+ type: "core::starknet::contract_address::ContractAddress",
40599
+ kind: "data"
40600
+ }
40601
+ ]
40602
+ },
40603
+ {
40604
+ type: "event",
40605
+ name: "openzeppelin_security::pausable::PausableComponent::Event",
40606
+ kind: "enum",
40607
+ variants: [
40608
+ {
40609
+ name: "Paused",
40610
+ type: "openzeppelin_security::pausable::PausableComponent::Paused",
40611
+ kind: "nested"
40612
+ },
40613
+ {
40614
+ name: "Unpaused",
40615
+ type: "openzeppelin_security::pausable::PausableComponent::Unpaused",
40616
+ kind: "nested"
40617
+ }
40618
+ ]
40619
+ },
40620
+ {
40621
+ type: "event",
40622
+ name: "vault_allocator::manager::manager::Manager::Event",
40623
+ kind: "enum",
40624
+ variants: [
40625
+ {
40626
+ name: "SRC5Event",
40627
+ type: "openzeppelin_introspection::src5::SRC5Component::Event",
40628
+ kind: "nested"
40629
+ },
40630
+ {
40631
+ name: "AccessControlEvent",
40632
+ type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::Event",
40633
+ kind: "nested"
40634
+ },
40635
+ {
40636
+ name: "UpgradeableEvent",
40637
+ type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
40638
+ kind: "nested"
40639
+ },
40640
+ {
40641
+ name: "PausableEvent",
40642
+ type: "openzeppelin_security::pausable::PausableComponent::Event",
40643
+ kind: "nested"
40644
+ }
40645
+ ]
40646
+ }
40647
+ ];
40648
+
40649
+ // src/strategies/types.ts
40650
+ var LSTPriceType = /* @__PURE__ */ ((LSTPriceType2) => {
40651
+ LSTPriceType2["ENDUR_PRICE"] = "ENDUR_PRICE";
40652
+ LSTPriceType2["AVNU_PRICE"] = "AVNU_PRICE";
40653
+ return LSTPriceType2;
40654
+ })(LSTPriceType || {});
40655
+
40656
+ // src/strategies/universal-strategy.tsx
40657
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
40658
+ var AUMTypes = /* @__PURE__ */ ((AUMTypes2) => {
40659
+ AUMTypes2["FINALISED"] = "finalised";
40660
+ AUMTypes2["DEFISPRING"] = "defispring";
40661
+ return AUMTypes2;
40662
+ })(AUMTypes || {});
40663
+ var PositionTypeAvnuExtended = /* @__PURE__ */ ((PositionTypeAvnuExtended2) => {
40664
+ PositionTypeAvnuExtended2["OPEN"] = "open";
40665
+ PositionTypeAvnuExtended2["CLOSE"] = "close";
40666
+ return PositionTypeAvnuExtended2;
40667
+ })(PositionTypeAvnuExtended || {});
40668
+ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
40669
+ constructor(config, pricer, metadata) {
40670
+ super(config);
40671
+ this.pricer = pricer;
40672
+ assert(
40673
+ metadata.depositTokens.length === 1,
40674
+ "VesuRebalance only supports 1 deposit token"
40675
+ );
40676
+ this.metadata = metadata;
40677
+ this.address = metadata.address;
40678
+ this.contract = new Contract15({
40679
+ abi: universal_vault_abi_default,
40680
+ address: this.address.address,
40681
+ providerOrAccount: this.config.provider
40682
+ });
40683
+ this.managerContract = new Contract15({
40684
+ abi: vault_manager_abi_default,
40685
+ address: this.metadata.additionalInfo.manager.address,
40686
+ providerOrAccount: this.config.provider
40687
+ });
40688
+ }
40689
+ getMerkleTree() {
40690
+ if (this.merkleTree) return this.merkleTree;
40691
+ const leaves = this.metadata.additionalInfo.leafAdapters.map((adapter, index) => {
40692
+ return adapter();
40693
+ });
40694
+ const standardTree = StandardMerkleTree.of(leaves.flatMap((l) => l.leaves));
40695
+ this.merkleTree = standardTree;
40696
+ return standardTree;
40697
+ }
40698
+ getMerkleRoot() {
40699
+ return this.getMerkleTree().root;
40700
+ }
40701
+ getProofs(id) {
40702
+ const tree = this.getMerkleTree();
40703
+ let proofs = [];
40704
+ for (const [i, v] of tree.entries()) {
40705
+ if (v.readableId == id) {
40706
+ proofs = tree.getProof(i);
40707
+ }
40708
+ }
40709
+ if (proofs.length === 0) {
40710
+ throw new Error(`Proof not found for ID: ${id}`);
40711
+ }
40712
+ const leafAdapter = this.metadata.additionalInfo.leafAdapters.find((adapter) => adapter().leaves[0]?.readableId === id);
40713
+ if (!leafAdapter) {
40714
+ throw new Error(`Leaf adapter not found for ID: ${id}`);
40715
+ }
40716
+ const leafInfo = leafAdapter();
40717
+ return {
40718
+ proofs,
40719
+ callConstructor: leafInfo.callConstructor.bind(leafInfo)
40720
+ };
40721
+ }
40722
+ getAdapter(id) {
40723
+ const adapter = this.metadata.additionalInfo.adapters.find((adapter2) => adapter2.id === id);
40724
+ if (!adapter) {
40725
+ throw new Error(`Adapter not found for ID: ${id}`);
40726
+ }
40727
+ return adapter.adapter;
40728
+ }
40729
+ asset() {
40730
+ return this.metadata.depositTokens[0];
40731
+ }
40732
+ async depositCall(amountInfo, receiver) {
40733
+ assert(
40734
+ amountInfo.tokenInfo.address.eq(this.asset().address),
40735
+ "Deposit token mismatch"
40736
+ );
40737
+ const assetContract = new Contract15({
40738
+ abi: universal_vault_abi_default,
40739
+ address: this.asset().address.address,
40740
+ providerOrAccount: this.config.provider
40741
+ });
40742
+ const call1 = assetContract.populate("approve", [
40743
+ this.address.address,
40744
+ uint25620.bnToUint256(amountInfo.amount.toWei())
40745
+ ]);
40746
+ const call2 = this.contract.populate("deposit", [
40747
+ uint25620.bnToUint256(amountInfo.amount.toWei()),
40748
+ receiver.address
40749
+ ]);
40750
+ return [call1, call2];
40751
+ }
40752
+ async withdrawCall(amountInfo, receiver, owner) {
40753
+ assert(
40754
+ amountInfo.tokenInfo.address.eq(this.asset().address),
40755
+ "Withdraw token mismatch"
40756
+ );
40757
+ const shares = await this.contract.call("convert_to_shares", [uint25620.bnToUint256(amountInfo.amount.toWei())]);
40758
+ const call = this.contract.populate("request_redeem", [
40759
+ uint25620.bnToUint256(shares.toString()),
40760
+ receiver.address,
40761
+ owner.address
40762
+ ]);
40763
+ return [call];
40764
+ }
40765
+ async getUserTVL(user, blockIdentifier = "latest") {
40766
+ const shares = await this.contract.call("balanceOf", [user.address], { blockIdentifier });
40767
+ const assets = await this.contract.call(
40768
+ "convert_to_assets",
40769
+ [uint25620.bnToUint256(shares)],
40770
+ { blockIdentifier }
40771
+ );
40772
+ const amount = Web3Number.fromWei(
40773
+ assets.toString(),
40774
+ this.metadata.depositTokens[0].decimals
40775
+ );
40776
+ const blockNumber = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : void 0;
40777
+ let price = await this.pricer.getPrice(
40778
+ this.metadata.depositTokens[0].symbol,
40779
+ blockNumber
40780
+ );
40781
+ const usdValue = Number(amount.toFixed(6)) * price.price;
40782
+ return {
40783
+ tokenInfo: this.asset(),
40784
+ amount,
40785
+ usdValue
40786
+ };
40787
+ }
40788
+ async getVesuAPYs() {
40789
+ const vesuAdapters = this.getVesuAdapters();
40790
+ const allVesuPools = await VesuAdapter.getVesuPools();
40791
+ const pools = vesuAdapters.map((vesuAdapter) => {
40792
+ return allVesuPools.pools.find((p) => vesuAdapter.config.poolId.eqString(num12.getHexString(p.id)));
40793
+ });
40794
+ logger.verbose(`${this.metadata.name}::netAPY: vesu-pools: ${JSON.stringify(pools)}`);
40795
+ if (pools.some((p) => !p)) {
40796
+ throw new Error("Pool not found");
40797
+ }
40798
+ ;
40799
+ const positions = await this.getVesuPositions();
40800
+ logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
40801
+ const baseAPYs = [];
40802
+ const rewardAPYs = [];
40803
+ for (const [index, pool] of pools.entries()) {
40804
+ const vesuAdapter = vesuAdapters[index];
40805
+ const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
40806
+ const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
40807
+ const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
40808
+ const lstAPY = await this.getLSTAPR(vesuAdapter.config.collateral.address);
40809
+ logger.verbose(`${this.metadata.name}::netAPY: ${vesuAdapter.config.collateral.symbol} LST APR from Endur: ${lstAPY}`);
40810
+ baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
40811
+ rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
40812
+ }
40813
+ logger.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
40814
+ logger.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
40815
+ assert(baseAPYs.length == positions.length, "APYs and positions length mismatch");
40816
+ return {
40817
+ baseAPYs,
40818
+ rewardAPYs,
40819
+ positions
40820
+ };
40821
+ }
40822
+ /**
40823
+ * Calculates the weighted average APY across all pools based on USD value.
40824
+ * @returns {Promise<number>} The weighted average APY across all pools
40825
+ */
40826
+ async netAPY() {
40827
+ if (this.metadata.isPreview) {
40828
+ return { net: 0, splits: [{
40829
+ apy: 0,
40830
+ id: "base"
40831
+ }, {
40832
+ apy: 0,
40833
+ id: "defispring"
40834
+ }] };
40835
+ }
40836
+ const { positions, baseAPYs, rewardAPYs } = await this.getVesuAPYs();
40837
+ const unusedBalanceAPY = await this.getUnusedBalanceAPY();
40838
+ baseAPYs.push(...[unusedBalanceAPY.apy]);
40839
+ rewardAPYs.push(0);
40840
+ const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
40841
+ weights.push(unusedBalanceAPY.weight);
40842
+ const prevAUM = await this.getPrevAUM();
40843
+ const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
40844
+ const prevAUMUSD = prevAUM.multipliedBy(price.price);
40845
+ return this.returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD);
40846
+ }
40847
+ async returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD) {
40848
+ if (weights.every((p) => p == 0)) {
40849
+ return { net: 0, splits: [{
40850
+ apy: 0,
40851
+ id: "base"
40852
+ }, {
40853
+ apy: 0,
40854
+ id: "defispring"
40855
+ }] };
40856
+ }
40857
+ const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
40858
+ const rewardAPY = this.computeAPY(rewardAPYs, weights, prevAUMUSD);
40859
+ const netAPY = baseAPY + rewardAPY;
40860
+ logger.verbose(`${this.metadata.name}::netAPY: net: ${netAPY}, baseAPY: ${baseAPY}, rewardAPY: ${rewardAPY}`);
40861
+ return { net: netAPY, splits: [{
40862
+ apy: baseAPY,
40863
+ id: "base"
40864
+ }, {
40865
+ apy: rewardAPY,
40866
+ id: "defispring"
40867
+ }] };
40868
+ }
40869
+ async getUnusedBalanceAPY() {
40870
+ return {
40871
+ apy: 0,
40872
+ weight: 0
40873
+ };
40874
+ }
40875
+ computeAPY(apys, weights, currentAUM) {
40876
+ assert(apys.length === weights.length, "APYs and weights length mismatch");
40877
+ const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
40878
+ logger.verbose(`${this.getTag()} computeAPY: apys: ${JSON.stringify(apys)}, weights: ${JSON.stringify(weights)}, weightedSum: ${weightedSum}, currentAUM: ${currentAUM}`);
40879
+ return weightedSum / currentAUM.toNumber();
40880
+ }
40881
+ /**
40882
+ * Calculates user realized APY based on trueSharesBasedAPY method.
40883
+ * Returns the APY as a number.
40884
+ */
40885
+ async getUserRealizedAPY(blockIdentifier = "latest", sinceBlocks = 6e5) {
40886
+ logger.verbose(
40887
+ `${this.getTag()}: getUserRealizedAPY => starting with blockIdentifier=${blockIdentifier}, sinceBlocks=${sinceBlocks}`
40888
+ );
40889
+ let blockNow = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : (await this.config.provider.getBlockLatestAccepted()).block_number;
40890
+ const blockNowTime = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? (await this.config.provider.getBlockWithTxs(blockIdentifier)).timestamp : (/* @__PURE__ */ new Date()).getTime() / 1e3;
40891
+ const blockBefore = Math.max(
40892
+ blockNow - sinceBlocks,
40893
+ this.metadata.launchBlock
40894
+ );
40895
+ const assetsNowRaw = await this.contract.call("total_assets", [], {
40896
+ blockIdentifier
40897
+ });
40898
+ const amountNow = Web3Number.fromWei(
40899
+ assetsNowRaw.toString(),
40900
+ this.metadata.depositTokens[0].decimals
40901
+ );
40902
+ const supplyNowRaw = await this.contract.call("total_supply", [], {
40903
+ blockIdentifier
40904
+ });
40905
+ const supplyNow = Web3Number.fromWei(supplyNowRaw.toString(), 18);
40906
+ const assetsBeforeRaw = await this.contract.call(
40907
+ "total_assets",
40908
+ [],
40909
+ { blockIdentifier: blockBefore }
40910
+ );
40911
+ const amountBefore = Web3Number.fromWei(
40912
+ assetsBeforeRaw.toString(),
40913
+ this.metadata.depositTokens[0].decimals
40914
+ );
40915
+ const supplyBeforeRaw = await this.contract.call(
40916
+ "total_supply",
40917
+ [],
40918
+ { blockIdentifier: blockBefore }
40919
+ );
40920
+ const supplyBefore = Web3Number.fromWei(supplyBeforeRaw.toString(), 18);
40921
+ const blockBeforeInfo = await this.config.provider.getBlockWithTxs(
40922
+ blockBefore
40923
+ );
40924
+ const assetsPerShareNow = amountNow.multipliedBy(1e18).dividedBy(supplyNow.toString());
40925
+ const assetsPerShareBf = amountBefore.multipliedBy(1e18).dividedBy(supplyBefore.toString());
40926
+ const timeDiffSeconds = blockNowTime - blockBeforeInfo.timestamp;
40927
+ logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsNow: ${amountNow.toString()}`);
40928
+ logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsBefore: ${amountBefore.toString()}`);
40929
+ logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsPerShareNow: ${assetsPerShareNow.toString()}`);
40930
+ logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsPerShareBf: ${assetsPerShareBf.toString()}`);
40931
+ logger.verbose(`${this.getTag()} [getUserRealizedAPY] Supply before: ${supplyBefore.toString()}`);
40932
+ logger.verbose(`${this.getTag()} [getUserRealizedAPY] Supply now: ${supplyNow.toString()}`);
40933
+ logger.verbose(`${this.getTag()} [getUserRealizedAPY] Time diff in seconds: ${timeDiffSeconds}`);
40934
+ const apyForGivenBlocks = Number(
40935
+ assetsPerShareNow.minus(assetsPerShareBf).multipliedBy(1e4).dividedBy(assetsPerShareBf)
40936
+ ) / 1e4;
40937
+ return apyForGivenBlocks * (365 * 24 * 3600) / timeDiffSeconds;
40938
+ }
40939
+ /**
40940
+ * Calculates the total TVL of the strategy.
40941
+ * @returns Object containing the total amount in token units and USD value
40942
+ */
40943
+ async getTVL() {
40944
+ const assets = await this.contract.total_assets();
40945
+ const amount = Web3Number.fromWei(
40946
+ assets.toString(),
40947
+ this.metadata.depositTokens[0].decimals
40948
+ );
40949
+ let price = await this.pricer.getPrice(
40950
+ this.metadata.depositTokens[0].symbol
40951
+ );
40952
+ const usdValue = Number(amount.toFixed(6)) * price.price;
40953
+ return {
40954
+ tokenInfo: this.asset(),
40955
+ amount,
40956
+ usdValue
40957
+ };
40958
+ }
40959
+ async getUnusedBalance() {
40960
+ const balance = await new ERC20(this.config).balanceOf(this.asset().address, this.metadata.additionalInfo.vaultAllocator, this.asset().decimals);
40961
+ const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
40962
+ const usdValue = Number(balance.toFixed(6)) * price.price;
40963
+ return {
40964
+ tokenInfo: this.asset(),
40065
40965
  amount: balance,
40066
40966
  usdValue
40067
40967
  };
@@ -40879,9 +41779,9 @@ var SVKStrategy = class extends BaseStrategy {
40879
41779
  * Builds a manage call from an adapter's proof tree.
40880
41780
  * DRY helper for the repeated getProofs → getManageCall pattern.
40881
41781
  */
40882
- async buildManageCallFromAdapter(adapter, isDeposit, amount) {
41782
+ async buildManageCallFromAdapter(adapter, isDeposit, amount, additionalParams) {
40883
41783
  const proofsInfo = adapter.getProofs(isDeposit, this.getMerkleTree());
40884
- const manageCalls = await proofsInfo.callConstructor({ amount });
41784
+ const manageCalls = await proofsInfo.callConstructor({ amount, ...additionalParams });
40885
41785
  return this.getManageCall(
40886
41786
  this.getProofGroupsForManageCalls(manageCalls),
40887
41787
  manageCalls
@@ -41901,177 +42801,697 @@ var hyperxLBTC = {
41901
42801
  underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "LBTC"),
41902
42802
  quoteAmountToFetchPrice: new Web3Number("0.001", Global.getDefaultTokens().find((token) => token.symbol === "LBTC").decimals)
41903
42803
  };
41904
- var hypermRe7BTC = {
41905
- vaultAddress: ContractAddr.from("0x6c89b75d09de82477edb86b2c2918cfc1a5dc0177cfbdea46278386b6499645"),
41906
- manager: ContractAddr.from("0x7bc2d0535e13352d3ab78ea047616a3162068294297304943d2302122a150a1"),
41907
- vaultAllocator: ContractAddr.from("0x760f9cebca9d2ee624f4224591da6da8b3ea5fd2410590735709551bd4e7570"),
41908
- redeemRequestNFT: ContractAddr.from("0x5e045ae0160f7650f8a4dd7c826f25630a89fe62434db4441e7e0075608180f"),
41909
- aumOracle: ContractAddr.from("0x3958df341b838813c24efb9183c23bddd1c57d44b1b86c0dd57f67887b89fba"),
41910
- leafAdapters: [],
41911
- adapters: [],
41912
- targetHealthFactor: 1.1,
41913
- minHealthFactor: 1.05,
41914
- borrowable_assets: borrowableAssets.map((asset) => Global.getDefaultTokens().find((token) => token.symbol === asset)),
41915
- underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "WBTC"),
41916
- quoteAmountToFetchPrice: new Web3Number("0.001", Global.getDefaultTokens().find((token) => token.symbol === "mRe7BTC").decimals)
42804
+ var hypermRe7BTC = {
42805
+ vaultAddress: ContractAddr.from("0x6c89b75d09de82477edb86b2c2918cfc1a5dc0177cfbdea46278386b6499645"),
42806
+ manager: ContractAddr.from("0x7bc2d0535e13352d3ab78ea047616a3162068294297304943d2302122a150a1"),
42807
+ vaultAllocator: ContractAddr.from("0x760f9cebca9d2ee624f4224591da6da8b3ea5fd2410590735709551bd4e7570"),
42808
+ redeemRequestNFT: ContractAddr.from("0x5e045ae0160f7650f8a4dd7c826f25630a89fe62434db4441e7e0075608180f"),
42809
+ aumOracle: ContractAddr.from("0x3958df341b838813c24efb9183c23bddd1c57d44b1b86c0dd57f67887b89fba"),
42810
+ leafAdapters: [],
42811
+ adapters: [],
42812
+ targetHealthFactor: 1.1,
42813
+ minHealthFactor: 1.05,
42814
+ borrowable_assets: borrowableAssets.map((asset) => Global.getDefaultTokens().find((token) => token.symbol === asset)),
42815
+ underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "WBTC"),
42816
+ quoteAmountToFetchPrice: new Web3Number("0.001", Global.getDefaultTokens().find((token) => token.symbol === "mRe7BTC").decimals)
42817
+ };
42818
+ var hypermRe7YIELD = {
42819
+ vaultAddress: ContractAddr.from("0x42797ab4eb1f72787442e91a73d63a39e3a141c1106470a946ecc328db6896c"),
42820
+ manager: ContractAddr.from("0x435b45d40fbb406cf69ac84bb471e7b7a4ea2295d0893c05dd2db565295e77f"),
42821
+ vaultAllocator: ContractAddr.from("0x456c4c6afca90512aeb5c735d84405fea6e51ab06d1851ac8cdb0a235e14f15"),
42822
+ redeemRequestNFT: ContractAddr.from("0x4bbb25c2568af07967342833f7db1aece1be1be2330798dab4ee585aa6c2c72"),
42823
+ aumOracle: ContractAddr.from("0x3e1f2825158cafccc9b42a8165d17ceb6b8e966474d9c63587d338746888382"),
42824
+ leafAdapters: [],
42825
+ adapters: [],
42826
+ targetHealthFactor: 1.1,
42827
+ minHealthFactor: 1.05,
42828
+ borrowable_assets: [Global.getDefaultTokens().find((token) => token.symbol === "USDC")],
42829
+ underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "USDC"),
42830
+ quoteAmountToFetchPrice: new Web3Number("0.001", Global.getDefaultTokens().find((token) => token.symbol === "mRe7BTC").decimals)
42831
+ };
42832
+ function getInvestmentSteps(lstSymbol, underlyingSymbol) {
42833
+ return [
42834
+ `Deposit ${lstSymbol} into the vault`,
42835
+ `The vault manager loops the ${underlyingSymbol} to buy ${lstSymbol}`,
42836
+ `The vault manager collateralizes the ${lstSymbol} on Vesu`,
42837
+ `The vault manager borrows more ${underlyingSymbol} to loop further`,
42838
+ `If required, adjust leverage or re-allocate assets within LST pool on Vesu to optimize yield`
42839
+ ];
42840
+ }
42841
+ function getMaxTVL(lstSymbol) {
42842
+ const lstMaxTVLs = {
42843
+ xWBTC: 5,
42844
+ xLBTC: 5,
42845
+ xtBTC: 5,
42846
+ xsBTC: 5,
42847
+ xSTRK: 7e6
42848
+ };
42849
+ const maxTVLValue = lstMaxTVLs[lstSymbol] || 0;
42850
+ const token = Global.getDefaultTokens().find(
42851
+ (token2) => token2.symbol === lstSymbol
42852
+ );
42853
+ if (!token) {
42854
+ return Web3Number.fromWei(0, 18);
42855
+ }
42856
+ return Web3Number.fromWei(maxTVLValue, token.decimals);
42857
+ }
42858
+ function createHyperLSTSettings(lstSymbol, underlyingSymbol) {
42859
+ const depositToken = Global.getDefaultTokens().find(
42860
+ (token) => token.symbol === lstSymbol
42861
+ );
42862
+ return {
42863
+ maxTVL: getMaxTVL(lstSymbol),
42864
+ isPaused: false,
42865
+ liveStatus: "Hot & New \u{1F525}" /* HOT */,
42866
+ isAudited: true,
42867
+ isInstantWithdrawal: false,
42868
+ hideHarvestInfo: true,
42869
+ quoteToken: depositToken,
42870
+ showWithdrawalWarningModal: false,
42871
+ alerts: [
42872
+ {
42873
+ tab: "withdraw",
42874
+ text: "On withdrawal, you will receive an NFT representing your withdrawal request. The funds will be automatically sent to your wallet (NFT owner) in 24 hours (In this initial phase of Launch). You can monitor the status in transactions tab.",
42875
+ type: "info"
42876
+ },
42877
+ {
42878
+ tab: "deposit",
42879
+ text: /* @__PURE__ */ jsxs4(Fragment3, { children: [
42880
+ "To acquire the LST, please visit",
42881
+ " ",
42882
+ /* @__PURE__ */ jsx5("a", { href: "https://app.endur.fi", target: "_blank", rel: "noopener noreferrer", children: "endur.fi" })
42883
+ ] }),
42884
+ type: "info"
42885
+ },
42886
+ {
42887
+ tab: "deposit",
42888
+ text: "It may take up to one week for your deposit to appreciate in value. This delay occurs because the LST price is sourced from DEXes and liquidity is usually rebased once a week.",
42889
+ type: "info"
42890
+ }
42891
+ ]
42892
+ };
42893
+ }
42894
+ var HYPER_LST_SECURITY = {
42895
+ auditStatus: "Audited" /* AUDITED */,
42896
+ sourceCode: {
42897
+ type: "Closed Source" /* CLOSED_SOURCE */,
42898
+ contractLink: "https://github.com/trovesfi/troves-contracts"
42899
+ },
42900
+ accessControl: {
42901
+ type: "Standard Account" /* STANDARD_ACCOUNT */,
42902
+ addresses: [ContractAddr.from("0x0")],
42903
+ timeLock: "2 Days"
42904
+ }
42905
+ };
42906
+ var HYPER_LST_REDEMPTION_INFO = {
42907
+ instantWithdrawalVault: "No" /* NO */,
42908
+ redemptionsInfo: [
42909
+ {
42910
+ title: "Typical Duration",
42911
+ description: "1-2 hours"
42912
+ }
42913
+ ],
42914
+ alerts: [
42915
+ {
42916
+ type: "info",
42917
+ text: "In cases of low liquidity, high slippages, the redemptions can take longer time. Redemption times are estimates and may vary based on network conditions and liquidity requirements.",
42918
+ tab: "withdraw"
42919
+ }
42920
+ ]
41917
42921
  };
41918
- var hypermRe7YIELD = {
41919
- vaultAddress: ContractAddr.from("0x42797ab4eb1f72787442e91a73d63a39e3a141c1106470a946ecc328db6896c"),
41920
- manager: ContractAddr.from("0x435b45d40fbb406cf69ac84bb471e7b7a4ea2295d0893c05dd2db565295e77f"),
41921
- vaultAllocator: ContractAddr.from("0x456c4c6afca90512aeb5c735d84405fea6e51ab06d1851ac8cdb0a235e14f15"),
41922
- redeemRequestNFT: ContractAddr.from("0x4bbb25c2568af07967342833f7db1aece1be1be2330798dab4ee585aa6c2c72"),
41923
- aumOracle: ContractAddr.from("0x3e1f2825158cafccc9b42a8165d17ceb6b8e966474d9c63587d338746888382"),
41924
- leafAdapters: [],
41925
- adapters: [],
41926
- targetHealthFactor: 1.1,
41927
- minHealthFactor: 1.05,
41928
- borrowable_assets: [Global.getDefaultTokens().find((token) => token.symbol === "USDC")],
41929
- underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "USDC"),
41930
- quoteAmountToFetchPrice: new Web3Number("0.001", Global.getDefaultTokens().find((token) => token.symbol === "mRe7BTC").decimals)
42922
+ function getStrategySettings(lstSymbol, underlyingSymbol, settings, isPreview = false, isLST) {
42923
+ return {
42924
+ id: `hyper_${lstSymbol.toLowerCase()}`,
42925
+ name: `Hyper ${lstSymbol}`,
42926
+ description: getDescription2(lstSymbol, underlyingSymbol),
42927
+ address: settings.vaultAddress,
42928
+ launchBlock: 0,
42929
+ type: "Other",
42930
+ vaultType: {
42931
+ type: "Looping" /* LOOPING */,
42932
+ description: `Creates leveraged looping position on ${lstSymbol} by borrowing ${underlyingSymbol} to increase yield`
42933
+ },
42934
+ depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === lstSymbol)],
42935
+ additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, settings, lstSymbol === "xSTRK" ? VesuPools.Re7xSTRK : VesuPools.Re7xBTC),
42936
+ risk: {
42937
+ riskFactor: _riskFactor4,
42938
+ netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
42939
+ notARisks: getNoRiskTags(_riskFactor4)
42940
+ },
42941
+ auditUrl: AUDIT_URL4,
42942
+ protocols: [Protocols.ENDUR, Protocols.VESU],
42943
+ curator: {
42944
+ name: "Unwrap Labs",
42945
+ logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
42946
+ },
42947
+ settings: createHyperLSTSettings(lstSymbol, underlyingSymbol),
42948
+ contractDetails: getContractDetails(settings),
42949
+ faqs: getFAQs2(lstSymbol, underlyingSymbol, isLST),
42950
+ investmentSteps: getInvestmentSteps(lstSymbol, underlyingSymbol),
42951
+ isPreview,
42952
+ apyMethodology: "Current annualized APY in terms of base asset of the LST. There is no additional fee taken by Troves on LST APY. We charge a 10% performance fee on the additional gain which is already accounted in the APY shown.",
42953
+ realizedAPYMethodology: "The realizedAPY is based on past 14 days performance by the vault",
42954
+ tags: lstSymbol.includes("BTC") ? ["BTC" /* BTC */, "Maxx" /* LEVERED */] : ["Maxx" /* LEVERED */],
42955
+ security: HYPER_LST_SECURITY,
42956
+ redemptionInfo: HYPER_LST_REDEMPTION_INFO,
42957
+ usualTimeToEarnings: "2 weeks",
42958
+ usualTimeToEarningsDescription: "Strategy returns depend on LST price on DEXes. Even though the true price of LST on Endur increases continuously, the DEX price may lag sometimes, and historically is seen to rebase at least once every 2 hours. This is when you realise your earnings.",
42959
+ points: lstSymbol === "xSTRK" ? [{
42960
+ multiplier: 4,
42961
+ logo: "https://endur.fi/favicon.ico",
42962
+ toolTip: "This strategy holds xSTRK. Earn 3-4x Endur points on your xSTRK due to the leverage. Points can be found on endur.fi."
42963
+ }] : void 0
42964
+ };
42965
+ }
42966
+ var HyperLSTStrategies = [
42967
+ getStrategySettings("xSTRK", "STRK", hyperxSTRK, false, true),
42968
+ getStrategySettings("xWBTC", "WBTC", hyperxWBTC, false, false),
42969
+ getStrategySettings("xtBTC", "tBTC", hyperxtBTC, false, false),
42970
+ getStrategySettings("xsBTC", "solvBTC", hyperxsBTC, false, false),
42971
+ getStrategySettings("xLBTC", "LBTC", hyperxLBTC, false, false),
42972
+ getStrategySettings("mRe7BTC", "mRe7BTC", hypermRe7BTC, false, false),
42973
+ getStrategySettings("mRe7YIELD", "mRe7YIELD", hypermRe7YIELD, false, false)
42974
+ ];
42975
+
42976
+ // src/strategies/usdc-boosted-strategy.tsx
42977
+ import { uint256 as uint25623 } from "starknet";
42978
+ var USDCBoostedStrategy = class _USDCBoostedStrategy extends SVKStrategy {
42979
+ constructor(config, pricer, metadata) {
42980
+ super(config, pricer, metadata);
42981
+ this.metadata.additionalInfo.adapters.forEach((adapter) => {
42982
+ adapter.adapter.config.networkConfig = this.config;
42983
+ adapter.adapter.config.pricer = this.pricer;
42984
+ if (adapter.adapter._vesuAdapter) {
42985
+ adapter.adapter._vesuAdapter.networkConfig = this.config;
42986
+ adapter.adapter._vesuAdapter.pricer = this.pricer;
42987
+ }
42988
+ });
42989
+ }
42990
+ getTag() {
42991
+ return `${_USDCBoostedStrategy.name}:${this.metadata.name}`;
42992
+ }
42993
+ getAdapterById(id) {
42994
+ const entry = this.metadata.additionalInfo.adapters.find(
42995
+ (a) => a.id === id
42996
+ );
42997
+ if (!entry) {
42998
+ throw new Error(
42999
+ `${this.getTag()}::getAdapterById: adapter not found for id "${id}"`
43000
+ );
43001
+ }
43002
+ return entry.adapter;
43003
+ }
43004
+ async getVesuModifyPositionCall(params) {
43005
+ logger.verbose(
43006
+ `${this.getTag()}::getVesuModifyPositionCall isDeposit=${params.isDeposit}, amount=${params.leg1DepositAmount}, debtAmount=${params.debtAmount?.toNumber()}`
43007
+ );
43008
+ return this.buildManageCallFromAdapter(
43009
+ this.getAdapterById("vesu_usdc_strk"),
43010
+ params.isDeposit,
43011
+ params.leg1DepositAmount,
43012
+ params.debtAmount ? { debtAmount: params.debtAmount } : void 0
43013
+ );
43014
+ }
43015
+ async getVesuPositions() {
43016
+ const positions = await this.getAdapterById(
43017
+ "vesu_usdc_strk"
43018
+ ).getPositions();
43019
+ return positions.map((p) => ({
43020
+ amount: p.amount,
43021
+ usdValue: p.usdValue,
43022
+ remarks: p.remarks ?? "",
43023
+ token: p.tokenInfo,
43024
+ protocol: p.protocol
43025
+ }));
43026
+ }
43027
+ async getVesuHealthFactor(blockNumber = "latest") {
43028
+ const vesuAdapter = this.getAdapterById("vesu_usdc_strk");
43029
+ return await vesuAdapter._vesuAdapter.getHealthFactor(blockNumber);
43030
+ }
43031
+ // TODO: will have to still modify for instant withdrawals as of now
43032
+ async getModifyHyperPositionCall(params) {
43033
+ logger.verbose(
43034
+ `${this.getTag()}::getModifyHyperPositionCall isDeposit=${params.isDeposit}, amount=${params.amount}`
43035
+ );
43036
+ return this.buildManageCallFromAdapter(
43037
+ this.getAdapterById("hyper_xstrk"),
43038
+ params.isDeposit,
43039
+ params.amount
43040
+ );
43041
+ }
43042
+ async getAvnuSwapCall(params) {
43043
+ logger.verbose(
43044
+ `${this.getTag()}::getAvnuSwapCall isDeposit=${params.isDeposit}, amount=${params.amount}`
43045
+ );
43046
+ return this.buildManageCallFromAdapter(
43047
+ this.getAdapterById("avnu_strk_xstrk"),
43048
+ params.isDeposit,
43049
+ params.amount
43050
+ );
43051
+ }
43052
+ /**
43053
+ * Returns the USDC balance sitting idle inside the vault contract itself.
43054
+ * This balance can offset the required liquidity during withdrawal processing.
43055
+ */
43056
+ async getUnusedBalanceVault() {
43057
+ const collateralToken = this.metadata.additionalInfo.collateralToken;
43058
+ return new ERC20(this.config).balanceOf(
43059
+ collateralToken.address,
43060
+ this.metadata.additionalInfo.vaultAddress,
43061
+ collateralToken.decimals
43062
+ );
43063
+ }
43064
+ /**
43065
+ * Returns the current STRK balance sitting unused in the vault allocator.
43066
+ * This covers STRK from prior borrow cycles that hasn't been swapped yet.
43067
+ */
43068
+ // Technically we can use this or we can even use the avnu-adapter to get the unused debt
43069
+ async getUnusedDebt() {
43070
+ const debtToken = this.metadata.additionalInfo.debtToken;
43071
+ return new ERC20(this.config).balanceOf(
43072
+ debtToken.address,
43073
+ this.metadata.additionalInfo.vaultAllocator,
43074
+ debtToken.decimals
43075
+ );
43076
+ }
43077
+ /**
43078
+ * Returns the xSTRK balance sitting in the vault allocator.
43079
+ * This is non-zero when the previous cycle's request_redeem on the HyperPosition
43080
+ * has been settled — the redeemed xSTRK lands here and is ready to be swapped.
43081
+ */
43082
+ async getxSTRKInVault() {
43083
+ const xstrkToken = Global.getDefaultTokens().find(
43084
+ (t) => t.symbol === "xSTRK"
43085
+ );
43086
+ if (!xstrkToken) {
43087
+ throw new Error(`${this.getTag()}:: xSTRK token not found`);
43088
+ }
43089
+ return new ERC20(this.config).balanceOf(
43090
+ xstrkToken.address.address,
43091
+ this.metadata.additionalInfo.vaultAllocator,
43092
+ xstrkToken.decimals
43093
+ );
43094
+ }
43095
+ /**
43096
+ * Simulates depositing `depositAmount` USDC on Vesu and returns the
43097
+ * incremental STRK that would be borrowed. Needed to size the AVNU swap
43098
+ * call that is batched together with the Vesu call in the same transaction.
43099
+ */
43100
+ async computeVesuDepositBorrowAmount(depositAmount) {
43101
+ return this.getAdapterById(
43102
+ "vesu_usdc_strk"
43103
+ ).getExpectedDepositDebtDelta(depositAmount);
43104
+ }
43105
+ async computeVesuWithdrawDebtDelta(withdrawAmount) {
43106
+ return this.getAdapterById(
43107
+ "vesu_usdc_strk"
43108
+ ).getExpectedWithdrawDebtDelta(withdrawAmount);
43109
+ }
43110
+ async getPendingHyperAssets() {
43111
+ const xstrkToken = Global.getDefaultTokens().find(
43112
+ (t) => t.symbol === "xSTRK"
43113
+ );
43114
+ const hyperXstrkRedeemNFT = ContractAddr.from(
43115
+ "0x51e40b839dc0c2feca923f863072673b94abfa2483345be3b30b457a90d095"
43116
+ );
43117
+ return this.getAdapterById(
43118
+ "hyper_xstrk"
43119
+ ).getPendingAssetsFromOwnerNFTMethod(
43120
+ hyperXstrkRedeemNFT,
43121
+ this.metadata.additionalInfo.vaultAllocator,
43122
+ xstrkToken.decimals
43123
+ );
43124
+ }
43125
+ // TODO: rn we are just making these functions in the strategy itself but
43126
+ // later on we will move them to the SVKStrategy for generalization
43127
+ async getUserTVL(user, blockIdentifier = "latest") {
43128
+ const shares = await this.contract.call("balanceOf", [user.address], {
43129
+ blockIdentifier
43130
+ });
43131
+ const assets = await this.contract.call(
43132
+ "convert_to_assets",
43133
+ [uint25623.bnToUint256(shares)],
43134
+ { blockIdentifier }
43135
+ );
43136
+ const amount = Web3Number.fromWei(
43137
+ assets.toString(),
43138
+ this.metadata.depositTokens[0].decimals
43139
+ );
43140
+ const blockNumber = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : void 0;
43141
+ const price = await this.pricer.getPrice(
43142
+ this.metadata.depositTokens[0].symbol,
43143
+ blockNumber
43144
+ );
43145
+ const usdValue = Number(amount.toFixed(6)) * price.price;
43146
+ return {
43147
+ tokenInfo: this.asset(),
43148
+ amount,
43149
+ usdValue
43150
+ };
43151
+ }
43152
+ async getTVL() {
43153
+ const assets = await this.contract.total_assets();
43154
+ const amount = Web3Number.fromWei(
43155
+ assets.toString(),
43156
+ this.metadata.depositTokens[0].decimals
43157
+ );
43158
+ const price = await this.pricer.getPrice(
43159
+ this.metadata.depositTokens[0].symbol
43160
+ );
43161
+ const usdValue = Number(amount.toFixed(6)) * price.price;
43162
+ return {
43163
+ tokenInfo: this.asset(),
43164
+ amount,
43165
+ usdValue
43166
+ };
43167
+ }
43168
+ async getAUM() {
43169
+ const underlying = this.asset();
43170
+ const usdcPrice = await this.pricer.getPrice(underlying.symbol);
43171
+ const allPositions = [];
43172
+ for (const adapter of this.metadata.additionalInfo.adapters) {
43173
+ const positions = await adapter.adapter.getPositions();
43174
+ allPositions.push(...positions);
43175
+ }
43176
+ let netAUM = new Web3Number(0, underlying.decimals);
43177
+ for (const position of allPositions) {
43178
+ if (position.tokenInfo.address.eq(underlying.address)) {
43179
+ netAUM = netAUM.plus(position.amount);
43180
+ } else {
43181
+ const valueInUSDC = position.usdValue;
43182
+ netAUM = netAUM.plus(valueInUSDC);
43183
+ }
43184
+ }
43185
+ const unusedBalance = await this.getUnusedBalance();
43186
+ logger.verbose(
43187
+ `${this.getTag()} unused balance: ${unusedBalance.amount.toNumber()}`
43188
+ );
43189
+ netAUM = netAUM.plus(unusedBalance.amount);
43190
+ const prevAum = await this.getPrevAUM();
43191
+ logger.verbose(`${this.getTag()} AUM: ${netAUM}`);
43192
+ const realAUM = {
43193
+ tokenInfo: underlying,
43194
+ amount: netAUM,
43195
+ usdValue: netAUM.toNumber() * usdcPrice.price,
43196
+ apy: { apy: 0, type: "base" /* BASE */ },
43197
+ remarks: "finalised" /* FINALISED */,
43198
+ protocol: Protocols.NONE
43199
+ };
43200
+ const estimatedAUMDelta = {
43201
+ tokenInfo: underlying,
43202
+ amount: Web3Number.fromWei("0", underlying.decimals),
43203
+ usdValue: 0,
43204
+ apy: { apy: 0, type: "base" /* BASE */ },
43205
+ remarks: "defispring" /* DEFISPRING */,
43206
+ protocol: Protocols.NONE
43207
+ };
43208
+ return {
43209
+ net: {
43210
+ tokenInfo: underlying,
43211
+ amount: netAUM,
43212
+ usdValue: netAUM.toNumber() * usdcPrice.price
43213
+ },
43214
+ prevAum,
43215
+ splits: [realAUM, estimatedAUMDelta]
43216
+ };
43217
+ }
43218
+ // TODO: can refactor later but seems redundant since not being used ANYWHERE
43219
+ // Most of the fund management done through adapters only
43220
+ async getFundManagementCall(params) {
43221
+ logger.verbose(
43222
+ `${this.getTag()}::getFundManagementCall params: ${JSON.stringify(params)}`
43223
+ );
43224
+ const allAdapters = this.metadata.additionalInfo.adapters.map(
43225
+ (a) => a.adapter
43226
+ );
43227
+ if (!params.isDeposit) {
43228
+ const unusedBalance = await this.getUnusedBalance();
43229
+ logger.verbose(
43230
+ `${this.getTag()}::getFundManagementCall unusedBalance: ${unusedBalance.amount}, required: ${params.leg1DepositAmount}`
43231
+ );
43232
+ if (unusedBalance.amount.gte(params.leg1DepositAmount)) {
43233
+ return null;
43234
+ }
43235
+ const adapters2 = await AdapterOptimizer.getAdapterToUse(
43236
+ allAdapters,
43237
+ false,
43238
+ params.leg1DepositAmount
43239
+ );
43240
+ if (adapters2.length > 0) {
43241
+ const proofsInfo = adapters2.map(
43242
+ (adapter) => adapter.getProofs(false, this.getMerkleTree())
43243
+ );
43244
+ const calls = [];
43245
+ for (const info of proofsInfo) {
43246
+ const manageCalls = await info.callConstructor({
43247
+ amount: params.leg1DepositAmount
43248
+ });
43249
+ const call = this.getManageCall(
43250
+ this.getProofGroupsForManageCalls(manageCalls),
43251
+ manageCalls
43252
+ );
43253
+ calls.push(call);
43254
+ }
43255
+ return calls;
43256
+ }
43257
+ throw new Error(
43258
+ `${this.getTag()}::getFundManagementCall: no adapters for withdraw: ${unusedBalance.amount}`
43259
+ );
43260
+ }
43261
+ const adapters = await AdapterOptimizer.getAdapterToUse(
43262
+ allAdapters,
43263
+ true,
43264
+ params.leg1DepositAmount
43265
+ );
43266
+ if (adapters.length > 0) {
43267
+ const proofsInfo = adapters.map(
43268
+ (adapter) => adapter.getProofs(true, this.getMerkleTree())
43269
+ );
43270
+ const calls = [];
43271
+ for (const info of proofsInfo) {
43272
+ const manageCalls = await info.callConstructor({
43273
+ amount: params.leg1DepositAmount
43274
+ });
43275
+ const call = this.getManageCall(
43276
+ this.getProofGroupsForManageCalls(manageCalls),
43277
+ manageCalls
43278
+ );
43279
+ calls.push(call);
43280
+ }
43281
+ return calls;
43282
+ }
43283
+ throw new Error(
43284
+ `${this.getTag()}::getFundManagementCall: no adapters for deposit: ${params.leg1DepositAmount}`
43285
+ );
43286
+ }
41931
43287
  };
41932
- function getInvestmentSteps(lstSymbol, underlyingSymbol) {
41933
- return [
41934
- `Deposit ${lstSymbol} into the vault`,
41935
- `The vault manager loops the ${underlyingSymbol} to buy ${lstSymbol}`,
41936
- `The vault manager collateralizes the ${lstSymbol} on Vesu`,
41937
- `The vault manager borrows more ${underlyingSymbol} to loop further`,
41938
- `If required, adjust leverage or re-allocate assets within LST pool on Vesu to optimize yield`
41939
- ];
41940
- }
41941
- function getMaxTVL(lstSymbol) {
41942
- const lstMaxTVLs = {
41943
- xWBTC: 5,
41944
- xLBTC: 5,
41945
- xtBTC: 5,
41946
- xsBTC: 5,
41947
- xSTRK: 7e6
43288
+ function getUSDCBoostedSettings(vaultSettings) {
43289
+ vaultSettings.leafAdapters = [];
43290
+ const xSTRKToken = Global.getDefaultTokens().find(
43291
+ (t) => t.symbol === "xSTRK"
43292
+ );
43293
+ const USDCToken = Global.getDefaultTokens().find((t) => t.symbol === "USDC");
43294
+ const STRKToken = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
43295
+ const baseAdapterConfig = {
43296
+ baseToken: USDCToken,
43297
+ supportedPositions: [{ asset: USDCToken, isDebt: false }],
43298
+ networkConfig: getMainnetConfig(),
43299
+ pricer: new PricerFromApi(getMainnetConfig(), Global.getDefaultTokens()),
43300
+ vaultAllocator: vaultSettings.vaultAllocator,
43301
+ vaultAddress: vaultSettings.vaultAddress
41948
43302
  };
41949
- const maxTVLValue = lstMaxTVLs[lstSymbol] || 0;
41950
- const token = Global.getDefaultTokens().find(
41951
- (token2) => token2.symbol === lstSymbol
43303
+ const vesuModifyPositionAdapter = new VesuModifyPositionAdapter({
43304
+ poolId: vaultSettings.vesuPoolId,
43305
+ collateral: vaultSettings.collateralToken,
43306
+ debt: vaultSettings.debtToken,
43307
+ targetLtv: vaultSettings.targetLTV,
43308
+ maxLtv: vaultSettings.maxLTV,
43309
+ ...baseAdapterConfig,
43310
+ supportedPositions: [
43311
+ { asset: USDCToken, isDebt: false },
43312
+ { asset: STRKToken, isDebt: true }
43313
+ ]
43314
+ });
43315
+ const avnuAdapter = new AvnuAdapter({
43316
+ baseUrl: AVNU_QUOTE_URL,
43317
+ avnuContract: AVNU_EXCHANGE,
43318
+ slippage: 0.01,
43319
+ minimumExtendedPriceDifferenceForSwapOpen: 0,
43320
+ maximumExtendedPriceDifferenceForSwapClosing: 0,
43321
+ ...baseAdapterConfig,
43322
+ baseToken: STRKToken,
43323
+ supportedPositions: [
43324
+ { asset: STRKToken, isDebt: false },
43325
+ { asset: xSTRKToken, isDebt: false }
43326
+ ]
43327
+ });
43328
+ const svkTrovesAdapter = new SvkTrovesAdapter({
43329
+ ...baseAdapterConfig,
43330
+ baseToken: xSTRKToken,
43331
+ supportedPositions: [{ asset: xSTRKToken, isDebt: false }],
43332
+ strategyVault: vaultSettings.hyperxSTRKVaultAddress,
43333
+ trovesStrategyId: "hyper_xstrk"
43334
+ });
43335
+ const usdcTransferAdapter = new TokenTransferAdapter({
43336
+ ...baseAdapterConfig,
43337
+ fromAddress: vaultSettings.vaultAllocator,
43338
+ toAddress: vaultSettings.vaultAddress
43339
+ });
43340
+ const commonAdapter = new CommonAdapter({
43341
+ id: "flash_loan_init" /* FLASH_LOAN */,
43342
+ vaultAddress: vaultSettings.vaultAddress,
43343
+ vaultAllocator: vaultSettings.vaultAllocator,
43344
+ manager: vaultSettings.manager,
43345
+ asset: USDCToken.address
43346
+ });
43347
+ vaultSettings.adapters.push(
43348
+ // TODO: generalize the ids
43349
+ { id: "vesu_usdc_strk", adapter: vesuModifyPositionAdapter },
43350
+ // Used to track swapped funds in vaultAllocator
43351
+ { id: "avnu_strk_xstrk", adapter: avnuAdapter },
43352
+ { id: "hyper_xstrk", adapter: svkTrovesAdapter },
43353
+ { id: "usdc_transfer", adapter: usdcTransferAdapter }
41952
43354
  );
41953
- if (!token) {
41954
- return Web3Number.fromWei(0, 18);
41955
- }
41956
- return Web3Number.fromWei(maxTVLValue, token.decimals);
41957
- }
41958
- function createHyperLSTSettings(lstSymbol, underlyingSymbol) {
41959
- const depositToken = Global.getDefaultTokens().find(
41960
- (token) => token.symbol === lstSymbol
43355
+ vaultSettings.leafAdapters.push(
43356
+ () => vesuModifyPositionAdapter.getDepositLeaf()
41961
43357
  );
41962
- return {
41963
- maxTVL: getMaxTVL(lstSymbol),
41964
- isPaused: false,
41965
- liveStatus: "Hot & New \u{1F525}" /* HOT */,
41966
- isAudited: true,
41967
- isInstantWithdrawal: false,
41968
- hideHarvestInfo: true,
41969
- quoteToken: depositToken,
41970
- showWithdrawalWarningModal: false,
41971
- alerts: [
41972
- {
41973
- tab: "withdraw",
41974
- text: "On withdrawal, you will receive an NFT representing your withdrawal request. The funds will be automatically sent to your wallet (NFT owner) in 24 hours (In this initial phase of Launch). You can monitor the status in transactions tab.",
41975
- type: "info"
41976
- },
41977
- {
41978
- tab: "deposit",
41979
- text: /* @__PURE__ */ jsxs4(Fragment3, { children: [
41980
- "To acquire the LST, please visit",
41981
- " ",
41982
- /* @__PURE__ */ jsx5("a", { href: "https://app.endur.fi", target: "_blank", rel: "noopener noreferrer", children: "endur.fi" })
41983
- ] }),
41984
- type: "info"
41985
- },
41986
- {
41987
- tab: "deposit",
41988
- text: "It may take up to one week for your deposit to appreciate in value. This delay occurs because the LST price is sourced from DEXes and liquidity is usually rebased once a week.",
41989
- type: "info"
41990
- }
41991
- ]
41992
- };
43358
+ vaultSettings.leafAdapters.push(
43359
+ () => vesuModifyPositionAdapter.getWithdrawLeaf()
43360
+ );
43361
+ vaultSettings.leafAdapters.push(() => avnuAdapter.getDepositLeaf());
43362
+ vaultSettings.leafAdapters.push(() => avnuAdapter.getWithdrawLeaf());
43363
+ vaultSettings.leafAdapters.push(() => svkTrovesAdapter.getDepositLeaf());
43364
+ vaultSettings.leafAdapters.push(() => svkTrovesAdapter.getWithdrawLeaf());
43365
+ vaultSettings.leafAdapters.push(
43366
+ commonAdapter.getApproveAdapter(
43367
+ USDCToken.address,
43368
+ vaultSettings.vaultAddress,
43369
+ "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */
43370
+ ).bind(commonAdapter)
43371
+ );
43372
+ vaultSettings.leafAdapters.push(
43373
+ commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter)
43374
+ );
43375
+ return vaultSettings;
41993
43376
  }
41994
- var HYPER_LST_SECURITY = {
41995
- auditStatus: "Audited" /* AUDITED */,
41996
- sourceCode: {
41997
- type: "Closed Source" /* CLOSED_SOURCE */,
41998
- contractLink: "https://github.com/trovesfi/troves-contracts"
41999
- },
42000
- accessControl: {
42001
- type: "Standard Account" /* STANDARD_ACCOUNT */,
42002
- addresses: [ContractAddr.from("0x0")],
42003
- timeLock: "2 Days"
42004
- }
42005
- };
42006
- var HYPER_LST_REDEMPTION_INFO = {
42007
- instantWithdrawalVault: "No" /* NO */,
42008
- redemptionsInfo: [
42009
- {
42010
- title: "Typical Duration",
42011
- description: "1-2 hours"
42012
- }
42013
- ],
42014
- alerts: [
42015
- {
42016
- type: "info",
42017
- text: "In cases of low liquidity, high slippages, the redemptions can take longer time. Redemption times are estimates and may vary based on network conditions and liquidity requirements.",
42018
- tab: "withdraw"
42019
- }
42020
- ]
43377
+ var usdcBoostedSettings = {
43378
+ vaultAddress: ContractAddr.from(
43379
+ "0xcdb0e3b2e076a2cdc4ee958b726b47c066239ef91c5ac80c94cf814147b84"
43380
+ ),
43381
+ manager: ContractAddr.from(
43382
+ "0x72eea9bac9fa8cfffda637d3b990851446860c6fd8987d6cb50e659b01ee50f"
43383
+ ),
43384
+ vaultAllocator: ContractAddr.from(
43385
+ "0x6d3101cff7f821412a99ebe23bb31a1950f93276285102eb4313e3601f5f927"
43386
+ ),
43387
+ redeemRequestNFT: ContractAddr.from(
43388
+ "0x47dcc6889ca8db4e9eea8f55421e10f8ce7e356ccb45260a1c49a76f733c309"
43389
+ ),
43390
+ // TODO: not applicable in our case -> remove later ( make it optional if needed)
43391
+ aumOracle: ContractAddr.from("0x0"),
43392
+ leafAdapters: [],
43393
+ adapters: [],
43394
+ // Calc using the maxLTV / targetLTV (0.5)
43395
+ targetHealthFactor: 1.32,
43396
+ // Calc using the maxLTV / maxAcceptableLTV (0.55)
43397
+ minHealthFactor: 1.2,
43398
+ vesuPoolId: VesuPools.Prime,
43399
+ collateralToken: Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
43400
+ debtToken: Global.getDefaultTokens().find((t) => t.symbol === "STRK"),
43401
+ maxLTV: 0.66,
43402
+ targetLTV: 0.5,
43403
+ hyperxSTRKVaultAddress: ContractAddr.from(
43404
+ "0x46c7a54c82b1fe374353859f554a40b8bd31d3e30f742901579e7b57b1b5960"
43405
+ )
42021
43406
  };
42022
- function getStrategySettings(lstSymbol, underlyingSymbol, settings, isPreview = false, isLST) {
43407
+ function getStrategySettings2(settings) {
43408
+ const USDCToken = Global.getDefaultTokens().find((t) => t.symbol === "USDC");
43409
+ const STRKToken = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
42023
43410
  return {
42024
- id: `hyper_${lstSymbol.toLowerCase()}`,
42025
- name: `Hyper ${lstSymbol}`,
42026
- description: getDescription2(lstSymbol, underlyingSymbol),
43411
+ id: "usdc_boosted",
43412
+ name: "USDC Boosted",
43413
+ description: "Deposits USDC as collateral on Vesu, borrows STRK, swaps to xSTRK, and deposits into Hyper-xSTRK for boosted yield",
42027
43414
  address: settings.vaultAddress,
42028
- launchBlock: 0,
42029
- type: "Other",
43415
+ launchBlock: 8742931,
43416
+ type: "ERC4626",
42030
43417
  vaultType: {
42031
- type: "Looping" /* LOOPING */,
42032
- description: `Creates leveraged looping position on ${lstSymbol} by borrowing ${underlyingSymbol} to increase yield`
43418
+ // TODO: can change as per need
43419
+ type: "Meta Vault" /* META_VAULT */,
43420
+ description: "Deposits USDC as collateral on Vesu, borrows STRK, swaps to xSTRK, and deposits into Hyper-xSTRK for boosted yield"
42033
43421
  },
42034
- depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === lstSymbol)],
42035
- additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, settings, lstSymbol === "xSTRK" ? VesuPools.Re7xSTRK : VesuPools.Re7xBTC),
43422
+ depositTokens: [USDCToken],
43423
+ additionalInfo: getUSDCBoostedSettings(settings),
43424
+ // TODO: config lateron
42036
43425
  risk: {
42037
- riskFactor: _riskFactor4,
42038
- netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
42039
- notARisks: getNoRiskTags(_riskFactor4)
43426
+ riskFactor: [],
43427
+ netRisk: 0,
43428
+ notARisks: []
42040
43429
  },
42041
- auditUrl: AUDIT_URL4,
42042
- protocols: [Protocols.ENDUR, Protocols.VESU],
43430
+ protocols: [Protocols.VESU, Protocols.TROVES],
42043
43431
  curator: {
42044
43432
  name: "Unwrap Labs",
42045
43433
  logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
42046
43434
  },
42047
- settings: createHyperLSTSettings(lstSymbol, underlyingSymbol),
43435
+ settings: {
43436
+ maxTVL: Web3Number.fromWei(0, USDCToken.decimals),
43437
+ isPaused: false,
43438
+ isAudited: false,
43439
+ isInstantWithdrawal: false,
43440
+ hideHarvestInfo: true,
43441
+ quoteToken: USDCToken,
43442
+ alerts: [
43443
+ {
43444
+ tab: "withdraw",
43445
+ text: "On withdrawal, you will receive an NFT representing your withdrawal request. The funds will be automatically sent to your wallet (NFT owner) in 1-2 hours. You can monitor the status in transactions tab.",
43446
+ type: "info"
43447
+ }
43448
+ ]
43449
+ },
42048
43450
  contractDetails: getContractDetails(settings),
42049
- faqs: getFAQs2(lstSymbol, underlyingSymbol, isLST),
42050
- investmentSteps: getInvestmentSteps(lstSymbol, underlyingSymbol),
42051
- isPreview,
42052
- apyMethodology: "Current annualized APY in terms of base asset of the LST. There is no additional fee taken by Troves on LST APY. We charge a 10% performance fee on the additional gain which is already accounted in the APY shown.",
42053
- realizedAPYMethodology: "The realizedAPY is based on past 14 days performance by the vault",
42054
- tags: lstSymbol.includes("BTC") ? ["BTC" /* BTC */, "Maxx" /* LEVERED */] : ["Maxx" /* LEVERED */],
42055
- security: HYPER_LST_SECURITY,
42056
- redemptionInfo: HYPER_LST_REDEMPTION_INFO,
42057
- usualTimeToEarnings: "2 weeks",
42058
- usualTimeToEarningsDescription: "Strategy returns depend on LST price on DEXes. Even though the true price of LST on Endur increases continuously, the DEX price may lag sometimes, and historically is seen to rebase at least once every 2 hours. This is when you realise your earnings.",
42059
- points: lstSymbol === "xSTRK" ? [{
42060
- multiplier: 4,
42061
- logo: "https://endur.fi/favicon.ico",
42062
- toolTip: "This strategy holds xSTRK. Earn 3-4x Endur points on your xSTRK due to the leverage. Points can be found on endur.fi."
42063
- }] : void 0
43451
+ // TODO: config later
43452
+ faqs: [],
43453
+ investmentSteps: [
43454
+ "Deposit USDC into the vault",
43455
+ "USDC is supplied as collateral on Vesu, STRK is borrowed",
43456
+ "Borrowed STRK is swapped to xSTRK via Avnu",
43457
+ "xSTRK is deposited into the Hyper-xSTRK vault for additional yield",
43458
+ "On withdrawal, the pipeline reverses to return USDC"
43459
+ ],
43460
+ // TODO: config later
43461
+ tags: ["Meta Vaults" /* META_VAULT */],
43462
+ security: {
43463
+ auditStatus: "Audited" /* AUDITED */,
43464
+ sourceCode: {
43465
+ type: "Closed Source" /* CLOSED_SOURCE */,
43466
+ contractLink: "https://github.com/trovesfi/troves-contracts"
43467
+ },
43468
+ accessControl: {
43469
+ type: "Standard Account" /* STANDARD_ACCOUNT */,
43470
+ addresses: [ContractAddr.from("0x0")],
43471
+ timeLock: "2 Days"
43472
+ }
43473
+ },
43474
+ redemptionInfo: {
43475
+ instantWithdrawalVault: "No" /* NO */,
43476
+ redemptionsInfo: [
43477
+ {
43478
+ title: "Typical Duration",
43479
+ description: "1-2 hours"
43480
+ }
43481
+ ],
43482
+ alerts: [
43483
+ {
43484
+ type: "info",
43485
+ text: "Redemption times are estimates and may vary based on network conditions and liquidity requirements.",
43486
+ tab: "withdraw"
43487
+ }
43488
+ ]
43489
+ },
43490
+ usualTimeToEarnings: null,
43491
+ usualTimeToEarningsDescription: null
42064
43492
  };
42065
43493
  }
42066
- var HyperLSTStrategies = [
42067
- getStrategySettings("xSTRK", "STRK", hyperxSTRK, false, true),
42068
- getStrategySettings("xWBTC", "WBTC", hyperxWBTC, false, false),
42069
- getStrategySettings("xtBTC", "tBTC", hyperxtBTC, false, false),
42070
- getStrategySettings("xsBTC", "solvBTC", hyperxsBTC, false, false),
42071
- getStrategySettings("xLBTC", "LBTC", hyperxLBTC, false, false),
42072
- getStrategySettings("mRe7BTC", "mRe7BTC", hypermRe7BTC, false, false),
42073
- getStrategySettings("mRe7YIELD", "mRe7YIELD", hypermRe7YIELD, false, false)
42074
- ];
43494
+ var USDCBoostedStrategies = [getStrategySettings2(usdcBoostedSettings)];
42075
43495
 
42076
43496
  // src/strategies/vesu-extended-strategy/services/ltv-imbalance-rebalance-math.ts
42077
43497
  function ceilBtc(v, precision) {
@@ -45456,7 +46876,7 @@ var ExtendedSVKVesuStateManager = class {
45456
46876
  };
45457
46877
 
45458
46878
  // src/strategies/vesu-extended-strategy/services/executionService.ts
45459
- import { uint256 as uint25623 } from "starknet";
46879
+ import { uint256 as uint25624 } from "starknet";
45460
46880
 
45461
46881
  // src/strategies/vesu-extended-strategy/types/transaction-metadata.ts
45462
46882
  var CycleType = /* @__PURE__ */ ((CycleType2) => {
@@ -46388,7 +47808,7 @@ var _ExecutionService = class _ExecutionService {
46388
47808
  const extendedContract = extendedAdapter.config.extendedContract;
46389
47809
  const vaultId = extendedAdapter.config.vaultIdExtended;
46390
47810
  const salt = Math.floor(Math.random() * 10 ** usdcToken.decimals);
46391
- const uint256Amount = uint25623.bnToUint256(amount.toWei());
47811
+ const uint256Amount = uint25624.bnToUint256(amount.toWei());
46392
47812
  const approveCall = {
46393
47813
  contractAddress: usdcToken.address.address,
46394
47814
  entrypoint: "approve",
@@ -48181,6 +49601,7 @@ export {
48181
49601
  SIMPLE_SANITIZER,
48182
49602
  SIMPLE_SANITIZER_V2,
48183
49603
  SIMPLE_SANITIZER_VESU_V1_DELEGATIONS,
49604
+ SVK_SIMPLE_SANITIZER,
48184
49605
  SenseiStrategies,
48185
49606
  SenseiVault,
48186
49607
  SolveBudget,
@@ -48197,6 +49618,8 @@ export {
48197
49618
  TokenTransferAdapter,
48198
49619
  UNIVERSAL_ADAPTERS,
48199
49620
  UNIVERSAL_MANAGE_IDS,
49621
+ USDCBoostedStrategies,
49622
+ USDCBoostedStrategy,
48200
49623
  UniversalLstMultiplierStrategy,
48201
49624
  UniversalStrategies,
48202
49625
  UniversalStrategy,