@strkfarm/sdk 1.0.61 → 1.0.63

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.
@@ -423,7 +423,8 @@ var Pricer = class extends PricerBase {
423
423
  const url = this.EKUBO_API.replace("{{TOKEN_ADDRESS}}", token.address.toString()).replace("{{AMOUNT}}", amountIn.toWei());
424
424
  const result = await axios2.get(url);
425
425
  const data = result.data;
426
- const outputUSDC = Number(Web3Number.fromWei(data.total_calculated, 6).toFixed(6));
426
+ const multiplier = 1 / amountIn.toNumber();
427
+ const outputUSDC = Number(Web3Number.fromWei(data.total_calculated, 6).toFixed(6)) * multiplier;
427
428
  logger.verbose(`Ekubo: ${token.symbol} -> USDC: ${outputUSDC}, retry: ${retry}`);
428
429
  if (outputUSDC === 0 && retry < 3) {
429
430
  const amountIn2 = new Web3Number(100, token.decimals);
@@ -3840,11 +3841,12 @@ var EkuboHarvests = class extends Harvests {
3840
3841
  return rewards.sort((a, b) => b.endDate.getTime() - a.endDate.getTime());
3841
3842
  }
3842
3843
  };
3844
+ var VESU_REWARDS_CONTRACT = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
3843
3845
  var VesuHarvests = class _VesuHarvests extends Harvests {
3844
3846
  async getHarvests(addr) {
3845
3847
  const result = await fetch(`https://api.vesu.xyz/users/${addr.address}/strk-rewards/calldata`);
3846
3848
  const data = await result.json();
3847
- const rewardsContract = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
3849
+ const rewardsContract = VESU_REWARDS_CONTRACT;
3848
3850
  const cls = await this.config.provider.getClassAt(rewardsContract.address);
3849
3851
  const contract = new Contract4(cls.abi, rewardsContract.address, this.config.provider);
3850
3852
  const _claimed_amount = await contract.call("amount_already_claimed", [addr.address]);
@@ -18436,7 +18438,9 @@ var SenseiStrategies = [
18436
18438
  import { hash, num as num6, shortString } from "starknet";
18437
18439
 
18438
18440
  // src/strategies/universal-adapters/adapter-utils.ts
18439
- var SIMPLE_SANITIZER = ContractAddr.from("0x3798dc4f83fdfad199e5236e3656cf2fb79bc50c00504d0dd41522e0f042072");
18441
+ var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
18442
+ var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
18443
+ var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
18440
18444
  function toBigInt(value) {
18441
18445
  if (typeof value === "string") {
18442
18446
  return BigInt(value);
@@ -18469,7 +18473,7 @@ var BaseAdapter = class extends CacheClass {
18469
18473
  };
18470
18474
 
18471
18475
  // src/strategies/universal-adapters/common-adapter.ts
18472
- import { hash as hash2, uint256 as uint2566 } from "starknet";
18476
+ import { hash as hash2, num as num7, uint256 as uint2566 } from "starknet";
18473
18477
  var CommonAdapter = class extends BaseAdapter {
18474
18478
  constructor(config) {
18475
18479
  super();
@@ -18580,10 +18584,70 @@ var CommonAdapter = class extends BaseAdapter {
18580
18584
  };
18581
18585
  };
18582
18586
  }
18587
+ getAvnuAdapter(fromToken, toToken, id) {
18588
+ return () => ({
18589
+ leaf: this.constructSimpleLeafData({
18590
+ id,
18591
+ target: AVNU_MIDDLEWARE,
18592
+ method: "multi_route_swap",
18593
+ packedArguments: [
18594
+ fromToken.toBigInt(),
18595
+ toToken.toBigInt(),
18596
+ this.config.vaultAllocator.toBigInt()
18597
+ ]
18598
+ }),
18599
+ callConstructor: this.getAvnuCall(fromToken, toToken).bind(this)
18600
+ });
18601
+ }
18602
+ getAvnuCall(fromToken, toToken) {
18603
+ return (params) => {
18604
+ return {
18605
+ sanitizer: SIMPLE_SANITIZER,
18606
+ call: {
18607
+ contractAddress: AVNU_MIDDLEWARE,
18608
+ selector: hash2.getSelectorFromName("multi_route_swap"),
18609
+ calldata: [
18610
+ fromToken.toBigInt(),
18611
+ // sell_token_address
18612
+ toBigInt(params.props.token_from_amount.low.toString()),
18613
+ // sell_token_amount low
18614
+ toBigInt(params.props.token_from_amount.high.toString()),
18615
+ // sell_token_amount high
18616
+ toToken.toBigInt(),
18617
+ // buy_token_address
18618
+ toBigInt(params.props.token_to_amount.low.toString()),
18619
+ // buy_token_amount low
18620
+ toBigInt(params.props.token_to_amount.high.toString()),
18621
+ // buy_token_amount high
18622
+ toBigInt(params.props.token_to_min_amount.low.toString()),
18623
+ // buy_token_min_amount low
18624
+ toBigInt(params.props.token_to_min_amount.high.toString()),
18625
+ // buy_token_min_amount high
18626
+ this.config.vaultAllocator.toBigInt(),
18627
+ // beneficiary
18628
+ toBigInt(0),
18629
+ // integrator_fee_amount_bps
18630
+ this.config.vaultAllocator.toBigInt(),
18631
+ // integrator_fee_recipient
18632
+ // unpack routes
18633
+ BigInt(params.props.routes.length),
18634
+ ...params.props.routes.map((r) => [
18635
+ BigInt(num7.hexToDecimalString(r.token_from)),
18636
+ BigInt(num7.hexToDecimalString(r.token_to)),
18637
+ BigInt(num7.hexToDecimalString(r.exchange_address)),
18638
+ BigInt(r.percent),
18639
+ BigInt(r.additional_swap_params.length),
18640
+ ...r.additional_swap_params.map((p) => BigInt(num7.hexToDecimalString(p)))
18641
+ ]).flat()
18642
+ ]
18643
+ }
18644
+ };
18645
+ };
18646
+ }
18583
18647
  };
18584
18648
 
18585
18649
  // src/strategies/universal-adapters/vesu-adapter.ts
18586
- import { CairoCustomEnum as CairoCustomEnum2, Contract as Contract8, hash as hash3, RpcProvider as RpcProvider4, uint256 as uint2567 } from "starknet";
18650
+ import { CairoCustomEnum as CairoCustomEnum2, Contract as Contract8, hash as hash3, num as num8, RpcProvider as RpcProvider4, shortString as shortString3, uint256 as uint2567 } from "starknet";
18587
18651
 
18588
18652
  // src/data/vesu-singleton.abi.json
18589
18653
  var vesu_singleton_abi_default = [
@@ -20916,6 +20980,40 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
20916
20980
  }
20917
20981
  };
20918
20982
  };
20983
+ this.getDefispringRewardsAdapter = (id) => {
20984
+ return () => {
20985
+ const packedArguments = [];
20986
+ const output = {
20987
+ id: BigInt(num8.getDecimalString(shortString3.encodeShortString(id))),
20988
+ readableId: id,
20989
+ data: [
20990
+ SIMPLE_SANITIZER.toBigInt(),
20991
+ // sanitizer address
20992
+ VESU_REWARDS_CONTRACT.toBigInt(),
20993
+ // contract
20994
+ toBigInt(hash3.getSelectorFromName("claim")),
20995
+ // method name
20996
+ BigInt(packedArguments.length),
20997
+ ...packedArguments
20998
+ ]
20999
+ };
21000
+ return { leaf: output, callConstructor: this.getDefiSpringClaimCall().bind(this) };
21001
+ };
21002
+ };
21003
+ this.getDefiSpringClaimCall = () => {
21004
+ return (params) => ({
21005
+ sanitizer: SIMPLE_SANITIZER,
21006
+ call: {
21007
+ contractAddress: VESU_REWARDS_CONTRACT,
21008
+ selector: hash3.getSelectorFromName("claim"),
21009
+ calldata: [
21010
+ BigInt(params.amount.toWei()),
21011
+ BigInt(params.proofs.length),
21012
+ ...params.proofs.map((proof) => BigInt(num8.hexToDecimalString(proof)))
21013
+ ]
21014
+ }
21015
+ });
21016
+ };
20919
21017
  this.config = config;
20920
21018
  }
20921
21019
  static getDefaultModifyPositionCallParams(params) {
@@ -23545,7 +23643,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
23545
23643
  const aumToken = vesuAum.plus(balance.amount);
23546
23644
  logger.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
23547
23645
  const netAPY = await this.netAPY();
23548
- const defispringAPY = netAPY.splits.find((s) => s.id === "defispring")?.apy || 0;
23646
+ const defispringAPY = (netAPY.splits.find((s) => s.id === "defispring")?.apy || 0) * 0.8;
23549
23647
  if (!defispringAPY) throw new Error("DefiSpring APY not found");
23550
23648
  const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
23551
23649
  const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
@@ -23788,6 +23886,51 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
23788
23886
  const manageCall = this.getManageCall(["approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */, "bring_liquidity" /* BRING_LIQUIDITY */], [manageCall1, manageCall2]);
23789
23887
  return manageCall;
23790
23888
  }
23889
+ async getHarvestCall() {
23890
+ const vesuHarvest = new VesuHarvests(this.config);
23891
+ const harvestInfo = await vesuHarvest.getUnHarvestedRewards(this.metadata.additionalInfo.vaultAllocator);
23892
+ if (harvestInfo.length != 1) {
23893
+ throw new Error(`Expected 1 harvest info, got ${harvestInfo.length}`);
23894
+ }
23895
+ const amount = harvestInfo[0].claim.amount;
23896
+ const actualReward = harvestInfo[0].actualReward;
23897
+ const proofs = harvestInfo[0].proof;
23898
+ if (actualReward.isZero()) {
23899
+ throw new Error(`Expected non-zero actual reward, got ${harvestInfo[0].actualReward}`);
23900
+ }
23901
+ const manage1Info = this.getProofs("defispring_rewards" /* DEFISPRING_REWARDS */);
23902
+ const manageCall1 = manage1Info.callConstructor({
23903
+ amount,
23904
+ proofs
23905
+ });
23906
+ const proofIds = ["defispring_rewards" /* DEFISPRING_REWARDS */];
23907
+ const manageCalls = [manageCall1];
23908
+ const STRK2 = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
23909
+ if (this.asset().symbol != "STRK") {
23910
+ const manage2Info = this.getProofs("approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */);
23911
+ const manageCall2 = manage2Info.callConstructor({
23912
+ amount: actualReward
23913
+ });
23914
+ const avnuModule = new AvnuWrapper();
23915
+ const quote = await avnuModule.getQuotes(
23916
+ STRK2.address.address,
23917
+ this.asset().address.address,
23918
+ actualReward.toWei(),
23919
+ this.address.address
23920
+ );
23921
+ const swapInfo = await avnuModule.getSwapInfo(quote, this.address.address, 0, this.address.address);
23922
+ const manage3Info = this.getProofs("avnu_swap_rewards" /* AVNU_SWAP_REWARDS */);
23923
+ const manageCall3 = manage3Info.callConstructor({
23924
+ props: swapInfo
23925
+ });
23926
+ proofIds.push("approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */);
23927
+ proofIds.push("avnu_swap_rewards" /* AVNU_SWAP_REWARDS */);
23928
+ manageCalls.push(manageCall2);
23929
+ manageCalls.push(manageCall3);
23930
+ }
23931
+ const manageCall = this.getManageCall(proofIds, manageCalls);
23932
+ return { call: manageCall, reward: actualReward, tokenInfo: STRK2 };
23933
+ }
23791
23934
  async getRebalanceCall(params) {
23792
23935
  let callSet1 = this.getVesuModifyPositionCalls({
23793
23936
  isLeg1: true,
@@ -23824,6 +23967,9 @@ var UNIVERSAL_MANAGE_IDS = /* @__PURE__ */ ((UNIVERSAL_MANAGE_IDS2) => {
23824
23967
  UNIVERSAL_MANAGE_IDS2["APPROVE_TOKEN2"] = "approve_token2";
23825
23968
  UNIVERSAL_MANAGE_IDS2["APPROVE_BRING_LIQUIDITY"] = "approve_bring_liquidity";
23826
23969
  UNIVERSAL_MANAGE_IDS2["BRING_LIQUIDITY"] = "bring_liquidity";
23970
+ UNIVERSAL_MANAGE_IDS2["DEFISPRING_REWARDS"] = "defispring_rewards";
23971
+ UNIVERSAL_MANAGE_IDS2["APPROVE_SWAP_TOKEN1"] = "approve_swap_token1";
23972
+ UNIVERSAL_MANAGE_IDS2["AVNU_SWAP_REWARDS"] = "avnu_swap_rewards";
23827
23973
  return UNIVERSAL_MANAGE_IDS2;
23828
23974
  })(UNIVERSAL_MANAGE_IDS || {});
23829
23975
  var UNIVERSAL_ADAPTERS = /* @__PURE__ */ ((UNIVERSAL_ADAPTERS2) => {
@@ -23873,6 +24019,10 @@ function getLooperSettings(token1Symbol, token2Symbol, vaultSettings, pool1, poo
23873
24019
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(ETHToken.address, vesuAdapterETHUSDC.VESU_SINGLETON, "approve_token2" /* APPROVE_TOKEN2 */).bind(commonAdapter));
23874
24020
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(USDCToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
23875
24021
  vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
24022
+ vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterUSDCETH));
24023
+ const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
24024
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
24025
+ vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
23876
24026
  return vaultSettings;
23877
24027
  }
23878
24028
  var _riskFactor4 = [
package/dist/index.d.ts CHANGED
@@ -921,6 +921,9 @@ interface FlashloanCallParams {
921
921
  interface ApproveCallParams {
922
922
  amount: Web3Number;
923
923
  }
924
+ interface AvnuSwapCallParams {
925
+ props: SwapInfo;
926
+ }
924
927
  interface CommonAdapterConfig {
925
928
  id: string;
926
929
  vaultAddress: ContractAddr;
@@ -951,6 +954,8 @@ declare class CommonAdapter extends BaseAdapter {
951
954
  calldata: bigint[];
952
955
  };
953
956
  };
957
+ getAvnuAdapter(fromToken: ContractAddr, toToken: ContractAddr, id: string): () => AdapterLeafType<AvnuSwapCallParams>;
958
+ getAvnuCall(fromToken: ContractAddr, toToken: ContractAddr): GenerateCallFn<AvnuSwapCallParams>;
954
959
  }
955
960
 
956
961
  interface VesuPoolsInfo {
@@ -978,6 +983,10 @@ interface VesuModifyPositionCallParams {
978
983
  collateralAmount: VesuAmount;
979
984
  debtAmount: VesuAmount;
980
985
  }
986
+ interface VesuDefiSpringRewardsCallParams {
987
+ amount: Web3Number;
988
+ proofs: string[];
989
+ }
981
990
  interface VesuAdapterConfig {
982
991
  poolId: ContractAddr;
983
992
  collateral: TokenInfo;
@@ -1019,6 +1028,8 @@ declare class VesuAdapter extends BaseAdapter {
1019
1028
  };
1020
1029
  };
1021
1030
  getModifyPositionCall: (params: VesuModifyPositionCallParams) => ManageCall;
1031
+ getDefispringRewardsAdapter: (id: string) => () => AdapterLeafType<VesuDefiSpringRewardsCallParams>;
1032
+ getDefiSpringClaimCall: () => GenerateCallFn<VesuDefiSpringRewardsCallParams>;
1022
1033
  formatAmountTypeEnum(amountType: VesuAmountType): CairoCustomEnum;
1023
1034
  formatAmountDenominationEnum(denomination: VesuAmountDenomination): CairoCustomEnum;
1024
1035
  getVesuSingletonContract(config: IConfig): Contract;
@@ -1151,6 +1162,11 @@ declare class UniversalStrategy<S extends UniversalStrategySettings> extends Bas
1151
1162
  getBringLiquidityCall(params: {
1152
1163
  amount: Web3Number;
1153
1164
  }): Promise<Call>;
1165
+ getHarvestCall(): Promise<{
1166
+ call: Call;
1167
+ reward: Web3Number;
1168
+ tokenInfo: TokenInfo;
1169
+ }>;
1154
1170
  getRebalanceCall(params: {
1155
1171
  isLeg1toLeg2: boolean;
1156
1172
  amount: Web3Number;
@@ -1163,7 +1179,10 @@ declare enum UNIVERSAL_MANAGE_IDS {
1163
1179
  APPROVE_TOKEN1 = "approve_token1",
1164
1180
  APPROVE_TOKEN2 = "approve_token2",
1165
1181
  APPROVE_BRING_LIQUIDITY = "approve_bring_liquidity",
1166
- BRING_LIQUIDITY = "bring_liquidity"
1182
+ BRING_LIQUIDITY = "bring_liquidity",
1183
+ DEFISPRING_REWARDS = "defispring_rewards",
1184
+ APPROVE_SWAP_TOKEN1 = "approve_swap_token1",
1185
+ AVNU_SWAP_REWARDS = "avnu_swap_rewards"
1167
1186
  }
1168
1187
  declare enum UNIVERSAL_ADAPTERS {
1169
1188
  COMMON = "common_adapter",
@@ -1304,4 +1323,4 @@ declare class PasswordJsonCryptoUtil {
1304
1323
  decrypt(encryptedData: string, password: string): any;
1305
1324
  }
1306
1325
 
1307
- export { AUMTypes, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type ApproveCallParams, AutoCompounderSTRK, AvnuWrapper, BaseAdapter, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type FAQ, FatalError, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, Initializable, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, Network, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerRedis, Protocols, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type SwapInfo, TelegramNotif, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, type VaultPosition, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuModifyPositionCallParams, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getAPIUsingHeadlessBrowser, getDefaultStoreConfig, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getTrovesEndpoint, highlightTextWithLinks, type i257, logger };
1326
+ export { AUMTypes, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type ApproveCallParams, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, BaseAdapter, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type FAQ, FatalError, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, Initializable, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, Network, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerRedis, Protocols, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type SwapInfo, TelegramNotif, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, type VaultPosition, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuModifyPositionCallParams, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getAPIUsingHeadlessBrowser, getDefaultStoreConfig, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getTrovesEndpoint, highlightTextWithLinks, type i257, logger };
package/dist/index.js CHANGED
@@ -551,7 +551,8 @@ var Pricer = class extends PricerBase {
551
551
  const url = this.EKUBO_API.replace("{{TOKEN_ADDRESS}}", token.address.toString()).replace("{{AMOUNT}}", amountIn.toWei());
552
552
  const result = await import_axios2.default.get(url);
553
553
  const data = result.data;
554
- const outputUSDC = Number(Web3Number.fromWei(data.total_calculated, 6).toFixed(6));
554
+ const multiplier = 1 / amountIn.toNumber();
555
+ const outputUSDC = Number(Web3Number.fromWei(data.total_calculated, 6).toFixed(6)) * multiplier;
555
556
  logger.verbose(`Ekubo: ${token.symbol} -> USDC: ${outputUSDC}, retry: ${retry}`);
556
557
  if (outputUSDC === 0 && retry < 3) {
557
558
  const amountIn2 = new Web3Number(100, token.decimals);
@@ -3976,11 +3977,12 @@ var EkuboHarvests = class extends Harvests {
3976
3977
  return rewards.sort((a, b) => b.endDate.getTime() - a.endDate.getTime());
3977
3978
  }
3978
3979
  };
3980
+ var VESU_REWARDS_CONTRACT = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
3979
3981
  var VesuHarvests = class _VesuHarvests extends Harvests {
3980
3982
  async getHarvests(addr) {
3981
3983
  const result = await fetch(`https://api.vesu.xyz/users/${addr.address}/strk-rewards/calldata`);
3982
3984
  const data = await result.json();
3983
- const rewardsContract = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
3985
+ const rewardsContract = VESU_REWARDS_CONTRACT;
3984
3986
  const cls = await this.config.provider.getClassAt(rewardsContract.address);
3985
3987
  const contract = new import_starknet8.Contract(cls.abi, rewardsContract.address, this.config.provider);
3986
3988
  const _claimed_amount = await contract.call("amount_already_claimed", [addr.address]);
@@ -18568,7 +18570,9 @@ var SenseiStrategies = [
18568
18570
  var import_starknet12 = require("starknet");
18569
18571
 
18570
18572
  // src/strategies/universal-adapters/adapter-utils.ts
18571
- var SIMPLE_SANITIZER = ContractAddr.from("0x3798dc4f83fdfad199e5236e3656cf2fb79bc50c00504d0dd41522e0f042072");
18573
+ var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
18574
+ var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
18575
+ var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
18572
18576
  function toBigInt(value) {
18573
18577
  if (typeof value === "string") {
18574
18578
  return BigInt(value);
@@ -18712,6 +18716,66 @@ var CommonAdapter = class extends BaseAdapter {
18712
18716
  };
18713
18717
  };
18714
18718
  }
18719
+ getAvnuAdapter(fromToken, toToken, id) {
18720
+ return () => ({
18721
+ leaf: this.constructSimpleLeafData({
18722
+ id,
18723
+ target: AVNU_MIDDLEWARE,
18724
+ method: "multi_route_swap",
18725
+ packedArguments: [
18726
+ fromToken.toBigInt(),
18727
+ toToken.toBigInt(),
18728
+ this.config.vaultAllocator.toBigInt()
18729
+ ]
18730
+ }),
18731
+ callConstructor: this.getAvnuCall(fromToken, toToken).bind(this)
18732
+ });
18733
+ }
18734
+ getAvnuCall(fromToken, toToken) {
18735
+ return (params) => {
18736
+ return {
18737
+ sanitizer: SIMPLE_SANITIZER,
18738
+ call: {
18739
+ contractAddress: AVNU_MIDDLEWARE,
18740
+ selector: import_starknet13.hash.getSelectorFromName("multi_route_swap"),
18741
+ calldata: [
18742
+ fromToken.toBigInt(),
18743
+ // sell_token_address
18744
+ toBigInt(params.props.token_from_amount.low.toString()),
18745
+ // sell_token_amount low
18746
+ toBigInt(params.props.token_from_amount.high.toString()),
18747
+ // sell_token_amount high
18748
+ toToken.toBigInt(),
18749
+ // buy_token_address
18750
+ toBigInt(params.props.token_to_amount.low.toString()),
18751
+ // buy_token_amount low
18752
+ toBigInt(params.props.token_to_amount.high.toString()),
18753
+ // buy_token_amount high
18754
+ toBigInt(params.props.token_to_min_amount.low.toString()),
18755
+ // buy_token_min_amount low
18756
+ toBigInt(params.props.token_to_min_amount.high.toString()),
18757
+ // buy_token_min_amount high
18758
+ this.config.vaultAllocator.toBigInt(),
18759
+ // beneficiary
18760
+ toBigInt(0),
18761
+ // integrator_fee_amount_bps
18762
+ this.config.vaultAllocator.toBigInt(),
18763
+ // integrator_fee_recipient
18764
+ // unpack routes
18765
+ BigInt(params.props.routes.length),
18766
+ ...params.props.routes.map((r) => [
18767
+ BigInt(import_starknet13.num.hexToDecimalString(r.token_from)),
18768
+ BigInt(import_starknet13.num.hexToDecimalString(r.token_to)),
18769
+ BigInt(import_starknet13.num.hexToDecimalString(r.exchange_address)),
18770
+ BigInt(r.percent),
18771
+ BigInt(r.additional_swap_params.length),
18772
+ ...r.additional_swap_params.map((p) => BigInt(import_starknet13.num.hexToDecimalString(p)))
18773
+ ]).flat()
18774
+ ]
18775
+ }
18776
+ };
18777
+ };
18778
+ }
18715
18779
  };
18716
18780
 
18717
18781
  // src/strategies/universal-adapters/vesu-adapter.ts
@@ -21048,6 +21112,40 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
21048
21112
  }
21049
21113
  };
21050
21114
  };
21115
+ this.getDefispringRewardsAdapter = (id) => {
21116
+ return () => {
21117
+ const packedArguments = [];
21118
+ const output = {
21119
+ id: BigInt(import_starknet14.num.getDecimalString(import_starknet14.shortString.encodeShortString(id))),
21120
+ readableId: id,
21121
+ data: [
21122
+ SIMPLE_SANITIZER.toBigInt(),
21123
+ // sanitizer address
21124
+ VESU_REWARDS_CONTRACT.toBigInt(),
21125
+ // contract
21126
+ toBigInt(import_starknet14.hash.getSelectorFromName("claim")),
21127
+ // method name
21128
+ BigInt(packedArguments.length),
21129
+ ...packedArguments
21130
+ ]
21131
+ };
21132
+ return { leaf: output, callConstructor: this.getDefiSpringClaimCall().bind(this) };
21133
+ };
21134
+ };
21135
+ this.getDefiSpringClaimCall = () => {
21136
+ return (params) => ({
21137
+ sanitizer: SIMPLE_SANITIZER,
21138
+ call: {
21139
+ contractAddress: VESU_REWARDS_CONTRACT,
21140
+ selector: import_starknet14.hash.getSelectorFromName("claim"),
21141
+ calldata: [
21142
+ BigInt(params.amount.toWei()),
21143
+ BigInt(params.proofs.length),
21144
+ ...params.proofs.map((proof) => BigInt(import_starknet14.num.hexToDecimalString(proof)))
21145
+ ]
21146
+ }
21147
+ });
21148
+ };
21051
21149
  this.config = config;
21052
21150
  }
21053
21151
  static getDefaultModifyPositionCallParams(params) {
@@ -23677,7 +23775,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
23677
23775
  const aumToken = vesuAum.plus(balance.amount);
23678
23776
  logger.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
23679
23777
  const netAPY = await this.netAPY();
23680
- const defispringAPY = netAPY.splits.find((s) => s.id === "defispring")?.apy || 0;
23778
+ const defispringAPY = (netAPY.splits.find((s) => s.id === "defispring")?.apy || 0) * 0.8;
23681
23779
  if (!defispringAPY) throw new Error("DefiSpring APY not found");
23682
23780
  const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
23683
23781
  const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
@@ -23920,6 +24018,51 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
23920
24018
  const manageCall = this.getManageCall(["approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */, "bring_liquidity" /* BRING_LIQUIDITY */], [manageCall1, manageCall2]);
23921
24019
  return manageCall;
23922
24020
  }
24021
+ async getHarvestCall() {
24022
+ const vesuHarvest = new VesuHarvests(this.config);
24023
+ const harvestInfo = await vesuHarvest.getUnHarvestedRewards(this.metadata.additionalInfo.vaultAllocator);
24024
+ if (harvestInfo.length != 1) {
24025
+ throw new Error(`Expected 1 harvest info, got ${harvestInfo.length}`);
24026
+ }
24027
+ const amount = harvestInfo[0].claim.amount;
24028
+ const actualReward = harvestInfo[0].actualReward;
24029
+ const proofs = harvestInfo[0].proof;
24030
+ if (actualReward.isZero()) {
24031
+ throw new Error(`Expected non-zero actual reward, got ${harvestInfo[0].actualReward}`);
24032
+ }
24033
+ const manage1Info = this.getProofs("defispring_rewards" /* DEFISPRING_REWARDS */);
24034
+ const manageCall1 = manage1Info.callConstructor({
24035
+ amount,
24036
+ proofs
24037
+ });
24038
+ const proofIds = ["defispring_rewards" /* DEFISPRING_REWARDS */];
24039
+ const manageCalls = [manageCall1];
24040
+ const STRK2 = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
24041
+ if (this.asset().symbol != "STRK") {
24042
+ const manage2Info = this.getProofs("approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */);
24043
+ const manageCall2 = manage2Info.callConstructor({
24044
+ amount: actualReward
24045
+ });
24046
+ const avnuModule = new AvnuWrapper();
24047
+ const quote = await avnuModule.getQuotes(
24048
+ STRK2.address.address,
24049
+ this.asset().address.address,
24050
+ actualReward.toWei(),
24051
+ this.address.address
24052
+ );
24053
+ const swapInfo = await avnuModule.getSwapInfo(quote, this.address.address, 0, this.address.address);
24054
+ const manage3Info = this.getProofs("avnu_swap_rewards" /* AVNU_SWAP_REWARDS */);
24055
+ const manageCall3 = manage3Info.callConstructor({
24056
+ props: swapInfo
24057
+ });
24058
+ proofIds.push("approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */);
24059
+ proofIds.push("avnu_swap_rewards" /* AVNU_SWAP_REWARDS */);
24060
+ manageCalls.push(manageCall2);
24061
+ manageCalls.push(manageCall3);
24062
+ }
24063
+ const manageCall = this.getManageCall(proofIds, manageCalls);
24064
+ return { call: manageCall, reward: actualReward, tokenInfo: STRK2 };
24065
+ }
23923
24066
  async getRebalanceCall(params) {
23924
24067
  let callSet1 = this.getVesuModifyPositionCalls({
23925
24068
  isLeg1: true,
@@ -23956,6 +24099,9 @@ var UNIVERSAL_MANAGE_IDS = /* @__PURE__ */ ((UNIVERSAL_MANAGE_IDS2) => {
23956
24099
  UNIVERSAL_MANAGE_IDS2["APPROVE_TOKEN2"] = "approve_token2";
23957
24100
  UNIVERSAL_MANAGE_IDS2["APPROVE_BRING_LIQUIDITY"] = "approve_bring_liquidity";
23958
24101
  UNIVERSAL_MANAGE_IDS2["BRING_LIQUIDITY"] = "bring_liquidity";
24102
+ UNIVERSAL_MANAGE_IDS2["DEFISPRING_REWARDS"] = "defispring_rewards";
24103
+ UNIVERSAL_MANAGE_IDS2["APPROVE_SWAP_TOKEN1"] = "approve_swap_token1";
24104
+ UNIVERSAL_MANAGE_IDS2["AVNU_SWAP_REWARDS"] = "avnu_swap_rewards";
23959
24105
  return UNIVERSAL_MANAGE_IDS2;
23960
24106
  })(UNIVERSAL_MANAGE_IDS || {});
23961
24107
  var UNIVERSAL_ADAPTERS = /* @__PURE__ */ ((UNIVERSAL_ADAPTERS2) => {
@@ -24005,6 +24151,10 @@ function getLooperSettings(token1Symbol, token2Symbol, vaultSettings, pool1, poo
24005
24151
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(ETHToken.address, vesuAdapterETHUSDC.VESU_SINGLETON, "approve_token2" /* APPROVE_TOKEN2 */).bind(commonAdapter));
24006
24152
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(USDCToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
24007
24153
  vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
24154
+ vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterUSDCETH));
24155
+ const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
24156
+ vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
24157
+ vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
24008
24158
  return vaultSettings;
24009
24159
  }
24010
24160
  var _riskFactor4 = [