@strkfarm/sdk 1.1.17 → 1.1.20

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.
@@ -28641,6 +28641,7 @@ ${r2}}` : "}", l2;
28641
28641
  var index_browser_exports = {};
28642
28642
  __export(index_browser_exports, {
28643
28643
  AUMTypes: () => AUMTypes,
28644
+ AVNU_MIDDLEWARE: () => AVNU_MIDDLEWARE,
28644
28645
  AutoCompounderSTRK: () => AutoCompounderSTRK,
28645
28646
  AvnuWrapper: () => AvnuWrapper,
28646
28647
  BaseAdapter: () => BaseAdapter,
@@ -28659,12 +28660,16 @@ ${r2}}` : "}", l2;
28659
28660
  Initializable: () => Initializable,
28660
28661
  MarginType: () => MarginType,
28661
28662
  Network: () => Network,
28663
+ PRICE_ROUTER: () => PRICE_ROUTER,
28662
28664
  Pragma: () => Pragma,
28663
28665
  Pricer: () => Pricer,
28664
28666
  PricerFromApi: () => PricerFromApi,
28665
28667
  PricerLST: () => PricerLST,
28666
28668
  Protocols: () => Protocols,
28667
28669
  RiskType: () => RiskType,
28670
+ SIMPLE_SANITIZER: () => SIMPLE_SANITIZER,
28671
+ SIMPLE_SANITIZER_V2: () => SIMPLE_SANITIZER_V2,
28672
+ SIMPLE_SANITIZER_VESU_V1_DELEGATIONS: () => SIMPLE_SANITIZER_VESU_V1_DELEGATIONS,
28668
28673
  SenseiStrategies: () => SenseiStrategies,
28669
28674
  SenseiVault: () => SenseiVault,
28670
28675
  UNIVERSAL_ADAPTERS: () => UNIVERSAL_ADAPTERS,
@@ -28672,6 +28677,7 @@ ${r2}}` : "}", l2;
28672
28677
  UniversalLstMultiplierStrategy: () => UniversalLstMultiplierStrategy,
28673
28678
  UniversalStrategies: () => UniversalStrategies,
28674
28679
  UniversalStrategy: () => UniversalStrategy,
28680
+ VESU_SINGLETON: () => VESU_SINGLETON,
28675
28681
  VesuAdapter: () => VesuAdapter,
28676
28682
  VesuAmountDenomination: () => VesuAmountDenomination,
28677
28683
  VesuAmountType: () => VesuAmountType,
@@ -28685,7 +28691,9 @@ ${r2}}` : "}", l2;
28685
28691
  getNoRiskTags: () => getNoRiskTags,
28686
28692
  getRiskColor: () => getRiskColor,
28687
28693
  getRiskExplaination: () => getRiskExplaination,
28688
- highlightTextWithLinks: () => highlightTextWithLinks
28694
+ getVesuSingletonAddress: () => getVesuSingletonAddress,
28695
+ highlightTextWithLinks: () => highlightTextWithLinks,
28696
+ toBigInt: () => toBigInt3
28689
28697
  });
28690
28698
 
28691
28699
  // node_modules/.pnpm/axios@1.11.0/node_modules/axios/lib/helpers/bind.js
@@ -31217,23 +31225,27 @@ ${r2}}` : "}", l2;
31217
31225
  this.decimals = decimals;
31218
31226
  }
31219
31227
  toWei() {
31220
- return this.mul(10 ** this.decimals).toFixed(0);
31228
+ return super.mul(10 ** this.decimals).toFixed(0);
31221
31229
  }
31222
31230
  multipliedBy(value) {
31223
31231
  const _value = this.getStandardString(value);
31224
- return this.construct(this.mul(_value).toString(), this.decimals);
31232
+ return this.construct(super.mul(_value).toString(), this.decimals);
31225
31233
  }
31226
31234
  dividedBy(value) {
31227
31235
  const _value = this.getStandardString(value);
31228
- return this.construct(this.div(_value).toString(), this.decimals);
31236
+ return this.construct(super.dividedBy(_value).toString(), this.decimals);
31229
31237
  }
31230
31238
  plus(value) {
31231
- const _value = this.getStandardString(value);
31232
- return this.construct(this.add(_value).toString(), this.decimals);
31239
+ const rawValue = this.getStandardString(value);
31240
+ const thisBN = new import_bignumber.default(this.toString());
31241
+ const result = thisBN.plus(rawValue);
31242
+ return this.construct(result.toString(), this.decimals);
31233
31243
  }
31234
31244
  minus(n, base2) {
31235
- const _value = this.getStandardString(n);
31236
- return this.construct(super.minus(_value, base2).toString(), this.decimals);
31245
+ const rawValue = this.getStandardString(n);
31246
+ const thisBN = new import_bignumber.default(this.toString());
31247
+ const result = thisBN.minus(rawValue, base2);
31248
+ return this.construct(result.toString(), this.decimals);
31237
31249
  }
31238
31250
  construct(value, decimals) {
31239
31251
  return new this.constructor(value, decimals);
@@ -31251,10 +31263,13 @@ ${r2}}` : "}", l2;
31251
31263
  return Math.min(this.decimals, 18);
31252
31264
  }
31253
31265
  getStandardString(value) {
31254
- if (typeof value == "string") {
31266
+ if (typeof value === "string") {
31255
31267
  return value;
31256
31268
  }
31257
- return value.toFixed(this.maxToFixedDecimals());
31269
+ if (typeof value === "number") {
31270
+ return value.toString();
31271
+ }
31272
+ return import_bignumber.default.prototype.toString.call(value);
31258
31273
  }
31259
31274
  minimum(value) {
31260
31275
  const _value = new import_bignumber.default(value);
@@ -31265,12 +31280,10 @@ ${r2}}` : "}", l2;
31265
31280
  maximum(value) {
31266
31281
  const _value = new import_bignumber.default(value);
31267
31282
  const _valueMe = new import_bignumber.default(this.toString());
31268
- console.warn(`maximum: _value: ${_value.toString()}, _valueMe: ${_valueMe.toString()}`);
31269
31283
  const answer = _value.greaterThanOrEqualTo(_valueMe) ? _value : _valueMe;
31270
31284
  return this.construct(answer.toString(), this.decimals);
31271
31285
  }
31272
31286
  abs() {
31273
- console.warn(`abs: this: ${this}`);
31274
31287
  return this.construct(Math.abs(this.toNumber()).toFixed(12), this.decimals);
31275
31288
  }
31276
31289
  toI129() {
@@ -49759,7 +49772,7 @@ ${JSON.stringify(data, null, 2)}`;
49759
49772
  }
49760
49773
  async getPriceFromMyAPI(tokenSymbol) {
49761
49774
  logger2.verbose(`getPrice from redis: ${tokenSymbol}`);
49762
- const endpoint = "https://cache-server-t2me.onrender.com";
49775
+ const endpoint = "https://proxy.api.troves.fi";
49763
49776
  const url = `${endpoint}/api/price/${tokenSymbol}`;
49764
49777
  const priceInfoRes = await fetch(url);
49765
49778
  const priceInfo = await priceInfoRes.json();
@@ -55566,6 +55579,9 @@ ${JSON.stringify(data, null, 2)}`;
55566
55579
  async withdrawCall(amountInfo, receiver, owner) {
55567
55580
  throw new Error("Not implemented");
55568
55581
  }
55582
+ async getVaultPositions() {
55583
+ throw new Error("Not implemented");
55584
+ }
55569
55585
  };
55570
55586
 
55571
55587
  // src/node/headless.browser.ts
@@ -55581,7 +55597,7 @@ ${JSON.stringify(data, null, 2)}`;
55581
55597
  sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
55582
55598
  }];
55583
55599
  var ENDPOINTS = {
55584
- VESU_BASE: "https://cache-server-t2me.onrender.com/vesu"
55600
+ VESU_BASE: "https://proxy.api.troves.fi/vesu-staging"
55585
55601
  };
55586
55602
 
55587
55603
  // src/modules/harvests.ts
@@ -67297,6 +67313,49 @@ ${JSON.stringify(data, null, 2)}`;
67297
67313
  const tick = Math.floor(value / tickSpacing) * tickSpacing;
67298
67314
  return this.tickToi129(tick);
67299
67315
  }
67316
+ async getVaultPositions() {
67317
+ const tvlInfo = await this.getTVL();
67318
+ const fees = await this.getUncollectedFees();
67319
+ const unusedBalance = await this.unusedBalances();
67320
+ return [
67321
+ {
67322
+ amount: tvlInfo.token0.amount,
67323
+ usdValue: tvlInfo.token0.usdValue,
67324
+ token: tvlInfo.token0.tokenInfo,
67325
+ remarks: `Liquidity in Ekubo`
67326
+ },
67327
+ {
67328
+ amount: fees.token0.amount,
67329
+ usdValue: fees.token0.usdValue,
67330
+ token: fees.token0.tokenInfo,
67331
+ remarks: "Uncollected Fees in Ekubo"
67332
+ },
67333
+ {
67334
+ amount: unusedBalance.token0.amount,
67335
+ usdValue: unusedBalance.token0.usdValue,
67336
+ token: unusedBalance.token0.tokenInfo,
67337
+ remarks: "Unused Balance in the Vault"
67338
+ },
67339
+ {
67340
+ amount: tvlInfo.token1.amount,
67341
+ usdValue: tvlInfo.token1.usdValue,
67342
+ token: tvlInfo.token1.tokenInfo,
67343
+ remarks: "Liquidity in Ekubo"
67344
+ },
67345
+ {
67346
+ amount: fees.token1.amount,
67347
+ usdValue: fees.token1.usdValue,
67348
+ token: fees.token1.tokenInfo,
67349
+ remarks: "Uncollected Fees in Ekubo"
67350
+ },
67351
+ {
67352
+ amount: unusedBalance.token1.amount,
67353
+ usdValue: unusedBalance.token1.usdValue,
67354
+ token: unusedBalance.token1.tokenInfo,
67355
+ remarks: "Unused Balance in the Vault"
67356
+ }
67357
+ ];
67358
+ }
67300
67359
  async getPoolKey(blockIdentifier = "latest") {
67301
67360
  if (this.poolKey) {
67302
67361
  return this.poolKey;
@@ -70452,9 +70511,11 @@ ${JSON.stringify(data, null, 2)}`;
70452
70511
 
70453
70512
  // src/strategies/universal-adapters/adapter-utils.ts
70454
70513
  var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
70455
- var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a");
70514
+ var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x7b6f98311af8aa425278570e62abf523e6462eaa01a38c1feab9b2f416492e2");
70515
+ var SIMPLE_SANITIZER_VESU_V1_DELEGATIONS = ContractAddr.from("0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a");
70456
70516
  var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
70457
70517
  var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
