@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.
package/dist/index.mjs CHANGED
@@ -15,23 +15,27 @@ var _Web3Number = class extends BigNumber {
15
15
  this.decimals = decimals;
16
16
  }
17
17
  toWei() {
18
- return this.mul(10 ** this.decimals).toFixed(0);
18
+ return super.mul(10 ** this.decimals).toFixed(0);
19
19
  }
20
20
  multipliedBy(value) {
21
21
  const _value = this.getStandardString(value);
22
- return this.construct(this.mul(_value).toString(), this.decimals);
22
+ return this.construct(super.mul(_value).toString(), this.decimals);
23
23
  }
24
24
  dividedBy(value) {
25
25
  const _value = this.getStandardString(value);
26
- return this.construct(this.div(_value).toString(), this.decimals);
26
+ return this.construct(super.dividedBy(_value).toString(), this.decimals);
27
27
  }
28
28
  plus(value) {
29
- const _value = this.getStandardString(value);
30
- return this.construct(this.add(_value).toString(), this.decimals);
29
+ const rawValue = this.getStandardString(value);
30
+ const thisBN = new BigNumber(this.toString());
31
+ const result = thisBN.plus(rawValue);
32
+ return this.construct(result.toString(), this.decimals);
31
33
  }
32
34
  minus(n, base) {
33
- const _value = this.getStandardString(n);
34
- return this.construct(super.minus(_value, base).toString(), this.decimals);
35
+ const rawValue = this.getStandardString(n);
36
+ const thisBN = new BigNumber(this.toString());
37
+ const result = thisBN.minus(rawValue, base);
38
+ return this.construct(result.toString(), this.decimals);
35
39
  }
