@strkfarm/sdk 1.2.0 → 2.0.0-dev-strategy2.1

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.
Files changed (60) hide show
  1. package/dist/index.browser.global.js +76556 -66640
  2. package/dist/index.browser.mjs +34235 -24392
  3. package/dist/index.d.ts +2372 -793
  4. package/dist/index.js +31967 -22084
  5. package/dist/index.mjs +25545 -15719
  6. package/package.json +86 -76
  7. package/readme.md +56 -1
  8. package/src/data/extended-deposit.abi.json +3613 -0
  9. package/src/data/universal-vault.abi.json +135 -20
  10. package/src/dataTypes/_bignumber.ts +11 -0
  11. package/src/dataTypes/address.ts +7 -0
  12. package/src/global.ts +240 -193
  13. package/src/interfaces/common.tsx +26 -2
  14. package/src/modules/ExtendedWrapperSDk/index.ts +62 -0
  15. package/src/modules/ExtendedWrapperSDk/types.ts +311 -0
  16. package/src/modules/ExtendedWrapperSDk/wrapper.ts +448 -0
  17. package/src/modules/avnu.ts +17 -4
  18. package/src/modules/ekubo-quoter.ts +89 -10
  19. package/src/modules/erc20.ts +67 -21
  20. package/src/modules/harvests.ts +29 -43
  21. package/src/modules/index.ts +5 -1
  22. package/src/modules/lst-apr.ts +36 -0
  23. package/src/modules/midas.ts +159 -0
  24. package/src/modules/pricer-from-api.ts +2 -2
  25. package/src/modules/pricer-lst.ts +1 -1
  26. package/src/modules/pricer.ts +3 -38
  27. package/src/modules/token-market-data.ts +202 -0
  28. package/src/node/deployer.ts +1 -36
  29. package/src/strategies/autoCompounderStrk.ts +1 -1
  30. package/src/strategies/base-strategy.ts +20 -3
  31. package/src/strategies/btc-vesu-extended-strategy/core-strategy.tsx +1486 -0
  32. package/src/strategies/btc-vesu-extended-strategy/services/operationService.ts +32 -0
  33. package/src/strategies/btc-vesu-extended-strategy/utils/constants.ts +3 -0
  34. package/src/strategies/btc-vesu-extended-strategy/utils/helper.ts +396 -0
  35. package/src/strategies/btc-vesu-extended-strategy/utils/types.ts +5 -0
  36. package/src/strategies/ekubo-cl-vault.tsx +123 -306
  37. package/src/strategies/index.ts +7 -1
  38. package/src/strategies/svk-strategy.ts +247 -0
  39. package/src/strategies/universal-adapters/adapter-optimizer.ts +65 -0
  40. package/src/strategies/universal-adapters/adapter-utils.ts +5 -1
  41. package/src/strategies/universal-adapters/avnu-adapter.ts +432 -0
  42. package/src/strategies/universal-adapters/baseAdapter.ts +181 -153
  43. package/src/strategies/universal-adapters/common-adapter.ts +98 -77
  44. package/src/strategies/universal-adapters/extended-adapter.ts +976 -0
  45. package/src/strategies/universal-adapters/index.ts +7 -1
  46. package/src/strategies/universal-adapters/unused-balance-adapter.ts +109 -0
  47. package/src/strategies/universal-adapters/vesu-adapter.ts +230 -230
  48. package/src/strategies/universal-adapters/vesu-borrow-adapter.ts +1247 -0
  49. package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +1306 -0
  50. package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +58 -51
  51. package/src/strategies/universal-lst-muliplier-strategy.tsx +716 -844
  52. package/src/strategies/universal-strategy.tsx +1103 -1181
  53. package/src/strategies/vesu-extended-strategy/services/operationService.ts +34 -0
  54. package/src/strategies/vesu-extended-strategy/types/transaction-metadata.ts +25 -0
  55. package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +77 -0
  56. package/src/strategies/vesu-extended-strategy/utils/constants.ts +50 -0
  57. package/src/strategies/vesu-extended-strategy/utils/helper.ts +367 -0
  58. package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +1420 -0
  59. package/src/strategies/vesu-rebalance.tsx +16 -20
  60. package/src/utils/health-factor-math.ts +11 -5
@@ -17,15 +17,15 @@ import VesuRebalanceAbi from "@/data/vesu-rebalance.abi.json";
17
17
  import { Global } from "@/global";
18
18
  import { assert } from "@/utils";
19
19
  import { logger } from "@/utils/logger";
20
- import axios from "axios";
21
20
  import { PricerBase } from "@/modules/pricerBase";
22
21
  import {
22
+ APYInfo,
23
23
  BaseStrategy,
24
24
  SingleActionAmount,
25
25
  SingleTokenInfo
26
26
  } from "./base-strategy";
27
27
  import { getAPIUsingHeadlessBrowser } from "@/node/headless";
28
- import { HarvestInfo, VesuHarvests } from "@/modules/harvests";
28
+ import { VESU_REWARDS_ENDPOINT, VesuHarvests } from "@/modules/harvests";
29
29
  import VesuPoolIDs from "@/data/vesu_pools.json";
30
30
  import { COMMON_CONTRACTS, ENDPOINTS } from "./constants";
31
31
 
@@ -182,7 +182,7 @@ export class VesuRebalance extends BaseStrategy<
182
182
  * @returns Object containing the amount in token units and USD value
183
183
  */
184
184
  async getUserTVL(user: ContractAddr) {
185
- const shares = await this.contract.balanceOf(user.address);
185
+ const shares = await this.contract.balance_of(user.address);
186
186
  const assets = await this.contract.convert_to_assets(
187
187
  uint256.bnToUint256(shares)
188
188
  );
@@ -288,7 +288,7 @@ export class VesuRebalance extends BaseStrategy<
288
288
  address: p.v_token.address,
289
289
  providerOrAccount: this.config.provider
290
290
  });