70518
+ var VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
70458
70519
  function toBigInt3(value) {
70459
70520
  if (typeof value === "string") {
70460
70521
  return BigInt(value);
@@ -73385,529 +73446,2424 @@ ${JSON.stringify(data, null, 2)}`;
73385
73446
  }
73386
73447
  ];
73387
73448
 
73388
- // src/strategies/universal-adapters/vesu-adapter.ts
73389
- var VesuAmountType = /* @__PURE__ */ ((VesuAmountType2) => {
73390
- VesuAmountType2[VesuAmountType2["Delta"] = 0] = "Delta";
73391
- VesuAmountType2[VesuAmountType2["Target"] = 1] = "Target";
73392
- return VesuAmountType2;
73393
- })(VesuAmountType || {});
73394
- var VesuAmountDenomination = /* @__PURE__ */ ((VesuAmountDenomination2) => {
73395
- VesuAmountDenomination2[VesuAmountDenomination2["Native"] = 0] = "Native";
73396
- VesuAmountDenomination2[VesuAmountDenomination2["Assets"] = 1] = "Assets";
73397
- return VesuAmountDenomination2;
73398
- })(VesuAmountDenomination || {});
73399
- function getVesuMultiplyParams(isIncrease, params) {
73400
- if (isIncrease) {
73401
- const _params2 = params;
73402
- return {
73403
- action: new CairoCustomEnum({ IncreaseLever: {
73404
- pool_id: _params2.pool_id.toBigInt(),
73405
- collateral_asset: _params2.collateral_asset.toBigInt(),
73406
- debt_asset: _params2.debt_asset.toBigInt(),
73407
- user: _params2.user.toBigInt(),
73408
- add_margin: BigInt(_params2.add_margin.toWei()),
73409
- margin_swap: _params2.margin_swap.map((swap) => ({
73410
- route: swap.route.map((route) => ({
73411
- pool_key: {
73412
- token0: route.pool_key.token0.toBigInt(),
73413
- token1: route.pool_key.token1.toBigInt(),
73414
- fee: route.pool_key.fee,
73415
- tick_spacing: route.pool_key.tick_spacing,
73416
- extension: BigInt(num_exports.hexToDecimalString(route.pool_key.extension))
73417
- },
73418
- sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
73419
- skip_ahead: BigInt(100)
73420
- })),
73421
- token_amount: {
73422
- token: swap.token_amount.token.toBigInt(),
73423
- amount: swap.token_amount.amount.toI129()
73424
- }
73425
- })),
73426
- margin_swap_limit_amount: BigInt(_params2.margin_swap_limit_amount.toWei()),
73427
- lever_swap: _params2.lever_swap.map((swap) => ({
73428
- route: swap.route.map((route) => ({
73429
- pool_key: {
73430
- token0: route.pool_key.token0.toBigInt(),
73431
- token1: route.pool_key.token1.toBigInt(),
73432
- fee: route.pool_key.fee,
73433
- tick_spacing: route.pool_key.tick_spacing,
73434
- extension: BigInt(num_exports.hexToDecimalString(route.pool_key.extension))
73435
- },
73436
- sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
73437
- skip_ahead: BigInt(100)
73438
- })),
73439
- token_amount: {
73440
- token: swap.token_amount.token.toBigInt(),
73441
- amount: swap.token_amount.amount.toI129()
73442
- }
73443
- })),
73444
- lever_swap_limit_amount: BigInt(_params2.lever_swap_limit_amount.toWei())
73445
- } })
73446
- };
73447
- }
73448
- const _params = params;
73449
- return {
73450
- action: new CairoCustomEnum({ DecreaseLever: {
73451
- pool_id: _params.pool_id.toBigInt(),
73452
- collateral_asset: _params.collateral_asset.toBigInt(),
73453
- debt_asset: _params.debt_asset.toBigInt(),
73454
- user: _params.user.toBigInt(),
73455
- sub_margin: BigInt(_params.sub_margin.toWei()),
73456
- recipient: _params.recipient.toBigInt(),
73457
- lever_swap: _params.lever_swap.map((swap) => ({
73458
- route: swap.route.map((route) => ({
73459
- pool_key: {
73460
- token0: route.pool_key.token0.toBigInt(),
73461
- token1: route.pool_key.token1.toBigInt(),
73462
- fee: route.pool_key.fee,
73463
- tick_spacing: route.pool_key.tick_spacing,
73464
- extension: ContractAddr.from(route.pool_key.extension).toBigInt()
73465
- },
73466
- sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
73467
- skip_ahead: BigInt(route.skip_ahead.toWei())
73468
- })),
73469
- token_amount: {
73470
- token: swap.token_amount.token.toBigInt(),
73471
- amount: swap.token_amount.amount.toI129()
73472
- }
73473
- })),
73474
- lever_swap_limit_amount: BigInt(_params.lever_swap_limit_amount.toWei()),
73475
- lever_swap_weights: _params.lever_swap_weights.map((weight) => BigInt(weight.toWei())),
73476
- withdraw_swap: _params.withdraw_swap.map((swap) => ({
73477
- route: swap.route.map((route) => ({
73478
- pool_key: {
73479
- token0: route.pool_key.token0.toBigInt(),
73480
- token1: route.pool_key.token1.toBigInt(),
73481
- fee: route.pool_key.fee,
73482
- tick_spacing: route.pool_key.tick_spacing,
73483
- extension: ContractAddr.from(route.pool_key.extension).toBigInt()
73484
- },
73485
- sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
73486
- skip_ahead: BigInt(route.skip_ahead.toWei())
73487
- })),
73488
- token_amount: {
73489
- token: swap.token_amount.token.toBigInt(),
73490
- amount: swap.token_amount.amount.toI129()
73491
- }
73492
- })),
73493
- withdraw_swap_limit_amount: BigInt(_params.withdraw_swap_limit_amount.toWei()),
73494
- withdraw_swap_weights: _params.withdraw_swap_weights.map((weight) => BigInt(weight.toWei())),
73495
- close_position: _params.close_position
73496
- } })
73497
- };
73498
- }
73499
- var VesuPools = {
73500
- Genesis: ContractAddr.from("0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28"),
73501
- Re7xSTRK: ContractAddr.from("0x052fb52363939c3aa848f8f4ac28f0a51379f8d1b971d8444de25fbd77d8f161")
73502
- };
73503
- var VesuAdapter = class _VesuAdapter extends BaseAdapter {
73504
- constructor(config3) {
73505
- super();
73506
- this.VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
73507
- this.VESU_MULTIPLY = ContractAddr.from("0x3630f1f8e5b8f5c4c4ae9b6620f8a570ae55cddebc0276c37550e7c118edf67");
73508
- this.getModifyPosition = () => {
73509
- const positionData = [0n];
73510
- const packedArguments = [
73511
- toBigInt3(this.config.poolId.toString()),
73512
- // pool id
73513
- toBigInt3(this.config.collateral.address.toString()),
73514
- // collateral
73515
- toBigInt3(this.config.debt.address.toString()),
73516
- // debt
73517
- toBigInt3(this.config.vaultAllocator.toString()),
73518
- // vault allocator
73519
- toBigInt3(positionData.length),
73520
- ...positionData
73521
- ];
73522
- const output = this.constructSimpleLeafData({
73523
- id: this.config.id,
73524
- target: this.VESU_SINGLETON,
73525
- method: "modify_position",
73526
- packedArguments
73527
- });
73528
- return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
73529
- };
73530
- this.getModifyPositionCall = (params) => {
73531
- const _collateral = {
73532
- amount_type: this.formatAmountTypeEnum(params.collateralAmount.amount_type),
73533
- denomination: this.formatAmountDenominationEnum(params.collateralAmount.denomination),
73534
- value: {
73535
- abs: uint256_exports.bnToUint256(params.collateralAmount.value.abs.toWei()),
73536
- is_negative: params.collateralAmount.value.abs.isZero() ? false : params.collateralAmount.value.is_negative
73537
- }
73538
- };
73539
- logger2.verbose(`VesuAdapter::ConstructingModify::Collateral::${JSON.stringify(_collateral)}`);
73540
- const _debt = {
73541
- amount_type: this.formatAmountTypeEnum(params.debtAmount.amount_type),
73542
- denomination: this.formatAmountDenominationEnum(params.debtAmount.denomination),
73543
- value: {
73544
- abs: uint256_exports.bnToUint256(params.debtAmount.value.abs.toWei()),
73545
- is_negative: params.debtAmount.value.abs.isZero() ? false : params.debtAmount.value.is_negative
73546
- }
73547
- };
73548
- logger2.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`);
73549
- const singletonContract = new Contract({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider2({ nodeUrl: "" }) });
73550
- const call = singletonContract.populate("modify_position", {
73551
- params: {
73552
- pool_id: this.config.poolId.toBigInt(),
73553
- collateral_asset: this.config.collateral.address.toBigInt(),
73554
- debt_asset: this.config.debt.address.toBigInt(),
73555
- user: this.config.vaultAllocator.toBigInt(),
73556
- collateral: _collateral,
73557
- debt: _debt,
73558
- data: [0]
73559
- }
73560
- });
73561
- return {
73562
- sanitizer: SIMPLE_SANITIZER,
73563
- call: {
73564
- contractAddress: this.VESU_SINGLETON,
73565
- selector: hash_exports.getSelectorFromName("modify_position"),
73566
- calldata: [
73567
- ...call.calldata
73568
- ]
73569
- }
73570
- };
73571
- };
73572
- this.getMultiplyAdapter = () => {
73573
- const packedArguments = [
73574
- toBigInt3(this.config.poolId.toString()),
73575
- // pool id
73576
- toBigInt3(this.config.collateral.address.toString()),
73577
- // collateral
73578
- toBigInt3(this.config.debt.address.toString()),
73579
- // debt
73580
- toBigInt3(this.config.vaultAllocator.toString())
73581
- // vault allocator
73582
- ];
73583
- const output = this.constructSimpleLeafData({
73584
- id: this.config.id,
73585
- target: this.VESU_MULTIPLY,
73586
- method: "modify_lever",
73587
- packedArguments
73588
- }, SIMPLE_SANITIZER_V2);
73589
- return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
73590
- };
73591
- this.getMultiplyCall = (params) => {
73592
- const isIncrease = params.isIncrease;
73593
- const multiplyParams = isIncrease ? params.increaseParams : params.decreaseParams;
73594
- if (!multiplyParams) {
73595
- throw new Error("Multiply params are not provided");
73596
- }
73597
- const multiplyContract = new Contract({ abi: vesu_multiple_abi_default, address: this.VESU_MULTIPLY.toString(), providerOrAccount: new RpcProvider2({ nodeUrl: "" }) });
73598
- const call = multiplyContract.populate("modify_lever", {
73599
- modify_lever_params: getVesuMultiplyParams(isIncrease, {
73600
- ...multiplyParams,
73601
- user: this.config.vaultAllocator,
73602
- pool_id: this.config.poolId,
73603
- collateral_asset: this.config.collateral.address,
73604
- debt_asset: this.config.debt.address,
73605
- recipient: this.config.vaultAllocator
73606
- })
73607
- });
73608
- return {
73609
- sanitizer: SIMPLE_SANITIZER_V2,
73610
- call: {
73611
- contractAddress: this.VESU_MULTIPLY,
73612
- selector: hash_exports.getSelectorFromName("modify_lever"),
73613
- calldata: [
73614
- ...call.calldata
73615
- ]
73616
- }
73617
- };
73618
- };
73619
- this.getVesuModifyDelegationAdapter = (id) => {
73620
- return () => {
73621
- const packedArguments = [
73622
- toBigInt3(this.config.poolId.toString()),
73623
- // pool id
73624
- toBigInt3(this.VESU_MULTIPLY.toString())
73625
- // vault allocator
73626
- ];
73627
- const output = this.constructSimpleLeafData({
73628
- id,
73629
- target: this.VESU_SINGLETON,
73630
- method: "modify_delegation",
73631
- packedArguments
73632
- }, SIMPLE_SANITIZER_V2);
73633
- return { leaf: output, callConstructor: this.getVesuModifyDelegationCall.bind(this) };
73634
- };
73635
- };
73636
- this.getVesuModifyDelegationCall = (params) => {
73637
- const singletonContract = new Contract({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider2({ nodeUrl: "" }) });
73638
- const call = singletonContract.populate("modify_delegation", {
73639
- pool_id: this.config.poolId.toBigInt(),
73640
- delegatee: this.VESU_MULTIPLY.toBigInt(),
73641
- delegation: params.delegation
73642
- });
73643
- return {
73644
- sanitizer: SIMPLE_SANITIZER_V2,
73645
- call: {
73646
- contractAddress: this.VESU_SINGLETON,
73647
- selector: hash_exports.getSelectorFromName("modify_delegation"),
73648
- calldata: [
73649
- ...call.calldata
73650
- ]
73651
- }
73652
- };
73653
- };
73654
- this.getDefispringRewardsAdapter = (id) => {
73655
- return () => {
73656
- const packedArguments = [];
73657
- const output = {
73658
- id: BigInt(num_exports.getDecimalString(shortString_exports.encodeShortString(id))),
73659
- readableId: id,
73660
- data: [
73661
- SIMPLE_SANITIZER.toBigInt(),
73662
- // sanitizer address
73663
- VESU_REWARDS_CONTRACT.toBigInt(),
73664
- // contract
73665
- toBigInt3(hash_exports.getSelectorFromName("claim")),
73666
- // method name
73667
- BigInt(packedArguments.length),
73668
- ...packedArguments
73669
- ]
73670
- };
73671
- return { leaf: output, callConstructor: this.getDefiSpringClaimCall().bind(this) };
73672
- };
73673
- };
73674
- this.getDefiSpringClaimCall = () => {
73675
- return (params) => ({
73676
- sanitizer: SIMPLE_SANITIZER,
73677
- call: {
73678
- contractAddress: VESU_REWARDS_CONTRACT,
73679
- selector: hash_exports.getSelectorFromName("claim"),
73680
- calldata: [
73681
- BigInt(params.amount.toWei()),
73682
- BigInt(params.proofs.length),
73683
- ...params.proofs.map((proof) => BigInt(num_exports.hexToDecimalString(proof)))
73684
- ]
73685
- }
73686
- });
73687
- };
73688
- this.config = config3;
73689
- }
73690
- static getDefaultModifyPositionCallParams(params) {
73691
- return {
73692
- collateralAmount: {
73693
- amount_type: 0 /* Delta */,
73694
- denomination: 1 /* Assets */,
73695
- value: {
73696
- abs: params.collateralAmount,
73697
- is_negative: !params.isAddCollateral
73698
- }
73699
- },
73700
- debtAmount: {
73701
- amount_type: 0 /* Delta */,
73702
- denomination: 1 /* Assets */,
73703
- value: {
73704
- abs: params.debtAmount,
73705
- is_negative: !params.isBorrow
73706
- }
73707
- }
73708
- };
73709
- }
73710
- formatAmountTypeEnum(amountType) {
73711
- switch (amountType) {
73712
- case 0 /* Delta */:
73713
- return new CairoCustomEnum({ Delta: {} });
73714
- case 1 /* Target */:
73715
- return new CairoCustomEnum({ Target: {} });
73716
- }
73717
- throw new Error(`Unknown VesuAmountType: ${amountType}`);
73718
- }
73719
- formatAmountDenominationEnum(denomination) {
73720
- switch (denomination) {
73721
- case 0 /* Native */:
73722
- return new CairoCustomEnum({ Native: {} });
73723
- case 1 /* Assets */:
73724
- return new CairoCustomEnum({ Assets: {} });
73725
- }
73726
- throw new Error(`Unknown VesuAmountDenomination: ${denomination}`);
73727
- }
73728
- getVesuSingletonContract(config3) {
73729
- return new Contract({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.address, providerOrAccount: config3.provider });
73730
- }
73731
- async getLTVConfig(config3) {
73732
- const CACHE_KEY = "ltv_config";
73733
- const cacheData = this.getCache(CACHE_KEY);
73734
- if (cacheData) {
73735
- return cacheData;
73736
- }
73737
- const output = await this.getVesuSingletonContract(config3).call("ltv_config", [this.config.poolId.address, this.config.collateral.address.address, this.config.debt.address.address]);
73738
- this.setCache(CACHE_KEY, Number(output.max_ltv) / 1e18, 3e5);
73739
- return this.getCache(CACHE_KEY);
73740
- }
73741
- async getPositions(config3) {
73742
- if (!this.pricer) {
73743
- throw new Error("Pricer is not initialized");
73744
- }
73745
- const CACHE_KEY = "positions";
73746
- const cacheData = this.getCache(CACHE_KEY);
73747
- if (cacheData) {
73748
- return cacheData;
73749
- }
73750
- const output = await this.getVesuSingletonContract(config3).call("position_unsafe", [
73751
- this.config.poolId.address,
73752
- this.config.collateral.address.address,
73753
- this.config.debt.address.address,
73754
- this.config.vaultAllocator.address
73755
- ]);
73756
- const token1Price = await this.pricer.getPrice(this.config.collateral.symbol);
73757
- const token2Price = await this.pricer.getPrice(this.config.debt.symbol);
73758
- const collateralAmount = Web3Number.fromWei(output["1"].toString(), this.config.collateral.decimals);
73759
- const debtAmount = Web3Number.fromWei(output["2"].toString(), this.config.debt.decimals);
73760
- const value = [{
73761
- amount: collateralAmount,
73762
- token: this.config.collateral,
73763
- usdValue: collateralAmount.multipliedBy(token1Price.price).toNumber(),
73764
- remarks: "Collateral"
73765
- }, {
73766
- amount: debtAmount,
73767
- token: this.config.debt,
73768
- usdValue: debtAmount.multipliedBy(token2Price.price).toNumber(),
73769
- remarks: "Debt"
73770
- }];
73771
- this.setCache(CACHE_KEY, value, 6e4);
73772
- return value;
73773
- }
73774
- async getCollateralization(config3) {
73775
- if (!this.pricer) {
73776
- throw new Error("Pricer is not initialized");
73777
- }
73778
- const CACHE_KEY = "collateralization";
73779
- const cacheData = this.getCache(CACHE_KEY);
73780
- if (cacheData) {
73781
- return cacheData;
73782
- }
73783
- const output = await this.getVesuSingletonContract(config3).call("check_collateralization_unsafe", [
73784
- this.config.poolId.address,
73785
- this.config.collateral.address.address,
73786
- this.config.debt.address.address,
73787
- this.config.vaultAllocator.address
73788
- ]);
73789
- const collateralAmount = Web3Number.fromWei(output["1"].toString(), 18);
73790
- const debtAmount = Web3Number.fromWei(output["2"].toString(), 18);
73791
- const value = [{
73792
- token: this.config.collateral,
73793
- usdValue: collateralAmount.toNumber(),
73794
- remarks: "Collateral"
73795
- }, {
73796
- token: this.config.debt,
73797
- usdValue: debtAmount.toNumber(),
73798
- remarks: "Debt"
73799
- }];
73800
- this.setCache(CACHE_KEY, value, 6e4);
73801
- return value;
73802
- }
73803
- async getAssetPrices() {
73804
- const collateralizationProm = this.getCollateralization(this.networkConfig);
73805
- const positionsProm = this.getPositions(this.networkConfig);
73806
- const ltvProm = this.getLTVConfig(this.networkConfig);
73807
- const output = await Promise.all([collateralizationProm, positionsProm, ltvProm]);
73808
- const [collateralization, positions, ltv] = output;
73809
- const collateralTokenAmount = positions[0].amount;
73810
- const collateralUSDAmount = collateralization[0].usdValue;
73811
- const collateralPrice = collateralUSDAmount / collateralTokenAmount.toNumber();
73812
- const debtTokenAmount = positions[1].amount;
73813
- const debtUSDAmount = collateralization[1].usdValue;
73814
- const debtPrice = debtUSDAmount / debtTokenAmount.toNumber();
73815
- return {
73816
- collateralTokenAmount,
73817
- collateralUSDAmount,
73818
- collateralPrice,
73819
- debtTokenAmount,
73820
- debtUSDAmount,
73821
- debtPrice,
73822
- ltv
73823
- };
73824
- }
73825
- async getHealthFactor() {
73826
- const ltv = await this.getLTVConfig(this.networkConfig);
73827
- const collateralisation = await this.getCollateralization(this.networkConfig);
73828
- return collateralisation[0].usdValue * ltv / collateralisation[1].usdValue;
73829
- }
73830
- static async getVesuPools(retry = 0) {
73831
- const CACHE_KEY = "VESU_POOLS";
73832
- const cacheValue = Global.getGlobalCache(CACHE_KEY);
73833
- if (cacheValue) {
73834
- return cacheValue;
73835
- }
73836
- let isErrorPoolsAPI = false;
73837
- let pools = [];
73838
- try {
73839
- const data = await getAPIUsingHeadlessBrowser(
73840
- `${ENDPOINTS.VESU_BASE}/pools`
73841
- );
73842
- pools = data.data;
73843
- for (const pool of vesu_pools_default.data) {
73844
- const found = pools.find((d) => d.id === pool.id);
73845
- if (!found) {
73846
- logger2.verbose(`VesuRebalance: pools: ${JSON.stringify(pools)}`);
73847
- logger2.verbose(
73848
- `VesuRebalance: Pool ${pool.id} not found in Vesu API, using hardcoded data`
73849
- );
73850
- throw new Error(`pool not found [sanity check]: ${pool.id}`);
73851
- }
73852
- }
73853
- } catch (e) {
73854
- logger2.error(
73855
- `${_VesuAdapter.name}: Error fetching pools for retry ${retry}`,
73856
- e
73857
- );
73858
- isErrorPoolsAPI = true;
73859
- if (retry < 10) {
73860
- await new Promise((resolve) => setTimeout(resolve, 5e3 * (retry + 1)));
73861
- return await this.getVesuPools(retry + 1);
73862
- }
73863
- }
73864
- Global.setGlobalCache(CACHE_KEY, { pools, isErrorPoolsAPI }, 3e5);
73865
- return { pools, isErrorPoolsAPI };
73866
- }
73867
- };
73868
-
73869
- // src/data/universal-vault.abi.json
73870
- var universal_vault_abi_default = [
73871
- {
73872
- type: "impl",
73873
- name: "UpgradeableImpl",
73874
- interface_name: "openzeppelin_upgrades::interface::IUpgradeable"
73875
- },
73876
- {
73877
- type: "interface",
73878
- name: "openzeppelin_upgrades::interface::IUpgradeable",
73879
- items: [
73880
- {
73881
- type: "function",
73882
- name: "upgrade",
73883
- inputs: [
73884
- {
73885
- name: "new_class_hash",
73886
- type: "core::starknet::class_hash::ClassHash"
73887
- }
73888
- ],
73889
- outputs: [],
73890
- state_mutability: "external"
73891
- }
73892
- ]
73893
- },
73449
+ // src/data/vesu-pool-v2.abi.json
73450
+ var vesu_pool_v2_abi_default = [
73894
73451
  {
73895
73452
  type: "impl",
73896
- name: "VaultMetadataImpl",
73897
- interface_name: "openzeppelin_token::erc20::interface::IERC20Metadata"
73453
+ name: "PoolImpl",
73454
+ interface_name: "vesu::pool::IPool"
73898
73455
  },
73899
73456
  {
73900
73457
  type: "struct",
73901
- name: "core::byte_array::ByteArray",
73458
+ name: "core::integer::u256",
73902
73459
  members: [
73903
73460
  {
73904
- name: "data",
73905
- type: "core::array::Array::<core::bytes_31::bytes31>"
73461
+ name: "low",
73462
+ type: "core::integer::u128"
73906
73463
  },
73907
73464
  {
73908
- name: "pending_word",
73909
- type: "core::felt252"
73910
- },
73465
+ name: "high",
73466
+ type: "core::integer::u128"
73467
+ }
73468
+ ]
73469
+ },
73470
+ {
73471
+ type: "enum",
73472
+ name: "core::bool",
73473
+ variants: [
73474
+ {
73475
+ name: "False",
73476
+ type: "()"
73477
+ },
73478
+ {
73479
+ name: "True",
73480
+ type: "()"
73481
+ }
73482
+ ]
73483
+ },
73484
+ {
73485
+ type: "struct",
73486
+ name: "vesu::data_model::AssetConfig",
73487
+ members: [
73488
+ {
73489
+ name: "total_collateral_shares",
73490
+ type: "core::integer::u256"
73491
+ },
73492
+ {
73493
+ name: "total_nominal_debt",
73494
+ type: "core::integer::u256"
73495
+ },
73496
+ {
73497
+ name: "reserve",
73498
+ type: "core::integer::u256"
73499
+ },
73500
+ {
73501
+ name: "max_utilization",
73502
+ type: "core::integer::u256"
73503
+ },
73504
+ {
73505
+ name: "floor",
73506
+ type: "core::integer::u256"
73507
+ },
73508
+ {
73509
+ name: "scale",
73510
+ type: "core::integer::u256"
73511
+ },
73512
+ {
73513
+ name: "is_legacy",
73514
+ type: "core::bool"
73515
+ },
73516
+ {
73517
+ name: "last_updated",
73518
+ type: "core::integer::u64"
73519
+ },
73520
+ {
73521
+ name: "last_rate_accumulator",
73522
+ type: "core::integer::u256"
73523
+ },
73524
+ {
73525
+ name: "last_full_utilization_rate",
73526
+ type: "core::integer::u256"
73527
+ },
73528
+ {
73529
+ name: "fee_rate",
73530
+ type: "core::integer::u256"
73531
+ },
73532
+ {
73533
+ name: "fee_shares",
73534
+ type: "core::integer::u256"
73535
+ }
73536
+ ]
73537
+ },
73538
+ {
73539
+ type: "struct",
73540
+ name: "vesu::data_model::AssetPrice",
73541
+ members: [
73542
+ {
73543
+ name: "value",
73544
+ type: "core::integer::u256"
73545
+ },
73546
+ {
73547
+ name: "is_valid",
73548
+ type: "core::bool"
73549
+ }
73550
+ ]
73551
+ },
73552
+ {
73553
+ type: "struct",
73554
+ name: "vesu::data_model::Position",
73555
+ members: [
73556
+ {
73557
+ name: "collateral_shares",
73558
+ type: "core::integer::u256"
73559
+ },
73560
+ {
73561
+ name: "nominal_debt",
73562
+ type: "core::integer::u256"
73563
+ }
73564
+ ]
73565
+ },
73566
+ {
73567
+ type: "struct",
73568
+ name: "vesu::data_model::Context",
73569
+ members: [
73570
+ {
73571
+ name: "collateral_asset",
73572
+ type: "core::starknet::contract_address::ContractAddress"
73573
+ },
73574
+ {
73575
+ name: "debt_asset",
73576
+ type: "core::starknet::contract_address::ContractAddress"
73577
+ },
73578
+ {
73579
+ name: "collateral_asset_config",
73580
+ type: "vesu::data_model::AssetConfig"
73581
+ },
73582
+ {
73583
+ name: "debt_asset_config",
73584
+ type: "vesu::data_model::AssetConfig"
73585
+ },
73586
+ {
73587
+ name: "collateral_asset_price",
73588
+ type: "vesu::data_model::AssetPrice"
73589
+ },
73590
+ {
73591
+ name: "debt_asset_price",
73592
+ type: "vesu::data_model::AssetPrice"
73593
+ },
73594
+ {
73595
+ name: "max_ltv",
73596
+ type: "core::integer::u64"
73597
+ },
73598
+ {
73599
+ name: "user",
73600
+ type: "core::starknet::contract_address::ContractAddress"
73601
+ },
73602
+ {
73603
+ name: "position",
73604
+ type: "vesu::data_model::Position"
73605
+ }
73606
+ ]
73607
+ },
73608
+ {
73609
+ type: "struct",
73610
+ name: "alexandria_math::i257::i257",
73611
+ members: [
73612
+ {
73613
+ name: "abs",
73614
+ type: "core::integer::u256"
73615
+ },
73616
+ {
73617
+ name: "is_negative",
73618
+ type: "core::bool"
73619
+ }
73620
+ ]
73621
+ },
73622
+ {
73623
+ type: "enum",
73624
+ name: "vesu::data_model::AmountDenomination",
73625
+ variants: [
73626
+ {
73627
+ name: "Native",
73628
+ type: "()"
73629
+ },
73630
+ {
73631
+ name: "Assets",
73632
+ type: "()"
73633
+ }
73634
+ ]
73635
+ },
73636
+ {
73637
+ type: "struct",
73638
+ name: "vesu::data_model::Amount",
73639
+ members: [
73640
+ {
73641
+ name: "denomination",
73642
+ type: "vesu::data_model::AmountDenomination"
73643
+ },
73644
+ {
73645
+ name: "value",
73646
+ type: "alexandria_math::i257::i257"
73647
+ }
73648
+ ]
73649
+ },
73650
+ {
73651
+ type: "struct",
73652
+ name: "vesu::data_model::ModifyPositionParams",
73653
+ members: [
73654
+ {
73655
+ name: "collateral_asset",
73656
+ type: "core::starknet::contract_address::ContractAddress"
73657
+ },
73658
+ {
73659
+ name: "debt_asset",
73660
+ type: "core::starknet::contract_address::ContractAddress"
73661
+ },
73662
+ {
73663
+ name: "user",
73664
+ type: "core::starknet::contract_address::ContractAddress"
73665
+ },
73666
+ {
73667
+ name: "collateral",
73668
+ type: "vesu::data_model::Amount"
73669
+ },
73670
+ {
73671
+ name: "debt",
73672
+ type: "vesu::data_model::Amount"
73673
+ }
73674
+ ]
73675
+ },
73676
+ {
73677
+ type: "struct",
73678
+ name: "vesu::data_model::UpdatePositionResponse",
73679
+ members: [
73680
+ {
73681
+ name: "collateral_delta",
73682
+ type: "alexandria_math::i257::i257"
73683
+ },
73684
+ {
73685
+ name: "collateral_shares_delta",
73686
+ type: "alexandria_math::i257::i257"
73687
+ },
73688
+ {
73689
+ name: "debt_delta",
73690
+ type: "alexandria_math::i257::i257"
73691
+ },
73692
+ {
73693
+ name: "nominal_debt_delta",
73694
+ type: "alexandria_math::i257::i257"
73695
+ },
73696
+ {
73697
+ name: "bad_debt",
73698
+ type: "core::integer::u256"
73699
+ }
73700
+ ]
73701
+ },
73702
+ {
73703
+ type: "struct",
73704
+ name: "vesu::data_model::LiquidatePositionParams",
73705
+ members: [
73706
+ {
73707
+ name: "collateral_asset",
73708
+ type: "core::starknet::contract_address::ContractAddress"
73709
+ },
73710
+ {
73711
+ name: "debt_asset",
73712
+ type: "core::starknet::contract_address::ContractAddress"
73713
+ },
73714
+ {
73715
+ name: "user",
73716
+ type: "core::starknet::contract_address::ContractAddress"
73717
+ },
73718
+ {
73719
+ name: "min_collateral_to_receive",
73720
+ type: "core::integer::u256"
73721
+ },
73722
+ {
73723
+ name: "debt_to_repay",
73724
+ type: "core::integer::u256"
73725
+ }
73726
+ ]
73727
+ },
73728
+ {
73729
+ type: "struct",
73730
+ name: "core::array::Span::<core::felt252>",
73731
+ members: [
73732
+ {
73733
+ name: "snapshot",
73734
+ type: "@core::array::Array::<core::felt252>"
73735
+ }
73736
+ ]
73737
+ },
73738
+ {
73739
+ type: "struct",
73740
+ name: "vesu::data_model::AssetParams",
73741
+ members: [
73742
+ {
73743
+ name: "asset",
73744
+ type: "core::starknet::contract_address::ContractAddress"
73745
+ },
73746
+ {
73747
+ name: "floor",
73748
+ type: "core::integer::u256"
73749
+ },
73750
+ {
73751
+ name: "initial_full_utilization_rate",
73752
+ type: "core::integer::u256"
73753
+ },
73754
+ {
73755
+ name: "max_utilization",
73756
+ type: "core::integer::u256"
73757
+ },
73758
+ {
73759
+ name: "is_legacy",
73760
+ type: "core::bool"
73761
+ },
73762
+ {
73763
+ name: "fee_rate",
73764
+ type: "core::integer::u256"
73765
+ }
73766
+ ]
73767
+ },
73768
+ {
73769
+ type: "struct",
73770
+ name: "vesu::interest_rate_model::InterestRateConfig",
73771
+ members: [
73772
+ {
73773
+ name: "min_target_utilization",
73774
+ type: "core::integer::u256"
73775
+ },
73776
+ {
73777
+ name: "max_target_utilization",
73778
+ type: "core::integer::u256"
73779
+ },
73780
+ {
73781
+ name: "target_utilization",
73782
+ type: "core::integer::u256"
73783
+ },
73784
+ {
73785
+ name: "min_full_utilization_rate",
73786
+ type: "core::integer::u256"
73787
+ },
73788
+ {
73789
+ name: "max_full_utilization_rate",
73790
+ type: "core::integer::u256"
73791
+ },
73792
+ {
73793
+ name: "zero_utilization_rate",
73794
+ type: "core::integer::u256"
73795
+ },
73796
+ {
73797
+ name: "rate_half_life",
73798
+ type: "core::integer::u256"
73799
+ },
73800
+ {
73801
+ name: "target_rate_percent",
73802
+ type: "core::integer::u256"
73803
+ }
73804
+ ]
73805
+ },
73806
+ {
73807
+ type: "struct",
73808
+ name: "vesu::data_model::Pair",
73809
+ members: [
73810
+ {
73811
+ name: "total_collateral_shares",
73812
+ type: "core::integer::u256"
73813
+ },
73814
+ {
73815
+ name: "total_nominal_debt",
73816
+ type: "core::integer::u256"
73817
+ }
73818
+ ]
73819
+ },
73820
+ {
73821
+ type: "struct",
73822
+ name: "vesu::data_model::PairConfig",
73823
+ members: [
73824
+ {
73825
+ name: "max_ltv",
73826
+ type: "core::integer::u64"
73827
+ },
73828
+ {
73829
+ name: "liquidation_factor",
73830
+ type: "core::integer::u64"
73831
+ },
73832
+ {
73833
+ name: "debt_cap",
73834
+ type: "core::integer::u128"
73835
+ }
73836
+ ]
73837
+ },
73838
+ {
73839
+ type: "enum",
73840
+ name: "core::option::Option::<(core::starknet::class_hash::ClassHash, core::array::Span::<core::felt252>)>",
73841
+ variants: [
73842
+ {
73843
+ name: "Some",
73844
+ type: "(core::starknet::class_hash::ClassHash, core::array::Span::<core::felt252>)"
73845
+ },
73846
+ {
73847
+ name: "None",
73848
+ type: "()"
73849
+ }
73850
+ ]
73851
+ },
73852
+ {
73853
+ type: "interface",
73854
+ name: "vesu::pool::IPool",
73855
+ items: [
73856
+ {
73857
+ type: "function",
73858
+ name: "pool_name",
73859
+ inputs: [],
73860
+ outputs: [
73861
+ {
73862
+ type: "core::felt252"
73863
+ }
73864
+ ],
73865
+ state_mutability: "view"
73866
+ },
73867
+ {
73868
+ type: "function",
73869
+ name: "context",
73870
+ inputs: [
73871
+ {
73872
+ name: "collateral_asset",
73873
+ type: "core::starknet::contract_address::ContractAddress"
73874
+ },
73875
+ {
73876
+ name: "debt_asset",
73877
+ type: "core::starknet::contract_address::ContractAddress"
73878
+ },
73879
+ {
73880
+ name: "user",
73881
+ type: "core::starknet::contract_address::ContractAddress"
73882
+ }
73883
+ ],
73884
+ outputs: [
73885
+ {
73886
+ type: "vesu::data_model::Context"
73887
+ }
73888
+ ],
73889
+ state_mutability: "view"
73890
+ },
73891
+ {
73892
+ type: "function",
73893
+ name: "position",
73894
+ inputs: [
73895
+ {
73896
+ name: "collateral_asset",
73897
+ type: "core::starknet::contract_address::ContractAddress"
73898
+ },
73899
+ {
73900
+ name: "debt_asset",
73901
+ type: "core::starknet::contract_address::ContractAddress"
73902
+ },
73903
+ {
73904
+ name: "user",
73905
+ type: "core::starknet::contract_address::ContractAddress"
73906
+ }
73907
+ ],
73908
+ outputs: [
73909
+ {
73910
+ type: "(vesu::data_model::Position, core::integer::u256, core::integer::u256)"
73911
+ }
73912
+ ],
73913
+ state_mutability: "view"
73914
+ },
73915
+ {
73916
+ type: "function",
73917
+ name: "check_collateralization",
73918
+ inputs: [
73919
+ {
73920
+ name: "collateral_asset",
73921
+ type: "core::starknet::contract_address::ContractAddress"
73922
+ },
73923
+ {
73924
+ name: "debt_asset",
73925
+ type: "core::starknet::contract_address::ContractAddress"
73926
+ },
73927
+ {
73928
+ name: "user",
73929
+ type: "core::starknet::contract_address::ContractAddress"
73930
+ }
73931
+ ],
73932
+ outputs: [
73933
+ {
73934
+ type: "(core::bool, core::integer::u256, core::integer::u256)"
73935
+ }
73936
+ ],
73937
+ state_mutability: "view"
73938
+ },
73939
+ {
73940
+ type: "function",
73941
+ name: "check_invariants",
73942
+ inputs: [
73943
+ {
73944
+ name: "collateral_asset",
73945
+ type: "core::starknet::contract_address::ContractAddress"
73946
+ },
73947
+ {
73948
+ name: "debt_asset",
73949
+ type: "core::starknet::contract_address::ContractAddress"
73950
+ },
73951
+ {
73952
+ name: "user",
73953
+ type: "core::starknet::contract_address::ContractAddress"
73954
+ },
73955
+ {
73956
+ name: "collateral_delta",
73957
+ type: "alexandria_math::i257::i257"
73958
+ },
73959
+ {
73960
+ name: "collateral_shares_delta",
73961
+ type: "alexandria_math::i257::i257"
73962
+ },
73963
+ {
73964
+ name: "debt_delta",
73965
+ type: "alexandria_math::i257::i257"
73966
+ },
73967
+ {
73968
+ name: "nominal_debt_delta",
73969
+ type: "alexandria_math::i257::i257"
73970
+ },
73971
+ {
73972
+ name: "is_liquidation",
73973
+ type: "core::bool"
73974
+ }
73975
+ ],
73976
+ outputs: [],
73977
+ state_mutability: "view"
73978
+ },
73979
+ {
73980
+ type: "function",
73981
+ name: "modify_position",
73982
+ inputs: [
73983
+ {
73984
+ name: "params",
73985
+ type: "vesu::data_model::ModifyPositionParams"
73986
+ }
73987
+ ],
73988
+ outputs: [
73989
+ {
73990
+ type: "vesu::data_model::UpdatePositionResponse"
73991
+ }
73992
+ ],
73993
+ state_mutability: "external"
73994
+ },
73995
+ {
73996
+ type: "function",
73997
+ name: "liquidate_position",
73998
+ inputs: [
73999
+ {
74000
+ name: "params",
74001
+ type: "vesu::data_model::LiquidatePositionParams"
74002
+ }
74003
+ ],
74004
+ outputs: [
74005
+ {
74006
+ type: "vesu::data_model::UpdatePositionResponse"
74007
+ }
74008
+ ],
74009
+ state_mutability: "external"
74010
+ },
74011
+ {
74012
+ type: "function",
74013
+ name: "flash_loan",
74014
+ inputs: [
74015
+ {
74016
+ name: "receiver",
74017
+ type: "core::starknet::contract_address::ContractAddress"
74018
+ },
74019
+ {
74020
+ name: "asset",
74021
+ type: "core::starknet::contract_address::ContractAddress"
74022
+ },
74023
+ {
74024
+ name: "amount",
74025
+ type: "core::integer::u256"
74026
+ },
74027
+ {
74028
+ name: "is_legacy",
74029
+ type: "core::bool"
74030
+ },
74031
+ {
74032
+ name: "data",
74033
+ type: "core::array::Span::<core::felt252>"
74034
+ }
74035
+ ],
74036
+ outputs: [],
74037
+ state_mutability: "external"
74038
+ },
74039
+ {
74040
+ type: "function",
74041
+ name: "modify_delegation",
74042
+ inputs: [
74043
+ {
74044
+ name: "delegatee",
74045
+ type: "core::starknet::contract_address::ContractAddress"
74046
+ },
74047
+ {
74048
+ name: "delegation",
74049
+ type: "core::bool"
74050
+ }
74051
+ ],
74052
+ outputs: [],
74053
+ state_mutability: "external"
74054
+ },
74055
+ {
74056
+ type: "function",
74057
+ name: "delegation",
74058
+ inputs: [
74059
+ {
74060
+ name: "delegator",
74061
+ type: "core::starknet::contract_address::ContractAddress"
74062
+ },
74063
+ {
74064
+ name: "delegatee",
74065
+ type: "core::starknet::contract_address::ContractAddress"
74066
+ }
74067
+ ],
74068
+ outputs: [
74069
+ {
74070
+ type: "core::bool"
74071
+ }
74072
+ ],
74073
+ state_mutability: "view"
74074
+ },
74075
+ {
74076
+ type: "function",
74077
+ name: "donate_to_reserve",
74078
+ inputs: [
74079
+ {
74080
+ name: "asset",
74081
+ type: "core::starknet::contract_address::ContractAddress"
74082
+ },
74083
+ {
74084
+ name: "amount",
74085
+ type: "core::integer::u256"
74086
+ }
74087
+ ],
74088
+ outputs: [],
74089
+ state_mutability: "external"
74090
+ },
74091
+ {
74092
+ type: "function",
74093
+ name: "add_asset",
74094
+ inputs: [
74095
+ {
74096
+ name: "params",
74097
+ type: "vesu::data_model::AssetParams"
74098
+ },
74099
+ {
74100
+ name: "interest_rate_config",
74101
+ type: "vesu::interest_rate_model::InterestRateConfig"
74102
+ }
74103
+ ],
74104
+ outputs: [],
74105
+ state_mutability: "external"
74106
+ },
74107
+ {
74108
+ type: "function",
74109
+ name: "set_asset_parameter",
74110
+ inputs: [
74111
+ {
74112
+ name: "asset",
74113
+ type: "core::starknet::contract_address::ContractAddress"
74114
+ },
74115
+ {
74116
+ name: "parameter",
74117
+ type: "core::felt252"
74118
+ },
74119
+ {
74120
+ name: "value",
74121
+ type: "core::integer::u256"
74122
+ }
74123
+ ],
74124
+ outputs: [],
74125
+ state_mutability: "external"
74126
+ },
74127
+ {
74128
+ type: "function",
74129
+ name: "asset_config",
74130
+ inputs: [
74131
+ {
74132
+ name: "asset",
74133
+ type: "core::starknet::contract_address::ContractAddress"
74134
+ }
74135
+ ],
74136
+ outputs: [
74137
+ {
74138
+ type: "vesu::data_model::AssetConfig"
74139
+ }
74140
+ ],
74141
+ state_mutability: "view"
74142
+ },
74143
+ {
74144
+ type: "function",
74145
+ name: "set_oracle",
74146
+ inputs: [
74147
+ {
74148
+ name: "oracle",
74149
+ type: "core::starknet::contract_address::ContractAddress"
74150
+ }
74151
+ ],
74152
+ outputs: [],
74153
+ state_mutability: "external"
74154
+ },
74155
+ {
74156
+ type: "function",
74157
+ name: "oracle",
74158
+ inputs: [],
74159
+ outputs: [
74160
+ {
74161
+ type: "core::starknet::contract_address::ContractAddress"
74162
+ }
74163
+ ],
74164
+ state_mutability: "view"
74165
+ },
74166
+ {
74167
+ type: "function",
74168
+ name: "price",
74169
+ inputs: [
74170
+ {
74171
+ name: "asset",
74172
+ type: "core::starknet::contract_address::ContractAddress"
74173
+ }
74174
+ ],
74175
+ outputs: [
74176
+ {
74177
+ type: "vesu::data_model::AssetPrice"
74178
+ }
74179
+ ],
74180
+ state_mutability: "view"
74181
+ },
74182
+ {
74183
+ type: "function",
74184
+ name: "set_fee_recipient",
74185
+ inputs: [
74186
+ {
74187
+ name: "fee_recipient",
74188
+ type: "core::starknet::contract_address::ContractAddress"
74189
+ }
74190
+ ],
74191
+ outputs: [],
74192
+ state_mutability: "external"
74193
+ },
74194
+ {
74195
+ type: "function",
74196
+ name: "fee_recipient",
74197
+ inputs: [],
74198
+ outputs: [
74199
+ {
74200
+ type: "core::starknet::contract_address::ContractAddress"
74201
+ }
74202
+ ],
74203
+ state_mutability: "view"
74204
+ },
74205
+ {
74206
+ type: "function",
74207
+ name: "claim_fees",
74208
+ inputs: [
74209
+ {
74210
+ name: "asset",
74211
+ type: "core::starknet::contract_address::ContractAddress"
74212
+ },
74213
+ {
74214
+ name: "fee_shares",
74215
+ type: "core::integer::u256"
74216
+ }
74217
+ ],
74218
+ outputs: [],
74219
+ state_mutability: "external"
74220
+ },
74221
+ {
74222
+ type: "function",
74223
+ name: "get_fees",
74224
+ inputs: [
74225
+ {
74226
+ name: "asset",
74227
+ type: "core::starknet::contract_address::ContractAddress"
74228
+ }
74229
+ ],
74230
+ outputs: [
74231
+ {
74232
+ type: "(core::integer::u256, core::integer::u256)"
74233
+ }
74234
+ ],
74235
+ state_mutability: "view"
74236
+ },
74237
+ {
74238
+ type: "function",
74239
+ name: "rate_accumulator",
74240
+ inputs: [
74241
+ {
74242
+ name: "asset",
74243
+ type: "core::starknet::contract_address::ContractAddress"
74244
+ }
74245
+ ],
74246
+ outputs: [
74247
+ {
74248
+ type: "core::integer::u256"
74249
+ }
74250
+ ],
74251
+ state_mutability: "view"
74252
+ },
74253
+ {
74254
+ type: "function",
74255
+ name: "utilization",
74256
+ inputs: [
74257
+ {
74258
+ name: "asset",
74259
+ type: "core::starknet::contract_address::ContractAddress"
74260
+ }
74261
+ ],
74262
+ outputs: [
74263
+ {
74264
+ type: "core::integer::u256"
74265
+ }
74266
+ ],
74267
+ state_mutability: "view"
74268
+ },
74269
+ {
74270
+ type: "function",
74271
+ name: "interest_rate",
74272
+ inputs: [
74273
+ {
74274
+ name: "asset",
74275
+ type: "core::starknet::contract_address::ContractAddress"
74276
+ },
74277
+ {
74278
+ name: "utilization",
74279
+ type: "core::integer::u256"
74280
+ },
74281
+ {
74282
+ name: "last_updated",
74283
+ type: "core::integer::u64"
74284
+ },
74285
+ {
74286
+ name: "last_full_utilization_rate",
74287
+ type: "core::integer::u256"
74288
+ }
74289
+ ],
74290
+ outputs: [
74291
+ {
74292
+ type: "core::integer::u256"
74293
+ }
74294
+ ],
74295
+ state_mutability: "view"
74296
+ },
74297
+ {
74298
+ type: "function",
74299
+ name: "set_interest_rate_parameter",
74300
+ inputs: [
74301
+ {
74302
+ name: "asset",
74303
+ type: "core::starknet::contract_address::ContractAddress"
74304
+ },
74305
+ {
74306
+ name: "parameter",
74307
+ type: "core::felt252"
74308
+ },
74309
+ {
74310
+ name: "value",
74311
+ type: "core::integer::u256"
74312
+ }
74313
+ ],
74314
+ outputs: [],
74315
+ state_mutability: "external"
74316
+ },
74317
+ {
74318
+ type: "function",
74319
+ name: "interest_rate_config",
74320
+ inputs: [
74321
+ {
74322
+ name: "asset",
74323
+ type: "core::starknet::contract_address::ContractAddress"
74324
+ }
74325
+ ],
74326
+ outputs: [
74327
+ {
74328
+ type: "vesu::interest_rate_model::InterestRateConfig"
74329
+ }
74330
+ ],
74331
+ state_mutability: "view"
74332
+ },
74333
+ {
74334
+ type: "function",
74335
+ name: "pairs",
74336
+ inputs: [
74337
+ {
74338
+ name: "collateral_asset",
74339
+ type: "core::starknet::contract_address::ContractAddress"
74340
+ },
74341
+ {
74342
+ name: "debt_asset",
74343
+ type: "core::starknet::contract_address::ContractAddress"
74344
+ }
74345
+ ],
74346
+ outputs: [
74347
+ {
74348
+ type: "vesu::data_model::Pair"
74349
+ }
74350
+ ],
74351
+ state_mutability: "view"
74352
+ },
74353
+ {
74354
+ type: "function",
74355
+ name: "set_pair_config",
74356
+ inputs: [
74357
+ {
74358
+ name: "collateral_asset",
74359
+ type: "core::starknet::contract_address::ContractAddress"
74360
+ },
74361
+ {
74362
+ name: "debt_asset",
74363
+ type: "core::starknet::contract_address::ContractAddress"
74364
+ },
74365
+ {
74366
+ name: "pair_config",
74367
+ type: "vesu::data_model::PairConfig"
74368
+ }
74369
+ ],
74370
+ outputs: [],
74371
+ state_mutability: "external"
74372
+ },
74373
+ {
74374
+ type: "function",
74375
+ name: "set_pair_parameter",
74376
+ inputs: [
74377
+ {
74378
+ name: "collateral_asset",
74379
+ type: "core::starknet::contract_address::ContractAddress"
74380
+ },
74381
+ {
74382
+ name: "debt_asset",
74383
+ type: "core::starknet::contract_address::ContractAddress"
74384
+ },
74385
+ {
74386
+ name: "parameter",
74387
+ type: "core::felt252"
74388
+ },
74389
+ {
74390
+ name: "value",
74391
+ type: "core::integer::u128"
74392
+ }
74393
+ ],
74394
+ outputs: [],
74395
+ state_mutability: "external"
74396
+ },
74397
+ {
74398
+ type: "function",
74399
+ name: "pair_config",
74400
+ inputs: [
74401
+ {
74402
+ name: "collateral_asset",
74403
+ type: "core::starknet::contract_address::ContractAddress"
74404
+ },
74405
+ {
74406
+ name: "debt_asset",
74407
+ type: "core::starknet::contract_address::ContractAddress"
74408
+ }
74409
+ ],
74410
+ outputs: [
74411
+ {
74412
+ type: "vesu::data_model::PairConfig"
74413
+ }
74414
+ ],
74415
+ state_mutability: "view"
74416
+ },
74417
+ {
74418
+ type: "function",
74419
+ name: "calculate_debt",
74420
+ inputs: [
74421
+ {
74422
+ name: "nominal_debt",
74423
+ type: "alexandria_math::i257::i257"
74424
+ },
74425
+ {
74426
+ name: "rate_accumulator",
74427
+ type: "core::integer::u256"
74428
+ },
74429
+ {
74430
+ name: "asset_scale",
74431
+ type: "core::integer::u256"
74432
+ }
74433
+ ],
74434
+ outputs: [
74435
+ {
74436
+ type: "core::integer::u256"
74437
+ }
74438
+ ],
74439
+ state_mutability: "view"
74440
+ },
74441
+ {
74442
+ type: "function",
74443
+ name: "calculate_nominal_debt",
74444
+ inputs: [
74445
+ {
74446
+ name: "debt",
74447
+ type: "alexandria_math::i257::i257"
74448
+ },
74449
+ {
74450
+ name: "rate_accumulator",
74451
+ type: "core::integer::u256"
74452
+ },
74453
+ {
74454
+ name: "asset_scale",
74455
+ type: "core::integer::u256"
74456
+ }
74457
+ ],
74458
+ outputs: [
74459
+ {
74460
+ type: "core::integer::u256"
74461
+ }
74462
+ ],
74463
+ state_mutability: "view"
74464
+ },
74465
+ {
74466
+ type: "function",
74467
+ name: "calculate_collateral_shares",
74468
+ inputs: [
74469
+ {
74470
+ name: "asset",
74471
+ type: "core::starknet::contract_address::ContractAddress"
74472
+ },
74473
+ {
74474
+ name: "collateral",
74475
+ type: "alexandria_math::i257::i257"
74476
+ }
74477
+ ],
74478
+ outputs: [
74479
+ {
74480
+ type: "core::integer::u256"
74481
+ }
74482
+ ],
74483
+ state_mutability: "view"
74484
+ },
74485
+ {
74486
+ type: "function",
74487
+ name: "calculate_collateral",
74488
+ inputs: [
74489
+ {
74490
+ name: "asset",
74491
+ type: "core::starknet::contract_address::ContractAddress"
74492
+ },
74493
+ {
74494
+ name: "collateral_shares",
74495
+ type: "alexandria_math::i257::i257"
74496
+ }
74497
+ ],
74498
+ outputs: [
74499
+ {
74500
+ type: "core::integer::u256"
74501
+ }
74502
+ ],
74503
+ state_mutability: "view"
74504
+ },
74505
+ {
74506
+ type: "function",
74507
+ name: "deconstruct_collateral_amount",
74508
+ inputs: [
74509
+ {
74510
+ name: "collateral_asset",
74511
+ type: "core::starknet::contract_address::ContractAddress"
74512
+ },
74513
+ {
74514
+ name: "debt_asset",
74515
+ type: "core::starknet::contract_address::ContractAddress"
74516
+ },
74517
+ {
74518
+ name: "user",
74519
+ type: "core::starknet::contract_address::ContractAddress"
74520
+ },
74521
+ {
74522
+ name: "collateral",
74523
+ type: "vesu::data_model::Amount"
74524
+ }
74525
+ ],
74526
+ outputs: [
74527
+ {
74528
+ type: "(alexandria_math::i257::i257, alexandria_math::i257::i257)"
74529
+ }
74530
+ ],
74531
+ state_mutability: "view"
74532
+ },
74533
+ {
74534
+ type: "function",
74535
+ name: "deconstruct_debt_amount",
74536
+ inputs: [
74537
+ {
74538
+ name: "collateral_asset",
74539
+ type: "core::starknet::contract_address::ContractAddress"
74540
+ },
74541
+ {
74542
+ name: "debt_asset",
74543
+ type: "core::starknet::contract_address::ContractAddress"
74544
+ },
74545
+ {
74546
+ name: "user",
74547
+ type: "core::starknet::contract_address::ContractAddress"
74548
+ },
74549
+ {
74550
+ name: "debt",
74551
+ type: "vesu::data_model::Amount"
74552
+ }
74553
+ ],
74554
+ outputs: [
74555
+ {
74556
+ type: "(alexandria_math::i257::i257, alexandria_math::i257::i257)"
74557
+ }
74558
+ ],
74559
+ state_mutability: "view"
74560
+ },
74561
+ {
74562
+ type: "function",
74563
+ name: "curator",
74564
+ inputs: [],
74565
+ outputs: [
74566
+ {
74567
+ type: "core::starknet::contract_address::ContractAddress"
74568
+ }
74569
+ ],
74570
+ state_mutability: "view"
74571
+ },
74572
+ {
74573
+ type: "function",
74574
+ name: "pending_curator",
74575
+ inputs: [],
74576
+ outputs: [
74577
+ {
74578
+ type: "core::starknet::contract_address::ContractAddress"
74579
+ }
74580
+ ],
74581
+ state_mutability: "view"
74582
+ },
74583
+ {
74584
+ type: "function",
74585
+ name: "nominate_curator",
74586
+ inputs: [
74587
+ {
74588
+ name: "pending_curator",
74589
+ type: "core::starknet::contract_address::ContractAddress"
74590
+ }
74591
+ ],
74592
+ outputs: [],
74593
+ state_mutability: "external"
74594
+ },
74595
+ {
74596
+ type: "function",
74597
+ name: "accept_curator_ownership",
74598
+ inputs: [],
74599
+ outputs: [],
74600
+ state_mutability: "external"
74601
+ },
74602
+ {
74603
+ type: "function",
74604
+ name: "set_pausing_agent",
74605
+ inputs: [
74606
+ {
74607
+ name: "pausing_agent",
74608
+ type: "core::starknet::contract_address::ContractAddress"
74609
+ }
74610
+ ],
74611
+ outputs: [],
74612
+ state_mutability: "external"
74613
+ },
74614
+ {
74615
+ type: "function",
74616
+ name: "pausing_agent",
74617
+ inputs: [],
74618
+ outputs: [
74619
+ {
74620
+ type: "core::starknet::contract_address::ContractAddress"
74621
+ }
74622
+ ],
74623
+ state_mutability: "view"
74624
+ },
74625
+ {
74626
+ type: "function",
74627
+ name: "pause",
74628
+ inputs: [],
74629
+ outputs: [],
74630
+ state_mutability: "external"
74631
+ },
74632
+ {
74633
+ type: "function",
74634
+ name: "unpause",
74635
+ inputs: [],
74636
+ outputs: [],
74637
+ state_mutability: "external"
74638
+ },
74639
+ {
74640
+ type: "function",
74641
+ name: "is_paused",
74642
+ inputs: [],
74643
+ outputs: [
74644
+ {
74645
+ type: "core::bool"
74646
+ }
74647
+ ],
74648
+ state_mutability: "view"
74649
+ },
74650
+ {
74651
+ type: "function",
74652
+ name: "upgrade_name",
74653
+ inputs: [],
74654
+ outputs: [
74655
+ {
74656
+ type: "core::felt252"
74657
+ }
74658
+ ],
74659
+ state_mutability: "view"
74660
+ },
74661
+ {
74662
+ type: "function",
74663
+ name: "upgrade",
74664
+ inputs: [
74665
+ {
74666
+ name: "new_implementation",
74667
+ type: "core::starknet::class_hash::ClassHash"
74668
+ },
74669
+ {
74670
+ name: "eic_implementation_data",
74671
+ type: "core::option::Option::<(core::starknet::class_hash::ClassHash, core::array::Span::<core::felt252>)>"
74672
+ }
74673
+ ],
74674
+ outputs: [],
74675
+ state_mutability: "external"
74676
+ }
74677
+ ]
74678
+ },
74679
+ {
74680
+ type: "impl",
74681
+ name: "OwnableTwoStepImpl",
74682
+ interface_name: "openzeppelin_access::ownable::interface::IOwnableTwoStep"
74683
+ },
74684
+ {
74685
+ type: "interface",
74686
+ name: "openzeppelin_access::ownable::interface::IOwnableTwoStep",
74687
+ items: [
74688
+ {
74689
+ type: "function",
74690
+ name: "owner",
74691
+ inputs: [],
74692
+ outputs: [
74693
+ {
74694
+ type: "core::starknet::contract_address::ContractAddress"
74695
+ }
74696
+ ],
74697
+ state_mutability: "view"
74698
+ },
74699
+ {
74700
+ type: "function",
74701
+ name: "pending_owner",
74702
+ inputs: [],
74703
+ outputs: [
74704
+ {
74705
+ type: "core::starknet::contract_address::ContractAddress"
74706
+ }
74707
+ ],
74708
+ state_mutability: "view"
74709
+ },
74710
+ {
74711
+ type: "function",
74712
+ name: "accept_ownership",
74713
+ inputs: [],
74714
+ outputs: [],
74715
+ state_mutability: "external"
74716
+ },
74717
+ {
74718
+ type: "function",
74719
+ name: "transfer_ownership",
74720
+ inputs: [
74721
+ {
74722
+ name: "new_owner",
74723
+ type: "core::starknet::contract_address::ContractAddress"
74724
+ }
74725
+ ],
74726
+ outputs: [],
74727
+ state_mutability: "external"
74728
+ },
74729
+ {
74730
+ type: "function",
74731
+ name: "renounce_ownership",
74732
+ inputs: [],
74733
+ outputs: [],
74734
+ state_mutability: "external"
74735
+ }
74736
+ ]
74737
+ },
74738
+ {
74739
+ type: "constructor",
74740
+ name: "constructor",
74741
+ inputs: [
74742
+ {
74743
+ name: "name",
74744
+ type: "core::felt252"
74745
+ },
74746
+ {
74747
+ name: "owner",
74748
+ type: "core::starknet::contract_address::ContractAddress"
74749
+ },
74750
+ {
74751
+ name: "curator",
74752
+ type: "core::starknet::contract_address::ContractAddress"
74753
+ },
74754
+ {
74755
+ name: "oracle",
74756
+ type: "core::starknet::contract_address::ContractAddress"
74757
+ }
74758
+ ]
74759
+ },
74760
+ {
74761
+ type: "event",
74762
+ name: "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferred",
74763
+ kind: "struct",
74764
+ members: [
74765
+ {
74766
+ name: "previous_owner",
74767
+ type: "core::starknet::contract_address::ContractAddress",
74768
+ kind: "key"
74769
+ },
74770
+ {
74771
+ name: "new_owner",
74772
+ type: "core::starknet::contract_address::ContractAddress",
74773
+ kind: "key"
74774
+ }
74775
+ ]
74776
+ },
74777
+ {
74778
+ type: "event",
74779
+ name: "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferStarted",
74780
+ kind: "struct",
74781
+ members: [
74782
+ {
74783
+ name: "previous_owner",
74784
+ type: "core::starknet::contract_address::ContractAddress",
74785
+ kind: "key"
74786
+ },
74787
+ {
74788
+ name: "new_owner",
74789
+ type: "core::starknet::contract_address::ContractAddress",
74790
+ kind: "key"
74791
+ }
74792
+ ]
74793
+ },
74794
+ {
74795
+ type: "event",
74796
+ name: "openzeppelin_access::ownable::ownable::OwnableComponent::Event",
74797
+ kind: "enum",
74798
+ variants: [
74799
+ {
74800
+ name: "OwnershipTransferred",
74801
+ type: "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferred",
74802
+ kind: "nested"
74803
+ },
74804
+ {
74805
+ name: "OwnershipTransferStarted",
74806
+ type: "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferStarted",
74807
+ kind: "nested"
74808
+ }
74809
+ ]
74810
+ },
74811
+ {
74812
+ type: "event",
74813
+ name: "vesu::interest_rate_model::interest_rate_model_component::SetInterestRateConfig",
74814
+ kind: "struct",
74815
+ members: [
74816
+ {
74817
+ name: "asset",
74818
+ type: "core::starknet::contract_address::ContractAddress",
74819
+ kind: "data"
74820
+ },
74821
+ {
74822
+ name: "interest_rate_config",
74823
+ type: "vesu::interest_rate_model::InterestRateConfig",
74824
+ kind: "data"
74825
+ }
74826
+ ]
74827
+ },
74828
+ {
74829
+ type: "event",
74830
+ name: "vesu::interest_rate_model::interest_rate_model_component::Event",
74831
+ kind: "enum",
74832
+ variants: [
74833
+ {
74834
+ name: "SetInterestRateConfig",
74835
+ type: "vesu::interest_rate_model::interest_rate_model_component::SetInterestRateConfig",
74836
+ kind: "nested"
74837
+ }
74838
+ ]
74839
+ },
74840
+ {
74841
+ type: "event",
74842
+ name: "vesu::pool::Pool::UpdateContext",
74843
+ kind: "struct",
74844
+ members: [
74845
+ {
74846
+ name: "collateral_asset",
74847
+ type: "core::starknet::contract_address::ContractAddress",
74848
+ kind: "key"
74849
+ },
74850
+ {
74851
+ name: "debt_asset",
74852
+ type: "core::starknet::contract_address::ContractAddress",
74853
+ kind: "key"
74854
+ },
74855
+ {
74856
+ name: "collateral_asset_config",
74857
+ type: "vesu::data_model::AssetConfig",
74858
+ kind: "data"
74859
+ },
74860
+ {
74861
+ name: "debt_asset_config",
74862
+ type: "vesu::data_model::AssetConfig",
74863
+ kind: "data"
74864
+ },
74865
+ {
74866
+ name: "collateral_asset_price",
74867
+ type: "vesu::data_model::AssetPrice",
74868
+ kind: "data"
74869
+ },
74870
+ {
74871
+ name: "debt_asset_price",
74872
+ type: "vesu::data_model::AssetPrice",
74873
+ kind: "data"
74874
+ }
74875
+ ]
74876
+ },
74877
+ {
74878
+ type: "event",
74879
+ name: "vesu::pool::Pool::ModifyPosition",
74880
+ kind: "struct",
74881
+ members: [
74882
+ {
74883
+ name: "collateral_asset",
74884
+ type: "core::starknet::contract_address::ContractAddress",
74885
+ kind: "key"
74886
+ },
74887
+ {
74888
+ name: "debt_asset",
74889
+ type: "core::starknet::contract_address::ContractAddress",
74890
+ kind: "key"
74891
+ },
74892
+ {
74893
+ name: "user",
74894
+ type: "core::starknet::contract_address::ContractAddress",
74895
+ kind: "key"
74896
+ },
74897
+ {
74898
+ name: "collateral_delta",
74899
+ type: "alexandria_math::i257::i257",
74900
+ kind: "data"
74901
+ },
74902
+ {
74903
+ name: "collateral_shares_delta",
74904
+ type: "alexandria_math::i257::i257",
74905
+ kind: "data"
74906
+ },
74907
+ {
74908
+ name: "debt_delta",
74909
+ type: "alexandria_math::i257::i257",
74910
+ kind: "data"
74911
+ },
74912
+ {
74913
+ name: "nominal_debt_delta",
74914
+ type: "alexandria_math::i257::i257",
74915
+ kind: "data"
74916
+ }
74917
+ ]
74918
+ },
74919
+ {
74920
+ type: "event",
74921
+ name: "vesu::pool::Pool::LiquidatePosition",
74922
+ kind: "struct",
74923
+ members: [
74924
+ {
74925
+ name: "collateral_asset",
74926
+ type: "core::starknet::contract_address::ContractAddress",
74927
+ kind: "key"
74928
+ },
74929
+ {
74930
+ name: "debt_asset",
74931
+ type: "core::starknet::contract_address::ContractAddress",
74932
+ kind: "key"
74933
+ },
74934
+ {
74935
+ name: "user",
74936
+ type: "core::starknet::contract_address::ContractAddress",
74937
+ kind: "key"
74938
+ },
74939
+ {
74940
+ name: "liquidator",
74941
+ type: "core::starknet::contract_address::ContractAddress",
74942
+ kind: "key"
74943
+ },
74944
+ {
74945
+ name: "collateral_delta",
74946
+ type: "alexandria_math::i257::i257",
74947
+ kind: "data"
74948
+ },
74949
+ {
74950
+ name: "collateral_shares_delta",
74951
+ type: "alexandria_math::i257::i257",
74952
+ kind: "data"
74953
+ },
74954
+ {
74955
+ name: "debt_delta",
74956
+ type: "alexandria_math::i257::i257",
74957
+ kind: "data"
74958
+ },
74959
+ {
74960
+ name: "nominal_debt_delta",
74961
+ type: "alexandria_math::i257::i257",
74962
+ kind: "data"
74963
+ },
74964
+ {
74965
+ name: "bad_debt",
74966
+ type: "core::integer::u256",
74967
+ kind: "data"
74968
+ }
74969
+ ]
74970
+ },
74971
+ {
74972
+ type: "event",
74973
+ name: "vesu::pool::Pool::Flashloan",
74974
+ kind: "struct",
74975
+ members: [
74976
+ {
74977
+ name: "sender",
74978
+ type: "core::starknet::contract_address::ContractAddress",
74979
+ kind: "key"
74980
+ },
74981
+ {
74982
+ name: "receiver",
74983
+ type: "core::starknet::contract_address::ContractAddress",
74984
+ kind: "key"
74985
+ },
74986
+ {
74987
+ name: "asset",
74988
+ type: "core::starknet::contract_address::ContractAddress",
74989
+ kind: "key"
74990
+ },
74991
+ {
74992
+ name: "amount",
74993
+ type: "core::integer::u256",
74994
+ kind: "data"
74995
+ }
74996
+ ]
74997
+ },
74998
+ {
74999
+ type: "event",
75000
+ name: "vesu::pool::Pool::ModifyDelegation",
75001
+ kind: "struct",
75002
+ members: [
75003
+ {
75004
+ name: "delegator",
75005
+ type: "core::starknet::contract_address::ContractAddress",
75006
+ kind: "key"
75007
+ },
75008
+ {
75009
+ name: "delegatee",
75010
+ type: "core::starknet::contract_address::ContractAddress",
75011
+ kind: "key"
75012
+ },
75013
+ {
75014
+ name: "delegation",
75015
+ type: "core::bool",
75016
+ kind: "data"
75017
+ }
75018
+ ]
75019
+ },
75020
+ {
75021
+ type: "event",
75022
+ name: "vesu::pool::Pool::Donate",
75023
+ kind: "struct",
75024
+ members: [
75025
+ {
75026
+ name: "asset",
75027
+ type: "core::starknet::contract_address::ContractAddress",
75028
+ kind: "key"
75029
+ },
75030
+ {
75031
+ name: "amount",
75032
+ type: "core::integer::u256",
75033
+ kind: "data"
75034
+ }
75035
+ ]
75036
+ },
75037
+ {
75038
+ type: "event",
75039
+ name: "vesu::pool::Pool::SetAssetConfig",
75040
+ kind: "struct",
75041
+ members: [
75042
+ {
75043
+ name: "asset",
75044
+ type: "core::starknet::contract_address::ContractAddress",
75045
+ kind: "key"
75046
+ },
75047
+ {
75048
+ name: "asset_config",
75049
+ type: "vesu::data_model::AssetConfig",
75050
+ kind: "data"
75051
+ }
75052
+ ]
75053
+ },
75054
+ {
75055
+ type: "event",
75056
+ name: "vesu::pool::Pool::SetOracle",
75057
+ kind: "struct",
75058
+ members: [
75059
+ {
75060
+ name: "oracle",
75061
+ type: "core::starknet::contract_address::ContractAddress",
75062
+ kind: "data"
75063
+ }
75064
+ ]
75065
+ },
75066
+ {
75067
+ type: "event",
75068
+ name: "vesu::pool::Pool::SetPairConfig",
75069
+ kind: "struct",
75070
+ members: [
75071
+ {
75072
+ name: "collateral_asset",
75073
+ type: "core::starknet::contract_address::ContractAddress",
75074
+ kind: "key"
75075
+ },
75076
+ {
75077
+ name: "debt_asset",
75078
+ type: "core::starknet::contract_address::ContractAddress",
75079
+ kind: "key"
75080
+ },
75081
+ {
75082
+ name: "pair_config",
75083
+ type: "vesu::data_model::PairConfig",
75084
+ kind: "data"
75085
+ }
75086
+ ]
75087
+ },
75088
+ {
75089
+ type: "event",
75090
+ name: "vesu::pool::Pool::ClaimFees",
75091
+ kind: "struct",
75092
+ members: [
75093
+ {
75094
+ name: "asset",
75095
+ type: "core::starknet::contract_address::ContractAddress",
75096
+ kind: "key"
75097
+ },
75098
+ {
75099
+ name: "recipient",
75100
+ type: "core::starknet::contract_address::ContractAddress",
75101
+ kind: "data"
75102
+ },
75103
+ {
75104
+ name: "fee_shares",
75105
+ type: "core::integer::u256",
75106
+ kind: "data"
75107
+ },
75108
+ {
75109
+ name: "fee_amount",
75110
+ type: "core::integer::u256",
75111
+ kind: "data"
75112
+ }
75113
+ ]
75114
+ },
75115
+ {
75116
+ type: "event",
75117
+ name: "vesu::pool::Pool::SetFeeRecipient",
75118
+ kind: "struct",
75119
+ members: [
75120
+ {
75121
+ name: "fee_recipient",
75122
+ type: "core::starknet::contract_address::ContractAddress",
75123
+ kind: "key"
75124
+ }
75125
+ ]
75126
+ },
75127
+ {
75128
+ type: "event",
75129
+ name: "vesu::pool::Pool::SetPausingAgent",
75130
+ kind: "struct",
75131
+ members: [
75132
+ {
75133
+ name: "agent",
75134
+ type: "core::starknet::contract_address::ContractAddress",
75135
+ kind: "key"
75136
+ }
75137
+ ]
75138
+ },
75139
+ {
75140
+ type: "event",
75141
+ name: "vesu::pool::Pool::SetCurator",
75142
+ kind: "struct",
75143
+ members: [
75144
+ {
75145
+ name: "curator",
75146
+ type: "core::starknet::contract_address::ContractAddress",
75147
+ kind: "key"
75148
+ }
75149
+ ]
75150
+ },
75151
+ {
75152
+ type: "event",
75153
+ name: "vesu::pool::Pool::NominateCurator",
75154
+ kind: "struct",
75155
+ members: [
75156
+ {
75157
+ name: "pending_curator",
75158
+ type: "core::starknet::contract_address::ContractAddress",
75159
+ kind: "key"
75160
+ }
75161
+ ]
75162
+ },
75163
+ {
75164
+ type: "event",
75165
+ name: "vesu::pool::Pool::ContractPaused",
75166
+ kind: "struct",
75167
+ members: [
75168
+ {
75169
+ name: "account",
75170
+ type: "core::starknet::contract_address::ContractAddress",
75171
+ kind: "data"
75172
+ }
75173
+ ]
75174
+ },
75175
+ {
75176
+ type: "event",
75177
+ name: "vesu::pool::Pool::ContractUnpaused",
75178
+ kind: "struct",
75179
+ members: [
75180
+ {
75181
+ name: "account",
75182
+ type: "core::starknet::contract_address::ContractAddress",
75183
+ kind: "data"
75184
+ }
75185
+ ]
75186
+ },
75187
+ {
75188
+ type: "event",
75189
+ name: "vesu::pool::Pool::ContractUpgraded",
75190
+ kind: "struct",
75191
+ members: [
75192
+ {
75193
+ name: "new_implementation",
75194
+ type: "core::starknet::class_hash::ClassHash",
75195
+ kind: "data"
75196
+ }
75197
+ ]
75198
+ },
75199
+ {
75200
+ type: "event",
75201
+ name: "vesu::pool::Pool::Event",
75202
+ kind: "enum",
75203
+ variants: [
75204
+ {
75205
+ name: "OwnableEvent",
75206
+ type: "openzeppelin_access::ownable::ownable::OwnableComponent::Event",
75207
+ kind: "flat"
75208
+ },
75209
+ {
75210
+ name: "InterestRateModelEvents",
75211
+ type: "vesu::interest_rate_model::interest_rate_model_component::Event",
75212
+ kind: "nested"
75213
+ },
75214
+ {
75215
+ name: "UpdateContext",
75216
+ type: "vesu::pool::Pool::UpdateContext",
75217
+ kind: "nested"
75218
+ },
75219
+ {
75220
+ name: "ModifyPosition",
75221
+ type: "vesu::pool::Pool::ModifyPosition",
75222
+ kind: "nested"
75223
+ },
75224
+ {
75225
+ name: "LiquidatePosition",
75226
+ type: "vesu::pool::Pool::LiquidatePosition",
75227
+ kind: "nested"
75228
+ },
75229
+ {
75230
+ name: "Flashloan",
75231
+ type: "vesu::pool::Pool::Flashloan",
75232
+ kind: "nested"
75233
+ },
75234
+ {
75235
+ name: "ModifyDelegation",
75236
+ type: "vesu::pool::Pool::ModifyDelegation",
75237
+ kind: "nested"
75238
+ },
75239
+ {
75240
+ name: "Donate",
75241
+ type: "vesu::pool::Pool::Donate",
75242
+ kind: "nested"
75243
+ },
75244
+ {
75245
+ name: "SetAssetConfig",
75246
+ type: "vesu::pool::Pool::SetAssetConfig",
75247
+ kind: "nested"
75248
+ },
75249
+ {
75250
+ name: "SetOracle",
75251
+ type: "vesu::pool::Pool::SetOracle",
75252
+ kind: "nested"
75253
+ },
75254
+ {
75255
+ name: "SetPairConfig",
75256
+ type: "vesu::pool::Pool::SetPairConfig",
75257
+ kind: "nested"
75258
+ },
75259
+ {
75260
+ name: "ClaimFees",
75261
+ type: "vesu::pool::Pool::ClaimFees",
75262
+ kind: "nested"
75263
+ },
75264
+ {
75265
+ name: "SetFeeRecipient",
75266
+ type: "vesu::pool::Pool::SetFeeRecipient",
75267
+ kind: "nested"
75268
+ },
75269
+ {
75270
+ name: "SetPausingAgent",
75271
+ type: "vesu::pool::Pool::SetPausingAgent",
75272
+ kind: "nested"
75273
+ },
75274
+ {
75275
+ name: "SetCurator",
75276
+ type: "vesu::pool::Pool::SetCurator",
75277
+ kind: "nested"
75278
+ },
75279
+ {
75280
+ name: "NominateCurator",
75281
+ type: "vesu::pool::Pool::NominateCurator",
75282
+ kind: "nested"
75283
+ },
75284
+ {
75285
+ name: "ContractPaused",
75286
+ type: "vesu::pool::Pool::ContractPaused",
75287
+ kind: "nested"
75288
+ },
75289
+ {
75290
+ name: "ContractUnpaused",
75291
+ type: "vesu::pool::Pool::ContractUnpaused",
75292
+ kind: "nested"
75293
+ },
75294
+ {
75295
+ name: "ContractUpgraded",
75296
+ type: "vesu::pool::Pool::ContractUpgraded",
75297
+ kind: "nested"
75298
+ }
75299
+ ]
75300
+ }
75301
+ ];
75302
+
75303
+ // src/strategies/universal-adapters/vesu-adapter.ts
75304
+ var VesuAmountType = /* @__PURE__ */ ((VesuAmountType2) => {
75305
+ VesuAmountType2[VesuAmountType2["Delta"] = 0] = "Delta";
75306
+ VesuAmountType2[VesuAmountType2["Target"] = 1] = "Target";
75307
+ return VesuAmountType2;
75308
+ })(VesuAmountType || {});
75309
+ var VesuAmountDenomination = /* @__PURE__ */ ((VesuAmountDenomination2) => {
75310
+ VesuAmountDenomination2[VesuAmountDenomination2["Native"] = 0] = "Native";
75311
+ VesuAmountDenomination2[VesuAmountDenomination2["Assets"] = 1] = "Assets";
75312
+ return VesuAmountDenomination2;
75313
+ })(VesuAmountDenomination || {});
75314
+ function getVesuMultiplyParams(isIncrease, params) {
75315
+ if (isIncrease) {
75316
+ const _params2 = params;
75317
+ return {
75318
+ action: new CairoCustomEnum({ IncreaseLever: {
75319
+ pool_id: _params2.pool_id.toBigInt(),
75320
+ collateral_asset: _params2.collateral_asset.toBigInt(),
75321
+ debt_asset: _params2.debt_asset.toBigInt(),
75322
+ user: _params2.user.toBigInt(),
75323
+ add_margin: BigInt(_params2.add_margin.toWei()),
75324
+ margin_swap: _params2.margin_swap.map((swap) => ({
75325
+ route: swap.route.map((route) => ({
75326
+ pool_key: {
75327
+ token0: route.pool_key.token0.toBigInt(),
75328
+ token1: route.pool_key.token1.toBigInt(),
75329
+ fee: route.pool_key.fee,
75330
+ tick_spacing: route.pool_key.tick_spacing,
75331
+ extension: BigInt(num_exports.hexToDecimalString(route.pool_key.extension))
75332
+ },
75333
+ sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
75334
+ skip_ahead: BigInt(100)
75335
+ })),
75336
+ token_amount: {
75337
+ token: swap.token_amount.token.toBigInt(),
75338
+ amount: swap.token_amount.amount.toI129()
75339
+ }
75340
+ })),
75341
+ margin_swap_limit_amount: BigInt(_params2.margin_swap_limit_amount.toWei()),
75342
+ lever_swap: _params2.lever_swap.map((swap) => ({
75343
+ route: swap.route.map((route) => ({
75344
+ pool_key: {
75345
+ token0: route.pool_key.token0.toBigInt(),
75346
+ token1: route.pool_key.token1.toBigInt(),
75347
+ fee: route.pool_key.fee,
75348
+ tick_spacing: route.pool_key.tick_spacing,
75349
+ extension: BigInt(num_exports.hexToDecimalString(route.pool_key.extension))
75350
+ },
75351
+ sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
75352
+ skip_ahead: BigInt(100)
75353
+ })),
75354
+ token_amount: {
75355
+ token: swap.token_amount.token.toBigInt(),
75356
+ amount: swap.token_amount.amount.toI129()
75357
+ }
75358
+ })),
75359
+ lever_swap_limit_amount: BigInt(_params2.lever_swap_limit_amount.toWei())
75360
+ } })
75361
+ };
75362
+ }
75363
+ const _params = params;
75364
+ return {
75365
+ action: new CairoCustomEnum({ DecreaseLever: {
75366
+ pool_id: _params.pool_id.toBigInt(),
75367
+ collateral_asset: _params.collateral_asset.toBigInt(),
75368
+ debt_asset: _params.debt_asset.toBigInt(),
75369
+ user: _params.user.toBigInt(),
75370
+ sub_margin: BigInt(_params.sub_margin.toWei()),
75371
+ recipient: _params.recipient.toBigInt(),
75372
+ lever_swap: _params.lever_swap.map((swap) => ({
75373
+ route: swap.route.map((route) => ({
75374
+ pool_key: {
75375
+ token0: route.pool_key.token0.toBigInt(),
75376
+ token1: route.pool_key.token1.toBigInt(),
75377
+ fee: route.pool_key.fee,
75378
+ tick_spacing: route.pool_key.tick_spacing,
75379
+ extension: ContractAddr.from(route.pool_key.extension).toBigInt()
75380
+ },
75381
+ sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
75382
+ skip_ahead: BigInt(route.skip_ahead.toWei())
75383
+ })),
75384
+ token_amount: {
75385
+ token: swap.token_amount.token.toBigInt(),
75386
+ amount: swap.token_amount.amount.toI129()
75387
+ }
75388
+ })),
75389
+ lever_swap_limit_amount: BigInt(_params.lever_swap_limit_amount.toWei()),
75390
+ lever_swap_weights: _params.lever_swap_weights.map((weight) => BigInt(weight.toWei())),
75391
+ withdraw_swap: _params.withdraw_swap.map((swap) => ({
75392
+ route: swap.route.map((route) => ({
75393
+ pool_key: {
75394
+ token0: route.pool_key.token0.toBigInt(),
75395
+ token1: route.pool_key.token1.toBigInt(),
75396
+ fee: route.pool_key.fee,
75397
+ tick_spacing: route.pool_key.tick_spacing,
75398
+ extension: ContractAddr.from(route.pool_key.extension).toBigInt()
75399
+ },
75400
+ sqrt_ratio_limit: uint256_exports.bnToUint256(route.sqrt_ratio_limit.toWei()),
75401
+ skip_ahead: BigInt(route.skip_ahead.toWei())
75402
+ })),
75403
+ token_amount: {
75404
+ token: swap.token_amount.token.toBigInt(),
75405
+ amount: swap.token_amount.amount.toI129()
75406
+ }
75407
+ })),
75408
+ withdraw_swap_limit_amount: BigInt(_params.withdraw_swap_limit_amount.toWei()),
75409
+ withdraw_swap_weights: _params.withdraw_swap_weights.map((weight) => BigInt(weight.toWei())),
75410
+ close_position: _params.close_position
75411
+ } })
75412
+ };
75413
+ }
75414
+ var VesuPools = {
75415
+ Genesis: ContractAddr.from("0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28"),
75416
+ Re7xSTRK: ContractAddr.from("0x052fb52363939c3aa848f8f4ac28f0a51379f8d1b971d8444de25fbd77d8f161"),
75417
+ Re7xBTC: ContractAddr.from("0x3a8416bf20d036df5b1cf3447630a2e1cb04685f6b0c3a70ed7fb1473548ecf")
75418
+ };
75419
+ function getVesuSingletonAddress(vesuPool) {
75420
+ if (vesuPool.eq(VesuPools.Genesis) || vesuPool.eq(VesuPools.Re7xSTRK)) {
75421
+ return { addr: VESU_SINGLETON, isV2: false };
75422
+ }
75423
+ return { addr: vesuPool, isV2: true };
75424
+ }
75425
+ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
75426
+ constructor(config3) {
75427
+ super();
75428
+ this.VESU_MULTIPLY_V1 = ContractAddr.from("0x3630f1f8e5b8f5c4c4ae9b6620f8a570ae55cddebc0276c37550e7c118edf67");
75429
+ this.VESU_MULTIPLY = ContractAddr.from("0x027fef272d0a9a3844767c851a64b36fe4f0115141d81134baade95d2b27b781");
75430
+ this.getModifyPosition = () => {
75431
+ const positionData = [0n];
75432
+ const packedArguments = [
75433
+ toBigInt3(this.config.poolId.toString()),
75434
+ // pool id
75435
+ toBigInt3(this.config.collateral.address.toString()),
75436
+ // collateral
75437
+ toBigInt3(this.config.debt.address.toString()),
75438
+ // debt
75439
+ toBigInt3(this.config.vaultAllocator.toString()),
75440
+ // vault allocator
75441
+ toBigInt3(positionData.length),
75442
+ ...positionData
75443
+ ];
75444
+ const output = this.constructSimpleLeafData({
75445
+ id: this.config.id,
75446
+ target: getVesuSingletonAddress(this.config.poolId).addr,
75447
+ method: "modify_position",
75448
+ packedArguments
75449
+ });
75450
+ return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
75451
+ };
75452
+ this.getModifyPositionCall = (params) => {
75453
+ const _collateral = {
75454
+ amount_type: this.formatAmountTypeEnum(params.collateralAmount.amount_type),
75455
+ denomination: this.formatAmountDenominationEnum(params.collateralAmount.denomination),
75456
+ value: {
75457
+ abs: uint256_exports.bnToUint256(params.collateralAmount.value.abs.toWei()),
75458
+ is_negative: params.collateralAmount.value.abs.isZero() ? false : params.collateralAmount.value.is_negative
75459
+ }
75460
+ };
75461
+ logger2.verbose(`VesuAdapter::ConstructingModify::Collateral::${JSON.stringify(_collateral)}`);
75462
+ const _debt = {
75463
+ amount_type: this.formatAmountTypeEnum(params.debtAmount.amount_type),
75464
+ denomination: this.formatAmountDenominationEnum(params.debtAmount.denomination),
75465
+ value: {
75466
+ abs: uint256_exports.bnToUint256(params.debtAmount.value.abs.toWei()),
75467
+ is_negative: params.debtAmount.value.abs.isZero() ? false : params.debtAmount.value.is_negative
75468
+ }
75469
+ };
75470
+ logger2.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`);
75471
+ const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
75472
+ const call = contract.populate("modify_position", {
75473
+ params: isV2 ? {
75474
+ collateral_asset: this.config.collateral.address.toBigInt(),
75475
+ debt_asset: this.config.debt.address.toBigInt(),
75476
+ user: this.config.vaultAllocator.toBigInt(),
75477
+ collateral: _collateral,
75478
+ debt: _debt
75479
+ } : {
75480
+ pool_id: this.config.poolId.toBigInt(),
75481
+ collateral_asset: this.config.collateral.address.toBigInt(),
75482
+ debt_asset: this.config.debt.address.toBigInt(),
75483
+ user: this.config.vaultAllocator.toBigInt(),
75484
+ collateral: _collateral,
75485
+ debt: _debt,
75486
+ data: [0]
75487
+ }
75488
+ });
75489
+ return {
75490
+ sanitizer: SIMPLE_SANITIZER,
75491
+ call: {
75492
+ contractAddress: ContractAddr.from(contract.address),
75493
+ selector: hash_exports.getSelectorFromName("modify_position"),
75494
+ calldata: [
75495
+ ...call.calldata
75496
+ ]
75497
+ }
75498
+ };
75499
+ };
75500
+ this.getMultiplyAdapter = () => {
75501
+ const packedArguments = [
75502
+ toBigInt3(this.config.poolId.toString()),
75503
+ // pool id
75504
+ toBigInt3(this.config.collateral.address.toString()),
75505
+ // collateral
75506
+ toBigInt3(this.config.debt.address.toString()),
75507
+ // debt
75508
+ toBigInt3(this.config.vaultAllocator.toString())
75509
+ // vault allocator
75510
+ ];
75511
+ const { isV2 } = getVesuSingletonAddress(this.config.poolId);
75512
+ const output = this.constructSimpleLeafData({
75513
+ id: this.config.id,
75514
+ target: isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1,
75515
+ method: "modify_lever",
75516
+ packedArguments
75517
+ }, SIMPLE_SANITIZER_V2);
75518
+ return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
75519
+ };
75520
+ this.getMultiplyCall = (params) => {
75521
+ const isIncrease = params.isIncrease;
75522
+ const multiplyParams = isIncrease ? params.increaseParams : params.decreaseParams;
75523
+ if (!multiplyParams) {
75524
+ throw new Error("Multiply params are not provided");
75525
+ }
75526
+ const { isV2 } = getVesuSingletonAddress(this.config.poolId);
75527
+ const VESU_MULTIPLY = isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1;
75528
+ const multiplyContract = new Contract({ abi: vesu_multiple_abi_default, address: VESU_MULTIPLY.toString(), providerOrAccount: new RpcProvider2({ nodeUrl: "" }) });
75529
+ const call = multiplyContract.populate("modify_lever", {
75530
+ modify_lever_params: getVesuMultiplyParams(isIncrease, {
75531
+ ...multiplyParams,
75532
+ user: this.config.vaultAllocator,
75533
+ pool_id: this.config.poolId,
75534
+ collateral_asset: this.config.collateral.address,
75535
+ debt_asset: this.config.debt.address,
75536
+ recipient: this.config.vaultAllocator
75537
+ })
75538
+ });
75539
+ return {
75540
+ sanitizer: SIMPLE_SANITIZER_V2,
75541
+ call: {
75542
+ contractAddress: VESU_MULTIPLY,
75543
+ selector: hash_exports.getSelectorFromName("modify_lever"),
75544
+ calldata: [
75545
+ ...call.calldata
75546
+ ]
75547
+ }
75548
+ };
75549
+ };
75550
+ this.getVesuModifyDelegationAdapter = (id) => {
75551
+ return () => {
75552
+ const { addr: VESU_SINGLETON2, isV2 } = getVesuSingletonAddress(this.config.poolId);
75553
+ const packedArguments = isV2 ? [
75554
+ toBigInt3(this.VESU_MULTIPLY.toString())
75555
+ // v2
75556
+ ] : [
75557
+ this.config.poolId.toBigInt(),
75558
+ toBigInt3(this.VESU_MULTIPLY_V1.toString())
75559
+ // v1
75560
+ ];
75561
+ const output = this.constructSimpleLeafData({
75562
+ id,
75563
+ target: VESU_SINGLETON2,
75564
+ method: "modify_delegation",
75565
+ packedArguments
75566
+ }, isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS);
75567
+ return { leaf: output, callConstructor: this.getVesuModifyDelegationCall.bind(this) };
75568
+ };
75569
+ };
75570
+ this.getVesuModifyDelegationCall = (params) => {
75571
+ const VESU_SINGLETON2 = getVesuSingletonAddress(this.config.poolId).addr;
75572
+ const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
75573
+ const call = contract.populate("modify_delegation", isV2 ? {
75574
+ delegatee: this.VESU_MULTIPLY.toBigInt(),
75575
+ delegation: params.delegation
75576
+ } : {
75577
+ pool_id: this.config.poolId.toBigInt(),
75578
+ delegatee: this.VESU_MULTIPLY_V1.toBigInt(),
75579
+ delegation: params.delegation
75580
+ });
75581
+ return {
75582
+ sanitizer: isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS,
75583
+ call: {
75584
+ contractAddress: VESU_SINGLETON2,
75585
+ selector: hash_exports.getSelectorFromName("modify_delegation"),
75586
+ calldata: [
75587
+ ...call.calldata
75588
+ ]
75589
+ }
75590
+ };
75591
+ };
75592
+ this.getDefispringRewardsAdapter = (id) => {
75593
+ return () => {
75594
+ const packedArguments = [];
75595
+ const output = {
75596
+ id: BigInt(num_exports.getDecimalString(shortString_exports.encodeShortString(id))),
75597
+ readableId: id,
75598
+ data: [
75599
+ SIMPLE_SANITIZER.toBigInt(),
75600
+ // sanitizer address
75601
+ VESU_REWARDS_CONTRACT.toBigInt(),
75602
+ // contract
75603
+ toBigInt3(hash_exports.getSelectorFromName("claim")),
75604
+ // method name
75605
+ BigInt(packedArguments.length),
75606
+ ...packedArguments
75607
+ ]
75608
+ };
75609
+ return { leaf: output, callConstructor: this.getDefiSpringClaimCall().bind(this) };
75610
+ };
75611
+ };
75612
+ this.getDefiSpringClaimCall = () => {
75613
+ return (params) => ({
75614
+ sanitizer: SIMPLE_SANITIZER,
75615
+ call: {
75616
+ contractAddress: VESU_REWARDS_CONTRACT,
75617
+ selector: hash_exports.getSelectorFromName("claim"),
75618
+ calldata: [
75619
+ BigInt(params.amount.toWei()),
75620
+ BigInt(params.proofs.length),
75621
+ ...params.proofs.map((proof) => BigInt(num_exports.hexToDecimalString(proof)))
75622
+ ]
75623
+ }
75624
+ });
75625
+ };
75626
+ this.config = config3;
75627
+ }
75628
+ static getDefaultModifyPositionCallParams(params) {
75629
+ return {
75630
+ collateralAmount: {
75631
+ amount_type: 0 /* Delta */,
75632
+ denomination: 1 /* Assets */,
75633
+ value: {
75634
+ abs: params.collateralAmount,
75635
+ is_negative: !params.isAddCollateral
75636
+ }
75637
+ },
75638
+ debtAmount: {
75639
+ amount_type: 0 /* Delta */,
75640
+ denomination: 1 /* Assets */,
75641
+ value: {
75642
+ abs: params.debtAmount,
75643
+ is_negative: !params.isBorrow
75644
+ }
75645
+ }
75646
+ };
75647
+ }
75648
+ formatAmountTypeEnum(amountType) {
75649
+ switch (amountType) {
75650
+ case 0 /* Delta */:
75651
+ return new CairoCustomEnum({ Delta: {} });
75652
+ case 1 /* Target */:
75653
+ return new CairoCustomEnum({ Target: {} });
75654
+ }
75655
+ throw new Error(`Unknown VesuAmountType: ${amountType}`);
75656
+ }
75657
+ formatAmountDenominationEnum(denomination) {
75658
+ switch (denomination) {
75659
+ case 0 /* Native */:
75660
+ return new CairoCustomEnum({ Native: {} });
75661
+ case 1 /* Assets */:
75662
+ return new CairoCustomEnum({ Assets: {} });
75663
+ }
75664
+ throw new Error(`Unknown VesuAmountDenomination: ${denomination}`);
75665
+ }
75666
+ getVesuSingletonContract(config3, poolId) {
75667
+ const { addr: VESU_SINGLETON2, isV2 } = getVesuSingletonAddress(poolId);
75668
+ const ABI = isV2 ? vesu_pool_v2_abi_default : vesu_singleton_abi_default;
75669
+ return {
75670
+ contract: new Contract({ abi: ABI, address: VESU_SINGLETON2.address, providerOrAccount: config3.provider }),
75671
+ isV2
75672
+ };
75673
+ }
75674
+ async getLTVConfig(config3) {
75675
+ const CACHE_KEY = "ltv_config";
75676
+ const cacheData = this.getCache(CACHE_KEY);
75677
+ if (cacheData) {
75678
+ return cacheData;
75679
+ }
75680
+ const { contract, isV2 } = await this.getVesuSingletonContract(config3, this.config.poolId);
75681
+ let ltv = 0;
75682
+ if (isV2) {
75683
+ const output = await contract.call("pair_config", [this.config.collateral.address.address, this.config.debt.address.address]);
75684
+ ltv = Number(output.max_ltv) / 1e18;
75685
+ } else {
75686
+ const output = await contract.call("ltv_config", [this.config.poolId.address, this.config.collateral.address.address, this.config.debt.address.address]);
75687
+ ltv = Number(output.max_ltv) / 1e18;
75688
+ }
75689
+ this.setCache(CACHE_KEY, ltv, 3e5);
75690
+ return this.getCache(CACHE_KEY);
75691
+ }
75692
+ async getPositions(config3) {
75693
+ if (!this.pricer) {
75694
+ throw new Error("Pricer is not initialized");
75695
+ }
75696
+ const CACHE_KEY = "positions";
75697
+ const cacheData = this.getCache(CACHE_KEY);
75698
+ if (cacheData) {
75699
+ return cacheData;
75700
+ }
75701
+ const { contract, isV2 } = this.getVesuSingletonContract(config3, this.config.poolId);
75702
+ const output = await contract.call(isV2 ? "position" : "position_unsafe", [
75703
+ ...isV2 ? [] : [this.config.poolId.address],
75704
+ // exclude pool id in v2
75705
+ this.config.collateral.address.address,
75706
+ this.config.debt.address.address,
75707
+ this.config.vaultAllocator.address
75708
+ ]);
75709
+ const token1Price = await this.pricer.getPrice(this.config.collateral.symbol);
75710
+ const token2Price = await this.pricer.getPrice(this.config.debt.symbol);
75711
+ logger2.verbose(`VesuAdapter::getPositions token1Price: ${token1Price.price}, token2Price: ${token2Price.price}`);
75712
+ const collateralAmount = Web3Number.fromWei(output["1"].toString(), this.config.collateral.decimals);
75713
+ const debtAmount = Web3Number.fromWei(output["2"].toString(), this.config.debt.decimals);
75714
+ const value = [{
75715
+ amount: collateralAmount,
75716
+ token: this.config.collateral,
75717
+ usdValue: collateralAmount.multipliedBy(token1Price.price).toNumber(),
75718
+ remarks: "Collateral"
75719
+ }, {
75720
+ amount: debtAmount,
75721
+ token: this.config.debt,
75722
+ usdValue: debtAmount.multipliedBy(token2Price.price).toNumber(),
75723
+ remarks: "Debt"
75724
+ }];
75725
+ this.setCache(CACHE_KEY, value, 6e4);
75726
+ return value;
75727
+ }
75728
+ async getCollateralization(config3) {
75729
+ if (!this.pricer) {
75730
+ throw new Error("Pricer is not initialized");
75731
+ }
75732
+ const CACHE_KEY = "collateralization";
75733
+ const cacheData = this.getCache(CACHE_KEY);
75734
+ if (cacheData) {
75735
+ return cacheData;
75736
+ }
75737
+ const { contract, isV2 } = this.getVesuSingletonContract(config3, this.config.poolId);
75738
+ const output = await contract.call(isV2 ? "check_collateralization" : "check_collateralization_unsafe", [
75739
+ ...isV2 ? [] : [this.config.poolId.address],
75740
+ // exclude pool id in v2
75741
+ this.config.collateral.address.address,
75742
+ this.config.debt.address.address,
75743
+ this.config.vaultAllocator.address
75744
+ ]);
75745
+ const collateralAmount = Web3Number.fromWei(output["1"].toString(), 18);
75746
+ const debtAmount = Web3Number.fromWei(output["2"].toString(), 18);
75747
+ const value = [{
75748
+ token: this.config.collateral,
75749
+ usdValue: collateralAmount.toNumber(),
75750
+ remarks: "Collateral"
75751
+ }, {
75752
+ token: this.config.debt,
75753
+ usdValue: debtAmount.toNumber(),
75754
+ remarks: "Debt"
75755
+ }];
75756
+ this.setCache(CACHE_KEY, value, 6e4);
75757
+ return value;
75758
+ }
75759
+ async getAssetPrices() {
75760
+ const collateralizationProm = this.getCollateralization(this.networkConfig);
75761
+ const positionsProm = this.getPositions(this.networkConfig);
75762
+ const ltvProm = this.getLTVConfig(this.networkConfig);
75763
+ const output = await Promise.all([collateralizationProm, positionsProm, ltvProm]);
75764
+ const [collateralization, positions, ltv] = output;
75765
+ const collateralTokenAmount = positions[0].amount;
75766
+ const collateralUSDAmount = collateralization[0].usdValue;
75767
+ const collateralPrice = collateralUSDAmount / collateralTokenAmount.toNumber();
75768
+ const debtTokenAmount = positions[1].amount;
75769
+ const debtUSDAmount = collateralization[1].usdValue;
75770
+ const debtPrice = debtUSDAmount / debtTokenAmount.toNumber();
75771
+ return {
75772
+ collateralTokenAmount,
75773
+ collateralUSDAmount,
75774
+ collateralPrice,
75775
+ debtTokenAmount,
75776
+ debtUSDAmount,
75777
+ debtPrice,
75778
+ ltv
75779
+ };
75780
+ }
75781
+ async getHealthFactor() {
75782
+ const ltv = await this.getLTVConfig(this.networkConfig);
75783
+ const collateralisation = await this.getCollateralization(this.networkConfig);
75784
+ return collateralisation[0].usdValue * ltv / collateralisation[1].usdValue;
75785
+ }
75786
+ static async getVesuPools(retry = 0) {
75787
+ const CACHE_KEY = "VESU_POOLS";
75788
+ const cacheValue = Global.getGlobalCache(CACHE_KEY);
75789
+ if (cacheValue) {
75790
+ return cacheValue;
75791
+ }
75792
+ let isErrorPoolsAPI = false;
75793
+ let pools = [];
75794
+ try {
75795
+ const data = await getAPIUsingHeadlessBrowser(
75796
+ `${ENDPOINTS.VESU_BASE}/pools`
75797
+ );
75798
+ pools = data.data;
75799
+ for (const pool of vesu_pools_default.data) {
75800
+ const found = pools.find((d) => ContractAddr.from(d.id).eqString(pool.id));
75801
+ if (!found) {
75802
+ logger2.verbose(`VesuRebalance: pools: ${JSON.stringify(pools)}`);
75803
+ logger2.verbose(
75804
+ `VesuRebalance: Pool ${pool.id} not found in Vesu API, using hardcoded data`
75805
+ );
75806
+ throw new Error(`pool not found [sanity check]: ${pool.id}`);
75807
+ }
75808
+ }
75809
+ } catch (e) {
75810
+ logger2.error(
75811
+ `${_VesuAdapter.name}: Error fetching pools for retry ${retry}`,
75812
+ e
75813
+ );
75814
+ isErrorPoolsAPI = true;
75815
+ if (retry < 10) {
75816
+ await new Promise((resolve) => setTimeout(resolve, 5e3 * (retry + 1)));
75817
+ return await this.getVesuPools(retry + 1);
75818
+ }
75819
+ }
75820
+ Global.setGlobalCache(CACHE_KEY, { pools, isErrorPoolsAPI }, 3e5);
75821
+ return { pools, isErrorPoolsAPI };
75822
+ }
75823
+ };
75824
+
75825
+ // src/data/universal-vault.abi.json
75826
+ var universal_vault_abi_default = [
75827
+ {
75828
+ type: "impl",
75829
+ name: "UpgradeableImpl",
75830
+ interface_name: "openzeppelin_upgrades::interface::IUpgradeable"
75831
+ },
75832
+ {
75833
+ type: "interface",
75834
+ name: "openzeppelin_upgrades::interface::IUpgradeable",
75835
+ items: [
75836
+ {
75837
+ type: "function",
75838
+ name: "upgrade",
75839
+ inputs: [
75840
+ {
75841
+ name: "new_class_hash",
75842
+ type: "core::starknet::class_hash::ClassHash"
75843
+ }
75844
+ ],
75845
+ outputs: [],
75846
+ state_mutability: "external"
75847
+ }
75848
+ ]
75849
+ },
75850
+ {
75851
+ type: "impl",
75852
+ name: "VaultMetadataImpl",
75853
+ interface_name: "openzeppelin_token::erc20::interface::IERC20Metadata"
75854
+ },
75855
+ {
75856
+ type: "struct",
75857
+ name: "core::byte_array::ByteArray",
75858
+ members: [
75859
+ {
75860
+ name: "data",
75861
+ type: "core::array::Array::<core::bytes_31::bytes31>"
75862
+ },
75863
+ {
75864
+ name: "pending_word",
75865
+ type: "core::felt252"
75866
+ },
73911
75867
  {
73912
75868
  name: "pending_word_len",
73913
75869
  type: "core::integer::u32"
@@ -76228,12 +78184,12 @@ ${JSON.stringify(data, null, 2)}`;
76228
78184
  const rewardAPYs = [];
76229
78185
  for (const [index, pool] of pools.entries()) {
76230
78186
  const vesuAdapter = vesuAdapters[index];
76231
- const collateralAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.collateral.symbol)?.stats;
76232
- const debtAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.debt.symbol)?.stats;
78187
+ const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
78188
+ const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
76233
78189
  const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
76234
78190
  const lstAPY = Number(collateralAsset.lstApr?.value || 0) / 1e18;
76235
78191
  baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
76236
- rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr.value || "0") / 1e18, 0]);
78192
+ rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
76237
78193
  }
