@strkfarm/sdk 1.1.16 → 1.1.19

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