36
40
  construct(value, decimals) {
37
41
  return new this.constructor(value, decimals);
@@ -49,10 +53,13 @@ var _Web3Number = class extends BigNumber {
49
53
  return Math.min(this.decimals, 18);
50
54
  }
51
55
  getStandardString(value) {
52
- if (typeof value == "string") {
56
+ if (typeof value === "string") {
53
57
  return value;
54
58
  }
55
- return value.toFixed(this.maxToFixedDecimals());
59
+ if (typeof value === "number") {
60
+ return value.toString();
61
+ }
62
+ return BigNumber.prototype.toString.call(value);
56
63
  }
57
64
  minimum(value) {
58
65
  const _value = new BigNumber(value);
@@ -63,12 +70,10 @@ var _Web3Number = class extends BigNumber {
63
70
  maximum(value) {
64
71
  const _value = new BigNumber(value);
65
72
  const _valueMe = new BigNumber(this.toString());
66
- console.warn(`maximum: _value: ${_value.toString()}, _valueMe: ${_valueMe.toString()}`);
67
73
  const answer = _value.greaterThanOrEqualTo(_valueMe) ? _value : _valueMe;
68
74
  return this.construct(answer.toString(), this.decimals);
69
75
  }
70
76
  abs() {
71
- console.warn(`abs: this: ${this}`);
72
77
  return this.construct(Math.abs(this.toNumber()).toFixed(12), this.decimals);
73
78
  }
74
79
  toI129() {
@@ -517,13 +522,14 @@ var Pricer = class extends PricerBase {
517
522
  logger.verbose(`Fetching price of ${token.symbol} using ${methodToUse}`);
518
523
  switch (methodToUse) {
519
524
  case "Coinbase":
520
- try {
521
- const result = await this._getPriceCoinbase(token);
522
- this.methodToUse[token.symbol] = "Coinbase";
523
- return result;
524
- } catch (error) {
525
- console.warn(`Coinbase: price err: message [${token.symbol}]: `, error.message);
526
- }
525
+ // try {
526
+ // const result = await this._getPriceCoinbase(token);
527
+ // this.methodToUse[token.symbol] = 'Coinbase';
528
+ // return result;
529
+ // } catch (error: any) {
530
+ // console.warn(`Coinbase: price err: message [${token.symbol}]: `, error.message);
531
+ // // do nothing, try next
532
+ // }
527
533
  case "Coinmarketcap":
528
534
  try {
529
535
  const result = await this._getPriceCoinMarketCap(token);
@@ -907,7 +913,7 @@ var PricerFromApi = class extends PricerBase {
907
913
  }
908
914
  async getPriceFromMyAPI(tokenSymbol) {
909
915
  logger.verbose(`getPrice from redis: ${tokenSymbol}`);
910
- const endpoint = "https://cache-server-t2me.onrender.com";
916
+ const endpoint = "https://proxy.api.troves.fi";
911
917
  const url = `${endpoint}/api/price/${tokenSymbol}`;
912
918
  const priceInfoRes = await fetch(url);
913
919
  const priceInfo = await priceInfoRes.json();
@@ -3975,6 +3981,9 @@ var BaseStrategy = class extends CacheClass {
3975
3981
  async withdrawCall(amountInfo, receiver, owner) {
3976
3982
  throw new Error("Not implemented");
3977
3983
  }
3984
+ async getVaultPositions() {
3985
+ throw new Error("Not implemented");
3986
+ }
3978
3987
  };
3979
3988
 
3980
3989
  // src/node/headless.browser.ts
@@ -3994,7 +4003,7 @@ var COMMON_CONTRACTS = [{
3994
4003
  sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
3995
4004
  }];
3996
4005
  var ENDPOINTS = {
3997
- VESU_BASE: "https://cache-server-t2me.onrender.com/vesu"
4006
+ VESU_BASE: "https://proxy.api.troves.fi/vesu-staging"
3998
4007
  };
3999
4008
 
4000
4009
  // src/modules/harvests.ts
@@ -15717,6 +15726,49 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15717
15726
  const tick = Math.floor(value / tickSpacing) * tickSpacing;
15718
15727
  return this.tickToi129(tick);
15719
15728
  }
15729
+ async getVaultPositions() {
15730
+ const tvlInfo = await this.getTVL();
15731
+ const fees = await this.getUncollectedFees();
15732
+ const unusedBalance = await this.unusedBalances();
15733
+ return [
15734
+ {
15735
+ amount: tvlInfo.token0.amount,
15736
+ usdValue: tvlInfo.token0.usdValue,
15737
+ token: tvlInfo.token0.tokenInfo,
15738
+ remarks: `Liquidity in Ekubo`
15739
+ },
15740
+ {
15741
+ amount: fees.token0.amount,
15742
+ usdValue: fees.token0.usdValue,
15743
+ token: fees.token0.tokenInfo,
15744
+ remarks: "Uncollected Fees in Ekubo"
15745
+ },
15746
+ {
15747
+ amount: unusedBalance.token0.amount,
15748
+ usdValue: unusedBalance.token0.usdValue,
15749
+ token: unusedBalance.token0.tokenInfo,
15750
+ remarks: "Unused Balance in the Vault"
15751
+ },
15752
+ {
15753
+ amount: tvlInfo.token1.amount,
15754
+ usdValue: tvlInfo.token1.usdValue,
15755
+ token: tvlInfo.token1.tokenInfo,
15756
+ remarks: "Liquidity in Ekubo"
15757
+ },
15758
+ {
15759
+ amount: fees.token1.amount,
15760
+ usdValue: fees.token1.usdValue,
15761
+ token: fees.token1.tokenInfo,
15762
+ remarks: "Uncollected Fees in Ekubo"
15763
+ },
15764
+ {
15765
+ amount: unusedBalance.token1.amount,
15766
+ usdValue: unusedBalance.token1.usdValue,
15767
+ token: unusedBalance.token1.tokenInfo,
15768
+ remarks: "Unused Balance in the Vault"
15769
+ }
15770
+ ];
15771
+ }
15720
15772
  async getPoolKey(blockIdentifier = "latest") {
15721
15773
  if (this.poolKey) {
15722
15774
  return this.poolKey;
@@ -18878,9 +18930,10 @@ import { hash, num as num6, shortString } from "starknet";
18878
18930
 
18879
18931
  // src/strategies/universal-adapters/adapter-utils.ts
18880
18932
  var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
18881
- var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a");
18933
+ var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x7b6f98311af8aa425278570e62abf523e6462eaa01a38c1feab9b2f416492e2");
18882
18934
  var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
18883
18935
  var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
18936
+ var VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
18884
18937
  function toBigInt(value) {
18885
18938
  if (typeof value === "string") {
18886
18939
  return BigInt(value);
@@ -21815,232 +21868,2098 @@ var vesu_multiple_abi_default = [
21815
21868
  }
21816
21869
  ];
21817
21870
 
21818
- // src/strategies/universal-adapters/vesu-adapter.ts
21819
- var VesuAmountType = /* @__PURE__ */ ((VesuAmountType2) => {
21820
- VesuAmountType2[VesuAmountType2["Delta"] = 0] = "Delta";
21821
- VesuAmountType2[VesuAmountType2["Target"] = 1] = "Target";
21822
- return VesuAmountType2;
21823
- })(VesuAmountType || {});
21824
- var VesuAmountDenomination = /* @__PURE__ */ ((VesuAmountDenomination2) => {
21825
- VesuAmountDenomination2[VesuAmountDenomination2["Native"] = 0] = "Native";
21826
- VesuAmountDenomination2[VesuAmountDenomination2["Assets"] = 1] = "Assets";
21827
- return VesuAmountDenomination2;
21828
- })(VesuAmountDenomination || {});
21829
- function getVesuMultiplyParams(isIncrease, params) {
21830
- if (isIncrease) {
21831
- const _params2 = params;
21832
- return {
21833
- action: new CairoCustomEnum2({ IncreaseLever: {
21834
- pool_id: _params2.pool_id.toBigInt(),
21835
- collateral_asset: _params2.collateral_asset.toBigInt(),
21836
- debt_asset: _params2.debt_asset.toBigInt(),
21837
- user: _params2.user.toBigInt(),
21838
- add_margin: BigInt(_params2.add_margin.toWei()),
21839
- margin_swap: _params2.margin_swap.map((swap) => ({
21840
- route: swap.route.map((route) => ({
21841
- pool_key: {
21842
- token0: route.pool_key.token0.toBigInt(),
21843
- token1: route.pool_key.token1.toBigInt(),
21844
- fee: route.pool_key.fee,
21845
- tick_spacing: route.pool_key.tick_spacing,
21846
- extension: BigInt(num8.hexToDecimalString(route.pool_key.extension))
21847
- },
21848
- sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
21849
- skip_ahead: BigInt(100)
21850
- })),
21851
- token_amount: {
21852
- token: swap.token_amount.token.toBigInt(),
21853
- amount: swap.token_amount.amount.toI129()
21854
- }
21855
- })),
21856
- margin_swap_limit_amount: BigInt(_params2.margin_swap_limit_amount.toWei()),
21857
- lever_swap: _params2.lever_swap.map((swap) => ({
21858
- route: swap.route.map((route) => ({
21859
- pool_key: {
21860
- token0: route.pool_key.token0.toBigInt(),
21861
- token1: route.pool_key.token1.toBigInt(),
21862
- fee: route.pool_key.fee,
21863
- tick_spacing: route.pool_key.tick_spacing,
21864
- extension: BigInt(num8.hexToDecimalString(route.pool_key.extension))
21865
- },
21866
- sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
21867
- skip_ahead: BigInt(100)
21868
- })),
21869
- token_amount: {
21870
- token: swap.token_amount.token.toBigInt(),
21871
- amount: swap.token_amount.amount.toI129()
21872
- }
21873
- })),
21874
- lever_swap_limit_amount: BigInt(_params2.lever_swap_limit_amount.toWei())
21875
- } })
21876
- };
21877
- }
21878
- const _params = params;
21879
- return {
21880
- action: new CairoCustomEnum2({ DecreaseLever: {
21881
- pool_id: _params.pool_id.toBigInt(),
21882
- collateral_asset: _params.collateral_asset.toBigInt(),
21883
- debt_asset: _params.debt_asset.toBigInt(),
21884
- user: _params.user.toBigInt(),
21885
- sub_margin: BigInt(_params.sub_margin.toWei()),
21886
- recipient: _params.recipient.toBigInt(),
21887
- lever_swap: _params.lever_swap.map((swap) => ({
21888
- route: swap.route.map((route) => ({
21889
- pool_key: {
21890
- token0: route.pool_key.token0.toBigInt(),
21891
- token1: route.pool_key.token1.toBigInt(),
21892
- fee: route.pool_key.fee,
21893
- tick_spacing: route.pool_key.tick_spacing,
21894
- extension: ContractAddr.from(route.pool_key.extension).toBigInt()
21895
- },
21896
- sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
21897
- skip_ahead: BigInt(route.skip_ahead.toWei())
21898
- })),
21899
- token_amount: {
21900
- token: swap.token_amount.token.toBigInt(),
21901
- amount: swap.token_amount.amount.toI129()
21902
- }
21903
- })),
21904
- lever_swap_limit_amount: BigInt(_params.lever_swap_limit_amount.toWei()),
21905
- lever_swap_weights: _params.lever_swap_weights.map((weight) => BigInt(weight.toWei())),
21906
- withdraw_swap: _params.withdraw_swap.map((swap) => ({
21907
- route: swap.route.map((route) => ({
21908
- pool_key: {
21909
- token0: route.pool_key.token0.toBigInt(),
21910
- token1: route.pool_key.token1.toBigInt(),
21911
- fee: route.pool_key.fee,
21912
- tick_spacing: route.pool_key.tick_spacing,
21913
- extension: ContractAddr.from(route.pool_key.extension).toBigInt()
21914
- },
21915
- sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
21916
- skip_ahead: BigInt(route.skip_ahead.toWei())
21917
- })),
21918
- token_amount: {
21919
- token: swap.token_amount.token.toBigInt(),
21920
- amount: swap.token_amount.amount.toI129()
21921
- }
21922
- })),
21923
- withdraw_swap_limit_amount: BigInt(_params.withdraw_swap_limit_amount.toWei()),
21924
- withdraw_swap_weights: _params.withdraw_swap_weights.map((weight) => BigInt(weight.toWei())),
21925
- close_position: _params.close_position
21926
- } })
21927
- };
21928
- }
21929
- var VesuPools = {
21930
- Genesis: ContractAddr.from("0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28"),
21931
- Re7xSTRK: ContractAddr.from("0x052fb52363939c3aa848f8f4ac28f0a51379f8d1b971d8444de25fbd77d8f161")
21932
- };
21933
- var VesuAdapter = class _VesuAdapter extends BaseAdapter {
21934
- constructor(config) {
21935
- super();
21936
- this.VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
21937
- this.VESU_MULTIPLY = ContractAddr.from("0x3630f1f8e5b8f5c4c4ae9b6620f8a570ae55cddebc0276c37550e7c118edf67");
21938
- this.getModifyPosition = () => {
21939
- const positionData = [0n];
21940
- const packedArguments = [
21941
- toBigInt(this.config.poolId.toString()),
21942
- // pool id
21943
- toBigInt(this.config.collateral.address.toString()),
21944
- // collateral
21945
- toBigInt(this.config.debt.address.toString()),
21946
- // debt
21947
- toBigInt(this.config.vaultAllocator.toString()),
21948
- // vault allocator
21949
- toBigInt(positionData.length),
21950
- ...positionData
21951
- ];
21952
- const output = this.constructSimpleLeafData({
21953
- id: this.config.id,
21954
- target: this.VESU_SINGLETON,
21955
- method: "modify_position",
21956
- packedArguments
21957
- });
21958
- return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
21959
- };
21960
- this.getModifyPositionCall = (params) => {
21961
- const _collateral = {
21962
- amount_type: this.formatAmountTypeEnum(params.collateralAmount.amount_type),
21963
- denomination: this.formatAmountDenominationEnum(params.collateralAmount.denomination),
21964
- value: {
21965
- abs: uint2567.bnToUint256(params.collateralAmount.value.abs.toWei()),
21966
- is_negative: params.collateralAmount.value.abs.isZero() ? false : params.collateralAmount.value.is_negative
21967
- }
21968
- };
21969
- logger.verbose(`VesuAdapter::ConstructingModify::Collateral::${JSON.stringify(_collateral)}`);
21970
- const _debt = {
21971
- amount_type: this.formatAmountTypeEnum(params.debtAmount.amount_type),
21972
- denomination: this.formatAmountDenominationEnum(params.debtAmount.denomination),
21973
- value: {
21974
- abs: uint2567.bnToUint256(params.debtAmount.value.abs.toWei()),
21975
- is_negative: params.debtAmount.value.abs.isZero() ? false : params.debtAmount.value.is_negative
21976
- }
21977
- };
21978
- logger.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`);
21979
- const singletonContract = new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
21980
- const call = singletonContract.populate("modify_position", {
21981
- params: {
21982
- pool_id: this.config.poolId.toBigInt(),
21983
- collateral_asset: this.config.collateral.address.toBigInt(),
21984
- debt_asset: this.config.debt.address.toBigInt(),
21985
- user: this.config.vaultAllocator.toBigInt(),
21986
- collateral: _collateral,
21987
- debt: _debt,
21988
- data: [0]
21989
- }
21990
- });
21991
- return {
21992
- sanitizer: SIMPLE_SANITIZER,
21993
- call: {
21994
- contractAddress: this.VESU_SINGLETON,
21995
- selector: hash3.getSelectorFromName("modify_position"),
21996
- calldata: [
21997
- ...call.calldata
21998
- ]
21999
- }
22000
- };
22001
- };
22002
- this.getMultiplyAdapter = () => {
22003
- const packedArguments = [
22004
- toBigInt(this.config.poolId.toString()),
22005
- // pool id
22006
- toBigInt(this.config.collateral.address.toString()),
22007
- // collateral
22008
- toBigInt(this.config.debt.address.toString()),
22009
- // debt
22010
- toBigInt(this.config.vaultAllocator.toString())
22011
- // vault allocator
22012
- ];
22013
- const output = this.constructSimpleLeafData({
22014
- id: this.config.id,
22015
- target: this.VESU_MULTIPLY,
22016
- method: "modify_lever",
22017
- packedArguments
22018
- }, SIMPLE_SANITIZER_V2);
22019
- return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
22020
- };
22021
- this.getMultiplyCall = (params) => {
22022
- const isIncrease = params.isIncrease;
22023
- const multiplyParams = isIncrease ? params.increaseParams : params.decreaseParams;
22024
- if (!multiplyParams) {
22025
- throw new Error("Multiply params are not provided");
21871
+ // src/data/vesu-pool-v2.abi.json
21872
+ var vesu_pool_v2_abi_default = [
21873
+ {
21874
+ type: "impl",
21875
+ name: "PoolImpl",
21876
+ interface_name: "vesu::pool::IPool"
21877
+ },
21878
+ {
21879
+ type: "struct",
21880
+ name: "core::integer::u256",
21881
+ members: [
21882
+ {
21883
+ name: "low",
21884
+ type: "core::integer::u128"
21885
+ },
21886
+ {
21887
+ name: "high",
21888
+ type: "core::integer::u128"
22026
21889
  }
22027
- const multiplyContract = new Contract8({ abi: vesu_multiple_abi_default, address: this.VESU_MULTIPLY.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
22028
- const call = multiplyContract.populate("modify_lever", {
22029
- modify_lever_params: getVesuMultiplyParams(isIncrease, {
22030
- ...multiplyParams,
22031
- user: this.config.vaultAllocator,
22032
- pool_id: this.config.poolId,
22033
- collateral_asset: this.config.collateral.address,
22034
- debt_asset: this.config.debt.address,
22035
- recipient: this.config.vaultAllocator
22036
- })
22037
- });
22038
- return {
22039
- sanitizer: SIMPLE_SANITIZER_V2,
22040
- call: {
22041
- contractAddress: this.VESU_MULTIPLY,
22042
- selector: hash3.getSelectorFromName("modify_lever"),
22043
- calldata: [
21890
+ ]
21891
+ },
21892
+ {
21893
+ type: "enum",
21894
+ name: "core::bool",
21895
+ variants: [
21896
+ {
21897
+ name: "False",
21898
+ type: "()"
21899
+ },
21900
+ {
21901
+ name: "True",
21902
+ type: "()"
21903
+ }
21904
+ ]
21905
+ },
21906
+ {
21907
+ type: "struct",
21908
+ name: "vesu::data_model::AssetConfig",
21909
+ members: [
21910
+ {
21911
+ name: "total_collateral_shares",
21912
+ type: "core::integer::u256"
21913
+ },
21914
+ {
21915
+ name: "total_nominal_debt",
21916
+ type: "core::integer::u256"
21917
+ },
21918
+ {
21919
+ name: "reserve",
21920
+ type: "core::integer::u256"
21921
+ },
21922
+ {
21923
+ name: "max_utilization",
21924
+ type: "core::integer::u256"
21925
+ },
21926
+ {
21927
+ name: "floor",
21928
+ type: "core::integer::u256"
21929
+ },
21930
+ {
21931
+ name: "scale",
21932
+ type: "core::integer::u256"
21933
+ },
21934
+ {
21935
+ name: "is_legacy",
21936
+ type: "core::bool"
21937
+ },
21938
+ {
21939
+ name: "last_updated",
21940
+ type: "core::integer::u64"
21941
+ },
21942
+ {
21943
+ name: "last_rate_accumulator",
21944
+ type: "core::integer::u256"
21945
+ },
21946
+ {
21947
+ name: "last_full_utilization_rate",
21948
+ type: "core::integer::u256"
21949
+ },
21950
+ {
21951
+ name: "fee_rate",
21952
+ type: "core::integer::u256"
21953
+ },
21954
+ {
21955
+ name: "fee_shares",
21956
+ type: "core::integer::u256"
21957
+ }
21958
+ ]
21959
+ },
21960
+ {
21961
+ type: "struct",
21962
+ name: "vesu::data_model::AssetPrice",
21963
+ members: [
21964
+ {
21965
+ name: "value",
21966
+ type: "core::integer::u256"
21967
+ },
21968
+ {
21969
+ name: "is_valid",
21970
+ type: "core::bool"
21971
+ }
21972
+ ]
21973
+ },
21974
+ {
21975
+ type: "struct",
21976
+ name: "vesu::data_model::Position",
21977
+ members: [
21978
+ {
21979
+ name: "collateral_shares",
21980
+ type: "core::integer::u256"
21981
+ },
21982
+ {
21983
+ name: "nominal_debt",
21984
+ type: "core::integer::u256"
21985
+ }
21986
+ ]
21987
+ },
21988
+ {
21989
+ type: "struct",
21990
+ name: "vesu::data_model::Context",
21991
+ members: [
21992
+ {
21993
+ name: "collateral_asset",
21994
+ type: "core::starknet::contract_address::ContractAddress"
21995
+ },
21996
+ {
21997
+ name: "debt_asset",
21998
+ type: "core::starknet::contract_address::ContractAddress"
21999
+ },
22000
+ {
22001
+ name: "collateral_asset_config",
22002
+ type: "vesu::data_model::AssetConfig"
22003
+ },
22004
+ {
22005
+ name: "debt_asset_config",
22006
+ type: "vesu::data_model::AssetConfig"
22007
+ },
22008
+ {
22009
+ name: "collateral_asset_price",
22010
+ type: "vesu::data_model::AssetPrice"
22011
+ },
22012
+ {
22013
+ name: "debt_asset_price",
22014
+ type: "vesu::data_model::AssetPrice"
22015
+ },
22016
+ {
22017
+ name: "max_ltv",
22018
+ type: "core::integer::u64"
22019
+ },
22020
+ {
22021
+ name: "user",
22022
+ type: "core::starknet::contract_address::ContractAddress"
22023
+ },
22024
+ {
22025
+ name: "position",
22026
+ type: "vesu::data_model::Position"
22027
+ }
22028
+ ]
22029
+ },
22030
+ {
22031
+ type: "struct",
22032
+ name: "alexandria_math::i257::i257",
22033
+ members: [
22034
+ {
22035
+ name: "abs",
22036
+ type: "core::integer::u256"
22037
+ },
22038
+ {
22039
+ name: "is_negative",
22040
+ type: "core::bool"
22041
+ }
22042
+ ]
22043
+ },
22044
+ {
22045
+ type: "enum",
22046
+ name: "vesu::data_model::AmountDenomination",
22047
+ variants: [
22048
+ {
22049
+ name: "Native",
22050
+ type: "()"
22051
+ },
22052
+ {
22053
+ name: "Assets",
22054
+ type: "()"
22055
+ }
22056
+ ]
22057
+ },
22058
+ {
22059
+ type: "struct",
22060
+ name: "vesu::data_model::Amount",
22061
+ members: [
22062
+ {
22063
+ name: "denomination",
22064
+ type: "vesu::data_model::AmountDenomination"
22065
+ },
22066
+ {
22067
+ name: "value",
22068
+ type: "alexandria_math::i257::i257"
22069
+ }
22070
+ ]
22071
+ },
22072
+ {
22073
+ type: "struct",
22074
+ name: "vesu::data_model::ModifyPositionParams",
22075
+ members: [
22076
+ {
22077
+ name: "collateral_asset",
22078
+ type: "core::starknet::contract_address::ContractAddress"
22079
+ },
22080
+ {
22081
+ name: "debt_asset",
22082
+ type: "core::starknet::contract_address::ContractAddress"
22083
+ },
22084
+ {
22085
+ name: "user",
22086
+ type: "core::starknet::contract_address::ContractAddress"
22087
+ },
22088
+ {
22089
+ name: "collateral",
22090
+ type: "vesu::data_model::Amount"
22091
+ },
22092
+ {
22093
+ name: "debt",
22094
+ type: "vesu::data_model::Amount"
22095
+ }
22096
+ ]
22097
+ },
22098
+ {
22099
+ type: "struct",
22100
+ name: "vesu::data_model::UpdatePositionResponse",
22101
+ members: [
22102
+ {
22103
+ name: "collateral_delta",
22104
+ type: "alexandria_math::i257::i257"
22105
+ },
22106
+ {
22107
+ name: "collateral_shares_delta",
22108
+ type: "alexandria_math::i257::i257"
22109
+ },
22110
+ {
22111
+ name: "debt_delta",
22112
+ type: "alexandria_math::i257::i257"
22113
+ },
22114
+ {
22115
+ name: "nominal_debt_delta",
22116
+ type: "alexandria_math::i257::i257"
22117
+ },
22118
+ {
22119
+ name: "bad_debt",
22120
+ type: "core::integer::u256"
22121
+ }
22122
+ ]
22123
+ },
22124
+ {
22125
+ type: "struct",
22126
+ name: "vesu::data_model::LiquidatePositionParams",
22127
+ members: [
22128
+ {
22129
+ name: "collateral_asset",
22130
+ type: "core::starknet::contract_address::ContractAddress"
22131
+ },
22132
+ {
22133
+ name: "debt_asset",
22134
+ type: "core::starknet::contract_address::ContractAddress"
22135
+ },
22136
+ {
22137
+ name: "user",
22138
+ type: "core::starknet::contract_address::ContractAddress"
22139
+ },
22140
+ {
22141
+ name: "min_collateral_to_receive",
22142
+ type: "core::integer::u256"
22143
+ },
22144
+ {
22145
+ name: "debt_to_repay",
22146
+ type: "core::integer::u256"
22147
+ }
22148
+ ]
22149
+ },
22150
+ {
22151
+ type: "struct",
22152
+ name: "core::array::Span::<core::felt252>",
22153
+ members: [
22154
+ {
22155
+ name: "snapshot",
22156
+ type: "@core::array::Array::<core::felt252>"
22157
+ }
22158
+ ]
22159
+ },
22160
+ {
22161
+ type: "struct",
22162
+ name: "vesu::data_model::AssetParams",
22163
+ members: [
22164
+ {
22165
+ name: "asset",
22166
+ type: "core::starknet::contract_address::ContractAddress"
22167
+ },
22168
+ {
22169
+ name: "floor",
22170
+ type: "core::integer::u256"
22171
+ },
22172
+ {
22173
+ name: "initial_full_utilization_rate",
22174
+ type: "core::integer::u256"
22175
+ },
22176
+ {
22177
+ name: "max_utilization",
22178
+ type: "core::integer::u256"
22179
+ },
22180
+ {
22181
+ name: "is_legacy",
22182
+ type: "core::bool"
22183
+ },
22184
+ {
22185
+ name: "fee_rate",
22186
+ type: "core::integer::u256"
22187
+ }
22188
+ ]
22189
+ },
22190
+ {
22191
+ type: "struct",
22192
+ name: "vesu::interest_rate_model::InterestRateConfig",
22193
+ members: [
22194
+ {
22195
+ name: "min_target_utilization",
22196
+ type: "core::integer::u256"
22197
+ },
22198
+ {
22199
+ name: "max_target_utilization",
22200
+ type: "core::integer::u256"
22201
+ },
22202
+ {
22203
+ name: "target_utilization",
22204
+ type: "core::integer::u256"
22205
+ },
22206
+ {
22207
+ name: "min_full_utilization_rate",
22208
+ type: "core::integer::u256"
22209
+ },
22210
+ {
22211
+ name: "max_full_utilization_rate",
22212
+ type: "core::integer::u256"
22213
+ },
22214
+ {
22215
+ name: "zero_utilization_rate",
22216
+ type: "core::integer::u256"
22217
+ },
22218
+ {
22219
+ name: "rate_half_life",
22220
+ type: "core::integer::u256"
22221
+ },
22222
+ {
22223
+ name: "target_rate_percent",
22224
+ type: "core::integer::u256"
22225
+ }
22226
+ ]
22227
+ },
22228
+ {
22229
+ type: "struct",
22230
+ name: "vesu::data_model::Pair",
22231
+ members: [
22232
+ {
22233
+ name: "total_collateral_shares",
22234
+ type: "core::integer::u256"
22235
+ },
22236
+ {
22237
+ name: "total_nominal_debt",
22238
+ type: "core::integer::u256"
22239
+ }
22240
+ ]
22241
+ },
22242
+ {
22243
+ type: "struct",
22244
+ name: "vesu::data_model::PairConfig",
22245
+ members: [
22246
+ {
22247
+ name: "max_ltv",
22248
+ type: "core::integer::u64"
22249
+ },
22250
+ {
22251
+ name: "liquidation_factor",
22252
+ type: "core::integer::u64"
22253
+ },
22254
+ {
22255
+ name: "debt_cap",
22256
+ type: "core::integer::u128"
22257
+ }
22258
+ ]
22259
+ },
22260
+ {
22261
+ type: "enum",
22262
+ name: "core::option::Option::<(core::starknet::class_hash::ClassHash, core::array::Span::<core::felt252>)>",
22263
+ variants: [
22264
+ {
22265
+ name: "Some",
22266
+ type: "(core::starknet::class_hash::ClassHash, core::array::Span::<core::felt252>)"
22267
+ },
22268
+ {
22269
+ name: "None",
22270
+ type: "()"
22271
+ }
22272
+ ]
22273
+ },
22274
+ {
22275
+ type: "interface",
22276
+ name: "vesu::pool::IPool",
22277
+ items: [
22278
+ {
22279
+ type: "function",
22280
+ name: "pool_name",
22281
+ inputs: [],
22282
+ outputs: [
22283
+ {
22284
+ type: "core::felt252"
22285
+ }
22286
+ ],
22287
+ state_mutability: "view"
22288
+ },
22289
+ {
22290
+ type: "function",
22291
+ name: "context",
22292
+ inputs: [
22293
+ {
22294
+ name: "collateral_asset",
22295
+ type: "core::starknet::contract_address::ContractAddress"
22296
+ },
22297
+ {
22298
+ name: "debt_asset",
22299
+ type: "core::starknet::contract_address::ContractAddress"
22300
+ },
22301
+ {
22302
+ name: "user",
22303
+ type: "core::starknet::contract_address::ContractAddress"
22304
+ }
22305
+ ],
22306
+ outputs: [
22307
+ {
22308
+ type: "vesu::data_model::Context"
22309
+ }
22310
+ ],
22311
+ state_mutability: "view"
22312
+ },
22313
+ {
22314
+ type: "function",
22315
+ name: "position",
22316
+ inputs: [
22317
+ {
22318
+ name: "collateral_asset",
22319
+ type: "core::starknet::contract_address::ContractAddress"
22320
+ },
22321
+ {
22322
+ name: "debt_asset",
22323
+ type: "core::starknet::contract_address::ContractAddress"
22324
+ },
22325
+ {
22326
+ name: "user",
22327
+ type: "core::starknet::contract_address::ContractAddress"
22328
+ }
22329
+ ],
22330
+ outputs: [
22331
+ {
22332
+ type: "(vesu::data_model::Position, core::integer::u256, core::integer::u256)"
22333
+ }
22334
+ ],
22335
+ state_mutability: "view"
22336
+ },
22337
+ {
22338
+ type: "function",
22339
+ name: "check_collateralization",
22340
+ inputs: [
22341
+ {
22342
+ name: "collateral_asset",
22343
+ type: "core::starknet::contract_address::ContractAddress"
22344
+ },
22345
+ {
22346
+ name: "debt_asset",
22347
+ type: "core::starknet::contract_address::ContractAddress"
22348
+ },
22349
+ {
22350
+ name: "user",
22351
+ type: "core::starknet::contract_address::ContractAddress"
22352
+ }
22353
+ ],
22354
+ outputs: [
22355
+ {
22356
+ type: "(core::bool, core::integer::u256, core::integer::u256)"
22357
+ }
22358
+ ],
22359
+ state_mutability: "view"
22360
+ },
22361
+ {
22362
+ type: "function",
22363
+ name: "check_invariants",
22364
+ inputs: [
22365
+ {
22366
+ name: "collateral_asset",
22367
+ type: "core::starknet::contract_address::ContractAddress"
22368
+ },
22369
+ {
22370
+ name: "debt_asset",
22371
+ type: "core::starknet::contract_address::ContractAddress"
22372
+ },
22373
+ {
22374
+ name: "user",
22375
+ type: "core::starknet::contract_address::ContractAddress"
22376
+ },
22377
+ {
22378
+ name: "collateral_delta",
22379
+ type: "alexandria_math::i257::i257"
22380
+ },
22381
+ {
22382
+ name: "collateral_shares_delta",
22383
+ type: "alexandria_math::i257::i257"
22384
+ },
22385
+ {
22386
+ name: "debt_delta",
22387
+ type: "alexandria_math::i257::i257"
22388
+ },
22389
+ {
22390
+ name: "nominal_debt_delta",
22391
+ type: "alexandria_math::i257::i257"
22392
+ },
22393
+ {
22394
+ name: "is_liquidation",
22395
+ type: "core::bool"
22396
+ }
22397
+ ],
22398
+ outputs: [],
22399
+ state_mutability: "view"
22400
+ },
22401
+ {
22402
+ type: "function",
22403
+ name: "modify_position",
22404
+ inputs: [
22405
+ {
22406
+ name: "params",
22407
+ type: "vesu::data_model::ModifyPositionParams"
22408
+ }
22409
+ ],
22410
+ outputs: [
22411
+ {
22412
+ type: "vesu::data_model::UpdatePositionResponse"
22413
+ }
22414
+ ],
22415
+ state_mutability: "external"
22416
+ },
22417
+ {
22418
+ type: "function",
22419
+ name: "liquidate_position",
22420
+ inputs: [
22421
+ {
22422
+ name: "params",
22423
+ type: "vesu::data_model::LiquidatePositionParams"
22424
+ }
22425
+ ],
22426
+ outputs: [
22427
+ {
22428
+ type: "vesu::data_model::UpdatePositionResponse"
22429
+ }
22430
+ ],
22431
+ state_mutability: "external"
22432
+ },
22433
+ {
22434
+ type: "function",
22435
+ name: "flash_loan",
22436
+ inputs: [
22437
+ {
22438
+ name: "receiver",
22439
+ type: "core::starknet::contract_address::ContractAddress"
22440
+ },
22441
+ {
22442
+ name: "asset",
22443
+ type: "core::starknet::contract_address::ContractAddress"
22444
+ },
22445
+ {
22446
+ name: "amount",
22447
+ type: "core::integer::u256"
22448
+ },
22449
+ {
22450
+ name: "is_legacy",
22451
+ type: "core::bool"
22452
+ },
22453
+ {
22454
+ name: "data",
22455
+ type: "core::array::Span::<core::felt252>"
22456
+ }
22457
+ ],
22458
+ outputs: [],
22459
+ state_mutability: "external"
22460
+ },
22461
+ {
22462
+ type: "function",
22463
+ name: "modify_delegation",
22464
+ inputs: [
22465
+ {
22466
+ name: "delegatee",
22467
+ type: "core::starknet::contract_address::ContractAddress"
22468
+ },
22469
+ {
22470
+ name: "delegation",
22471
+ type: "core::bool"
22472
+ }
22473
+ ],
22474
+ outputs: [],
22475
+ state_mutability: "external"
22476
+ },
22477
+ {
22478
+ type: "function",
22479
+ name: "delegation",
22480
+ inputs: [
22481
+ {
22482
+ name: "delegator",
22483
+ type: "core::starknet::contract_address::ContractAddress"
22484
+ },
22485
+ {
22486
+ name: "delegatee",
22487
+ type: "core::starknet::contract_address::ContractAddress"
22488
+ }
22489
+ ],
22490
+ outputs: [
22491
+ {
22492
+ type: "core::bool"
22493
+ }
22494
+ ],
22495
+ state_mutability: "view"
22496
+ },
22497
+ {
22498
+ type: "function",
22499
+ name: "donate_to_reserve",
22500
+ inputs: [
22501
+ {
22502
+ name: "asset",
22503
+ type: "core::starknet::contract_address::ContractAddress"
22504
+ },
22505
+ {
22506
+ name: "amount",
22507
+ type: "core::integer::u256"
22508
+ }
22509
+ ],
22510
+ outputs: [],
22511
+ state_mutability: "external"
22512
+ },
22513
+ {
22514
+ type: "function",
22515
+ name: "add_asset",
22516
+ inputs: [
22517
+ {
22518
+ name: "params",
22519
+ type: "vesu::data_model::AssetParams"
22520
+ },
22521
+ {
22522
+ name: "interest_rate_config",
22523
+ type: "vesu::interest_rate_model::InterestRateConfig"
22524
+ }
22525
+ ],
22526
+ outputs: [],
22527
+ state_mutability: "external"
22528
+ },
22529
+ {
22530
+ type: "function",
22531
+ name: "set_asset_parameter",
22532
+ inputs: [
22533
+ {
22534
+ name: "asset",
22535
+ type: "core::starknet::contract_address::ContractAddress"
22536
+ },
22537
+ {
22538
+ name: "parameter",
22539
+ type: "core::felt252"
22540
+ },
22541
+ {
22542
+ name: "value",
22543
+ type: "core::integer::u256"
22544
+ }
22545
+ ],
22546
+ outputs: [],
22547
+ state_mutability: "external"
22548
+ },
22549
+ {
22550
+ type: "function",
22551
+ name: "asset_config",
22552
+ inputs: [
22553
+ {
22554
+ name: "asset",
22555
+ type: "core::starknet::contract_address::ContractAddress"
22556
+ }
22557
+ ],
22558
+ outputs: [
22559
+ {
22560
+ type: "vesu::data_model::AssetConfig"
22561
+ }
22562
+ ],
22563
+ state_mutability: "view"
22564
+ },
22565
+ {
22566
+ type: "function",
22567
+ name: "set_oracle",
22568
+ inputs: [
22569
+ {
22570
+ name: "oracle",
22571
+ type: "core::starknet::contract_address::ContractAddress"
22572
+ }
22573
+ ],
22574
+ outputs: [],
22575
+ state_mutability: "external"
22576
+ },
22577
+ {
22578
+ type: "function",
22579
+ name: "oracle",
22580
+ inputs: [],
22581
+ outputs: [
22582
+ {
22583
+ type: "core::starknet::contract_address::ContractAddress"
22584
+ }
22585
+ ],
22586
+ state_mutability: "view"
22587
+ },
22588
+ {
22589
+ type: "function",
22590
+ name: "price",
22591
+ inputs: [
22592
+ {
22593
+ name: "asset",
22594
+ type: "core::starknet::contract_address::ContractAddress"
22595
+ }
22596
+ ],
22597
+ outputs: [
22598
+ {
22599
+ type: "vesu::data_model::AssetPrice"
22600
+ }
22601
+ ],
22602
+ state_mutability: "view"
22603
+ },
22604
+ {
22605
+ type: "function",
22606
+ name: "set_fee_recipient",
22607
+ inputs: [
22608
+ {
22609
+ name: "fee_recipient",
22610
+ type: "core::starknet::contract_address::ContractAddress"
22611
+ }
22612
+ ],
22613
+ outputs: [],
22614
+ state_mutability: "external"
22615
+ },
22616
+ {
22617
+ type: "function",
22618
+ name: "fee_recipient",
22619
+ inputs: [],
22620
+ outputs: [
22621
+ {
22622
+ type: "core::starknet::contract_address::ContractAddress"
22623
+ }
22624
+ ],
22625
+ state_mutability: "view"
22626
+ },
22627
+ {
22628
+ type: "function",
22629
+ name: "claim_fees",
22630
+ inputs: [
22631
+ {
22632
+ name: "asset",
22633
+ type: "core::starknet::contract_address::ContractAddress"
22634
+ },
22635
+ {
22636
+ name: "fee_shares",
22637
+ type: "core::integer::u256"
22638
+ }
22639
+ ],
22640
+ outputs: [],
22641
+ state_mutability: "external"
22642
+ },
22643
+ {
22644
+ type: "function",
22645
+ name: "get_fees",
22646
+ inputs: [
22647
+ {
22648
+ name: "asset",
22649
+ type: "core::starknet::contract_address::ContractAddress"
22650
+ }
22651
+ ],
22652
+ outputs: [
22653
+ {
22654
+ type: "(core::integer::u256, core::integer::u256)"
22655
+ }
22656
+ ],
22657
+ state_mutability: "view"
22658
+ },
22659
+ {
22660
+ type: "function",
22661
+ name: "rate_accumulator",
22662
+ inputs: [
22663
+ {
22664
+ name: "asset",
22665
+ type: "core::starknet::contract_address::ContractAddress"
22666
+ }
22667
+ ],
22668
+ outputs: [
22669
+ {
22670
+ type: "core::integer::u256"
22671
+ }
22672
+ ],
22673
+ state_mutability: "view"
22674
+ },
22675
+ {
22676
+ type: "function",
22677
+ name: "utilization",
22678
+ inputs: [
22679
+ {
22680
+ name: "asset",
22681
+ type: "core::starknet::contract_address::ContractAddress"
22682
+ }
22683
+ ],
22684
+ outputs: [
22685
+ {
22686
+ type: "core::integer::u256"
22687
+ }
22688
+ ],
22689
+ state_mutability: "view"
22690
+ },
22691
+ {
22692
+ type: "function",
22693
+ name: "interest_rate",
22694
+ inputs: [
22695
+ {
22696
+ name: "asset",
22697
+ type: "core::starknet::contract_address::ContractAddress"
22698
+ },
22699
+ {
22700
+ name: "utilization",
22701
+ type: "core::integer::u256"
22702
+ },
22703
+ {
22704
+ name: "last_updated",
22705
+ type: "core::integer::u64"
22706
+ },
22707
+ {
22708
+ name: "last_full_utilization_rate",
22709
+ type: "core::integer::u256"
22710
+ }
22711
+ ],
22712
+ outputs: [
22713
+ {
22714
+ type: "core::integer::u256"
22715
+ }
22716
+ ],
22717
+ state_mutability: "view"
22718
+ },
22719
+ {
22720
+ type: "function",
22721
+ name: "set_interest_rate_parameter",
22722
+ inputs: [
22723
+ {
22724
+ name: "asset",
22725
+ type: "core::starknet::contract_address::ContractAddress"
22726
+ },
22727
+ {
22728
+ name: "parameter",
22729
+ type: "core::felt252"
22730
+ },
22731
+ {
22732
+ name: "value",
22733
+ type: "core::integer::u256"
22734
+ }
22735
+ ],
22736
+ outputs: [],
22737
+ state_mutability: "external"
22738
+ },
22739
+ {
22740
+ type: "function",
22741
+ name: "interest_rate_config",
22742
+ inputs: [
22743
+ {
22744
+ name: "asset",
22745
+ type: "core::starknet::contract_address::ContractAddress"
22746
+ }
22747
+ ],
22748
+ outputs: [
22749
+ {
22750
+ type: "vesu::interest_rate_model::InterestRateConfig"
22751
+ }
22752
+ ],
22753
+ state_mutability: "view"
22754
+ },
22755
+ {
22756
+ type: "function",
22757
+ name: "pairs",
22758
+ inputs: [
22759
+ {
22760
+ name: "collateral_asset",
22761
+ type: "core::starknet::contract_address::ContractAddress"
22762
+ },
22763
+ {
22764
+ name: "debt_asset",
22765
+ type: "core::starknet::contract_address::ContractAddress"
22766
+ }
22767
+ ],
22768
+ outputs: [
22769
+ {
22770
+ type: "vesu::data_model::Pair"
22771
+ }
22772
+ ],
22773
+ state_mutability: "view"
22774
+ },
22775
+ {
22776
+ type: "function",
22777
+ name: "set_pair_config",
22778
+ inputs: [
22779
+ {
22780
+ name: "collateral_asset",
22781
+ type: "core::starknet::contract_address::ContractAddress"
22782
+ },
22783
+ {
22784
+ name: "debt_asset",
22785
+ type: "core::starknet::contract_address::ContractAddress"
22786
+ },
22787
+ {
22788
+ name: "pair_config",
22789
+ type: "vesu::data_model::PairConfig"
22790
+ }
22791
+ ],
22792
+ outputs: [],
22793
+ state_mutability: "external"
22794
+ },
22795
+ {
22796
+ type: "function",
22797
+ name: "set_pair_parameter",
22798
+ inputs: [
22799
+ {
22800
+ name: "collateral_asset",
22801
+ type: "core::starknet::contract_address::ContractAddress"
22802
+ },
22803
+ {
22804
+ name: "debt_asset",
22805
+ type: "core::starknet::contract_address::ContractAddress"
22806
+ },
22807
+ {
22808
+ name: "parameter",
22809
+ type: "core::felt252"
22810
+ },
22811
+ {
22812
+ name: "value",
22813
+ type: "core::integer::u128"
22814
+ }
22815
+ ],
22816
+ outputs: [],
22817
+ state_mutability: "external"
22818
+ },
22819
+ {
22820
+ type: "function",
22821
+ name: "pair_config",
22822
+ inputs: [
22823
+ {
22824
+ name: "collateral_asset",
22825
+ type: "core::starknet::contract_address::ContractAddress"
22826
+ },
22827
+ {
22828
+ name: "debt_asset",
22829
+ type: "core::starknet::contract_address::ContractAddress"
22830
+ }
22831
+ ],
22832
+ outputs: [
22833
+ {
22834
+ type: "vesu::data_model::PairConfig"
22835
+ }
22836
+ ],
22837
+ state_mutability: "view"
22838
+ },
22839
+ {
22840
+ type: "function",
22841
+ name: "calculate_debt",
22842
+ inputs: [
22843
+ {
22844
+ name: "nominal_debt",
22845
+ type: "alexandria_math::i257::i257"
22846
+ },
22847
+ {
22848
+ name: "rate_accumulator",
22849
+ type: "core::integer::u256"
22850
+ },
22851
+ {
22852
+ name: "asset_scale",
22853
+ type: "core::integer::u256"
22854
+ }
22855
+ ],
22856
+ outputs: [
22857
+ {
22858
+ type: "core::integer::u256"
22859
+ }
22860
+ ],
22861
+ state_mutability: "view"
22862
+ },
22863
+ {
22864
+ type: "function",
22865
+ name: "calculate_nominal_debt",
22866
+ inputs: [
22867
+ {
22868
+ name: "debt",
22869
+ type: "alexandria_math::i257::i257"
22870
+ },
22871
+ {
22872
+ name: "rate_accumulator",
22873
+ type: "core::integer::u256"
22874
+ },
22875
+ {
22876
+ name: "asset_scale",
22877
+ type: "core::integer::u256"
22878
+ }
22879
+ ],
22880
+ outputs: [
22881
+ {
22882
+ type: "core::integer::u256"
22883
+ }
22884
+ ],
22885
+ state_mutability: "view"
22886
+ },
22887
+ {
22888
+ type: "function",
22889
+ name: "calculate_collateral_shares",
22890
+ inputs: [
22891
+ {
22892
+ name: "asset",
22893
+ type: "core::starknet::contract_address::ContractAddress"
22894
+ },
22895
+ {
22896
+ name: "collateral",
22897
+ type: "alexandria_math::i257::i257"
22898
+ }
22899
+ ],
22900
+ outputs: [
22901
+ {
22902
+ type: "core::integer::u256"
22903
+ }
22904
+ ],
22905
+ state_mutability: "view"
22906
+ },
22907
+ {
22908
+ type: "function",
22909
+ name: "calculate_collateral",
22910
+ inputs: [
22911
+ {
22912
+ name: "asset",
22913
+ type: "core::starknet::contract_address::ContractAddress"
22914
+ },
22915
+ {
22916
+ name: "collateral_shares",
22917
+ type: "alexandria_math::i257::i257"
22918
+ }
22919
+ ],
22920
+ outputs: [
22921
+ {
22922
+ type: "core::integer::u256"
22923
+ }
22924
+ ],
22925
+ state_mutability: "view"
22926
+ },
22927
+ {
22928
+ type: "function",
22929
+ name: "deconstruct_collateral_amount",
22930
+ inputs: [
22931
+ {
22932
+ name: "collateral_asset",
22933
+ type: "core::starknet::contract_address::ContractAddress"
22934
+ },
22935
+ {
22936
+ name: "debt_asset",
22937
+ type: "core::starknet::contract_address::ContractAddress"
22938
+ },
22939
+ {
22940
+ name: "user",
22941
+ type: "core::starknet::contract_address::ContractAddress"
22942
+ },
22943
+ {
22944
+ name: "collateral",
22945
+ type: "vesu::data_model::Amount"
22946
+ }
22947
+ ],
22948
+ outputs: [
22949
+ {
22950
+ type: "(alexandria_math::i257::i257, alexandria_math::i257::i257)"
22951
+ }
22952
+ ],
22953
+ state_mutability: "view"
22954
+ },
22955
+ {
22956
+ type: "function",
22957
+ name: "deconstruct_debt_amount",
22958
+ inputs: [
22959
+ {
22960
+ name: "collateral_asset",
22961
+ type: "core::starknet::contract_address::ContractAddress"
22962
+ },
22963
+ {
22964
+ name: "debt_asset",
22965
+ type: "core::starknet::contract_address::ContractAddress"
22966
+ },
22967
+ {
22968
+ name: "user",
22969
+ type: "core::starknet::contract_address::ContractAddress"
22970
+ },
22971
+ {
22972
+ name: "debt",
22973
+ type: "vesu::data_model::Amount"
22974
+ }
22975
+ ],
22976
+ outputs: [
22977
+ {
22978
+ type: "(alexandria_math::i257::i257, alexandria_math::i257::i257)"
22979
+ }
22980
+ ],
22981
+ state_mutability: "view"
22982
+ },
22983
+ {
22984
+ type: "function",
22985
+ name: "curator",
22986
+ inputs: [],
22987
+ outputs: [
22988
+ {
22989
+ type: "core::starknet::contract_address::ContractAddress"
22990
+ }
22991
+ ],
22992
+ state_mutability: "view"
22993
+ },
22994
+ {
22995
+ type: "function",
22996
+ name: "pending_curator",
22997
+ inputs: [],
22998
+ outputs: [
22999
+ {
23000
+ type: "core::starknet::contract_address::ContractAddress"
23001
+ }
23002
+ ],
23003
+ state_mutability: "view"
23004
+ },
23005
+ {
23006
+ type: "function",
23007
+ name: "nominate_curator",
23008
+ inputs: [
23009
+ {
23010
+ name: "pending_curator",
23011
+ type: "core::starknet::contract_address::ContractAddress"
23012
+ }
23013
+ ],
23014
+ outputs: [],
23015
+ state_mutability: "external"
23016
+ },
23017
+ {
23018
+ type: "function",
23019
+ name: "accept_curator_ownership",
23020
+ inputs: [],
23021
+ outputs: [],
23022
+ state_mutability: "external"
23023
+ },
23024
+ {
23025
+ type: "function",
23026
+ name: "set_pausing_agent",
23027
+ inputs: [
23028
+ {
23029
+ name: "pausing_agent",
23030
+ type: "core::starknet::contract_address::ContractAddress"
23031
+ }
23032
+ ],
23033
+ outputs: [],
23034
+ state_mutability: "external"
23035
+ },
23036
+ {
23037
+ type: "function",
23038
+ name: "pausing_agent",
23039
+ inputs: [],
23040
+ outputs: [
23041
+ {
23042
+ type: "core::starknet::contract_address::ContractAddress"
23043
+ }
23044
+ ],
23045
+ state_mutability: "view"
23046
+ },
23047
+ {
23048
+ type: "function",
23049
+ name: "pause",
23050
+ inputs: [],
23051
+ outputs: [],
23052
+ state_mutability: "external"
23053
+ },
23054
+ {
23055
+ type: "function",
23056
+ name: "unpause",
23057
+ inputs: [],
23058
+ outputs: [],
23059
+ state_mutability: "external"
23060
+ },
23061
+ {
23062
+ type: "function",
23063
+ name: "is_paused",
23064
+ inputs: [],
23065
+ outputs: [
23066
+ {
23067
+ type: "core::bool"
23068
+ }
23069
+ ],
23070
+ state_mutability: "view"
23071
+ },
23072
+ {
23073
+ type: "function",
23074
+ name: "upgrade_name",
23075
+ inputs: [],
23076
+ outputs: [
23077
+ {
23078
+ type: "core::felt252"
23079
+ }
23080
+ ],
23081
+ state_mutability: "view"
23082
+ },
23083
+ {
23084
+ type: "function",
23085
+ name: "upgrade",
23086
+ inputs: [
23087
+ {
23088
+ name: "new_implementation",
23089
+ type: "core::starknet::class_hash::ClassHash"
23090
+ },
23091
+ {
23092
+ name: "eic_implementation_data",
23093
+ type: "core::option::Option::<(core::starknet::class_hash::ClassHash, core::array::Span::<core::felt252>)>"
23094
+ }
23095
+ ],
23096
+ outputs: [],
23097
+ state_mutability: "external"
23098
+ }
23099
+ ]
23100
+ },
23101
+ {
23102
+ type: "impl",
23103
+ name: "OwnableTwoStepImpl",
23104
+ interface_name: "openzeppelin_access::ownable::interface::IOwnableTwoStep"
23105
+ },
23106
+ {
23107
+ type: "interface",
23108
+ name: "openzeppelin_access::ownable::interface::IOwnableTwoStep",
23109
+ items: [
23110
+ {
23111
+ type: "function",
23112
+ name: "owner",
23113
+ inputs: [],
23114
+ outputs: [
23115
+ {
23116
+ type: "core::starknet::contract_address::ContractAddress"
23117
+ }
23118
+ ],
23119
+ state_mutability: "view"
23120
+ },
23121
+ {
23122
+ type: "function",
23123
+ name: "pending_owner",
23124
+ inputs: [],
23125
+ outputs: [
23126
+ {
23127
+ type: "core::starknet::contract_address::ContractAddress"
23128
+ }
23129
+ ],
23130
+ state_mutability: "view"
23131
+ },
23132
+ {
23133
+ type: "function",
23134
+ name: "accept_ownership",
23135
+ inputs: [],
23136
+ outputs: [],
23137
+ state_mutability: "external"
23138
+ },
23139
+ {
23140
+ type: "function",
23141
+ name: "transfer_ownership",
23142
+ inputs: [
23143
+ {
23144
+ name: "new_owner",
23145
+ type: "core::starknet::contract_address::ContractAddress"
23146
+ }
23147
+ ],
23148
+ outputs: [],
23149
+ state_mutability: "external"
23150
+ },
23151
+ {
23152
+ type: "function",
23153
+ name: "renounce_ownership",
23154
+ inputs: [],
23155
+ outputs: [],
23156
+ state_mutability: "external"
23157
+ }
23158
+ ]
23159
+ },
23160
+ {
23161
+ type: "constructor",
23162
+ name: "constructor",
23163
+ inputs: [
23164
+ {
23165
+ name: "name",
23166
+ type: "core::felt252"
23167
+ },
23168
+ {
23169
+ name: "owner",
23170
+ type: "core::starknet::contract_address::ContractAddress"
23171
+ },
23172
+ {
23173
+ name: "curator",
23174
+ type: "core::starknet::contract_address::ContractAddress"
23175
+ },
23176
+ {
23177
+ name: "oracle",
23178
+ type: "core::starknet::contract_address::ContractAddress"
23179
+ }
23180
+ ]
23181
+ },
23182
+ {
23183
+ type: "event",
23184
+ name: "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferred",
23185
+ kind: "struct",
23186
+ members: [
23187
+ {
23188
+ name: "previous_owner",
23189
+ type: "core::starknet::contract_address::ContractAddress",
23190
+ kind: "key"
23191
+ },
23192
+ {
23193
+ name: "new_owner",
23194
+ type: "core::starknet::contract_address::ContractAddress",
23195
+ kind: "key"
23196
+ }
23197
+ ]
23198
+ },
23199
+ {
23200
+ type: "event",
23201
+ name: "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferStarted",
23202
+ kind: "struct",
23203
+ members: [
23204
+ {
23205
+ name: "previous_owner",
23206
+ type: "core::starknet::contract_address::ContractAddress",
23207
+ kind: "key"
23208
+ },
23209
+ {
23210
+ name: "new_owner",
23211
+ type: "core::starknet::contract_address::ContractAddress",
23212
+ kind: "key"
23213
+ }
23214
+ ]
23215
+ },
23216
+ {
23217
+ type: "event",
23218
+ name: "openzeppelin_access::ownable::ownable::OwnableComponent::Event",
23219
+ kind: "enum",
23220
+ variants: [
23221
+ {
23222
+ name: "OwnershipTransferred",
23223
+ type: "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferred",
23224
+ kind: "nested"
23225
+ },
23226
+ {
23227
+ name: "OwnershipTransferStarted",
23228
+ type: "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferStarted",
23229
+ kind: "nested"
23230
+ }
23231
+ ]
23232
+ },
23233
+ {
23234
+ type: "event",
23235
+ name: "vesu::interest_rate_model::interest_rate_model_component::SetInterestRateConfig",
23236
+ kind: "struct",
23237
+ members: [
23238
+ {
23239
+ name: "asset",
23240
+ type: "core::starknet::contract_address::ContractAddress",
23241
+ kind: "data"
23242
+ },
23243
+ {
23244
+ name: "interest_rate_config",
23245
+ type: "vesu::interest_rate_model::InterestRateConfig",
23246
+ kind: "data"
23247
+ }
23248
+ ]
23249
+ },
23250
+ {
23251
+ type: "event",
23252
+ name: "vesu::interest_rate_model::interest_rate_model_component::Event",
23253
+ kind: "enum",
23254
+ variants: [
23255
+ {
23256
+ name: "SetInterestRateConfig",
23257
+ type: "vesu::interest_rate_model::interest_rate_model_component::SetInterestRateConfig",
23258
+ kind: "nested"
23259
+ }
23260
+ ]
23261
+ },
23262
+ {
23263
+ type: "event",
23264
+ name: "vesu::pool::Pool::UpdateContext",
23265
+ kind: "struct",
23266
+ members: [
23267
+ {
23268
+ name: "collateral_asset",
23269
+ type: "core::starknet::contract_address::ContractAddress",
23270
+ kind: "key"
23271
+ },
23272
+ {
23273
+ name: "debt_asset",
23274
+ type: "core::starknet::contract_address::ContractAddress",
23275
+ kind: "key"
23276
+ },
23277
+ {
23278
+ name: "collateral_asset_config",
23279
+ type: "vesu::data_model::AssetConfig",
23280
+ kind: "data"
23281
+ },
23282
+ {
23283
+ name: "debt_asset_config",
23284
+ type: "vesu::data_model::AssetConfig",
23285
+ kind: "data"
23286
+ },
23287
+ {
23288
+ name: "collateral_asset_price",
23289
+ type: "vesu::data_model::AssetPrice",
23290
+ kind: "data"
23291
+ },
23292
+ {
23293
+ name: "debt_asset_price",
23294
+ type: "vesu::data_model::AssetPrice",
23295
+ kind: "data"
23296
+ }
23297
+ ]
23298
+ },
23299
+ {
23300
+ type: "event",
23301
+ name: "vesu::pool::Pool::ModifyPosition",
23302
+ kind: "struct",
23303
+ members: [
23304
+ {
23305
+ name: "collateral_asset",
23306
+ type: "core::starknet::contract_address::ContractAddress",
23307
+ kind: "key"
23308
+ },
23309
+ {
23310
+ name: "debt_asset",
23311
+ type: "core::starknet::contract_address::ContractAddress",
23312
+ kind: "key"
23313
+ },
23314
+ {
23315
+ name: "user",
23316
+ type: "core::starknet::contract_address::ContractAddress",
23317
+ kind: "key"
23318
+ },
23319
+ {
23320
+ name: "collateral_delta",
23321
+ type: "alexandria_math::i257::i257",
23322
+ kind: "data"
23323
+ },
23324
+ {
23325
+ name: "collateral_shares_delta",
23326
+ type: "alexandria_math::i257::i257",
23327
+ kind: "data"
23328
+ },
23329
+ {
23330
+ name: "debt_delta",
23331
+ type: "alexandria_math::i257::i257",
23332
+ kind: "data"
23333
+ },
23334
+ {
23335
+ name: "nominal_debt_delta",
23336
+ type: "alexandria_math::i257::i257",
23337
+ kind: "data"
23338
+ }
23339
+ ]
23340
+ },
23341
+ {
23342
+ type: "event",
23343
+ name: "vesu::pool::Pool::LiquidatePosition",
23344
+ kind: "struct",
23345
+ members: [
23346
+ {
23347
+ name: "collateral_asset",
23348
+ type: "core::starknet::contract_address::ContractAddress",
23349
+ kind: "key"
23350
+ },
23351
+ {
23352
+ name: "debt_asset",
23353
+ type: "core::starknet::contract_address::ContractAddress",
23354
+ kind: "key"
23355
+ },
23356
+ {
23357
+ name: "user",
23358
+ type: "core::starknet::contract_address::ContractAddress",
23359
+ kind: "key"
23360
+ },
23361
+ {
23362
+ name: "liquidator",
23363
+ type: "core::starknet::contract_address::ContractAddress",
23364
+ kind: "key"
23365
+ },
23366
+ {
23367
+ name: "collateral_delta",
23368
+ type: "alexandria_math::i257::i257",
23369
+ kind: "data"
23370
+ },
23371
+ {
23372
+ name: "collateral_shares_delta",
23373
+ type: "alexandria_math::i257::i257",
23374
+ kind: "data"
23375
+ },
23376
+ {
23377
+ name: "debt_delta",
23378
+ type: "alexandria_math::i257::i257",
23379
+ kind: "data"
23380
+ },
23381
+ {
23382
+ name: "nominal_debt_delta",
23383
+ type: "alexandria_math::i257::i257",
23384
+ kind: "data"
23385
+ },
23386
+ {
23387
+ name: "bad_debt",
23388
+ type: "core::integer::u256",
23389
+ kind: "data"
23390
+ }
23391
+ ]
23392
+ },
23393
+ {
23394
+ type: "event",
23395
+ name: "vesu::pool::Pool::Flashloan",
23396
+ kind: "struct",
23397
+ members: [
23398
+ {
23399
+ name: "sender",
23400
+ type: "core::starknet::contract_address::ContractAddress",
23401
+ kind: "key"
23402
+ },
23403
+ {
23404
+ name: "receiver",
23405
+ type: "core::starknet::contract_address::ContractAddress",
23406
+ kind: "key"
23407
+ },
23408
+ {
23409
+ name: "asset",
23410
+ type: "core::starknet::contract_address::ContractAddress",
23411
+ kind: "key"
23412
+ },
23413
+ {
23414
+ name: "amount",
23415
+ type: "core::integer::u256",
23416
+ kind: "data"
23417
+ }
23418
+ ]
23419
+ },
23420
+ {
23421
+ type: "event",
23422
+ name: "vesu::pool::Pool::ModifyDelegation",
23423
+ kind: "struct",
23424
+ members: [
23425
+ {
23426
+ name: "delegator",
23427
+ type: "core::starknet::contract_address::ContractAddress",
23428
+ kind: "key"
23429
+ },
23430
+ {
23431
+ name: "delegatee",
23432
+ type: "core::starknet::contract_address::ContractAddress",
23433
+ kind: "key"
23434
+ },
23435
+ {
23436
+ name: "delegation",
23437
+ type: "core::bool",
23438
+ kind: "data"
23439
+ }
23440
+ ]
23441
+ },
23442
+ {
23443
+ type: "event",
23444
+ name: "vesu::pool::Pool::Donate",
23445
+ kind: "struct",
23446
+ members: [
23447
+ {
23448
+ name: "asset",
23449
+ type: "core::starknet::contract_address::ContractAddress",
23450
+ kind: "key"
23451
+ },
23452
+ {
23453
+ name: "amount",
23454
+ type: "core::integer::u256",
23455
+ kind: "data"
23456
+ }
23457
+ ]
23458
+ },
23459
+ {
23460
+ type: "event",
23461
+ name: "vesu::pool::Pool::SetAssetConfig",
23462
+ kind: "struct",
23463
+ members: [
23464
+ {
23465
+ name: "asset",
23466
+ type: "core::starknet::contract_address::ContractAddress",
23467
+ kind: "key"
23468
+ },
23469
+ {
23470
+ name: "asset_config",
23471
+ type: "vesu::data_model::AssetConfig",
23472
+ kind: "data"
23473
+ }
23474
+ ]
23475
+ },
23476
+ {
23477
+ type: "event",
23478
+ name: "vesu::pool::Pool::SetOracle",
23479
+ kind: "struct",
23480
+ members: [
23481
+ {
23482
+ name: "oracle",
23483
+ type: "core::starknet::contract_address::ContractAddress",
23484
+ kind: "data"
23485
+ }
23486
+ ]
23487
+ },
23488
+ {
23489
+ type: "event",
23490
+ name: "vesu::pool::Pool::SetPairConfig",
23491
+ kind: "struct",
23492
+ members: [
23493
+ {
23494
+ name: "collateral_asset",
23495
+ type: "core::starknet::contract_address::ContractAddress",
23496
+ kind: "key"
23497
+ },
23498
+ {
23499
+ name: "debt_asset",
23500
+ type: "core::starknet::contract_address::ContractAddress",
23501
+ kind: "key"
23502
+ },
23503
+ {
23504
+ name: "pair_config",
23505
+ type: "vesu::data_model::PairConfig",
23506
+ kind: "data"
23507
+ }
23508
+ ]
23509
+ },
23510
+ {
23511
+ type: "event",
23512
+ name: "vesu::pool::Pool::ClaimFees",
23513
+ kind: "struct",
23514
+ members: [
23515
+ {
23516
+ name: "asset",
23517
+ type: "core::starknet::contract_address::ContractAddress",
23518
+ kind: "key"
23519
+ },
23520
+ {
23521
+ name: "recipient",
23522
+ type: "core::starknet::contract_address::ContractAddress",
23523
+ kind: "data"
23524
+ },
23525
+ {
23526
+ name: "fee_shares",
23527
+ type: "core::integer::u256",
23528
+ kind: "data"
23529
+ },
23530
+ {
23531
+ name: "fee_amount",
23532
+ type: "core::integer::u256",
23533
+ kind: "data"
23534
+ }
23535
+ ]
23536
+ },
23537
+ {
23538
+ type: "event",
23539
+ name: "vesu::pool::Pool::SetFeeRecipient",
23540
+ kind: "struct",
23541
+ members: [
23542
+ {
23543
+ name: "fee_recipient",
23544
+ type: "core::starknet::contract_address::ContractAddress",
23545
+ kind: "key"
23546
+ }
23547
+ ]
23548
+ },
23549
+ {
23550
+ type: "event",
23551
+ name: "vesu::pool::Pool::SetPausingAgent",
23552
+ kind: "struct",
23553
+ members: [
23554
+ {
23555
+ name: "agent",
23556
+ type: "core::starknet::contract_address::ContractAddress",
23557
+ kind: "key"
23558
+ }
23559
+ ]
23560
+ },
23561
+ {
23562
+ type: "event",
23563
+ name: "vesu::pool::Pool::SetCurator",
23564
+ kind: "struct",
23565
+ members: [
23566
+ {
23567
+ name: "curator",
23568
+ type: "core::starknet::contract_address::ContractAddress",
23569
+ kind: "key"
23570
+ }
23571
+ ]
23572
+ },
23573
+ {
23574
+ type: "event",
23575
+ name: "vesu::pool::Pool::NominateCurator",
23576
+ kind: "struct",
23577
+ members: [
23578
+ {
23579
+ name: "pending_curator",
23580
+ type: "core::starknet::contract_address::ContractAddress",
23581
+ kind: "key"
23582
+ }
23583
+ ]
23584
+ },
23585
+ {
23586
+ type: "event",
23587
+ name: "vesu::pool::Pool::ContractPaused",
23588
+ kind: "struct",
23589
+ members: [
23590
+ {
23591
+ name: "account",
23592
+ type: "core::starknet::contract_address::ContractAddress",
23593
+ kind: "data"
23594
+ }
23595
+ ]
23596
+ },
23597
+ {
23598
+ type: "event",
23599
+ name: "vesu::pool::Pool::ContractUnpaused",
23600
+ kind: "struct",
23601
+ members: [
23602
+ {
23603
+ name: "account",
23604
+ type: "core::starknet::contract_address::ContractAddress",
23605
+ kind: "data"
23606
+ }
23607
+ ]
23608
+ },
23609
+ {
23610
+ type: "event",
23611
+ name: "vesu::pool::Pool::ContractUpgraded",
23612
+ kind: "struct",
23613
+ members: [
23614
+ {
23615
+ name: "new_implementation",
23616
+ type: "core::starknet::class_hash::ClassHash",
23617
+ kind: "data"
23618
+ }
23619
+ ]
23620
+ },
23621
+ {
23622
+ type: "event",
23623
+ name: "vesu::pool::Pool::Event",
23624
+ kind: "enum",
23625
+ variants: [
23626
+ {
23627
+ name: "OwnableEvent",
23628
+ type: "openzeppelin_access::ownable::ownable::OwnableComponent::Event",
23629
+ kind: "flat"
23630
+ },
23631
+ {
23632
+ name: "InterestRateModelEvents",
23633
+ type: "vesu::interest_rate_model::interest_rate_model_component::Event",
23634
+ kind: "nested"
23635
+ },
23636
+ {
23637
+ name: "UpdateContext",
23638
+ type: "vesu::pool::Pool::UpdateContext",
23639
+ kind: "nested"
23640
+ },
23641
+ {
23642
+ name: "ModifyPosition",
23643
+ type: "vesu::pool::Pool::ModifyPosition",
23644
+ kind: "nested"
23645
+ },
23646
+ {
23647
+ name: "LiquidatePosition",
23648
+ type: "vesu::pool::Pool::LiquidatePosition",
23649
+ kind: "nested"
23650
+ },
23651
+ {
23652
+ name: "Flashloan",
23653
+ type: "vesu::pool::Pool::Flashloan",
23654
+ kind: "nested"
23655
+ },
23656
+ {
23657
+ name: "ModifyDelegation",
23658
+ type: "vesu::pool::Pool::ModifyDelegation",
23659
+ kind: "nested"
23660
+ },
23661
+ {
23662
+ name: "Donate",
23663
+ type: "vesu::pool::Pool::Donate",
23664
+ kind: "nested"
23665
+ },
23666
+ {
23667
+ name: "SetAssetConfig",
23668
+ type: "vesu::pool::Pool::SetAssetConfig",
23669
+ kind: "nested"
23670
+ },
23671
+ {
23672
+ name: "SetOracle",
23673
+ type: "vesu::pool::Pool::SetOracle",
23674
+ kind: "nested"
23675
+ },
23676
+ {
23677
+ name: "SetPairConfig",
23678
+ type: "vesu::pool::Pool::SetPairConfig",
23679
+ kind: "nested"
23680
+ },
23681
+ {
23682
+ name: "ClaimFees",
23683
+ type: "vesu::pool::Pool::ClaimFees",
23684
+ kind: "nested"
23685
+ },
23686
+ {
23687
+ name: "SetFeeRecipient",
23688
+ type: "vesu::pool::Pool::SetFeeRecipient",
23689
+ kind: "nested"
23690
+ },
23691
+ {
23692
+ name: "SetPausingAgent",
23693
+ type: "vesu::pool::Pool::SetPausingAgent",
23694
+ kind: "nested"
23695
+ },
23696
+ {
23697
+ name: "SetCurator",
23698
+ type: "vesu::pool::Pool::SetCurator",
23699
+ kind: "nested"
23700
+ },
23701
+ {
23702
+ name: "NominateCurator",
23703
+ type: "vesu::pool::Pool::NominateCurator",
23704
+ kind: "nested"
23705
+ },
23706
+ {
23707
+ name: "ContractPaused",
23708
+ type: "vesu::pool::Pool::ContractPaused",
23709
+ kind: "nested"
23710
+ },
23711
+ {
23712
+ name: "ContractUnpaused",
23713
+ type: "vesu::pool::Pool::ContractUnpaused",
23714
+ kind: "nested"
23715
+ },
23716
+ {
23717
+ name: "ContractUpgraded",
23718
+ type: "vesu::pool::Pool::ContractUpgraded",
23719
+ kind: "nested"
23720
+ }
23721
+ ]
23722
+ }
23723
+ ];
23724
+
23725
+ // src/strategies/universal-adapters/vesu-adapter.ts
23726
+ var VesuAmountType = /* @__PURE__ */ ((VesuAmountType2) => {
23727
+ VesuAmountType2[VesuAmountType2["Delta"] = 0] = "Delta";
23728
+ VesuAmountType2[VesuAmountType2["Target"] = 1] = "Target";
23729
+ return VesuAmountType2;
23730
+ })(VesuAmountType || {});
23731
+ var VesuAmountDenomination = /* @__PURE__ */ ((VesuAmountDenomination2) => {
23732
+ VesuAmountDenomination2[VesuAmountDenomination2["Native"] = 0] = "Native";
23733
+ VesuAmountDenomination2[VesuAmountDenomination2["Assets"] = 1] = "Assets";
23734
+ return VesuAmountDenomination2;
23735
+ })(VesuAmountDenomination || {});
23736
+ function getVesuMultiplyParams(isIncrease, params) {
23737
+ if (isIncrease) {
23738
+ const _params2 = params;
23739
+ return {
23740
+ action: new CairoCustomEnum2({ IncreaseLever: {
23741
+ pool_id: _params2.pool_id.toBigInt(),
23742
+ collateral_asset: _params2.collateral_asset.toBigInt(),
23743
+ debt_asset: _params2.debt_asset.toBigInt(),
23744
+ user: _params2.user.toBigInt(),
23745
+ add_margin: BigInt(_params2.add_margin.toWei()),
23746
+ margin_swap: _params2.margin_swap.map((swap) => ({
23747
+ route: swap.route.map((route) => ({
23748
+ pool_key: {
23749
+ token0: route.pool_key.token0.toBigInt(),
23750
+ token1: route.pool_key.token1.toBigInt(),
23751
+ fee: route.pool_key.fee,
23752
+ tick_spacing: route.pool_key.tick_spacing,
23753
+ extension: BigInt(num8.hexToDecimalString(route.pool_key.extension))
23754
+ },
23755
+ sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
23756
+ skip_ahead: BigInt(100)
23757
+ })),
23758
+ token_amount: {
23759
+ token: swap.token_amount.token.toBigInt(),
23760
+ amount: swap.token_amount.amount.toI129()
23761
+ }
23762
+ })),
23763
+ margin_swap_limit_amount: BigInt(_params2.margin_swap_limit_amount.toWei()),
23764
+ lever_swap: _params2.lever_swap.map((swap) => ({
23765
+ route: swap.route.map((route) => ({
23766
+ pool_key: {
23767
+ token0: route.pool_key.token0.toBigInt(),
23768
+ token1: route.pool_key.token1.toBigInt(),
23769
+ fee: route.pool_key.fee,
23770
+ tick_spacing: route.pool_key.tick_spacing,
23771
+ extension: BigInt(num8.hexToDecimalString(route.pool_key.extension))
23772
+ },
23773
+ sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
23774
+ skip_ahead: BigInt(100)
23775
+ })),
23776
+ token_amount: {
23777
+ token: swap.token_amount.token.toBigInt(),
23778
+ amount: swap.token_amount.amount.toI129()
23779
+ }
23780
+ })),
23781
+ lever_swap_limit_amount: BigInt(_params2.lever_swap_limit_amount.toWei())
23782
+ } })
23783
+ };
23784
+ }
23785
+ const _params = params;
23786
+ return {
23787
+ action: new CairoCustomEnum2({ DecreaseLever: {
23788
+ pool_id: _params.pool_id.toBigInt(),
23789
+ collateral_asset: _params.collateral_asset.toBigInt(),
23790
+ debt_asset: _params.debt_asset.toBigInt(),
23791
+ user: _params.user.toBigInt(),
23792
+ sub_margin: BigInt(_params.sub_margin.toWei()),
23793
+ recipient: _params.recipient.toBigInt(),
23794
+ lever_swap: _params.lever_swap.map((swap) => ({
23795
+ route: swap.route.map((route) => ({
23796
+ pool_key: {
23797
+ token0: route.pool_key.token0.toBigInt(),
23798
+ token1: route.pool_key.token1.toBigInt(),
23799
+ fee: route.pool_key.fee,
23800
+ tick_spacing: route.pool_key.tick_spacing,
23801
+ extension: ContractAddr.from(route.pool_key.extension).toBigInt()
23802
+ },
23803
+ sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
23804
+ skip_ahead: BigInt(route.skip_ahead.toWei())
23805
+ })),
23806
+ token_amount: {
23807
+ token: swap.token_amount.token.toBigInt(),
23808
+ amount: swap.token_amount.amount.toI129()
23809
+ }
23810
+ })),
23811
+ lever_swap_limit_amount: BigInt(_params.lever_swap_limit_amount.toWei()),
23812
+ lever_swap_weights: _params.lever_swap_weights.map((weight) => BigInt(weight.toWei())),
23813
+ withdraw_swap: _params.withdraw_swap.map((swap) => ({
23814
+ route: swap.route.map((route) => ({
23815
+ pool_key: {
23816
+ token0: route.pool_key.token0.toBigInt(),
23817
+ token1: route.pool_key.token1.toBigInt(),
23818
+ fee: route.pool_key.fee,
23819
+ tick_spacing: route.pool_key.tick_spacing,
23820
+ extension: ContractAddr.from(route.pool_key.extension).toBigInt()
23821
+ },
23822
+ sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
23823
+ skip_ahead: BigInt(route.skip_ahead.toWei())
23824
+ })),
23825
+ token_amount: {
23826
+ token: swap.token_amount.token.toBigInt(),
23827
+ amount: swap.token_amount.amount.toI129()
23828
+ }
23829
+ })),
23830
+ withdraw_swap_limit_amount: BigInt(_params.withdraw_swap_limit_amount.toWei()),
23831
+ withdraw_swap_weights: _params.withdraw_swap_weights.map((weight) => BigInt(weight.toWei())),
23832
+ close_position: _params.close_position
23833
+ } })
23834
+ };
23835
+ }
23836
+ var VesuPools = {
23837
+ Genesis: ContractAddr.from("0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28"),
23838
+ Re7xSTRK: ContractAddr.from("0x052fb52363939c3aa848f8f4ac28f0a51379f8d1b971d8444de25fbd77d8f161"),
23839
+ Re7xBTC: ContractAddr.from("0x3a8416bf20d036df5b1cf3447630a2e1cb04685f6b0c3a70ed7fb1473548ecf")
23840
+ };
23841
+ function getVesuSingletonAddress(vesuPool) {
23842
+ if (vesuPool.eq(VesuPools.Genesis) || vesuPool.eq(VesuPools.Re7xSTRK)) {
23843
+ return { addr: VESU_SINGLETON, isV2: false };
23844
+ }
23845
+ return { addr: vesuPool, isV2: true };
23846
+ }
23847
+ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
23848
+ constructor(config) {
23849
+ super();
23850
+ this.VESU_MULTIPLY = ContractAddr.from("0x027fef272d0a9a3844767c851a64b36fe4f0115141d81134baade95d2b27b781");
23851
+ this.getModifyPosition = () => {
23852
+ const positionData = [0n];
23853
+ const packedArguments = [
23854
+ toBigInt(this.config.poolId.toString()),
23855
+ // pool id
23856
+ toBigInt(this.config.collateral.address.toString()),
23857
+ // collateral
23858
+ toBigInt(this.config.debt.address.toString()),
23859
+ // debt
23860
+ toBigInt(this.config.vaultAllocator.toString()),
23861
+ // vault allocator
23862
+ toBigInt(positionData.length),
23863
+ ...positionData
23864
+ ];
23865
+ const output = this.constructSimpleLeafData({
23866
+ id: this.config.id,
23867
+ target: getVesuSingletonAddress(this.config.poolId).addr,
23868
+ method: "modify_position",
23869
+ packedArguments
23870
+ });
23871
+ return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
23872
+ };
23873
+ this.getModifyPositionCall = (params) => {
23874
+ const _collateral = {
23875
+ amount_type: this.formatAmountTypeEnum(params.collateralAmount.amount_type),
23876
+ denomination: this.formatAmountDenominationEnum(params.collateralAmount.denomination),
23877
+ value: {
23878
+ abs: uint2567.bnToUint256(params.collateralAmount.value.abs.toWei()),
23879
+ is_negative: params.collateralAmount.value.abs.isZero() ? false : params.collateralAmount.value.is_negative
23880
+ }
23881
+ };
23882
+ logger.verbose(`VesuAdapter::ConstructingModify::Collateral::${JSON.stringify(_collateral)}`);
23883
+ const _debt = {
23884
+ amount_type: this.formatAmountTypeEnum(params.debtAmount.amount_type),
23885
+ denomination: this.formatAmountDenominationEnum(params.debtAmount.denomination),
23886
+ value: {
23887
+ abs: uint2567.bnToUint256(params.debtAmount.value.abs.toWei()),
23888
+ is_negative: params.debtAmount.value.abs.isZero() ? false : params.debtAmount.value.is_negative
23889
+ }
23890
+ };
23891
+ logger.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`);
23892
+ const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
23893
+ const call = contract.populate("modify_position", {
23894
+ params: isV2 ? {
23895
+ collateral_asset: this.config.collateral.address.toBigInt(),
23896
+ debt_asset: this.config.debt.address.toBigInt(),
23897
+ user: this.config.vaultAllocator.toBigInt(),
23898
+ collateral: _collateral,
23899
+ debt: _debt
23900
+ } : {
23901
+ pool_id: this.config.poolId.toBigInt(),
23902
+ collateral_asset: this.config.collateral.address.toBigInt(),
23903
+ debt_asset: this.config.debt.address.toBigInt(),
23904
+ user: this.config.vaultAllocator.toBigInt(),
23905
+ collateral: _collateral,
23906
+ debt: _debt,
23907
+ data: [0]
23908
+ }
23909
+ });
23910
+ return {
23911
+ sanitizer: SIMPLE_SANITIZER,
23912
+ call: {
23913
+ contractAddress: ContractAddr.from(contract.address),
23914
+ selector: hash3.getSelectorFromName("modify_position"),
23915
+ calldata: [
23916
+ ...call.calldata
23917
+ ]
23918
+ }
23919
+ };
23920
+ };
23921
+ this.getMultiplyAdapter = () => {
23922
+ const packedArguments = [
23923
+ toBigInt(this.config.poolId.toString()),
23924
+ // pool id
23925
+ toBigInt(this.config.collateral.address.toString()),
23926
+ // collateral
23927
+ toBigInt(this.config.debt.address.toString()),
23928
+ // debt
23929
+ toBigInt(this.config.vaultAllocator.toString())
23930
+ // vault allocator
23931
+ ];
23932
+ const output = this.constructSimpleLeafData({
23933
+ id: this.config.id,
23934
+ target: this.VESU_MULTIPLY,
23935
+ method: "modify_lever",
23936
+ packedArguments
23937
+ }, SIMPLE_SANITIZER_V2);
23938
+ return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
23939
+ };
23940
+ this.getMultiplyCall = (params) => {
23941
+ const isIncrease = params.isIncrease;
23942
+ const multiplyParams = isIncrease ? params.increaseParams : params.decreaseParams;
23943
+ if (!multiplyParams) {
23944
+ throw new Error("Multiply params are not provided");
23945
+ }
23946
+ const multiplyContract = new Contract8({ abi: vesu_multiple_abi_default, address: this.VESU_MULTIPLY.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
23947
+ const call = multiplyContract.populate("modify_lever", {
23948
+ modify_lever_params: getVesuMultiplyParams(isIncrease, {
23949
+ ...multiplyParams,
23950
+ user: this.config.vaultAllocator,
23951
+ pool_id: this.config.poolId,
23952
+ collateral_asset: this.config.collateral.address,
23953
+ debt_asset: this.config.debt.address,
23954
+ recipient: this.config.vaultAllocator
23955
+ })
23956
+ });
23957
+ return {
23958
+ sanitizer: SIMPLE_SANITIZER_V2,
23959
+ call: {
23960
+ contractAddress: this.VESU_MULTIPLY,
23961
+ selector: hash3.getSelectorFromName("modify_lever"),
23962
+ calldata: [
22044
23963
  ...call.calldata
22045
23964
  ]
22046
23965
  }
@@ -22049,14 +23968,12 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
22049
23968
  this.getVesuModifyDelegationAdapter = (id) => {
22050
23969
  return () => {
22051
23970
  const packedArguments = [
22052
- toBigInt(this.config.poolId.toString()),
22053
- // pool id
22054
23971
  toBigInt(this.VESU_MULTIPLY.toString())
22055
23972
  // vault allocator
22056
23973
  ];
22057
23974
  const output = this.constructSimpleLeafData({
22058
23975
  id,
22059
- target: this.VESU_SINGLETON,
23976
+ target: getVesuSingletonAddress(this.config.poolId).addr,
22060
23977
  method: "modify_delegation",
22061
23978
  packedArguments
22062
23979
  }, SIMPLE_SANITIZER_V2);
@@ -22064,8 +23981,12 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
22064
23981
  };
22065
23982
  };
22066
23983
  this.getVesuModifyDelegationCall = (params) => {
22067
- const singletonContract = new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
22068
- const call = singletonContract.populate("modify_delegation", {
23984
+ const VESU_SINGLETON2 = getVesuSingletonAddress(this.config.poolId).addr;
23985
+ const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
23986
+ const call = contract.populate("modify_delegation", isV2 ? {
23987
+ delegatee: this.VESU_MULTIPLY.toBigInt(),
23988
+ delegation: params.delegation
23989
+ } : {
22069
23990
  pool_id: this.config.poolId.toBigInt(),
22070
23991
  delegatee: this.VESU_MULTIPLY.toBigInt(),
22071
23992
  delegation: params.delegation
@@ -22073,7 +23994,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
22073
23994
  return {
22074
23995
  sanitizer: SIMPLE_SANITIZER_V2,
22075
23996
  call: {
22076
- contractAddress: this.VESU_SINGLETON,
23997
+ contractAddress: VESU_SINGLETON2,
22077
23998
  selector: hash3.getSelectorFromName("modify_delegation"),
22078
23999
  calldata: [
22079
24000
  ...call.calldata
@@ -22155,8 +24076,13 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
22155
24076
  }
22156
24077
  throw new Error(`Unknown VesuAmountDenomination: ${denomination}`);
22157
24078
  }
22158
- getVesuSingletonContract(config) {
22159
- return new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.address, providerOrAccount: config.provider });
24079
+ getVesuSingletonContract(config, poolId) {
24080
+ const { addr: VESU_SINGLETON2, isV2 } = getVesuSingletonAddress(poolId);
24081
+ const ABI = isV2 ? vesu_pool_v2_abi_default : vesu_singleton_abi_default;
24082
+ return {
24083
+ contract: new Contract8({ abi: ABI, address: VESU_SINGLETON2.address, providerOrAccount: config.provider }),
24084
+ isV2
24085
+ };
22160
24086
  }
22161
24087
  async getLTVConfig(config) {
22162
24088
  const CACHE_KEY = "ltv_config";
@@ -22164,8 +24090,16 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
22164
24090
  if (cacheData) {
22165
24091
  return cacheData;
22166
24092
  }
22167
- const output = await this.getVesuSingletonContract(config).call("ltv_config", [this.config.poolId.address, this.config.collateral.address.address, this.config.debt.address.address]);
22168
- this.setCache(CACHE_KEY, Number(output.max_ltv) / 1e18, 3e5);
24093
+ const { contract, isV2 } = await this.getVesuSingletonContract(config, this.config.poolId);
24094
+ let ltv = 0;
24095
+ if (isV2) {
24096
+ const output = await contract.call("pair_config", [this.config.collateral.address.address, this.config.debt.address.address]);
24097
+ ltv = Number(output.max_ltv) / 1e18;
24098
+ } else {
24099
+ const output = await contract.call("ltv_config", [this.config.poolId.address, this.config.collateral.address.address, this.config.debt.address.address]);
24100
+ ltv = Number(output.max_ltv) / 1e18;
24101
+ }
24102
+ this.setCache(CACHE_KEY, ltv, 3e5);
22169
24103
  return this.getCache(CACHE_KEY);
22170
24104
  }
22171
24105
  async getPositions(config) {
@@ -22177,14 +24111,17 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
22177
24111
  if (cacheData) {
22178
24112
  return cacheData;
22179
24113
  }
22180
- const output = await this.getVesuSingletonContract(config).call("position_unsafe", [
22181
- this.config.poolId.address,
24114
+ const { contract, isV2 } = this.getVesuSingletonContract(config, this.config.poolId);
24115
+ const output = await contract.call(isV2 ? "position" : "position_unsafe", [
24116
+ ...isV2 ? [] : [this.config.poolId.address],
24117
+ // exclude pool id in v2
22182
24118
  this.config.collateral.address.address,
22183
24119
  this.config.debt.address.address,
22184
24120
  this.config.vaultAllocator.address
22185
24121
  ]);
22186
24122
  const token1Price = await this.pricer.getPrice(this.config.collateral.symbol);
22187
24123
  const token2Price = await this.pricer.getPrice(this.config.debt.symbol);
24124
+ logger.verbose(`VesuAdapter::getPositions token1Price: ${token1Price.price}, token2Price: ${token2Price.price}`);
22188
24125
  const collateralAmount = Web3Number.fromWei(output["1"].toString(), this.config.collateral.decimals);
22189
24126
  const debtAmount = Web3Number.fromWei(output["2"].toString(), this.config.debt.decimals);
22190
24127
  const value = [{
@@ -22210,8 +24147,10 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
22210
24147
  if (cacheData) {
22211
24148
  return cacheData;
22212
24149
  }
22213
- const output = await this.getVesuSingletonContract(config).call("check_collateralization_unsafe", [
22214
- this.config.poolId.address,
24150
+ const { contract, isV2 } = this.getVesuSingletonContract(config, this.config.poolId);
24151
+ const output = await contract.call(isV2 ? "check_collateralization" : "check_collateralization_unsafe", [
24152
+ ...isV2 ? [] : [this.config.poolId.address],
24153
+ // exclude pool id in v2
22215
24154
  this.config.collateral.address.address,
22216
24155
  this.config.debt.address.address,
22217
24156
  this.config.vaultAllocator.address
@@ -22271,7 +24210,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
22271
24210
  );
22272
24211
  pools = data.data;
22273
24212
  for (const pool of vesu_pools_default.data) {
22274
- const found = pools.find((d) => d.id === pool.id);
24213
+ const found = pools.find((d) => ContractAddr.from(d.id).eqString(pool.id));
22275
24214
  if (!found) {
22276
24215
  logger.verbose(`VesuRebalance: pools: ${JSON.stringify(pools)}`);
22277
24216
  logger.verbose(
@@ -24661,12 +26600,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
24661
26600
  const rewardAPYs = [];
24662
26601
  for (const [index, pool] of pools.entries()) {
24663
26602
  const vesuAdapter = vesuAdapters[index];
24664
- const collateralAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.collateral.symbol)?.stats;
24665
- const debtAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.debt.symbol)?.stats;
26603
+ const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
26604
+ const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
24666
26605
  const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
24667
26606
  const lstAPY = Number(collateralAsset.lstApr?.value || 0) / 1e18;
24668
26607
  baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
24669
- rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr.value || "0") / 1e18, 0]);
26608
+ rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
24670
26609
  }
24671
26610
  logger.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
24672
26611
  logger.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
@@ -24736,6 +26675,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
24736
26675
  const underlying = this.asset();
24737
26676
  let vesuAum = Web3Number.fromWei("0", underlying.decimals);
24738
26677
  let tokenUnderlyingPrice = await this.pricer.getPrice(this.asset().symbol);
26678
+ logger.verbose(`${this.getTag()} tokenUnderlyingPrice: ${tokenUnderlyingPrice.price}`);
24739
26679
  if (legAUM[0].token.address.eq(underlying.address)) {
24740
26680
  vesuAum = vesuAum.plus(legAUM[0].amount);
24741
26681
  } else {
@@ -24836,7 +26776,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
24836
26776
  amount: unusedBalance.amount,
24837
26777
  usdValue: unusedBalance.usdValue,
24838
26778
  token: this.asset(),
24839
- remarks: "Unused Balance"
26779
+ remarks: "Unused Balance (may not include recent deposits)"
24840
26780
  }];
24841
26781
  }
24842
26782
  getSetManagerCall(strategist, root = this.getMerkleRoot()) {
@@ -25174,8 +27114,8 @@ function getLooperSettings(token1Symbol, token2Symbol, vaultSettings, pool1, poo
25174
27114
  vaultSettings.leafAdapters.push(commonAdapter.getFlashloanAdapter.bind(commonAdapter));
25175
27115
  vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getModifyPosition.bind(vesuAdapterUSDCETH));
25176
27116
  vaultSettings.leafAdapters.push(vesuAdapterETHUSDC.getModifyPosition.bind(vesuAdapterETHUSDC));
25177
- vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(USDCToken.address, vesuAdapterUSDCETH.VESU_SINGLETON, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
25178
- vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(ETHToken.address, vesuAdapterETHUSDC.VESU_SINGLETON, "approve_token2" /* APPROVE_TOKEN2 */).bind(commonAdapter));
27117
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(USDCToken.address, VESU_SINGLETON, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
27118
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(ETHToken.address, VESU_SINGLETON, "approve_token2" /* APPROVE_TOKEN2 */).bind(commonAdapter));
25179
27119
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(USDCToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
25180
27120
  vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
25181
27121
  vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterUSDCETH));
@@ -25479,7 +27419,7 @@ var UniversalStrategies = [
25479
27419
  // src/strategies/universal-lst-muliplier-strategy.tsx
25480
27420
  import { Contract as Contract10, uint256 as uint2569 } from "starknet";
25481
27421
  import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
25482
- var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
27422
+ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy extends UniversalStrategy {
25483
27423
  constructor(config, pricer, metadata) {
25484
27424
  super(config, pricer, metadata);
25485
27425
  this.quoteAmountToFetchPrice = new Web3Number(1, 18);
@@ -25491,8 +27431,15 @@ var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
25491
27431
  this.quoteAmountToFetchPrice = new Web3Number(0.01, this.asset().decimals);
25492
27432
  }
25493
27433
  }
27434
+ asset() {
27435
+ const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
27436
+ return vesuAdapter1.config.collateral;
27437
+ }
27438
+ getTag() {
27439
+ return `${_UniversalLstMultiplierStrategy.name}:${this.metadata.name}`;
27440
+ }
25494
27441
  // only one leg is used
25495
- // todo support lending assets of underlying as well
27442
+ // todo support lending assets of underlying as well (like if xSTRK looping is not viable, simply supply STRK)
25496
27443
  getVesuAdapters() {
25497
27444
  const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
25498
27445
  vesuAdapter1.pricer = this.pricer;
@@ -25501,9 +27448,13 @@ var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
25501
27448
  }
25502
27449
  // not applicable for this strategy
25503
27450
  // No rewards on collateral or borrowing of LST assets
25504
- // protected async getRewardsAUM(prevAum: Web3Number): Promise<Web3Number> {
25505
- // return Web3Number.fromWei("0", this.asset().decimals);
25506
- // }
27451
+ async getRewardsAUM(prevAum) {
27452
+ const lstToken = this.asset();
27453
+ if (lstToken.symbol === "xSTRK") {
27454
+ return super.getRewardsAUM(prevAum);
27455
+ }
27456
+ return Web3Number.fromWei("0", lstToken.decimals);
27457
+ }
25507
27458
  async getLSTDexPrice() {
25508
27459
  const ekuboQuoter = new EkuboQuoter(this.config);
25509
27460
  const lstTokenInfo = this.asset();
@@ -25526,6 +27477,7 @@ var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
25526
27477
  async getVesuMultiplyCall(params) {
25527
27478
  const [vesuAdapter1] = this.getVesuAdapters();
25528
27479
  const legLTV = await vesuAdapter1.getLTVConfig(this.config);
27480
+ logger.verbose(`${this.getTag()}::getVesuMultiplyCall legLTV: ${legLTV}`);
25529
27481
  const existingPositions = await vesuAdapter1.getPositions(this.config);
25530
27482
  const collateralisation = await vesuAdapter1.getCollateralization(this.config);
25531
27483
  const existingCollateralInfo = existingPositions[0];
@@ -25539,8 +27491,11 @@ var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
25539
27491
  const addedCollateral = params.leg1DepositAmount.multipliedBy(params.isDeposit ? 1 : -1);
25540
27492
  logger.verbose(`${this.getTag()}::getVesuMultiplyCall addedCollateral: ${addedCollateral}`);
25541
27493
  const numeratorPart1 = existingCollateralInfo.amount.plus(addedCollateral).multipliedBy(collateralPrice).multipliedBy(legLTV);
27494
+ logger.verbose(`${this.getTag()}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}`);
25542
27495
  const numeratorPart2 = existingDebtInfo.amount.multipliedBy(debtPrice).multipliedBy(this.metadata.additionalInfo.targetHealthFactor);
27496
+ logger.verbose(`${this.getTag()}::getVesuMultiplyCall numeratorPart2: ${numeratorPart2}`);
25543
27497
  const denominatorPart = this.metadata.additionalInfo.targetHealthFactor - legLTV / dexPrice;
27498
+ logger.verbose(`${this.getTag()}::getVesuMultiplyCall denominatorPart: ${denominatorPart}`);
25544
27499
  const x_debt_usd = numeratorPart1.minus(numeratorPart2).dividedBy(denominatorPart);
25545
27500
  logger.verbose(`${this.getTag()}::getVesuMultiplyCall x_debt_usd: ${x_debt_usd}`);
25546
27501
  logger.debug(`${this.getTag()}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}, numeratorPart2: ${numeratorPart2}, denominatorPart: ${denominatorPart}`);
@@ -25576,10 +27531,15 @@ var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
25576
27531
  * @param params marginAmount is in LST, debtAmount is in underlying
25577
27532
  */
25578
27533
  async getModifyLeverCall(params) {
27534
+ logger.verbose(`${this.getTag()}::getModifyLeverCall marginAmount: ${params.marginAmount}, debtAmount: ${params.debtAmount}, lstDexPriceInUnderlying: ${params.lstDexPriceInUnderlying}, isIncrease: ${params.isIncrease}`);
25579
27535
  assert(!params.marginAmount.isZero() || !params.debtAmount.isZero(), "Deposit/debt must be non-0");
25580
27536
  const [vesuAdapter1] = this.getVesuAdapters();
25581
27537
  const lstTokenInfo = this.asset();
25582
27538
  const lstUnderlyingTokenInfo = vesuAdapter1.config.debt;
27539
+ const maxAmounts = lstTokenInfo.symbol == "xSTRK" ? 5e5 : 0.5;
27540
+ if (params.marginAmount.greaterThan(maxAmounts)) {
27541
+ throw new Error(`Margin amount is greater than max amount: ${params.marginAmount.toNumber()} > ${maxAmounts}`);
27542
+ }
25583
27543
  const proofsIDs = [];
25584
27544
  const manageCalls = [];
25585
27545
  if (params.marginAmount.greaterThan(0)) {
@@ -25593,9 +27553,9 @@ var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
25593
27553
  manageCalls.push(manageCall1);
25594
27554
  }
25595
27555
  const lstDexPriceInUnderlying = params.lstDexPriceInUnderlying;
27556
+ const lstTrueExchangeRate = await this.getLSTExchangeRate();
25596
27557
  const ekuboQuoter = new EkuboQuoter(this.config);
25597
- const marginSwap = [];
25598
- const MAX_SLIPPAGE = 0.01;
27558
+ const MAX_SLIPPAGE = 2e-3;
25599
27559
  const fromToken = params.isIncrease ? lstUnderlyingTokenInfo : lstTokenInfo;
25600
27560
  const toToken = params.isIncrease ? lstTokenInfo : lstUnderlyingTokenInfo;
25601
27561
  const leverSwapQuote = await ekuboQuoter.getQuote(
@@ -25604,10 +27564,22 @@ var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
25604
27564
  params.debtAmount
25605
27565
  // negative for exact amount out
25606
27566
  );
25607
- assert(leverSwapQuote.price_impact < MAX_SLIPPAGE, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
27567
+ logger.verbose(`${this.getTag()}::getModifyLeverCall leverSwapQuote: ${JSON.stringify(leverSwapQuote)}`);
27568
+ assert(leverSwapQuote.price_impact < 0.01, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
25608
27569
  const leverSwap = ekuboQuoter.getVesuMultiplyQuote(leverSwapQuote, fromToken, toToken);
25609
- const minExpectedDebt = params.debtAmount.dividedBy(lstDexPriceInUnderlying).multipliedBy(1 - MAX_SLIPPAGE);
25610
- const maxUsedCollateral = params.debtAmount.abs().dividedBy(lstDexPriceInUnderlying).multipliedBy(1 + MAX_SLIPPAGE);
27570
+ logger.verbose(`${this.getTag()}::getModifyLeverCall leverSwap: ${JSON.stringify(leverSwap)}`);
27571
+ let minLSTReceived = params.debtAmount.dividedBy(lstDexPriceInUnderlying).multipliedBy(1 - MAX_SLIPPAGE);
27572
+ const minLSTReceivedAsPerTruePrice = params.debtAmount.dividedBy(lstTrueExchangeRate);
27573
+ if (minLSTReceived < minLSTReceivedAsPerTruePrice) {
27574
+ minLSTReceived = minLSTReceivedAsPerTruePrice;
27575
+ }
27576
+ logger.verbose(`${this.getTag()}::getModifyLeverCall minLSTReceivedAsPerTruePrice: ${minLSTReceivedAsPerTruePrice}, minLSTReceived: ${minLSTReceived}`);
27577
+ let maxUsedCollateral = params.debtAmount.abs().dividedBy(lstDexPriceInUnderlying).multipliedBy(1 + MAX_SLIPPAGE);
27578
+ const maxUsedCollateralInLST = params.debtAmount.abs().dividedBy(lstTrueExchangeRate).multipliedBy(1.005);
27579
+ logger.verbose(`${this.getTag()}::getModifyLeverCall maxUsedCollateralInLST: ${maxUsedCollateralInLST}, maxUsedCollateral: ${maxUsedCollateral}`);
27580
+ if (maxUsedCollateralInLST > maxUsedCollateral) {
27581
+ maxUsedCollateral = maxUsedCollateralInLST;
27582
+ }
25611
27583
  const STEP2_ID = "switch_delegation_on" /* SWITCH_DELEGATION_ON */;
25612
27584
  const manage2Info = this.getProofs(STEP2_ID);
25613
27585
  const manageCall2 = manage2Info.callConstructor({
@@ -25619,10 +27591,10 @@ var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
25619
27591
  isIncrease: true,
25620
27592
  increaseParams: {
25621
27593
  add_margin: params.marginAmount,
25622
- margin_swap: marginSwap,
27594
+ margin_swap: [],
25623
27595
  margin_swap_limit_amount: Web3Number.fromWei(0, this.asset().decimals),
25624
27596
  lever_swap: leverSwap,
25625
- lever_swap_limit_amount: minExpectedDebt
27597
+ lever_swap_limit_amount: minLSTReceived
25626
27598
  }
25627
27599
  } : {
25628
27600
  isIncrease: false,
@@ -25777,7 +27749,7 @@ var hyperxWBTC = {
25777
27749
  manager: ContractAddr.from("0x75866db44c81e6986f06035206ee9c7d15833ddb22d6a22c016cfb5c866a491"),
25778
27750
  vaultAllocator: ContractAddr.from("0x57b5c1bb457b5e840a2714ae53ada87d77be2f3fd33a59b4fe709ef20c020c1"),
25779
27751
  redeemRequestNFT: ContractAddr.from("0x7a5dc288325456f05e70e9616e16bc02ffbe448f4b89f80b47c0970b989c7c"),
25780
- aumOracle: ContractAddr.from(""),
27752
+ aumOracle: ContractAddr.from("0x258f8a0ca0d21f542e48ad89d00e92dc4d9db4999084f50ef9c22dfb1e83023"),
25781
27753
  leafAdapters: [],
25782
27754
  adapters: [],
25783
27755
  targetHealthFactor: 1.1,
@@ -25788,7 +27760,7 @@ var hyperxtBTC = {
25788
27760
  manager: ContractAddr.from("0xc4cc3e08029a0ae076f5fdfca70575abb78d23c5cd1c49a957f7e697885401"),
25789
27761
  vaultAllocator: ContractAddr.from("0x50bbd4fe69f841ecb13b2619fe50ebfa4e8944671b5d0ebf7868fd80c61b31e"),
25790
27762
  redeemRequestNFT: ContractAddr.from("0xeac9032f02057779816e38a6cb9185d12d86b3aacc9949b96b36de359c1e3"),
25791
- aumOracle: ContractAddr.from(""),
27763
+ aumOracle: ContractAddr.from("0x7e0d05cb7ba3f7db77a36c21c21583b5a524c2e685c08c24b3554911fb4a039"),
25792
27764
  leafAdapters: [],
25793
27765
  adapters: [],
25794
27766
  targetHealthFactor: 1.1,
@@ -25799,7 +27771,7 @@ var hyperxsBTC = {
25799
27771
  manager: ContractAddr.from("0xc9ac023090625b0be3f6532ca353f086746f9c09f939dbc1b2613f09e5f821"),
25800
27772
  vaultAllocator: ContractAddr.from("0x60c2d856936b975459a5b4eb28b8672d91f757bd76cebb6241f8d670185dc01"),
25801
27773
  redeemRequestNFT: ContractAddr.from("0x429e8ee8bc7ecd1ade72630d350a2e0f10f9a2507c45f188ba17fe8f2ab4cf3"),
25802
- aumOracle: ContractAddr.from(""),
27774
+ aumOracle: ContractAddr.from("0x149298ade3e79ec6cbdac6cfad289c57504eaf54e590939136ed1ceca60c345"),
25803
27775
  leafAdapters: [],
25804
27776
  adapters: [],
25805
27777
  targetHealthFactor: 1.1,
@@ -25834,7 +27806,7 @@ function getStrategySettings(lstSymbol, underlyingSymbol, addresses, isPreview =
25834
27806
  launchBlock: 0,
25835
27807
  type: "Other",
25836
27808
  depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === lstSymbol)],
25837
- additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, addresses, VesuPools.Re7xSTRK),
27809
+ additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, addresses, lstSymbol === "xSTRK" ? VesuPools.Re7xSTRK : VesuPools.Re7xBTC),
25838
27810
  risk: {
25839
27811
  riskFactor: _riskFactor4,
25840
27812
  netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
@@ -25850,10 +27822,10 @@ function getStrategySettings(lstSymbol, underlyingSymbol, addresses, isPreview =
25850
27822
  }
25851
27823
  var HyperLSTStrategies = [
25852
27824
  getStrategySettings("xSTRK", "STRK", hyperxSTRK, false),
25853
- getStrategySettings("xWBTC", "WBTC", hyperxWBTC, true),
25854
- getStrategySettings("xtBTC", "tBTC", hyperxtBTC, true),
25855
- getStrategySettings("xsBTC", "solvBTC", hyperxsBTC, true),
25856
- getStrategySettings("xLBTC", "LBTC", hyperxLBTC, true)
27825
+ getStrategySettings("xWBTC", "WBTC", hyperxWBTC, false),
27826
+ getStrategySettings("xtBTC", "tBTC", hyperxtBTC, false),
27827
+ getStrategySettings("xsBTC", "solvBTC", hyperxsBTC, false),
27828
+ getStrategySettings("xLBTC", "LBTC", hyperxLBTC, false)
25857
27829
  ];
25858
27830
 
25859
27831
  // src/modules/pricer-lst.ts
@@ -26383,6 +28355,7 @@ export {
26383
28355
  getRiskColor,
26384
28356
  getRiskExplaination,
26385
28357
  getTrovesEndpoint,
28358
+ getVesuSingletonAddress,
26386
28359
  highlightTextWithLinks,
26387
28360
  logger
26388
28361
  };