76238
78194
  logger2.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
76239
78195
  logger2.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
@@ -76303,6 +78259,7 @@ ${JSON.stringify(data, null, 2)}`;
76303
78259
  const underlying = this.asset();
76304
78260
  let vesuAum = Web3Number.fromWei("0", underlying.decimals);
76305
78261
  let tokenUnderlyingPrice = await this.pricer.getPrice(this.asset().symbol);
78262
+ logger2.verbose(`${this.getTag()} tokenUnderlyingPrice: ${tokenUnderlyingPrice.price}`);
76306
78263
  if (legAUM[0].token.address.eq(underlying.address)) {
76307
78264
  vesuAum = vesuAum.plus(legAUM[0].amount);
76308
78265
  } else {
@@ -76403,7 +78360,7 @@ ${JSON.stringify(data, null, 2)}`;
76403
78360
  amount: unusedBalance.amount,
76404
78361
  usdValue: unusedBalance.usdValue,
76405
78362
  token: this.asset(),
76406
- remarks: "Unused Balance"
78363
+ remarks: "Unused Balance (may not include recent deposits)"
76407
78364
  }];
76408
78365
  }
76409
78366
  getSetManagerCall(strategist, root = this.getMerkleRoot()) {
@@ -76741,8 +78698,8 @@ ${JSON.stringify(data, null, 2)}`;
76741
78698
  vaultSettings.leafAdapters.push(commonAdapter.getFlashloanAdapter.bind(commonAdapter));
76742
78699
  vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getModifyPosition.bind(vesuAdapterUSDCETH));
76743
78700
  vaultSettings.leafAdapters.push(vesuAdapterETHUSDC.getModifyPosition.bind(vesuAdapterETHUSDC));
76744
- vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(USDCToken.address, vesuAdapterUSDCETH.VESU_SINGLETON, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
76745
- vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(ETHToken.address, vesuAdapterETHUSDC.VESU_SINGLETON, "approve_token2" /* APPROVE_TOKEN2 */).bind(commonAdapter));
78701
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(USDCToken.address, VESU_SINGLETON, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
78702
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(ETHToken.address, VESU_SINGLETON, "approve_token2" /* APPROVE_TOKEN2 */).bind(commonAdapter));
76746
78703
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(USDCToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
76747
78704
  vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
76748
78705
  vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterUSDCETH));
@@ -77045,7 +79002,7 @@ ${JSON.stringify(data, null, 2)}`;
77045
79002
 
77046
79003
  // src/strategies/universal-lst-muliplier-strategy.tsx
77047
79004
  var import_jsx_runtime5 = __toESM(require_jsx_runtime());
77048
- var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
79005
+ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy extends UniversalStrategy {
77049
79006
  constructor(config3, pricer, metadata) {
77050
79007
  super(config3, pricer, metadata);
77051
79008
  this.quoteAmountToFetchPrice = new Web3Number(1, 18);
@@ -77057,8 +79014,15 @@ ${JSON.stringify(data, null, 2)}`;
77057
79014
  this.quoteAmountToFetchPrice = new Web3Number(0.01, this.asset().decimals);
77058
79015
  }
77059
79016
  }
79017
+ asset() {
79018
+ const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
79019
+ return vesuAdapter1.config.collateral;
79020
+ }
79021
+ getTag() {
79022
+ return `${_UniversalLstMultiplierStrategy.name}:${this.metadata.name}`;
79023
+ }
77060
79024
  // only one leg is used
77061
- // todo support lending assets of underlying as well
79025
+ // todo support lending assets of underlying as well (like if xSTRK looping is not viable, simply supply STRK)
77062
79026
  getVesuAdapters() {
77063
79027
  const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
77064
79028
  vesuAdapter1.pricer = this.pricer;
@@ -77067,9 +79031,13 @@ ${JSON.stringify(data, null, 2)}`;
77067
79031
  }
77068
79032
  // not applicable for this strategy
77069
79033
  // No rewards on collateral or borrowing of LST assets
77070
- // protected async getRewardsAUM(prevAum: Web3Number): Promise<Web3Number> {
77071
- // return Web3Number.fromWei("0", this.asset().decimals);
77072
- // }
79034
+ async getRewardsAUM(prevAum) {
79035
+ const lstToken = this.asset();
79036
+ if (lstToken.symbol === "xSTRK") {
79037
+ return super.getRewardsAUM(prevAum);
79038
+ }
79039
+ return Web3Number.fromWei("0", lstToken.decimals);
79040
+ }
77073
79041
  async getLSTDexPrice() {
77074
79042
  const ekuboQuoter = new EkuboQuoter(this.config);
77075
79043
  const lstTokenInfo = this.asset();
@@ -77092,6 +79060,7 @@ ${JSON.stringify(data, null, 2)}`;
77092
79060
  async getVesuMultiplyCall(params) {
77093
79061
  const [vesuAdapter1] = this.getVesuAdapters();
77094
79062
  const legLTV = await vesuAdapter1.getLTVConfig(this.config);
79063
+ logger2.verbose(`${this.getTag()}::getVesuMultiplyCall legLTV: ${legLTV}`);
77095
79064
  const existingPositions = await vesuAdapter1.getPositions(this.config);
77096
79065
  const collateralisation = await vesuAdapter1.getCollateralization(this.config);
77097
79066
  const existingCollateralInfo = existingPositions[0];
@@ -77105,8 +79074,11 @@ ${JSON.stringify(data, null, 2)}`;
77105
79074
  const addedCollateral = params.leg1DepositAmount.multipliedBy(params.isDeposit ? 1 : -1);
77106
79075
  logger2.verbose(`${this.getTag()}::getVesuMultiplyCall addedCollateral: ${addedCollateral}`);
77107
79076
  const numeratorPart1 = existingCollateralInfo.amount.plus(addedCollateral).multipliedBy(collateralPrice).multipliedBy(legLTV);
79077
+ logger2.verbose(`${this.getTag()}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}`);
77108
79078
  const numeratorPart2 = existingDebtInfo.amount.multipliedBy(debtPrice).multipliedBy(this.metadata.additionalInfo.targetHealthFactor);
79079
+ logger2.verbose(`${this.getTag()}::getVesuMultiplyCall numeratorPart2: ${numeratorPart2}`);
77109
79080
  const denominatorPart = this.metadata.additionalInfo.targetHealthFactor - legLTV / dexPrice;
79081
+ logger2.verbose(`${this.getTag()}::getVesuMultiplyCall denominatorPart: ${denominatorPart}`);
77110
79082
  const x_debt_usd = numeratorPart1.minus(numeratorPart2).dividedBy(denominatorPart);
77111
79083
  logger2.verbose(`${this.getTag()}::getVesuMultiplyCall x_debt_usd: ${x_debt_usd}`);
77112
79084
  logger2.debug(`${this.getTag()}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}, numeratorPart2: ${numeratorPart2}, denominatorPart: ${denominatorPart}`);
@@ -77142,10 +79114,15 @@ ${JSON.stringify(data, null, 2)}`;
77142
79114
  * @param params marginAmount is in LST, debtAmount is in underlying
77143
79115
  */
77144
79116
  async getModifyLeverCall(params) {
79117
+ logger2.verbose(`${this.getTag()}::getModifyLeverCall marginAmount: ${params.marginAmount}, debtAmount: ${params.debtAmount}, lstDexPriceInUnderlying: ${params.lstDexPriceInUnderlying}, isIncrease: ${params.isIncrease}`);
77145
79118
  assert3(!params.marginAmount.isZero() || !params.debtAmount.isZero(), "Deposit/debt must be non-0");
77146
79119
  const [vesuAdapter1] = this.getVesuAdapters();
77147
79120
  const lstTokenInfo = this.asset();
77148
79121
  const lstUnderlyingTokenInfo = vesuAdapter1.config.debt;
79122
+ const maxAmounts = lstTokenInfo.symbol == "xSTRK" ? 5e5 : 0.5;
79123
+ if (params.marginAmount.greaterThan(maxAmounts)) {
79124
+ throw new Error(`Margin amount is greater than max amount: ${params.marginAmount.toNumber()} > ${maxAmounts}`);
79125
+ }
77149
79126
  const proofsIDs = [];
77150
79127
  const manageCalls = [];
77151
79128
  if (params.marginAmount.greaterThan(0)) {
@@ -77159,9 +79136,9 @@ ${JSON.stringify(data, null, 2)}`;
77159
79136
  manageCalls.push(manageCall1);
77160
79137
  }
77161
79138
  const lstDexPriceInUnderlying = params.lstDexPriceInUnderlying;
79139
+ const lstTrueExchangeRate = await this.getLSTExchangeRate();
77162
79140
  const ekuboQuoter = new EkuboQuoter(this.config);
77163
- const marginSwap = [];
77164
- const MAX_SLIPPAGE = 0.01;
79141
+ const MAX_SLIPPAGE = 2e-3;
77165
79142
  const fromToken = params.isIncrease ? lstUnderlyingTokenInfo : lstTokenInfo;
77166
79143
  const toToken = params.isIncrease ? lstTokenInfo : lstUnderlyingTokenInfo;
77167
79144
  const leverSwapQuote = await ekuboQuoter.getQuote(
@@ -77170,10 +79147,22 @@ ${JSON.stringify(data, null, 2)}`;
77170
79147
  params.debtAmount
77171
79148
  // negative for exact amount out
77172
79149
  );
77173
- assert3(leverSwapQuote.price_impact < MAX_SLIPPAGE, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
79150
+ logger2.verbose(`${this.getTag()}::getModifyLeverCall leverSwapQuote: ${JSON.stringify(leverSwapQuote)}`);
79151
+ assert3(leverSwapQuote.price_impact < 0.01, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
77174
79152
  const leverSwap = ekuboQuoter.getVesuMultiplyQuote(leverSwapQuote, fromToken, toToken);
77175
- const minExpectedDebt = params.debtAmount.dividedBy(lstDexPriceInUnderlying).multipliedBy(1 - MAX_SLIPPAGE);
77176
- const maxUsedCollateral = params.debtAmount.abs().dividedBy(lstDexPriceInUnderlying).multipliedBy(1 + MAX_SLIPPAGE);
79153
+ logger2.verbose(`${this.getTag()}::getModifyLeverCall leverSwap: ${JSON.stringify(leverSwap)}`);
79154
+ let minLSTReceived = params.debtAmount.dividedBy(lstDexPriceInUnderlying).multipliedBy(1 - MAX_SLIPPAGE);
79155
+ const minLSTReceivedAsPerTruePrice = params.debtAmount.dividedBy(lstTrueExchangeRate);
79156
+ if (minLSTReceived < minLSTReceivedAsPerTruePrice) {
79157
+ minLSTReceived = minLSTReceivedAsPerTruePrice;
79158
+ }
79159
+ logger2.verbose(`${this.getTag()}::getModifyLeverCall minLSTReceivedAsPerTruePrice: ${minLSTReceivedAsPerTruePrice}, minLSTReceived: ${minLSTReceived}`);
79160
+ let maxUsedCollateral = params.debtAmount.abs().dividedBy(lstDexPriceInUnderlying).multipliedBy(1 + MAX_SLIPPAGE);
79161
+ const maxUsedCollateralInLST = params.debtAmount.abs().dividedBy(lstTrueExchangeRate).multipliedBy(1.005);
79162
+ logger2.verbose(`${this.getTag()}::getModifyLeverCall maxUsedCollateralInLST: ${maxUsedCollateralInLST}, maxUsedCollateral: ${maxUsedCollateral}`);
79163
+ if (maxUsedCollateralInLST > maxUsedCollateral) {
79164
+ maxUsedCollateral = maxUsedCollateralInLST;
79165
+ }
77177
79166
  const STEP2_ID = "switch_delegation_on" /* SWITCH_DELEGATION_ON */;
77178
79167
  const manage2Info = this.getProofs(STEP2_ID);
77179
79168
  const manageCall2 = manage2Info.callConstructor({
@@ -77185,10 +79174,10 @@ ${JSON.stringify(data, null, 2)}`;
77185
79174
  isIncrease: true,
77186
79175
  increaseParams: {
77187
79176
  add_margin: params.marginAmount,
77188
- margin_swap: marginSwap,
79177
+ margin_swap: [],
77189
79178
  margin_swap_limit_amount: Web3Number.fromWei(0, this.asset().decimals),
77190
79179
  lever_swap: leverSwap,
77191
- lever_swap_limit_amount: minExpectedDebt
79180
+ lever_swap_limit_amount: minLSTReceived
77192
79181
  }
77193
79182
  } : {
77194
79183
  isIncrease: false,
@@ -77257,7 +79246,9 @@ ${JSON.stringify(data, null, 2)}`;
77257
79246
  vaultAddress: vaultSettings.vaultAddress,
77258
79247
  vaultAllocator: vaultSettings.vaultAllocator
77259
79248
  });
77260
- vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vesuAdapterLST.VESU_MULTIPLY, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
79249
+ const { isV2 } = getVesuSingletonAddress(pool1);
79250
+ const VESU_MULTIPLY = isV2 ? vesuAdapterLST.VESU_MULTIPLY : vesuAdapterLST.VESU_MULTIPLY_V1;
79251
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
77261
79252
  vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter.bind(vesuAdapterLST));
77262
79253
  vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_on" /* SWITCH_DELEGATION_ON */).bind(vesuAdapterLST));
77263
79254
  vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_off" /* SWITCH_DELEGATION_OFF */).bind(vesuAdapterLST));
@@ -77343,7 +79334,7 @@ ${JSON.stringify(data, null, 2)}`;
77343
79334
  manager: ContractAddr.from("0x75866db44c81e6986f06035206ee9c7d15833ddb22d6a22c016cfb5c866a491"),
77344
79335
  vaultAllocator: ContractAddr.from("0x57b5c1bb457b5e840a2714ae53ada87d77be2f3fd33a59b4fe709ef20c020c1"),
77345
79336
  redeemRequestNFT: ContractAddr.from("0x7a5dc288325456f05e70e9616e16bc02ffbe448f4b89f80b47c0970b989c7c"),
77346
- aumOracle: ContractAddr.from(""),
79337
+ aumOracle: ContractAddr.from("0x258f8a0ca0d21f542e48ad89d00e92dc4d9db4999084f50ef9c22dfb1e83023"),
77347
79338
  leafAdapters: [],
77348
79339
  adapters: [],
77349
79340
  targetHealthFactor: 1.1,
@@ -77354,7 +79345,7 @@ ${JSON.stringify(data, null, 2)}`;
77354
79345
  manager: ContractAddr.from("0xc4cc3e08029a0ae076f5fdfca70575abb78d23c5cd1c49a957f7e697885401"),
77355
79346
  vaultAllocator: ContractAddr.from("0x50bbd4fe69f841ecb13b2619fe50ebfa4e8944671b5d0ebf7868fd80c61b31e"),
77356
79347
  redeemRequestNFT: ContractAddr.from("0xeac9032f02057779816e38a6cb9185d12d86b3aacc9949b96b36de359c1e3"),
77357
- aumOracle: ContractAddr.from(""),
79348
+ aumOracle: ContractAddr.from("0x7e0d05cb7ba3f7db77a36c21c21583b5a524c2e685c08c24b3554911fb4a039"),
77358
79349
  leafAdapters: [],
77359
79350
  adapters: [],
77360
79351
  targetHealthFactor: 1.1,
@@ -77365,7 +79356,7 @@ ${JSON.stringify(data, null, 2)}`;
77365
79356
  manager: ContractAddr.from("0xc9ac023090625b0be3f6532ca353f086746f9c09f939dbc1b2613f09e5f821"),
77366
79357
  vaultAllocator: ContractAddr.from("0x60c2d856936b975459a5b4eb28b8672d91f757bd76cebb6241f8d670185dc01"),
77367
79358
  redeemRequestNFT: ContractAddr.from("0x429e8ee8bc7ecd1ade72630d350a2e0f10f9a2507c45f188ba17fe8f2ab4cf3"),
77368
- aumOracle: ContractAddr.from(""),
79359
+ aumOracle: ContractAddr.from("0x149298ade3e79ec6cbdac6cfad289c57504eaf54e590939136ed1ceca60c345"),
77369
79360
  leafAdapters: [],
77370
79361
  adapters: [],
77371
79362
  targetHealthFactor: 1.1,
@@ -77400,7 +79391,7 @@ ${JSON.stringify(data, null, 2)}`;
77400
79391
  launchBlock: 0,
77401
79392
  type: "Other",
77402
79393
  depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === lstSymbol)],
77403
- additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, addresses, VesuPools.Re7xSTRK),
79394
+ additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, addresses, lstSymbol === "xSTRK" ? VesuPools.Re7xSTRK : VesuPools.Re7xBTC),
77404
79395
  risk: {
77405
79396
  riskFactor: _riskFactor4,
77406
79397
  netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
@@ -77416,10 +79407,10 @@ ${JSON.stringify(data, null, 2)}`;
77416
79407
  }
77417
79408
  var HyperLSTStrategies = [
77418
79409
  getStrategySettings("xSTRK", "STRK", hyperxSTRK, false),
77419
- getStrategySettings("xWBTC", "WBTC", hyperxWBTC, true),
77420
- getStrategySettings("xtBTC", "tBTC", hyperxtBTC, true),
77421
- getStrategySettings("xsBTC", "solvBTC", hyperxsBTC, true),
77422
- getStrategySettings("xLBTC", "LBTC", hyperxLBTC, true)
79410
+ getStrategySettings("xWBTC", "WBTC", hyperxWBTC, false),
79411
+ getStrategySettings("xtBTC", "tBTC", hyperxtBTC, false),
79412
+ getStrategySettings("xsBTC", "solvBTC", hyperxsBTC, false),
79413
+ getStrategySettings("xLBTC", "LBTC", hyperxLBTC, false)
77423
79414
  ];
77424
79415
  return __toCommonJS(index_browser_exports);
77425
79416
  })();