291
- const bal = await vTokenContract.balanceOf(this.address.address);
291
+ const bal = await vTokenContract.balance_of(this.address.address);
292
292
  const assets = await vTokenContract.convert_to_assets(
293
293
  uint256.bnToUint256(bal.toString())
294
294
  );
@@ -523,9 +523,12 @@ export class VesuRebalance extends BaseStrategy<
523
523
  * Calculates the weighted average APY across all pools based on USD value.
524
524
  * @returns {Promise<number>} The weighted average APY across all pools
525
525
  */
526
- async netAPY(): Promise<number> {
526
+ async netAPY(): Promise<APYInfo > {
527
527
  const { data: pools } = await this.getPools();
528
- return this.netAPYGivenPools(pools);
528
+ return {
529
+ net: await this.netAPYGivenPools(pools),
530
+ splits: []
531
+ };
529
532
  }
530
533
 
531
534
  /**
@@ -763,17 +766,10 @@ export class VesuRebalance extends BaseStrategy<
763
766
  return [baseFlow];
764
767
  }
765
768
 
766
- async getPendingRewards(): Promise<HarvestInfo[]> {
767
- const vesuHarvests = new VesuHarvests(this.config);
768
- return await vesuHarvests.getUnHarvestedRewards(this.address);
769
- }
770
-
771
- async harvest(acc: Account) {
772
- const pendingRewards = await this.getPendingRewards();
773
- if (pendingRewards.length == 0) {
774
- throw new Error(`No pending rewards found`);
775
- }
776
- const harvest = pendingRewards[0];
769
+ async harvest(acc: Account, endpoint = VESU_REWARDS_ENDPOINT) {
770
+ const vesuHarvest = new VesuHarvests(this.config);
771
+ const harvests = await vesuHarvest.getUnHarvestedRewards(this.address, endpoint);
772
+ const harvest = harvests[0];
777
773
  const avnu = new AvnuWrapper();
778
774
  let swapInfo: SwapInfo = {
779
775
  token_from_address: harvest.token.address,
@@ -1014,8 +1010,8 @@ export const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[]
1014
1010
  investmentSteps: []
1015
1011
  },
1016
1012
  {
1017
- name: "Vesu Fusion USDC.e",
1018
- description: _description.replace("{{TOKEN}}", "USDC.e"),
1013
+ name: "Vesu Fusion USDC",
1014
+ description: _description.replace("{{TOKEN}}", "USDC"),
1019
1015
  address: ContractAddr.from(
1020
1016
  "0xa858c97e9454f407d1bd7c57472fc8d8d8449a777c822b41d18e387816f29c"
1021
1017
  ),
@@ -1023,7 +1019,7 @@ export const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[]
1023
1019
  type: "ERC4626",
1024
1020
  auditUrl: AUDIT_URL,
1025
1021
  depositTokens: [
1026
- Global.getDefaultTokens().find((t) => t.symbol === "USDC.e")!
1022
+ Global.getDefaultTokens().find((t) => t.symbol === "USDC")!
1027
1023
  ],
1028
1024
  protocols: [_protocol],
1029
1025
  maxTVL: Web3Number.fromWei("0", 6),
@@ -1,5 +1,6 @@
1
1
  import { Web3Number } from "@/dataTypes";
2
2
  import { TokenInfo } from "@/interfaces";
3
+ import { logger } from "@/utils/logger";
3
4
 
4
5
  export class HealthFactorMath {
5
6
  static getCollateralRequired(
@@ -52,13 +53,18 @@ export class HealthFactorMath {
52
53
  debtTokenInfo: TokenInfo
53
54
  ) {
54
55
  // lets say debt usd value is X
55
- // HF = ((1 * cp) + X) * maxLTV / (X)
56
- // => X * HF = ((1 * cp) + X) * maxLTV
57
- // => X * (HF - maxLTV) = 1 * cp * maxLTV
58
- // => X = 1 * cp * maxLTV / (HF - maxLTV)
56
+ // HF = ((ca * cp) + X) * maxLTV / (X)
57
+ // => X * HF = ((ca * cp) + X) * maxLTV
58
+ // => X * (HF - maxLTV) = ca * cp * maxLTV
59
+ // => X = ca * cp * maxLTV / (HF - maxLTV)
59
60
  const numerator = collateralAmount.multipliedBy(collateralPrice).multipliedBy(maxLTV);
61
+ logger.verbose(`HealthFactorMath: Max debt amount on looping numerator: ${numerator.toNumber()}, collateralAmount: ${collateralAmount.toNumber()}, collateralPrice: ${collateralPrice}, maxLTV: ${maxLTV}, targetHF: ${targetHF}, debtPrice: ${debtPrice}`);
60
62
  const denominator = targetHF - maxLTV;
61
- const debtAmount = numerator.dividedBy(denominator);
63
+ logger.verbose(`HealthFactorMath: Max debt amount on looping denominator: ${denominator}`);
64
+ const debtAmountUSD = numerator.dividedBy(denominator);
65
+ logger.verbose(`HealthFactorMath: Max debt amount on looping debtAmountUSD: ${debtAmountUSD.toNumber()}`);
66
+ const debtAmount = debtAmountUSD.dividedBy(debtPrice);
67
+ logger.verbose(`HealthFactorMath: Max debt amount on looping debtAmount: ${debtAmount.toNumber()}`);
62
68
  return new Web3Number(debtAmount.toString(), debtTokenInfo.decimals);
63
69
  }
64
70