@strkfarm/sdk 1.0.15 → 1.0.16

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.
@@ -16283,6 +16283,9 @@ var strkfarm_risk_engine = (() => {
16283
16283
  Network: () => Network,
16284
16284
  Pragma: () => Pragma,
16285
16285
  Pricer: () => Pricer,
16286
+ PricerBase: () => PricerBase,
16287
+ VesuRebalance: () => VesuRebalance,
16288
+ VesuRebalanceStrategies: () => VesuRebalanceStrategies,
16286
16289
  Web3Number: () => Web3Number,
16287
16290
  ZkLend: () => ZkLend,
16288
16291
  getMainnetConfig: () => getMainnetConfig,
@@ -18731,7 +18734,13 @@ var strkfarm_risk_engine = (() => {
18731
18734
  this.name = "FatalError";
18732
18735
  }
18733
18736
  };
18734
- var tokens = [];
18737
+ var tokens = [{
18738
+ name: "Starknet",
18739
+ symbol: "STRK",
18740
+ address: "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
18741
+ decimals: 18,
18742
+ coingeckId: "starknet"
18743
+ }];
18735
18744
  var Global = class {
18736
18745
  static fatalError(message, err2) {
18737
18746
  logger.error(message);
@@ -18744,6 +18753,9 @@ var strkfarm_risk_engine = (() => {
18744
18753
  logger.error(`${url}: ${message}`);
18745
18754
  console.error(err2);
18746
18755
  }
18756
+ static getDefaultTokens() {
18757
+ return tokens;
18758
+ }
18747
18759
  static async getTokens() {
18748
18760
  if (tokens.length) return tokens;
18749
18761
  const data = await axios_default.get("https://starknet.api.avnu.fi/v1/starknet/tokens");
@@ -18785,10 +18797,12 @@ var strkfarm_risk_engine = (() => {
18785
18797
  return this.mul(10 ** this.decimals).toFixed(0);
18786
18798
  }
18787
18799
  multipliedBy(value) {
18788
- return new _Web3Number(this.mul(value).toString(), this.decimals);
18800
+ let _value = Number(value).toFixed(6);
18801
+ return new _Web3Number(this.mul(_value).toString(), this.decimals);
18789
18802
  }
18790
18803
  dividedBy(value) {
18791
- return new _Web3Number(this.div(value).toString(), this.decimals);
18804
+ let _value = Number(value).toFixed(6);
18805
+ return new _Web3Number(this.div(_value).toString(), this.decimals);
18792
18806
  }
18793
18807
  plus(value) {
18794
18808
  return new _Web3Number(this.add(value).toString(), this.decimals);
@@ -35034,6 +35048,11 @@ var strkfarm_risk_engine = (() => {
35034
35048
 
35035
35049
  // src/modules/pricer.ts
35036
35050
  var CoinMarketCap = require_coinmarketcap_api();
35051
+ var PricerBase = class {
35052
+ async getPrice(tokenSymbol) {
35053
+ throw new Error("Method not implemented");
35054
+ }
35055
+ };
35037
35056
  var Pricer = class {
35038
35057
  constructor(config2, tokens2) {
35039
35058
  this.tokens = [];
@@ -35092,10 +35111,10 @@ var strkfarm_risk_engine = (() => {
35092
35111
  assertNotStale(timestamp, tokenName) {
35093
35112
  Global.assert(!this.isStale(timestamp, tokenName), `Price of ${tokenName} is stale`);
35094
35113
  }
35095
- async getPrice(tokenName) {
35096
- Global.assert(this.prices[tokenName], `Price of ${tokenName} not found`);
35097
- this.assertNotStale(this.prices[tokenName].timestamp, tokenName);
35098
- return this.prices[tokenName];
35114
+ async getPrice(tokenSymbol) {
35115
+ Global.assert(this.prices[tokenSymbol], `Price of ${tokenSymbol} not found`);
35116
+ this.assertNotStale(this.prices[tokenSymbol].timestamp, tokenSymbol);
35117
+ return this.prices[tokenSymbol];
35099
35118
  }
35100
35119
  _loadPrices(onUpdate = () => {
35101
35120
  }) {
@@ -35576,6 +35595,1777 @@ var strkfarm_risk_engine = (() => {
35576
35595
  };
35577
35596
  }
35578
35597
  };
35598
+
35599
+ // src/data/vesu-rebalance.abi.json
35600
+ var vesu_rebalance_abi_default = [
35601
+ {
35602
+ type: "impl",
35603
+ name: "ExternalImpl",
35604
+ interface_name: "strkfarm_contracts::strategies::vesu_rebalance::interface::IVesuRebal"
35605
+ },
35606
+ {
35607
+ type: "enum",
35608
+ name: "strkfarm_contracts::strategies::vesu_rebalance::interface::Feature",
35609
+ variants: [
35610
+ {
35611
+ name: "DEPOSIT",
35612
+ type: "()"
35613
+ },
35614
+ {
35615
+ name: "WITHDRAW",
35616
+ type: "()"
35617
+ }
35618
+ ]
35619
+ },
35620
+ {
35621
+ type: "struct",
35622
+ name: "core::integer::u256",
35623
+ members: [
35624
+ {
35625
+ name: "low",
35626
+ type: "core::integer::u128"
35627
+ },
35628
+ {
35629
+ name: "high",
35630
+ type: "core::integer::u128"
35631
+ }
35632
+ ]
35633
+ },
35634
+ {
35635
+ type: "struct",
35636
+ name: "strkfarm_contracts::strategies::vesu_rebalance::interface::Action",
35637
+ members: [
35638
+ {
35639
+ name: "pool_id",
35640
+ type: "core::felt252"
35641
+ },
35642
+ {
35643
+ name: "feature",
35644
+ type: "strkfarm_contracts::strategies::vesu_rebalance::interface::Feature"
35645
+ },
35646
+ {
35647
+ name: "token",
35648
+ type: "core::starknet::contract_address::ContractAddress"
35649
+ },
35650
+ {
35651
+ name: "amount",
35652
+ type: "core::integer::u256"
35653
+ }
35654
+ ]
35655
+ },
35656
+ {
35657
+ type: "struct",
35658
+ name: "strkfarm_contracts::interfaces::IEkuboDistributor::Claim",
35659
+ members: [
35660
+ {
35661
+ name: "id",
35662
+ type: "core::integer::u64"
35663
+ },
35664
+ {
35665
+ name: "claimee",
35666
+ type: "core::starknet::contract_address::ContractAddress"
35667
+ },
35668
+ {
35669
+ name: "amount",
35670
+ type: "core::integer::u128"
35671
+ }
35672
+ ]
35673
+ },
35674
+ {
35675
+ type: "struct",
35676
+ name: "core::array::Span::<core::felt252>",
35677
+ members: [
35678
+ {
35679
+ name: "snapshot",
35680
+ type: "@core::array::Array::<core::felt252>"
35681
+ }
35682
+ ]
35683
+ },
35684
+ {
35685
+ type: "struct",
35686
+ name: "strkfarm_contracts::components::swap::Route",
35687
+ members: [
35688
+ {
35689
+ name: "token_from",
35690
+ type: "core::starknet::contract_address::ContractAddress"
35691
+ },
35692
+ {
35693
+ name: "token_to",
35694
+ type: "core::starknet::contract_address::ContractAddress"
35695
+ },
35696
+ {
35697
+ name: "exchange_address",
35698
+ type: "core::starknet::contract_address::ContractAddress"
35699
+ },
35700
+ {
35701
+ name: "percent",
35702
+ type: "core::integer::u128"
35703
+ },
35704
+ {
35705
+ name: "additional_swap_params",
35706
+ type: "core::array::Array::<core::felt252>"
35707
+ }
35708
+ ]
35709
+ },
35710
+ {
35711
+ type: "struct",
35712
+ name: "strkfarm_contracts::components::swap::AvnuMultiRouteSwap",
35713
+ members: [
35714
+ {
35715
+ name: "token_from_address",
35716
+ type: "core::starknet::contract_address::ContractAddress"
35717
+ },
35718
+ {
35719
+ name: "token_from_amount",
35720
+ type: "core::integer::u256"
35721
+ },
35722
+ {
35723
+ name: "token_to_address",
35724
+ type: "core::starknet::contract_address::ContractAddress"
35725
+ },
35726
+ {
35727
+ name: "token_to_amount",
35728
+ type: "core::integer::u256"
35729
+ },
35730
+ {
35731
+ name: "token_to_min_amount",
35732
+ type: "core::integer::u256"
35733
+ },
35734
+ {
35735
+ name: "beneficiary",
35736
+ type: "core::starknet::contract_address::ContractAddress"
35737
+ },
35738
+ {
35739
+ name: "integrator_fee_amount_bps",
35740
+ type: "core::integer::u128"
35741
+ },
35742
+ {
35743
+ name: "integrator_fee_recipient",
35744
+ type: "core::starknet::contract_address::ContractAddress"
35745
+ },
35746
+ {
35747
+ name: "routes",
35748
+ type: "core::array::Array::<strkfarm_contracts::components::swap::Route>"
35749
+ }
35750
+ ]
35751
+ },
35752
+ {
35753
+ type: "struct",
35754
+ name: "strkfarm_contracts::strategies::vesu_rebalance::interface::Settings",
35755
+ members: [
35756
+ {
35757
+ name: "default_pool_index",
35758
+ type: "core::integer::u8"
35759
+ },
35760
+ {
35761
+ name: "fee_bps",
35762
+ type: "core::integer::u32"
35763
+ },
35764
+ {
35765
+ name: "fee_receiver",
35766
+ type: "core::starknet::contract_address::ContractAddress"
35767
+ }
35768
+ ]
35769
+ },
35770
+ {
35771
+ type: "struct",
35772
+ name: "strkfarm_contracts::strategies::vesu_rebalance::interface::PoolProps",
35773
+ members: [
35774
+ {
35775
+ name: "pool_id",
35776
+ type: "core::felt252"
35777
+ },
35778
+ {
35779
+ name: "max_weight",
35780
+ type: "core::integer::u32"
35781
+ },
35782
+ {
35783
+ name: "v_token",
35784
+ type: "core::starknet::contract_address::ContractAddress"
35785
+ }
35786
+ ]
35787
+ },
35788
+ {
35789
+ type: "interface",
35790
+ name: "strkfarm_contracts::strategies::vesu_rebalance::interface::IVesuRebal",
35791
+ items: [
35792
+ {
35793
+ type: "function",
35794
+ name: "rebalance",
35795
+ inputs: [
35796
+ {
35797
+ name: "actions",
35798
+ type: "core::array::Array::<strkfarm_contracts::strategies::vesu_rebalance::interface::Action>"
35799
+ }
35800
+ ],
35801
+ outputs: [],
35802
+ state_mutability: "external"
35803
+ },
35804
+ {
35805
+ type: "function",
35806
+ name: "rebalance_weights",
35807
+ inputs: [
35808
+ {
35809
+ name: "actions",
35810
+ type: "core::array::Array::<strkfarm_contracts::strategies::vesu_rebalance::interface::Action>"
35811
+ }
35812
+ ],
35813
+ outputs: [],
35814
+ state_mutability: "external"
35815
+ },
35816
+ {
35817
+ type: "function",
35818
+ name: "emergency_withdraw",
35819
+ inputs: [],
35820
+ outputs: [],
35821
+ state_mutability: "external"
35822
+ },
35823
+ {
35824
+ type: "function",
35825
+ name: "emergency_withdraw_pool",
35826
+ inputs: [
35827
+ {
35828
+ name: "pool_index",
35829
+ type: "core::integer::u32"
35830
+ }
35831
+ ],
35832
+ outputs: [],
35833
+ state_mutability: "external"
35834
+ },
35835
+ {
35836
+ type: "function",
35837
+ name: "compute_yield",
35838
+ inputs: [],
35839
+ outputs: [
35840
+ {
35841
+ type: "(core::integer::u256, core::integer::u256)"
35842
+ }
35843
+ ],
35844
+ state_mutability: "view"
35845
+ },
35846
+ {
35847
+ type: "function",
35848
+ name: "harvest",
35849
+ inputs: [
35850
+ {
35851
+ name: "rewardsContract",
35852
+ type: "core::starknet::contract_address::ContractAddress"
35853
+ },
35854
+ {
35855
+ name: "claim",
35856
+ type: "strkfarm_contracts::interfaces::IEkuboDistributor::Claim"
35857
+ },
35858
+ {
35859
+ name: "proof",
35860
+ type: "core::array::Span::<core::felt252>"
35861
+ },
35862
+ {
35863
+ name: "swapInfo",
35864
+ type: "strkfarm_contracts::components::swap::AvnuMultiRouteSwap"
35865
+ }
35866
+ ],
35867
+ outputs: [],
35868
+ state_mutability: "external"
35869
+ },
35870
+ {
35871
+ type: "function",
35872
+ name: "set_settings",
35873
+ inputs: [
35874
+ {
35875
+ name: "settings",
35876
+ type: "strkfarm_contracts::strategies::vesu_rebalance::interface::Settings"
35877
+ }
35878
+ ],
35879
+ outputs: [],
35880
+ state_mutability: "external"
35881
+ },
35882
+ {
35883
+ type: "function",
35884
+ name: "set_allowed_pools",
35885
+ inputs: [
35886
+ {
35887
+ name: "pools",
35888
+ type: "core::array::Array::<strkfarm_contracts::strategies::vesu_rebalance::interface::PoolProps>"
35889
+ }
35890
+ ],
35891
+ outputs: [],
35892
+ state_mutability: "external"
35893
+ },
35894
+ {
35895
+ type: "function",
35896
+ name: "set_incentives_off",
35897
+ inputs: [],
35898
+ outputs: [],
35899
+ state_mutability: "external"
35900
+ },
35901
+ {
35902
+ type: "function",
35903
+ name: "get_settings",
35904
+ inputs: [],
35905
+ outputs: [
35906
+ {
35907
+ type: "strkfarm_contracts::strategies::vesu_rebalance::interface::Settings"
35908
+ }
35909
+ ],
35910
+ state_mutability: "view"
35911
+ },
35912
+ {
35913
+ type: "function",
35914
+ name: "get_allowed_pools",
35915
+ inputs: [],
35916
+ outputs: [
35917
+ {
35918
+ type: "core::array::Array::<strkfarm_contracts::strategies::vesu_rebalance::interface::PoolProps>"
35919
+ }
35920
+ ],
35921
+ state_mutability: "view"
35922
+ },
35923
+ {
35924
+ type: "function",
35925
+ name: "get_previous_index",
35926
+ inputs: [],
35927
+ outputs: [
35928
+ {
35929
+ type: "core::integer::u128"
35930
+ }
35931
+ ],
35932
+ state_mutability: "view"
35933
+ }
35934
+ ]
35935
+ },
35936
+ {
35937
+ type: "impl",
35938
+ name: "VesuERC4626Impl",
35939
+ interface_name: "strkfarm_contracts::interfaces::IERC4626::IERC4626"
35940
+ },
35941
+ {
35942
+ type: "interface",
35943
+ name: "strkfarm_contracts::interfaces::IERC4626::IERC4626",
35944
+ items: [
35945
+ {
35946
+ type: "function",
35947
+ name: "asset",
35948
+ inputs: [],
35949
+ outputs: [
35950
+ {
35951
+ type: "core::starknet::contract_address::ContractAddress"
35952
+ }
35953
+ ],
35954
+ state_mutability: "view"
35955
+ },
35956
+ {
35957
+ type: "function",
35958
+ name: "total_assets",
35959
+ inputs: [],
35960
+ outputs: [
35961
+ {
35962
+ type: "core::integer::u256"
35963
+ }
35964
+ ],
35965
+ state_mutability: "view"
35966
+ },
35967
+ {
35968
+ type: "function",
35969
+ name: "convert_to_shares",
35970
+ inputs: [
35971
+ {
35972
+ name: "assets",
35973
+ type: "core::integer::u256"
35974
+ }
35975
+ ],
35976
+ outputs: [
35977
+ {
35978
+ type: "core::integer::u256"
35979
+ }
35980
+ ],
35981
+ state_mutability: "view"
35982
+ },
35983
+ {
35984
+ type: "function",
35985
+ name: "convert_to_assets",
35986
+ inputs: [
35987
+ {
35988
+ name: "shares",
35989
+ type: "core::integer::u256"
35990
+ }
35991
+ ],
35992
+ outputs: [
35993
+ {
35994
+ type: "core::integer::u256"
35995
+ }
35996
+ ],
35997
+ state_mutability: "view"
35998
+ },
35999
+ {
36000
+ type: "function",
36001
+ name: "max_deposit",
36002
+ inputs: [
36003
+ {
36004
+ name: "receiver",
36005
+ type: "core::starknet::contract_address::ContractAddress"
36006
+ }
36007
+ ],
36008
+ outputs: [
36009
+ {
36010
+ type: "core::integer::u256"
36011
+ }
36012
+ ],
36013
+ state_mutability: "view"
36014
+ },
36015
+ {
36016
+ type: "function",
36017
+ name: "preview_deposit",
36018
+ inputs: [
36019
+ {
36020
+ name: "assets",
36021
+ type: "core::integer::u256"
36022
+ }
36023
+ ],
36024
+ outputs: [
36025
+ {
36026
+ type: "core::integer::u256"
36027
+ }
36028
+ ],
36029
+ state_mutability: "view"
36030
+ },
36031
+ {
36032
+ type: "function",
36033
+ name: "deposit",
36034
+ inputs: [
36035
+ {
36036
+ name: "assets",
36037
+ type: "core::integer::u256"
36038
+ },
36039
+ {
36040
+ name: "receiver",
36041
+ type: "core::starknet::contract_address::ContractAddress"
36042
+ }
36043
+ ],
36044
+ outputs: [
36045
+ {
36046
+ type: "core::integer::u256"
36047
+ }
36048
+ ],
36049
+ state_mutability: "external"
36050
+ },
36051
+ {
36052
+ type: "function",
36053
+ name: "max_mint",
36054
+ inputs: [
36055
+ {
36056
+ name: "receiver",
36057
+ type: "core::starknet::contract_address::ContractAddress"
36058
+ }
36059
+ ],
36060
+ outputs: [
36061
+ {
36062
+ type: "core::integer::u256"
36063
+ }
36064
+ ],
36065
+ state_mutability: "view"
36066
+ },
36067
+ {
36068
+ type: "function",
36069
+ name: "preview_mint",
36070
+ inputs: [
36071
+ {
36072
+ name: "shares",
36073
+ type: "core::integer::u256"
36074
+ }
36075
+ ],
36076
+ outputs: [
36077
+ {
36078
+ type: "core::integer::u256"
36079
+ }
36080
+ ],
36081
+ state_mutability: "view"
36082
+ },
36083
+ {
36084
+ type: "function",
36085
+ name: "mint",
36086
+ inputs: [
36087
+ {
36088
+ name: "shares",
36089
+ type: "core::integer::u256"
36090
+ },
36091
+ {
36092
+ name: "receiver",
36093
+ type: "core::starknet::contract_address::ContractAddress"
36094
+ }
36095
+ ],
36096
+ outputs: [
36097
+ {
36098
+ type: "core::integer::u256"
36099
+ }
36100
+ ],
36101
+ state_mutability: "external"
36102
+ },
36103
+ {
36104
+ type: "function",
36105
+ name: "max_withdraw",
36106
+ inputs: [
36107
+ {
36108
+ name: "owner",
36109
+ type: "core::starknet::contract_address::ContractAddress"
36110
+ }
36111
+ ],
36112
+ outputs: [
36113
+ {
36114
+ type: "core::integer::u256"
36115
+ }
36116
+ ],
36117
+ state_mutability: "view"
36118
+ },
36119
+ {
36120
+ type: "function",
36121
+ name: "preview_withdraw",
36122
+ inputs: [
36123
+ {
36124
+ name: "assets",
36125
+ type: "core::integer::u256"
36126
+ }
36127
+ ],
36128
+ outputs: [
36129
+ {
36130
+ type: "core::integer::u256"
36131
+ }
36132
+ ],
36133
+ state_mutability: "view"
36134
+ },
36135
+ {
36136
+ type: "function",
36137
+ name: "withdraw",
36138
+ inputs: [
36139
+ {
36140
+ name: "assets",
36141
+ type: "core::integer::u256"
36142
+ },
36143
+ {
36144
+ name: "receiver",
36145
+ type: "core::starknet::contract_address::ContractAddress"
36146
+ },
36147
+ {
36148
+ name: "owner",
36149
+ type: "core::starknet::contract_address::ContractAddress"
36150
+ }
36151
+ ],
36152
+ outputs: [
36153
+ {
36154
+ type: "core::integer::u256"
36155
+ }
36156
+ ],
36157
+ state_mutability: "external"
36158
+ },
36159
+ {
36160
+ type: "function",
36161
+ name: "max_redeem",
36162
+ inputs: [
36163
+ {
36164
+ name: "owner",
36165
+ type: "core::starknet::contract_address::ContractAddress"
36166
+ }
36167
+ ],
36168
+ outputs: [
36169
+ {
36170
+ type: "core::integer::u256"
36171
+ }
36172
+ ],
36173
+ state_mutability: "view"
36174
+ },
36175
+ {
36176
+ type: "function",
36177
+ name: "preview_redeem",
36178
+ inputs: [
36179
+ {
36180
+ name: "shares",
36181
+ type: "core::integer::u256"
36182
+ }
36183
+ ],
36184
+ outputs: [
36185
+ {
36186
+ type: "core::integer::u256"
36187
+ }
36188
+ ],
36189
+ state_mutability: "view"
36190
+ },
36191
+ {
36192
+ type: "function",
36193
+ name: "redeem",
36194
+ inputs: [
36195
+ {
36196
+ name: "shares",
36197
+ type: "core::integer::u256"
36198
+ },
36199
+ {
36200
+ name: "receiver",
36201
+ type: "core::starknet::contract_address::ContractAddress"
36202
+ },
36203
+ {
36204
+ name: "owner",
36205
+ type: "core::starknet::contract_address::ContractAddress"
36206
+ }
36207
+ ],
36208
+ outputs: [
36209
+ {
36210
+ type: "core::integer::u256"
36211
+ }
36212
+ ],
36213
+ state_mutability: "external"
36214
+ }
36215
+ ]
36216
+ },
36217
+ {
36218
+ type: "impl",
36219
+ name: "VesuERC20Impl",
36220
+ interface_name: "openzeppelin_token::erc20::interface::IERC20Mixin"
36221
+ },
36222
+ {
36223
+ type: "enum",
36224
+ name: "core::bool",
36225
+ variants: [
36226
+ {
36227
+ name: "False",
36228
+ type: "()"
36229
+ },
36230
+ {
36231
+ name: "True",
36232
+ type: "()"
36233
+ }
36234
+ ]
36235
+ },
36236
+ {
36237
+ type: "struct",
36238
+ name: "core::byte_array::ByteArray",
36239
+ members: [
36240
+ {
36241
+ name: "data",
36242
+ type: "core::array::Array::<core::bytes_31::bytes31>"
36243
+ },
36244
+ {
36245
+ name: "pending_word",
36246
+ type: "core::felt252"
36247
+ },
36248
+ {
36249
+ name: "pending_word_len",
36250
+ type: "core::integer::u32"
36251
+ }
36252
+ ]
36253
+ },
36254
+ {
36255
+ type: "interface",
36256
+ name: "openzeppelin_token::erc20::interface::IERC20Mixin",
36257
+ items: [
36258
+ {
36259
+ type: "function",
36260
+ name: "total_supply",
36261
+ inputs: [],
36262
+ outputs: [
36263
+ {
36264
+ type: "core::integer::u256"
36265
+ }
36266
+ ],
36267
+ state_mutability: "view"
36268
+ },
36269
+ {
36270
+ type: "function",
36271
+ name: "balance_of",
36272
+ inputs: [
36273
+ {
36274
+ name: "account",
36275
+ type: "core::starknet::contract_address::ContractAddress"
36276
+ }
36277
+ ],
36278
+ outputs: [
36279
+ {
36280
+ type: "core::integer::u256"
36281
+ }
36282
+ ],
36283
+ state_mutability: "view"
36284
+ },
36285
+ {
36286
+ type: "function",
36287
+ name: "allowance",
36288
+ inputs: [
36289
+ {
36290
+ name: "owner",
36291
+ type: "core::starknet::contract_address::ContractAddress"
36292
+ },
36293
+ {
36294
+ name: "spender",
36295
+ type: "core::starknet::contract_address::ContractAddress"
36296
+ }
36297
+ ],
36298
+ outputs: [
36299
+ {
36300
+ type: "core::integer::u256"
36301
+ }
36302
+ ],
36303
+ state_mutability: "view"
36304
+ },
36305
+ {
36306
+ type: "function",
36307
+ name: "transfer",
36308
+ inputs: [
36309
+ {
36310
+ name: "recipient",
36311
+ type: "core::starknet::contract_address::ContractAddress"
36312
+ },
36313
+ {
36314
+ name: "amount",
36315
+ type: "core::integer::u256"
36316
+ }
36317
+ ],
36318
+ outputs: [
36319
+ {
36320
+ type: "core::bool"
36321
+ }
36322
+ ],
36323
+ state_mutability: "external"
36324
+ },
36325
+ {
36326
+ type: "function",
36327
+ name: "transfer_from",
36328
+ inputs: [
36329
+ {
36330
+ name: "sender",
36331
+ type: "core::starknet::contract_address::ContractAddress"
36332
+ },
36333
+ {
36334
+ name: "recipient",
36335
+ type: "core::starknet::contract_address::ContractAddress"
36336
+ },
36337
+ {
36338
+ name: "amount",
36339
+ type: "core::integer::u256"
36340
+ }
36341
+ ],
36342
+ outputs: [
36343
+ {
36344
+ type: "core::bool"
36345
+ }
36346
+ ],
36347
+ state_mutability: "external"
36348
+ },
36349
+ {
36350
+ type: "function",
36351
+ name: "approve",
36352
+ inputs: [
36353
+ {
36354
+ name: "spender",
36355
+ type: "core::starknet::contract_address::ContractAddress"
36356
+ },
36357
+ {
36358
+ name: "amount",
36359
+ type: "core::integer::u256"
36360
+ }
36361
+ ],
36362
+ outputs: [
36363
+ {
36364
+ type: "core::bool"
36365
+ }
36366
+ ],
36367
+ state_mutability: "external"
36368
+ },
36369
+ {
36370
+ type: "function",
36371
+ name: "name",
36372
+ inputs: [],
36373
+ outputs: [
36374
+ {
36375
+ type: "core::byte_array::ByteArray"
36376
+ }
36377
+ ],
36378
+ state_mutability: "view"
36379
+ },
36380
+ {
36381
+ type: "function",
36382
+ name: "symbol",
36383
+ inputs: [],
36384
+ outputs: [
36385
+ {
36386
+ type: "core::byte_array::ByteArray"
36387
+ }
36388
+ ],
36389
+ state_mutability: "view"
36390
+ },
36391
+ {
36392
+ type: "function",
36393
+ name: "decimals",
36394
+ inputs: [],
36395
+ outputs: [
36396
+ {
36397
+ type: "core::integer::u8"
36398
+ }
36399
+ ],
36400
+ state_mutability: "view"
36401
+ },
36402
+ {
36403
+ type: "function",
36404
+ name: "totalSupply",
36405
+ inputs: [],
36406
+ outputs: [
36407
+ {
36408
+ type: "core::integer::u256"
36409
+ }
36410
+ ],
36411
+ state_mutability: "view"
36412
+ },
36413
+ {
36414
+ type: "function",
36415
+ name: "balanceOf",
36416
+ inputs: [
36417
+ {
36418
+ name: "account",
36419
+ type: "core::starknet::contract_address::ContractAddress"
36420
+ }
36421
+ ],
36422
+ outputs: [
36423
+ {
36424
+ type: "core::integer::u256"
36425
+ }
36426
+ ],
36427
+ state_mutability: "view"
36428
+ },
36429
+ {
36430
+ type: "function",
36431
+ name: "transferFrom",
36432
+ inputs: [
36433
+ {
36434
+ name: "sender",
36435
+ type: "core::starknet::contract_address::ContractAddress"
36436
+ },
36437
+ {
36438
+ name: "recipient",
36439
+ type: "core::starknet::contract_address::ContractAddress"
36440
+ },
36441
+ {
36442
+ name: "amount",
36443
+ type: "core::integer::u256"
36444
+ }
36445
+ ],
36446
+ outputs: [
36447
+ {
36448
+ type: "core::bool"
36449
+ }
36450
+ ],
36451
+ state_mutability: "external"
36452
+ }
36453
+ ]
36454
+ },
36455
+ {
36456
+ type: "impl",
36457
+ name: "CommonCompImpl",
36458
+ interface_name: "strkfarm_contracts::interfaces::common::ICommon"
36459
+ },
36460
+ {
36461
+ type: "interface",
36462
+ name: "strkfarm_contracts::interfaces::common::ICommon",
36463
+ items: [
36464
+ {
36465
+ type: "function",
36466
+ name: "upgrade",
36467
+ inputs: [
36468
+ {
36469
+ name: "new_class",
36470
+ type: "core::starknet::class_hash::ClassHash"
36471
+ }
36472
+ ],
36473
+ outputs: [],
36474
+ state_mutability: "external"
36475
+ },
36476
+ {
36477
+ type: "function",
36478
+ name: "pause",
36479
+ inputs: [],
36480
+ outputs: [],
36481
+ state_mutability: "external"
36482
+ },
36483
+ {
36484
+ type: "function",
36485
+ name: "unpause",
36486
+ inputs: [],
36487
+ outputs: [],
36488
+ state_mutability: "external"
36489
+ },
36490
+ {
36491
+ type: "function",
36492
+ name: "is_paused",
36493
+ inputs: [],
36494
+ outputs: [
36495
+ {
36496
+ type: "core::bool"
36497
+ }
36498
+ ],
36499
+ state_mutability: "view"
36500
+ }
36501
+ ]
36502
+ },
36503
+ {
36504
+ type: "impl",
36505
+ name: "RewardShareImpl",
36506
+ interface_name: "strkfarm_contracts::components::harvester::reward_shares::IRewardShare"
36507
+ },
36508
+ {
36509
+ type: "struct",
36510
+ name: "strkfarm_contracts::components::harvester::reward_shares::UserRewardsInfo",
36511
+ members: [
36512
+ {
36513
+ name: "pending_round_points",
36514
+ type: "core::integer::u128"
36515
+ },
36516
+ {
36517
+ name: "shares_owned",
36518
+ type: "core::integer::u128"
36519
+ },
36520
+ {
36521
+ name: "block_number",
36522
+ type: "core::integer::u64"
36523
+ },
36524
+ {
36525
+ name: "index",
36526
+ type: "core::integer::u32"
36527
+ }
36528
+ ]
36529
+ },
36530
+ {
36531
+ type: "struct",
36532
+ name: "strkfarm_contracts::components::harvester::reward_shares::RewardsInfo",
36533
+ members: [
36534
+ {
36535
+ name: "amount",
36536
+ type: "core::integer::u128"
36537
+ },
36538
+ {
36539
+ name: "shares",
36540
+ type: "core::integer::u128"
36541
+ },
36542
+ {
36543
+ name: "total_round_points",
36544
+ type: "core::integer::u128"
36545
+ },
36546
+ {
36547
+ name: "block_number",
36548
+ type: "core::integer::u64"
36549
+ }
36550
+ ]
36551
+ },
36552
+ {
36553
+ type: "interface",
36554
+ name: "strkfarm_contracts::components::harvester::reward_shares::IRewardShare",
36555
+ items: [
36556
+ {
36557
+ type: "function",
36558
+ name: "get_user_reward_info",
36559
+ inputs: [
36560
+ {
36561
+ name: "user",
36562
+ type: "core::starknet::contract_address::ContractAddress"
36563
+ }
36564
+ ],
36565
+ outputs: [
36566
+ {
36567
+ type: "strkfarm_contracts::components::harvester::reward_shares::UserRewardsInfo"
36568
+ }
36569
+ ],
36570
+ state_mutability: "view"
36571
+ },
36572
+ {
36573
+ type: "function",
36574
+ name: "get_rewards_info",
36575
+ inputs: [
36576
+ {
36577
+ name: "index",
36578
+ type: "core::integer::u32"
36579
+ }
36580
+ ],
36581
+ outputs: [
36582
+ {
36583
+ type: "strkfarm_contracts::components::harvester::reward_shares::RewardsInfo"
36584
+ }
36585
+ ],
36586
+ state_mutability: "view"
36587
+ },
36588
+ {
36589
+ type: "function",
36590
+ name: "get_total_rewards",
36591
+ inputs: [],
36592
+ outputs: [
36593
+ {
36594
+ type: "core::integer::u32"
36595
+ }
36596
+ ],
36597
+ state_mutability: "view"
36598
+ },
36599
+ {
36600
+ type: "function",
36601
+ name: "get_total_unminted_shares",
36602
+ inputs: [],
36603
+ outputs: [
36604
+ {
36605
+ type: "core::integer::u128"
36606
+ }
36607
+ ],
36608
+ state_mutability: "view"
36609
+ },
36610
+ {
36611
+ type: "function",
36612
+ name: "get_additional_shares",
36613
+ inputs: [
36614
+ {
36615
+ name: "user",
36616
+ type: "core::starknet::contract_address::ContractAddress"
36617
+ }
36618
+ ],
36619
+ outputs: [
36620
+ {
36621
+ type: "(core::integer::u128, core::integer::u64, core::integer::u128)"
36622
+ }
36623
+ ],
36624
+ state_mutability: "view"
36625
+ }
36626
+ ]
36627
+ },
36628
+ {
36629
+ type: "struct",
36630
+ name: "strkfarm_contracts::interfaces::IVesu::IStonDispatcher",
36631
+ members: [
36632
+ {
36633
+ name: "contract_address",
36634
+ type: "core::starknet::contract_address::ContractAddress"
36635
+ }
36636
+ ]
36637
+ },
36638
+ {
36639
+ type: "struct",
36640
+ name: "strkfarm_contracts::components::vesu::vesuStruct",
36641
+ members: [
36642
+ {
36643
+ name: "singleton",
36644
+ type: "strkfarm_contracts::interfaces::IVesu::IStonDispatcher"
36645
+ },
36646
+ {
36647
+ name: "pool_id",
36648
+ type: "core::felt252"
36649
+ },
36650
+ {
36651
+ name: "debt",
36652
+ type: "core::starknet::contract_address::ContractAddress"
36653
+ },
36654
+ {
36655
+ name: "col",
36656
+ type: "core::starknet::contract_address::ContractAddress"
36657
+ },
36658
+ {
36659
+ name: "oracle",
36660
+ type: "core::starknet::contract_address::ContractAddress"
36661
+ }
36662
+ ]
36663
+ },
36664
+ {
36665
+ type: "constructor",
36666
+ name: "constructor",
36667
+ inputs: [
36668
+ {
36669
+ name: "asset",
36670
+ type: "core::starknet::contract_address::ContractAddress"
36671
+ },
36672
+ {
36673
+ name: "access_control",
36674
+ type: "core::starknet::contract_address::ContractAddress"
36675
+ },
36676
+ {
36677
+ name: "allowed_pools",
36678
+ type: "core::array::Array::<strkfarm_contracts::strategies::vesu_rebalance::interface::PoolProps>"
36679
+ },
36680
+ {
36681
+ name: "settings",
36682
+ type: "strkfarm_contracts::strategies::vesu_rebalance::interface::Settings"
36683
+ },
36684
+ {
36685
+ name: "vesu_settings",
36686
+ type: "strkfarm_contracts::components::vesu::vesuStruct"
36687
+ }
36688
+ ]
36689
+ },
36690
+ {
36691
+ type: "event",
36692
+ name: "openzeppelin_security::reentrancyguard::ReentrancyGuardComponent::Event",
36693
+ kind: "enum",
36694
+ variants: []
36695
+ },
36696
+ {
36697
+ type: "event",
36698
+ name: "strkfarm_contracts::components::erc4626::ERC4626Component::Deposit",
36699
+ kind: "struct",
36700
+ members: [
36701
+ {
36702
+ name: "sender",
36703
+ type: "core::starknet::contract_address::ContractAddress",
36704
+ kind: "key"
36705
+ },
36706
+ {
36707
+ name: "owner",
36708
+ type: "core::starknet::contract_address::ContractAddress",
36709
+ kind: "key"
36710
+ },
36711
+ {
36712
+ name: "assets",
36713
+ type: "core::integer::u256",
36714
+ kind: "data"
36715
+ },
36716
+ {
36717
+ name: "shares",
36718
+ type: "core::integer::u256",
36719
+ kind: "data"
36720
+ }
36721
+ ]
36722
+ },
36723
+ {
36724
+ type: "event",
36725
+ name: "strkfarm_contracts::components::erc4626::ERC4626Component::Withdraw",
36726
+ kind: "struct",
36727
+ members: [
36728
+ {
36729
+ name: "sender",
36730
+ type: "core::starknet::contract_address::ContractAddress",
36731
+ kind: "key"
36732
+ },
36733
+ {
36734
+ name: "receiver",
36735
+ type: "core::starknet::contract_address::ContractAddress",
36736
+ kind: "key"
36737
+ },
36738
+ {
36739
+ name: "owner",
36740
+ type: "core::starknet::contract_address::ContractAddress",
36741
+ kind: "key"
36742
+ },
36743
+ {
36744
+ name: "assets",
36745
+ type: "core::integer::u256",
36746
+ kind: "data"
36747
+ },
36748
+ {
36749
+ name: "shares",
36750
+ type: "core::integer::u256",
36751
+ kind: "data"
36752
+ }
36753
+ ]
36754
+ },
36755
+ {
36756
+ type: "event",
36757
+ name: "strkfarm_contracts::components::erc4626::ERC4626Component::Event",
36758
+ kind: "enum",
36759
+ variants: [
36760
+ {
36761
+ name: "Deposit",
36762
+ type: "strkfarm_contracts::components::erc4626::ERC4626Component::Deposit",
36763
+ kind: "nested"
36764
+ },
36765
+ {
36766
+ name: "Withdraw",
36767
+ type: "strkfarm_contracts::components::erc4626::ERC4626Component::Withdraw",
36768
+ kind: "nested"
36769
+ }
36770
+ ]
36771
+ },
36772
+ {
36773
+ type: "event",
36774
+ name: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::Rewards",
36775
+ kind: "struct",
36776
+ members: [
36777
+ {
36778
+ name: "index",
36779
+ type: "core::integer::u32",
36780
+ kind: "data"
36781
+ },
36782
+ {
36783
+ name: "info",
36784
+ type: "strkfarm_contracts::components::harvester::reward_shares::RewardsInfo",
36785
+ kind: "data"
36786
+ },
36787
+ {
36788
+ name: "total_reward_shares",
36789
+ type: "core::integer::u128",
36790
+ kind: "data"
36791
+ },
36792
+ {
36793
+ name: "timestamp",
36794
+ type: "core::integer::u64",
36795
+ kind: "data"
36796
+ }
36797
+ ]
36798
+ },
36799
+ {
36800
+ type: "event",
36801
+ name: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::UserRewards",
36802
+ kind: "struct",
36803
+ members: [
36804
+ {
36805
+ name: "user",
36806
+ type: "core::starknet::contract_address::ContractAddress",
36807
+ kind: "key"
36808
+ },
36809
+ {
36810
+ name: "info",
36811
+ type: "strkfarm_contracts::components::harvester::reward_shares::UserRewardsInfo",
36812
+ kind: "data"
36813
+ },
36814
+ {
36815
+ name: "total_reward_shares",
36816
+ type: "core::integer::u128",
36817
+ kind: "data"
36818
+ },
36819
+ {
36820
+ name: "timestamp",
36821
+ type: "core::integer::u64",
36822
+ kind: "data"
36823
+ }
36824
+ ]
36825
+ },
36826
+ {
36827
+ type: "event",
36828
+ name: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::Event",
36829
+ kind: "enum",
36830
+ variants: [
36831
+ {
36832
+ name: "Rewards",
36833
+ type: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::Rewards",
36834
+ kind: "nested"
36835
+ },
36836
+ {
36837
+ name: "UserRewards",
36838
+ type: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::UserRewards",
36839
+ kind: "nested"
36840
+ }
36841
+ ]
36842
+ },
36843
+ {
36844
+ type: "event",
36845
+ name: "openzeppelin_token::erc20::erc20::ERC20Component::Transfer",
36846
+ kind: "struct",
36847
+ members: [
36848
+ {
36849
+ name: "from",
36850
+ type: "core::starknet::contract_address::ContractAddress",
36851
+ kind: "key"
36852
+ },
36853
+ {
36854
+ name: "to",
36855
+ type: "core::starknet::contract_address::ContractAddress",
36856
+ kind: "key"
36857
+ },
36858
+ {
36859
+ name: "value",
36860
+ type: "core::integer::u256",
36861
+ kind: "data"
36862
+ }
36863
+ ]
36864
+ },
36865
+ {
36866
+ type: "event",
36867
+ name: "openzeppelin_token::erc20::erc20::ERC20Component::Approval",
36868
+ kind: "struct",
36869
+ members: [
36870
+ {
36871
+ name: "owner",
36872
+ type: "core::starknet::contract_address::ContractAddress",
36873
+ kind: "key"
36874
+ },
36875
+ {
36876
+ name: "spender",
36877
+ type: "core::starknet::contract_address::ContractAddress",
36878
+ kind: "key"
36879
+ },
36880
+ {
36881
+ name: "value",
36882
+ type: "core::integer::u256",
36883
+ kind: "data"
36884
+ }
36885
+ ]
36886
+ },
36887
+ {
36888
+ type: "event",
36889
+ name: "openzeppelin_token::erc20::erc20::ERC20Component::Event",
36890
+ kind: "enum",
36891
+ variants: [
36892
+ {
36893
+ name: "Transfer",
36894
+ type: "openzeppelin_token::erc20::erc20::ERC20Component::Transfer",
36895
+ kind: "nested"
36896
+ },
36897
+ {
36898
+ name: "Approval",
36899
+ type: "openzeppelin_token::erc20::erc20::ERC20Component::Approval",
36900
+ kind: "nested"
36901
+ }
36902
+ ]
36903
+ },
36904
+ {
36905
+ type: "event",
36906
+ name: "openzeppelin_introspection::src5::SRC5Component::Event",
36907
+ kind: "enum",
36908
+ variants: []
36909
+ },
36910
+ {
36911
+ type: "event",
36912
+ name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
36913
+ kind: "struct",
36914
+ members: [
36915
+ {
36916
+ name: "class_hash",
36917
+ type: "core::starknet::class_hash::ClassHash",
36918
+ kind: "data"
36919
+ }
36920
+ ]
36921
+ },
36922
+ {
36923
+ type: "event",
36924
+ name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
36925
+ kind: "enum",
36926
+ variants: [
36927
+ {
36928
+ name: "Upgraded",
36929
+ type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
36930
+ kind: "nested"
36931
+ }
36932
+ ]
36933
+ },
36934
+ {
36935
+ type: "event",
36936
+ name: "openzeppelin_security::pausable::PausableComponent::Paused",
36937
+ kind: "struct",
36938
+ members: [
36939
+ {
36940
+ name: "account",
36941
+ type: "core::starknet::contract_address::ContractAddress",
36942
+ kind: "data"
36943
+ }
36944
+ ]
36945
+ },
36946
+ {
36947
+ type: "event",
36948
+ name: "openzeppelin_security::pausable::PausableComponent::Unpaused",
36949
+ kind: "struct",
36950
+ members: [
36951
+ {
36952
+ name: "account",
36953
+ type: "core::starknet::contract_address::ContractAddress",
36954
+ kind: "data"
36955
+ }
36956
+ ]
36957
+ },
36958
+ {
36959
+ type: "event",
36960
+ name: "openzeppelin_security::pausable::PausableComponent::Event",
36961
+ kind: "enum",
36962
+ variants: [
36963
+ {
36964
+ name: "Paused",
36965
+ type: "openzeppelin_security::pausable::PausableComponent::Paused",
36966
+ kind: "nested"
36967
+ },
36968
+ {
36969
+ name: "Unpaused",
36970
+ type: "openzeppelin_security::pausable::PausableComponent::Unpaused",
36971
+ kind: "nested"
36972
+ }
36973
+ ]
36974
+ },
36975
+ {
36976
+ type: "event",
36977
+ name: "strkfarm_contracts::components::common::CommonComp::Event",
36978
+ kind: "enum",
36979
+ variants: []
36980
+ },
36981
+ {
36982
+ type: "event",
36983
+ name: "strkfarm_contracts::strategies::vesu_rebalance::vesu_rebalance::VesuRebalance::Rebalance",
36984
+ kind: "struct",
36985
+ members: [
36986
+ {
36987
+ name: "yield_before",
36988
+ type: "core::integer::u128",
36989
+ kind: "data"
36990
+ },
36991
+ {
36992
+ name: "yield_after",
36993
+ type: "core::integer::u128",
36994
+ kind: "data"
36995
+ }
36996
+ ]
36997
+ },
36998
+ {
36999
+ type: "event",
37000
+ name: "strkfarm_contracts::strategies::vesu_rebalance::vesu_rebalance::VesuRebalance::CollectFees",
37001
+ kind: "struct",
37002
+ members: [
37003
+ {
37004
+ name: "fee_collected",
37005
+ type: "core::integer::u128",
37006
+ kind: "data"
37007
+ },
37008
+ {
37009
+ name: "fee_collector",
37010
+ type: "core::starknet::contract_address::ContractAddress",
37011
+ kind: "data"
37012
+ }
37013
+ ]
37014
+ },
37015
+ {
37016
+ type: "event",
37017
+ name: "strkfarm_contracts::strategies::vesu_rebalance::vesu_rebalance::VesuRebalance::Event",
37018
+ kind: "enum",
37019
+ variants: [
37020
+ {
37021
+ name: "ReentrancyGuardEvent",
37022
+ type: "openzeppelin_security::reentrancyguard::ReentrancyGuardComponent::Event",
37023
+ kind: "flat"
37024
+ },
37025
+ {
37026
+ name: "ERC4626Event",
37027
+ type: "strkfarm_contracts::components::erc4626::ERC4626Component::Event",
37028
+ kind: "flat"
37029
+ },
37030
+ {
37031
+ name: "RewardShareEvent",
37032
+ type: "strkfarm_contracts::components::harvester::reward_shares::RewardShareComponent::Event",
37033
+ kind: "flat"
37034
+ },
37035
+ {
37036
+ name: "ERC20Event",
37037
+ type: "openzeppelin_token::erc20::erc20::ERC20Component::Event",
37038
+ kind: "flat"
37039
+ },
37040
+ {
37041
+ name: "SRC5Event",
37042
+ type: "openzeppelin_introspection::src5::SRC5Component::Event",
37043
+ kind: "flat"
37044
+ },
37045
+ {
37046
+ name: "UpgradeableEvent",
37047
+ type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
37048
+ kind: "flat"
37049
+ },
37050
+ {
37051
+ name: "PausableEvent",
37052
+ type: "openzeppelin_security::pausable::PausableComponent::Event",
37053
+ kind: "flat"
37054
+ },
37055
+ {
37056
+ name: "CommonCompEvent",
37057
+ type: "strkfarm_contracts::components::common::CommonComp::Event",
37058
+ kind: "flat"
37059
+ },
37060
+ {
37061
+ name: "Rebalance",
37062
+ type: "strkfarm_contracts::strategies::vesu_rebalance::vesu_rebalance::VesuRebalance::Rebalance",
37063
+ kind: "nested"
37064
+ },
37065
+ {
37066
+ name: "CollectFees",
37067
+ type: "strkfarm_contracts::strategies::vesu_rebalance::vesu_rebalance::VesuRebalance::CollectFees",
37068
+ kind: "nested"
37069
+ }
37070
+ ]
37071
+ }
37072
+ ];
37073
+
37074
+ // src/utils/index.ts
37075
+ function assert2(condition, message) {
37076
+ if (!condition) {
37077
+ throw new Error(message);
37078
+ }
37079
+ }
37080
+
37081
+ // src/strategies/vesu-rebalance.ts
37082
+ var VesuRebalance = class _VesuRebalance {
37083
+ // 10000 bps = 100%
37084
+ /**
37085
+ * Creates a new VesuRebalance strategy instance.
37086
+ * @param config - Configuration object containing provider and other settings
37087
+ * @param pricer - Pricer instance for token price calculations
37088
+ * @param metadata - Strategy metadata including deposit tokens and address
37089
+ * @throws {Error} If more than one deposit token is specified
37090
+ */
37091
+ constructor(config2, pricer, metadata) {
37092
+ this.BASE_WEIGHT = 1e4;
37093
+ this.config = config2;
37094
+ this.pricer = pricer;
37095
+ assert2(metadata.depositTokens.length === 1, "VesuRebalance only supports 1 deposit token");
37096
+ this.metadata = metadata;
37097
+ this.address = metadata.address;
37098
+ this.contract = new Contract(vesu_rebalance_abi_default, this.address.address, this.config.provider);
37099
+ }
37100
+ /**
37101
+ * Creates a deposit call to the strategy contract.
37102
+ * @param assets - Amount of assets to deposit
37103
+ * @param receiver - Address that will receive the strategy tokens
37104
+ * @returns Populated contract call for deposit
37105
+ */
37106
+ depositCall(assets, receiver) {
37107
+ const assetContract = new Contract(vesu_rebalance_abi_default, this.metadata.depositTokens[0].address, this.config.provider);
37108
+ const call1 = assetContract.populate("approve", [this.address.address, uint256_exports.bnToUint256(assets.toWei())]);
37109
+ const call2 = this.contract.populate("deposit", [uint256_exports.bnToUint256(assets.toWei()), receiver.address]);
37110
+ return [call1, call2];
37111
+ }
37112
+ /**
37113
+ * Creates a withdrawal call to the strategy contract.
37114
+ * @param assets - Amount of assets to withdraw
37115
+ * @param receiver - Address that will receive the withdrawn assets
37116
+ * @param owner - Address that owns the strategy tokens
37117
+ * @returns Populated contract call for withdrawal
37118
+ */
37119
+ withdrawCall(assets, receiver, owner) {
37120
+ return [this.contract.populate("withdraw", [uint256_exports.bnToUint256(assets.toWei()), receiver.address, owner.address])];
37121
+ }
37122
+ /**
37123
+ * Returns the underlying asset token of the strategy.
37124
+ * @returns The deposit token supported by this strategy
37125
+ */
37126
+ asset() {
37127
+ return this.metadata.depositTokens[0];
37128
+ }
37129
+ /**
37130
+ * Returns the number of decimals used by the strategy token.
37131
+ * @returns Number of decimals (same as the underlying token)
37132
+ */
37133
+ decimals() {
37134
+ return this.metadata.depositTokens[0].decimals;
37135
+ }
37136
+ /**
37137
+ * Calculates the Total Value Locked (TVL) for a specific user.
37138
+ * @param user - Address of the user
37139
+ * @returns Object containing the amount in token units and USD value
37140
+ */
37141
+ async getUserTVL(user) {
37142
+ const shares = await this.contract.balanceOf(user.address);
37143
+ const assets = await this.contract.convert_to_assets(uint256_exports.bnToUint256(shares));
37144
+ const amount = Web3Number.fromWei(assets.toString(), this.metadata.depositTokens[0].decimals);
37145
+ let price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
37146
+ const usdValue = Number(amount.toFixed(6)) * price.price;
37147
+ return {
37148
+ amount,
37149
+ usdValue
37150
+ };
37151
+ }
37152
+ /**
37153
+ * Calculates the total TVL of the strategy.
37154
+ * @returns Object containing the total amount in token units and USD value
37155
+ */
37156
+ async getTVL() {
37157
+ const assets = await this.contract.total_assets();
37158
+ const amount = Web3Number.fromWei(assets.toString(), this.metadata.depositTokens[0].decimals);
37159
+ let price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
37160
+ const usdValue = Number(amount.toFixed(6)) * price.price;
37161
+ return {
37162
+ amount,
37163
+ usdValue
37164
+ };
37165
+ }
37166
+ /**
37167
+ * Retrieves the list of allowed pools and their detailed information from multiple sources:
37168
+ * 1. Contract's allowed pools
37169
+ * 2. Vesu positions API for current positions
37170
+ * 3. Vesu pools API for APY and utilization data
37171
+ *
37172
+ * @returns {Promise<{
37173
+ * data: Array<PoolInfoFull>,
37174
+ * isErrorPositionsAPI: boolean
37175
+ * }>} Object containing:
37176
+ * - data: Array of pool information including IDs, weights, amounts, APYs and utilization
37177
+ * - isErrorPositionsAPI: Boolean indicating if there was an error fetching position data
37178
+ */
37179
+ async getPools() {
37180
+ const allowedPools = (await this.contract.get_allowed_pools()).map((p) => ({
37181
+ pool_id: ContractAddr.from(p.pool_id),
37182
+ max_weight: Number(p.max_weight) / this.BASE_WEIGHT,
37183
+ v_token: ContractAddr.from(p.v_token)
37184
+ }));
37185
+ let isErrorPositionsAPI = false;
37186
+ let vesuPositions = [];
37187
+ try {
37188
+ const res = await axios_default.get(`https://api.vesu.xyz/positions?walletAddress=${this.address.address}`);
37189
+ const data2 = await res.data;
37190
+ vesuPositions = data2.data;
37191
+ } catch (e) {
37192
+ console.error(`${_VesuRebalance.name}: Error fetching pools for ${this.address.address}`, e);
37193
+ isErrorPositionsAPI = true;
37194
+ }
37195
+ let isErrorPoolsAPI = false;
37196
+ let pools = [];
37197
+ try {
37198
+ const res = await axios_default.get(`https://api.vesu.xyz/pools`);
37199
+ const data2 = await res.data;
37200
+ pools = data2.data;
37201
+ } catch (e) {
37202
+ console.error(`${_VesuRebalance.name}: Error fetching pools for ${this.address.address}`, e);
37203
+ isErrorPoolsAPI = true;
37204
+ }
37205
+ const totalAssets = (await this.getTVL()).amount;
37206
+ const info = allowedPools.map(async (p) => {
37207
+ const vesuPosition = vesuPositions.find((d) => d.pool.id.toString() === num_exports.getDecimalString(p.pool_id.address.toString()));
37208
+ const pool = pools.find((d) => d.id == num_exports.getDecimalString(p.pool_id.address));
37209
+ const assetInfo = pool?.assets.find((d) => ContractAddr.from(this.asset().address).eqString(d.address));
37210
+ let vTokenContract = new Contract(vesu_rebalance_abi_default, p.v_token.address, this.config.provider);
37211
+ const bal = await vTokenContract.balanceOf(this.address.address);
37212
+ const assets = await vTokenContract.convert_to_assets(uint256_exports.bnToUint256(bal.toString()));
37213
+ const item = {
37214
+ pool_id: p.pool_id,
37215
+ pool_name: vesuPosition?.pool.name,
37216
+ max_weight: p.max_weight,
37217
+ current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
37218
+ v_token: p.v_token,
37219
+ amount: Web3Number.fromWei(assets.toString(), this.decimals()),
37220
+ usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
37221
+ APY: isErrorPoolsAPI || !assetInfo ? {
37222
+ baseApy: 0,
37223
+ defiSpringApy: 0,
37224
+ netApy: 0
37225
+ } : {
37226
+ baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
37227
+ defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
37228
+ netApy: 0
37229
+ },
37230
+ currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
37231
+ maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6))
37232
+ };
37233
+ item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
37234
+ return item;
37235
+ });
37236
+ const data = await Promise.all(info);
37237
+ return {
37238
+ data,
37239
+ isErrorPositionsAPI,
37240
+ isErrorPoolsAPI,
37241
+ isError: isErrorPositionsAPI || isErrorPoolsAPI
37242
+ };
37243
+ }
37244
+ /**
37245
+ * Calculates the weighted average APY across all pools based on USD value.
37246
+ * @returns {Promise<number>} The weighted average APY across all pools
37247
+ */
37248
+ async netAPY() {
37249
+ const { data: pools } = await this.getPools();
37250
+ return this.netAPYGivenPools(pools);
37251
+ }
37252
+ /**
37253
+ * Calculates the weighted average APY across all pools based on USD value.
37254
+ * @returns {Promise<number>} The weighted average APY across all pools
37255
+ */
37256
+ netAPYGivenPools(pools) {
37257
+ const weightedApy = pools.reduce((acc, curr) => {
37258
+ const weight = curr.current_weight;
37259
+ return acc + curr.APY.netApy * weight;
37260
+ }, 0);
37261
+ return weightedApy;
37262
+ }
37263
+ /**
37264
+ * Calculates optimal position changes to maximize APY while respecting max weights.
37265
+ * The algorithm:
37266
+ * 1. Sorts pools by APY (highest first)
37267
+ * 2. Calculates target amounts based on max weights
37268
+ * 3. For each pool that needs more funds:
37269
+ * - Takes funds from lowest APY pools that are over their target
37270
+ * 4. Validates that total assets remain constant
37271
+ *
37272
+ * @returns {Promise<{
37273
+ * changes: Change[],
37274
+ * finalPools: PoolInfoFull[],
37275
+ * isAnyPoolOverMaxWeight: boolean
37276
+ * }>} Object containing:
37277
+ * - changes: Array of position changes
37278
+ * - finalPools: Array of pool information after rebalance
37279
+ * @throws Error if rebalance is not possible while maintaining constraints
37280
+ */
37281
+ async getRebalancedPositions() {
37282
+ const { data: pools } = await this.getPools();
37283
+ const totalAssets = (await this.getTVL()).amount;
37284
+ if (totalAssets.eq(0)) return {
37285
+ changes: [],
37286
+ finalPools: []
37287
+ };
37288
+ const sumPools = pools.reduce((acc, curr) => acc.plus(curr.amount.toString()), Web3Number.fromWei("0", this.decimals()));
37289
+ assert2(sumPools.lte(totalAssets), "Sum of pools.amount must be less than or equal to totalAssets");
37290
+ const sortedPools = [...pools].sort((a, b) => b.APY.netApy - a.APY.netApy);
37291
+ const targetAmounts = {};
37292
+ let remainingAssets = totalAssets;
37293
+ let isAnyPoolOverMaxWeight = false;
37294
+ for (const pool of sortedPools) {
37295
+ const maxAmount = totalAssets.multipliedBy(pool.max_weight * 0.9);
37296
+ const targetAmount = remainingAssets.gte(maxAmount) ? maxAmount : remainingAssets;
37297
+ targetAmounts[pool.pool_id.address.toString()] = targetAmount;
37298
+ remainingAssets = remainingAssets.minus(targetAmount.toString());
37299
+ if (pool.current_weight > pool.max_weight) {
37300
+ isAnyPoolOverMaxWeight = true;
37301
+ }
37302
+ }
37303
+ assert2(remainingAssets.lt(1e-5), "Remaining assets must be 0");
37304
+ const changes = sortedPools.map((pool) => {
37305
+ const target = targetAmounts[pool.pool_id.address.toString()] || Web3Number.fromWei("0", this.decimals());
37306
+ const change = Web3Number.fromWei(target.minus(pool.amount.toString()).toWei(), this.decimals());
37307
+ return {
37308
+ pool_id: pool.pool_id,
37309
+ changeAmt: change,
37310
+ finalAmt: target,
37311
+ isDeposit: change.gt(0)
37312
+ };
37313
+ });
37314
+ const sumChanges = changes.reduce((sum, c) => sum.plus(c.changeAmt.toString()), Web3Number.fromWei("0", this.decimals()));
37315
+ const sumFinal = changes.reduce((sum, c) => sum.plus(c.finalAmt.toString()), Web3Number.fromWei("0", this.decimals()));
37316
+ const hasChanges = changes.some((c) => !c.changeAmt.eq(0));
37317
+ if (!sumChanges.eq(0)) throw new Error("Sum of changes must be zero");
37318
+ if (!sumFinal.eq(totalAssets)) throw new Error("Sum of final amounts must equal total assets");
37319
+ if (!hasChanges) throw new Error("No changes required");
37320
+ const finalPools = pools.map((p) => {
37321
+ const target = targetAmounts[p.pool_id.address.toString()] || Web3Number.fromWei("0", this.decimals());
37322
+ return {
37323
+ ...p,
37324
+ amount: target,
37325
+ usdValue: Web3Number.fromWei("0", this.decimals())
37326
+ };
37327
+ });
37328
+ return {
37329
+ changes,
37330
+ finalPools,
37331
+ isAnyPoolOverMaxWeight
37332
+ };
37333
+ }
37334
+ /**
37335
+ * Creates a rebalance Call object for the strategy contract
37336
+ * @param pools - Array of pool information including IDs, weights, amounts, APYs and utilization
37337
+ * @returns Populated contract call for rebalance
37338
+ */
37339
+ async getRebalanceCall(pools, isOverWeightAdjustment) {
37340
+ const actions = [];
37341
+ pools.sort((a, b) => b.isDeposit ? -1 : 1);
37342
+ console.log("pools", pools);
37343
+ pools.forEach((p) => {
37344
+ if (p.changeAmt.eq(0)) return null;
37345
+ actions.push({
37346
+ pool_id: p.pool_id.address,
37347
+ feature: new CairoCustomEnum(p.isDeposit ? { DEPOSIT: {} } : { WITHDRAW: {} }),
37348
+ token: this.asset().address,
37349
+ amount: uint256_exports.bnToUint256(p.changeAmt.multipliedBy(p.isDeposit ? 1 : -1).toWei())
37350
+ });
37351
+ });
37352
+ if (actions.length === 0) return null;
37353
+ if (isOverWeightAdjustment) {
37354
+ return this.contract.populate("rebalance_weights", [actions]);
37355
+ }
37356
+ return this.contract.populate("rebalance", [actions]);
37357
+ }
37358
+ };
37359
+ var _description = "Automatically diversify {{TOKEN}} holdings into different Vesu pools while reducing risk and maximizing yield. Defi spring STRK Rewards are auto-compounded as well.";
37360
+ var _protocol = { name: "Vesu", logo: "https://static-assets-8zct.onrender.com/integrations/vesu/logo.png" };
37361
+ var VesuRebalanceStrategies = [{
37362
+ name: "Vesu STRK",
37363
+ description: _description.replace("{{TOKEN}}", "STRK"),
37364
+ address: ContractAddr.from("0xeeb729d554ae486387147b13a9c8871bc7991d454e8b5ff570d4bf94de71e1"),
37365
+ type: "ERC4626",
37366
+ depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "STRK")],
37367
+ protocols: [_protocol]
37368
+ }];
35579
37369
  return __toCommonJS(index_browser_exports);
35580
37370
  })();
35581
37371
  /*! Bundled license information: