@strkfarm/sdk 2.0.0-dev.43 → 2.0.0-dev.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -104,7 +104,7 @@ var Web3Number = class _Web3Number2 extends _Web3Number {
104
104
  [util.inspect.custom](depth, opts) {
105
105
  return this.toString();
106
106
  }
107
- [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](depth, inspectOptions, inspect) {
107
+ [Symbol.for("nodejs.util.inspect.custom")](depth, inspectOptions, inspect) {
108
108
  return this.toString();
109
109
  }
110
110
  inspect(depth, opts) {
@@ -155,7 +155,7 @@ var ContractAddr = class _ContractAddr {
155
155
  // src/dataTypes/mynumber.ts
156
156
  import BigNumber2 from "bignumber.js";
157
157
  import { ethers } from "ethers";
158
- var customInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
158
+ var customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
159
159
  BigNumber2.config({
160
160
  DECIMAL_PLACES: 18
161
161
  });
@@ -164,16 +164,16 @@ var MyNumber = class _MyNumber {
164
164
  this.bigNumber = new BigNumber2(bigNumber);
165
165
  this.decimals = decimals;
166
166
  }
167
- static fromEther(num16, decimals) {
167
+ static fromEther(num17, decimals) {
168
168
  try {
169
169
  return new _MyNumber(
170
170
  Number(
171
- ethers.parseUnits(Number(num16).toFixed(10), decimals)
171
+ ethers.parseUnits(Number(num17).toFixed(10), decimals)
172
172
  ).toFixed(6),
173
173
  decimals
174
174
  );
175
175
  } catch (e) {
176
- console.error("fromEther", e, num16, decimals);
176
+ console.error("fromEther", e, num17, decimals);
177
177
  throw e;
178
178
  }
179
179
  }
@@ -373,7 +373,7 @@ var getStackFromMeta = (stack, meta) => {
373
373
  if (typeof stack === "string" && stack.length > 0) {
374
374
  return stack;
375
375
  }
376
- const splat = meta[/* @__PURE__ */ Symbol.for("splat")];
376
+ const splat = meta[Symbol.for("splat")];
377
377
  if (Array.isArray(splat)) {
378
378
  for (const item of splat) {
379
379
  if (item instanceof Error && item.stack) {
@@ -447,7 +447,7 @@ function configureLogger(config = {}) {
447
447
  out += ` stack="${escapeValue(stripAnsi(derivedStack))}"`;
448
448
  }
449
449
  const metaCopy = { ...meta };
450
- delete metaCopy[/* @__PURE__ */ Symbol.for("splat")];
450
+ delete metaCopy[Symbol.for("splat")];
451
451
  if (Object.keys(metaCopy).length > 0) {
452
452
  out += ` meta=${escapeValue(stringifyUnknown(metaCopy))}`;
453
453
  }
@@ -466,283 +466,510 @@ function configureLogger(config = {}) {
466
466
  }
467
467
  configureLogger();
468
468
 
469
+ // src/interfaces/lending.ts
470
+ var MarginType = /* @__PURE__ */ ((MarginType2) => {
471
+ MarginType2["SHARED"] = "shared";
472
+ MarginType2["NONE"] = "none";
473
+ return MarginType2;
474
+ })(MarginType || {});
475
+ var ILending = class {
476
+ constructor(config, metadata) {
477
+ this.tokens = [];
478
+ this.initialised = false;
479
+ this.metadata = metadata;
480
+ this.config = config;
481
+ this.init();
482
+ }
483
+ /** Wait for initialisation */
484
+ waitForInitilisation() {
485
+ return new Promise((resolve, reject) => {
486
+ const interval = setInterval(() => {
487
+ logger.verbose(`Waiting for ${this.metadata.name} to initialise`);
488
+ if (this.initialised) {
489
+ logger.verbose(`${this.metadata.name} initialised`);
490
+ clearInterval(interval);
491
+ resolve();
492
+ }
493
+ }, 1e3);
494
+ });
495
+ }
496
+ };
497
+
498
+ // src/interfaces/common.tsx
499
+ import { BlockTag, RpcProvider } from "starknet";
500
+ import { Fragment, jsx } from "react/jsx-runtime";
501
+ var RiskType = /* @__PURE__ */ ((RiskType2) => {
502
+ RiskType2["MARKET_RISK"] = "Market Risk";
503
+ RiskType2["IMPERMANENT_LOSS"] = "Impermanent Loss Risk";
504
+ RiskType2["LIQUIDATION_RISK"] = "Liquidation Risk";
505
+ RiskType2["LOW_LIQUIDITY_RISK"] = "Low Liquidity Risk";
506
+ RiskType2["SMART_CONTRACT_RISK"] = "Smart Contract Risk";
507
+ RiskType2["ORACLE_RISK"] = "Oracle Risk";
508
+ RiskType2["TECHNICAL_RISK"] = "Technical Risk";
509
+ RiskType2["COUNTERPARTY_RISK"] = "Counterparty Risk";
510
+ RiskType2["DEPEG_RISK"] = "Depeg Risk";
511
+ return RiskType2;
512
+ })(RiskType || {});
513
+ var TokenIndexingType = /* @__PURE__ */ ((TokenIndexingType2) => {
514
+ TokenIndexingType2["PEGGED"] = "pegged";
515
+ TokenIndexingType2["INDEXER"] = "indexer";
516
+ TokenIndexingType2["LST_SCRIPT"] = "lstScript";
517
+ TokenIndexingType2["IGNORE"] = "ignore";
518
+ return TokenIndexingType2;
519
+ })(TokenIndexingType || {});
520
+ var Network = /* @__PURE__ */ ((Network2) => {
521
+ Network2["mainnet"] = "mainnet";
522
+ Network2["sepolia"] = "sepolia";
523
+ Network2["devnet"] = "devnet";
524
+ return Network2;
525
+ })(Network || {});
526
+ var StrategyTag = /* @__PURE__ */ ((StrategyTag3) => {
527
+ StrategyTag3["META_VAULT"] = "Meta Vaults";
528
+ StrategyTag3["LEVERED"] = "Maxx";
529
+ StrategyTag3["AUTOMATED_LP"] = "Ekubo";
530
+ StrategyTag3["BTC"] = "BTC";
531
+ return StrategyTag3;
532
+ })(StrategyTag || {});
533
+ var VaultType = /* @__PURE__ */ ((VaultType2) => {
534
+ VaultType2["LOOPING"] = "Looping";
535
+ VaultType2["META_VAULT"] = "Meta Vault";
536
+ VaultType2["DELTA_NEUTRAL"] = "Delta Neutral";
537
+ VaultType2["AUTOMATED_LP"] = "Automated LP";
538
+ VaultType2["TVA"] = "Troves Value Averaging";
539
+ return VaultType2;
540
+ })(VaultType || {});
541
+ var AuditStatus = /* @__PURE__ */ ((AuditStatus2) => {
542
+ AuditStatus2["AUDITED"] = "Audited";
543
+ AuditStatus2["NOT_AUDITED"] = "Not Audited";
544
+ return AuditStatus2;
545
+ })(AuditStatus || {});
546
+ var SourceCodeType = /* @__PURE__ */ ((SourceCodeType2) => {
547
+ SourceCodeType2["OPEN_SOURCE"] = "Open Source";
548
+ SourceCodeType2["CLOSED_SOURCE"] = "Closed Source";
549
+ return SourceCodeType2;
550
+ })(SourceCodeType || {});
551
+ var AccessControlType = /* @__PURE__ */ ((AccessControlType2) => {
552
+ AccessControlType2["MULTISIG_ACCOUNT"] = "Multisig Account";
553
+ AccessControlType2["STANDARD_ACCOUNT"] = "Standard Account";
554
+ AccessControlType2["ROLE_BASED_ACCESS"] = "Role Based Access";
555
+ return AccessControlType2;
556
+ })(AccessControlType || {});
557
+ var InstantWithdrawalVault = /* @__PURE__ */ ((InstantWithdrawalVault2) => {
558
+ InstantWithdrawalVault2["YES"] = "Yes";
559
+ InstantWithdrawalVault2["NO"] = "No";
560
+ return InstantWithdrawalVault2;
561
+ })(InstantWithdrawalVault || {});
562
+ var FlowChartColors = /* @__PURE__ */ ((FlowChartColors2) => {
563
+ FlowChartColors2["Green"] = "purple";
564
+ FlowChartColors2["Blue"] = "#35484f";
565
+ FlowChartColors2["Purple"] = "#6e53dc";
566
+ return FlowChartColors2;
567
+ })(FlowChartColors || {});
568
+ var StrategyLiveStatus = /* @__PURE__ */ ((StrategyLiveStatus2) => {
569
+ StrategyLiveStatus2["ACTIVE"] = "Active";
570
+ StrategyLiveStatus2["NEW"] = "New";
571
+ StrategyLiveStatus2["COMING_SOON"] = "Coming Soon";
572
+ StrategyLiveStatus2["DEPRECATED"] = "Deprecated";
573
+ StrategyLiveStatus2["RETIRED"] = "Retired";
574
+ StrategyLiveStatus2["HOT"] = "Hot & New \u{1F525}";
575
+ return StrategyLiveStatus2;
576
+ })(StrategyLiveStatus || {});
577
+ function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier = BlockTag.LATEST) {
578
+ return {
579
+ provider: new RpcProvider({
580
+ nodeUrl: rpcUrl,
581
+ blockIdentifier
582
+ // specVersion
583
+ }),
584
+ stage: "production",
585
+ network: "mainnet" /* mainnet */
586
+ };
587
+ }
588
+ var getStrategyTagDesciption = (tag) => {
589
+ switch (tag) {
590
+ case "Meta Vaults" /* META_VAULT */:
591
+ return "A meta vault is a vault that auto allocates funds to multiple vaults based on optimal yield opportunities";
592
+ case "Maxx" /* LEVERED */:
593
+ return "Looping vaults on Endur LSTs with leveraged borrowing of STRK or BTC to increase yield (2-4x higher yield than simply staking)";
594
+ case "Ekubo" /* AUTOMATED_LP */:
595
+ return "Automated LP vaults on Ekubo that rebalance position automatically, ensuring you earn fees efficiently";
596
+ case "BTC" /* BTC */:
597
+ return "BTC linked vaults";
598
+ }
599
+ };
600
+ var getAllStrategyTags = () => {
601
+ return Object.values(StrategyTag);
602
+ };
603
+ var getRiskExplaination = (riskType) => {
604
+ switch (riskType) {
605
+ case "Market Risk" /* MARKET_RISK */:
606
+ return "The risk of the market moving against the position.";
607
+ case "Impermanent Loss Risk" /* IMPERMANENT_LOSS */:
608
+ return "The temporary loss of value experienced by liquidity providers in AMMs when asset prices diverge compared to simply holding them.";
609
+ case "Liquidation Risk" /* LIQUIDATION_RISK */:
610
+ return "The risk of losing funds due to the position being liquidated.";
611
+ case "Low Liquidity Risk" /* LOW_LIQUIDITY_RISK */:
612
+ return "The risk of low liquidity in the pool, which can lead to high slippages or reduced in-abilities to quickly exit the position.";
613
+ case "Oracle Risk" /* ORACLE_RISK */:
614
+ return "The risk of the oracle being manipulated or incorrect.";
615
+ case "Smart Contract Risk" /* SMART_CONTRACT_RISK */:
616
+ return "The risk of the smart contract being vulnerable to attacks.";
617
+ case "Technical Risk" /* TECHNICAL_RISK */:
618
+ return "The risk of technical issues e.g. backend failure.";
619
+ case "Counterparty Risk" /* COUNTERPARTY_RISK */:
620
+ return "The risk of the counterparty defaulting e.g. bad debt on lending platforms.";
621
+ case "Depeg Risk" /* DEPEG_RISK */:
622
+ return "The risk of a token losing its peg to the underlying asset, leading to potential losses for holders.";
623
+ }
624
+ };
625
+ var getRiskColor = (risk) => {
626
+ const value = risk.value;
627
+ if (value <= 2) return "light_green_2";
628
+ if (value < 3) return "yellow";
629
+ return "red";
630
+ };
631
+ var getNoRiskTags = (risks) => {
632
+ const noRisks1 = risks.filter((risk) => risk.value === 0).map((risk) => risk.type);
633
+ const noRisks2 = Object.values(RiskType).filter(
634
+ (risk) => !risks.map((risk2) => risk2.type).includes(risk)
635
+ );
636
+ const mergedUnique = [.../* @__PURE__ */ new Set([...noRisks1, ...noRisks2])];
637
+ return mergedUnique;
638
+ };
639
+ function highlightTextWithLinks(put, highlights) {
640
+ const escapeRegExp = (text) => text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
641
+ const pattern = new RegExp(
642
+ `(${highlights.map((m) => escapeRegExp(m.highlight)).join("|")})`,
643
+ "gi"
644
+ );
645
+ const parts = put.split(pattern);
646
+ return /* @__PURE__ */ jsx(Fragment, { children: parts.map((part, i) => {
647
+ const match = highlights.find((m) => m.highlight.toLowerCase() === part.toLowerCase());
648
+ return match ? /* @__PURE__ */ jsx("a", { href: match.link, target: "_blank", style: { color: "white", background: "rgba(255, 255, 255, 0.04)" }, children: part }, i) : /* @__PURE__ */ jsx("span", { children: part }, i);
649
+ }) });
650
+ }
651
+ var VesuProtocol = {
652
+ name: "Vesu",
653
+ logo: "https://static-assets-8zct.onrender.com/integrations/vesu/logo.png"
654
+ };
655
+ var AvnuProtocol = {
656
+ name: "Avnu",
657
+ logo: "https://static-assets-8zct.onrender.com/integrations/avnu/logo.png"
658
+ };
659
+ var EndurProtocol = {
660
+ name: "Endur",
661
+ logo: "http://endur.fi/logo.png"
662
+ };
663
+ var ExtendedProtocol = {
664
+ name: "Extended",
665
+ logo: "https://static-assets-8zct.onrender.com/integrations/extended/extended.svg"
666
+ };
667
+ var EkuboProtocol = {
668
+ name: "Ekubo",
669
+ logo: "https://app.ekubo.org/favicon.ico"
670
+ };
671
+ var NoneProtocol = {
672
+ name: "-",
673
+ logo: ""
674
+ };
675
+ var VaultProtocol = {
676
+ name: "Vault",
677
+ logo: ""
678
+ };
679
+ var TrovesProtocol = {
680
+ name: "Troves",
681
+ logo: "https://app.troves.fi/favicon.ico"
682
+ };
683
+ var Protocols = {
684
+ NONE: NoneProtocol,
685
+ VESU: VesuProtocol,
686
+ ENDUR: EndurProtocol,
687
+ EXTENDED: ExtendedProtocol,
688
+ EKUBO: EkuboProtocol,
689
+ AVNU: AvnuProtocol,
690
+ VAULT: VaultProtocol,
691
+ TROVES: TrovesProtocol
692
+ };
693
+ var UnwrapLabsCurator = {
694
+ name: "Unwrap Labs",
695
+ logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
696
+ };
697
+
698
+ // src/interfaces/initializable.ts
699
+ var Initializable = class {
700
+ constructor() {
701
+ this.initialized = false;
702
+ }
703
+ async waitForInitilisation() {
704
+ return new Promise((resolve, reject) => {
705
+ const interval = setInterval(() => {
706
+ if (this.initialized) {
707
+ console.log("Initialised");
708
+ clearInterval(interval);
709
+ resolve();
710
+ }
711
+ }, 1e3);
712
+ });
713
+ }
714
+ };
715
+
469
716
  // src/global.ts
470
717
  var FatalError = class extends Error {
471
718
  constructor(message, err) {
472
719
  super(message);
473
720
  logger.error(message);
474
- if (err) logger.error(err.message);
721
+ if (err)
722
+ logger.error(err.message);
475
723
  this.name = "FatalError";
476
724
  }
477
725
  };
478
- var defaultTokens = [
479
- {
480
- name: "Starknet",
481
- symbol: "STRK",
482
- logo: "https://assets.troves.fi/integrations/tokens/strk.svg",
483
- address: ContractAddr.from(
484
- "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"
485
- ),
486
- decimals: 18,
487
- coingeckId: "starknet",
488
- displayDecimals: 2,
489
- priceCheckAmount: 1e3
490
- },
491
- {
492
- name: "xSTRK",
493
- symbol: "xSTRK",
494
- logo: "https://assets.troves.fi/integrations/tokens/xstrk.svg",
495
- address: ContractAddr.from(
496
- "0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
497
- ),
498
- decimals: 18,
499
- coingeckId: void 0,
500
- priceCheckAmount: 1e3,
501
- displayDecimals: 2
502
- },
503
- {
504
- name: "ETH",
505
- symbol: "ETH",
506
- logo: "https://assets.troves.fi/integrations/tokens/eth.svg",
507
- address: ContractAddr.from(
508
- "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
509
- ),
510
- decimals: 18,
511
- coingeckId: void 0,
512
- priceCheckAmount: 0.1,
513
- displayDecimals: 6
514
- },
515
- {
516
- name: "USDC.e",
517
- symbol: "USDC.e",
518
- logo: "https://assets.troves.fi/integrations/tokens/usdc.svg",
519
- address: ContractAddr.from("0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8"),
520
- decimals: 6,
521
- coingeckId: void 0,
522
- displayDecimals: 2,
523
- priceCheckAmount: 1e3,
524
- priceProxySymbol: "USDC"
525
- },
526
- {
527
- name: "USDC",
528
- symbol: "USDC",
529
- logo: "https://assets.troves.fi/integrations/tokens/usdc.svg",
530
- address: ContractAddr.from("0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb"),
531
- decimals: 6,
532
- coingeckId: void 0,
533
- displayDecimals: 2,
534
- priceCheckAmount: 1e3
535
- },
536
- {
537
- name: "USDT",
538
- symbol: "USDT",
539
- logo: "https://assets.troves.fi/integrations/tokens/usdt.svg",
540
- address: ContractAddr.from(
541
- "0x68f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8"
542
- ),
543
- decimals: 6,
544
- coingeckId: void 0,
545
- priceCheckAmount: 1e3,
546
- displayDecimals: 2
547
- },
548
- {
549
- name: "WBTC",
550
- symbol: "WBTC",
551
- logo: "https://assets.troves.fi/integrations/tokens/wbtc.svg",
552
- address: ContractAddr.from(
553
- "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac"
554
- ),
555
- decimals: 8,
556
- coingeckId: void 0,
557
- displayDecimals: 6,
558
- priceCheckAmount: 1e-3
559
- // 112000 * 0.0001 = $110.2
560
- },
561
- {
562
- name: "tBTC",
563
- symbol: "tBTC",
564
- logo: "https://assets.strkfarm.com/integrations/tokens/tbtc.svg",
565
- address: ContractAddr.from(
566
- "0x4daa17763b286d1e59b97c283c0b8c949994c361e426a28f743c67bdfe9a32f"
567
- ),
568
- decimals: 18,
569
- coingeckId: void 0,
570
- displayDecimals: 6,
571
- priceCheckAmount: 1e-3
572
- // 112000 * 0.0001 = $110.2
573
- },
574
- {
575
- name: "solvBTC",
576
- symbol: "solvBTC",
577
- logo: "https://assets.strkfarm.com/integrations/tokens/solvbtc.svg",
578
- address: ContractAddr.from(
579
- "0x0593e034dda23eea82d2ba9a30960ed42cf4a01502cc2351dc9b9881f9931a68"
580
- ),
581
- decimals: 18,
582
- coingeckId: void 0,
583
- priceProxySymbol: "WBTC",
584
- displayDecimals: 6,
585
- priceCheckAmount: 1e-4
586
- // 112000 * 0.0001 = $11.2
587
- },
588
- {
589
- name: "LBTC",
590
- symbol: "LBTC",
591
- logo: "https://assets.strkfarm.com/integrations/tokens/lbtc.svg",
592
- address: ContractAddr.from(
593
- "0x036834a40984312f7f7de8d31e3f6305b325389eaeea5b1c0664b2fb936461a4"
594
- ),
595
- decimals: 8,
596
- coingeckId: void 0,
597
- displayDecimals: 6,
598
- priceProxySymbol: "WBTC",
599
- priceCheckAmount: 1e-4
600
- // 112000 * 0.0001 = $11.2
601
- },
602
- {
603
- name: "xWBTC",
604
- symbol: "xWBTC",
605
- logo: "https://assets.strkfarm.com/integrations/tokens/xwbtc.svg",
606
- address: ContractAddr.from(
607
- "0x6a567e68c805323525fe1649adb80b03cddf92c23d2629a6779f54192dffc13"
608
- ),
609
- decimals: 8,
610
- coingeckId: void 0,
611
- displayDecimals: 6,
612
- priceProxySymbol: "WBTC",
613
- priceCheckAmount: 1e-3
614
- // 112000 * 0.0001 = $110.2
615
- },
616
- {
617
- name: "xsBTC",
618
- symbol: "xsBTC",
619
- logo: "https://assets.strkfarm.com/integrations/tokens/xsbtc_solv.svg",
620
- address: ContractAddr.from(
621
- "0x580f3dc564a7b82f21d40d404b3842d490ae7205e6ac07b1b7af2b4a5183dc9"
622
- ),
623
- decimals: 18,
624
- coingeckId: void 0,
625
- displayDecimals: 6,
626
- priceProxySymbol: "WBTC",
627
- priceCheckAmount: 1e-4
628
- // 112000 * 0.0001 = $11.2
629
- },
630
- {
631
- // todo upgrade proxy tokens once feeds are available
632
- name: "xtBTC",
633
- symbol: "xtBTC",
634
- logo: "https://assets.strkfarm.com/integrations/tokens/xtbtc.svg",
635
- address: ContractAddr.from(
636
- "0x43a35c1425a0125ef8c171f1a75c6f31ef8648edcc8324b55ce1917db3f9b91"
637
- ),
638
- decimals: 18,
639
- coingeckId: void 0,
640
- displayDecimals: 6,
641
- priceCheckAmount: 1e-3,
642
- // 112000 * 0.0001 = $110.2
643
- priceProxySymbol: "WBTC"
644
- },
645
- {
646
- name: "xLBTC",
647
- symbol: "xLBTC",
648
- logo: "https://assets.strkfarm.com/integrations/tokens/xlbtc.svg",
649
- address: ContractAddr.from("0x07dd3c80de9fcc5545f0cb83678826819c79619ed7992cc06ff81fc67cd2efe0"),
650
- decimals: 8,
651
- coingeckId: void 0,
652
- displayDecimals: 6,
653
- priceProxySymbol: "WBTC",
654
- priceCheckAmount: 1e-4
655
- // 112000 * 0.0001 = $11.2
656
- },
657
- {
658
- name: "mRe7BTC",
659
- symbol: "mRe7BTC",
660
- logo: "https://imagedelivery.net/0xPAQaDtnQhBs8IzYRIlNg/3a62ecee-1e58-45d3-9862-3ce90dff1900/logo",
661
- address: ContractAddr.from(
662
- "0x4e4fb1a9ca7e84bae609b9dc0078ad7719e49187ae7e425bb47d131710eddac"
663
- ),
664
- decimals: 18,
665
- coingeckId: void 0,
666
- displayDecimals: 6,
667
- priceCheckAmount: 1e-4,
668
- // 112000 * 0.0001 = $11.2
669
- dontPrice: true
670
- },
671
- {
672
- name: "mRe7YIELD",
673
- symbol: "mRe7YIELD",
674
- logo: "https://midas.app/assets/mre7-BcOOHm7i.svg",
675
- address: ContractAddr.from("0x4be8945e61dc3e19ebadd1579a6bd53b262f51ba89e6f8b0c4bc9a7e3c633fc"),
676
- decimals: 18,
677
- coingeckId: void 0,
678
- displayDecimals: 2,
679
- priceCheckAmount: 100,
680
- dontPrice: true
681
- },
682
- {
683
- name: "fyWBTC",
684
- symbol: "fyWBTC",
685
- logo: "https://assets.strkfarm.com/integrations/tokens/wbtc.svg",
686
- address: ContractAddr.from("0x04dd39de0a588f5e1c7a8377e1bef2c49caaee49a11433429d2c48f587b3a492"),
687
- decimals: 8,
688
- coingeckId: void 0,
689
- displayDecimals: 6,
690
- priceCheckAmount: 1e-3,
691
- // 112000 * 0.0001 = $110.2
692
- dontPrice: true
693
- },
694
- {
695
- name: "fyETH",
696
- symbol: "fyETH",
697
- logo: "https://assets.strkfarm.com/integrations/tokens/eth.svg",
698
- address: ContractAddr.from("0x050707bC3b8730022F10530C2c6f6b9467644129C50C2868Ad0036c5e4E9e616"),
699
- decimals: 18,
700
- coingeckId: void 0,
701
- displayDecimals: 4,
702
- priceCheckAmount: 0.1,
703
- dontPrice: true
704
- },
705
- {
706
- name: "fyUSDC",
707
- symbol: "fyUSDC",
708
- logo: "https://assets.strkfarm.com/integrations/tokens/usdc.svg",
709
- address: ContractAddr.from("0x07fdcec0cef01294c9c3d52415215949805c77bae8003702a7928fd6d2c36bc1"),
710
- decimals: 6,
711
- coingeckId: void 0,
712
- displayDecimals: 2,
713
- priceCheckAmount: 100,
714
- dontPrice: true
715
- },
716
- {
717
- name: "strkBTC",
718
- symbol: "strkBTC",
719
- logo: "https://assets.troves.fi/integrations/tokens/strkbtc.svg",
720
- address: ContractAddr.from("0x0787150e306e6eae6e3f79dea881770e8bbff2c1b8eb490f969669ee945b3135"),
721
- decimals: 8,
722
- coingeckId: void 0,
723
- displayDecimals: 6,
724
- priceCheckAmount: 1e-3,
725
- // 112000 * 0.0001 = $110.2
726
- priceProxySymbol: "WBTC"
727
- },
728
- {
729
- name: "xstrkBTC",
730
- symbol: "xstrkBTC",
731
- logo: "https://assets.troves.fi/integrations/tokens/xstrkbtc.svg",
732
- address: ContractAddr.from("0x047751b3532fabca89b0f2e35ca1cb45e5a7b11d5e3d3663dfa1f4406b45fd88"),
733
- decimals: 8,
734
- coingeckId: void 0,
735
- displayDecimals: 6,
736
- priceCheckAmount: 1e-3,
737
- priceProxySymbol: "WBTC"
738
- }
739
- ];
726
+ var defaultTokens = [{
727
+ name: "Starknet",
728
+ symbol: "STRK",
729
+ logo: "https://assets.troves.fi/integrations/tokens/strk.svg",
730
+ address: ContractAddr.from("0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"),
731
+ decimals: 18,
732
+ coingeckId: "starknet",
733
+ displayDecimals: 2,
734
+ priceCheckAmount: 5e3,
735
+ priceMethod: "Avnu",
736
+ indexingType: "indexer" /* INDEXER */
737
+ }, {
738
+ name: "xSTRK",
739
+ symbol: "xSTRK",
740
+ logo: "https://assets.troves.fi/integrations/tokens/xstrk.svg",
741
+ address: ContractAddr.from("0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"),
742
+ decimals: 18,
743
+ coingeckId: void 0,
744
+ priceCheckAmount: 5e3,
745
+ displayDecimals: 2,
746
+ priceMethod: "Avnu",
747
+ indexingType: "lstScript" /* LST_SCRIPT */
748
+ }, {
749
+ name: "ETH",
750
+ symbol: "ETH",
751
+ logo: "https://assets.troves.fi/integrations/tokens/eth.svg",
752
+ address: ContractAddr.from("0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"),
753
+ decimals: 18,
754
+ coingeckId: void 0,
755
+ priceCheckAmount: 0.1,
756
+ displayDecimals: 6,
757
+ indexingType: "indexer" /* INDEXER */
758
+ }, {
759
+ name: "USDC.e",
760
+ symbol: "USDC.e",
761
+ logo: "https://assets.troves.fi/integrations/tokens/usdc.svg",
762
+ address: ContractAddr.from("0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8"),
763
+ decimals: 6,
764
+ coingeckId: void 0,
765
+ displayDecimals: 2,
766
+ priceCheckAmount: 1e3,
767
+ priceProxySymbol: "USDC",
768
+ indexingType: "pegged" /* PEGGED */
769
+ }, {
770
+ name: "USDC",
771
+ symbol: "USDC",
772
+ logo: "https://assets.troves.fi/integrations/tokens/usdc.svg",
773
+ address: ContractAddr.from("0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb"),
774
+ decimals: 6,
775
+ coingeckId: void 0,
776
+ displayDecimals: 2,
777
+ priceCheckAmount: 1e3,
778
+ indexingType: "indexer" /* INDEXER */
779
+ }, {
780
+ name: "USDT",
781
+ symbol: "USDT",
782
+ logo: "https://assets.troves.fi/integrations/tokens/usdt.svg",
783
+ address: ContractAddr.from("0x68f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8"),
784
+ decimals: 6,
785
+ coingeckId: void 0,
786
+ priceCheckAmount: 1e3,
787
+ displayDecimals: 2,
788
+ indexingType: "indexer" /* INDEXER */
789
+ }, {
790
+ name: "WBTC",
791
+ symbol: "WBTC",
792
+ logo: "https://assets.troves.fi/integrations/tokens/wbtc.svg",
793
+ address: ContractAddr.from("0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac"),
794
+ decimals: 8,
795
+ coingeckId: void 0,
796
+ displayDecimals: 6,
797
+ priceCheckAmount: 1e-3,
798
+ // 112000 * 0.0001 = $110.2
799
+ indexingType: "indexer" /* INDEXER */
800
+ }, {
801
+ name: "tBTC",
802
+ symbol: "tBTC",
803
+ logo: "https://assets.strkfarm.com/integrations/tokens/tbtc.svg",
804
+ address: ContractAddr.from("0x4daa17763b286d1e59b97c283c0b8c949994c361e426a28f743c67bdfe9a32f"),
805
+ decimals: 18,
806
+ coingeckId: void 0,
807
+ displayDecimals: 6,
808
+ priceCheckAmount: 1e-3,
809
+ // 112000 * 0.0001 = $110.2
810
+ priceProxySymbol: "WBTC",
811
+ indexingType: "pegged" /* PEGGED */
812
+ }, {
813
+ name: "solvBTC",
814
+ symbol: "solvBTC",
815
+ logo: "https://assets.strkfarm.com/integrations/tokens/solvbtc.svg",
816
+ address: ContractAddr.from("0x0593e034dda23eea82d2ba9a30960ed42cf4a01502cc2351dc9b9881f9931a68"),
817
+ decimals: 18,
818
+ coingeckId: void 0,
819
+ priceProxySymbol: "WBTC",
820
+ displayDecimals: 6,
821
+ priceCheckAmount: 1e-4,
822
+ // 112000 * 0.0001 = $11.2
823
+ indexingType: "pegged" /* PEGGED */
824
+ }, {
825
+ name: "LBTC",
826
+ symbol: "LBTC",
827
+ logo: "https://assets.strkfarm.com/integrations/tokens/lbtc.svg",
828
+ address: ContractAddr.from("0x036834a40984312f7f7de8d31e3f6305b325389eaeea5b1c0664b2fb936461a4"),
829
+ decimals: 8,
830
+ coingeckId: void 0,
831
+ displayDecimals: 6,
832
+ priceProxySymbol: "WBTC",
833
+ priceCheckAmount: 1e-4,
834
+ // 112000 * 0.0001 = $11.2
835
+ indexingType: "pegged" /* PEGGED */
836
+ }, {
837
+ name: "xWBTC",
838
+ symbol: "xWBTC",
839
+ logo: "https://assets.strkfarm.com/integrations/tokens/xwbtc.svg",
840
+ address: ContractAddr.from("0x6a567e68c805323525fe1649adb80b03cddf92c23d2629a6779f54192dffc13"),
841
+ decimals: 8,
842
+ coingeckId: void 0,
843
+ displayDecimals: 6,
844
+ priceCheckAmount: 1e-3,
845
+ // 112000 * 0.0001 = $110.2
846
+ priceMethod: "Avnu",
847
+ indexingType: "lstScript" /* LST_SCRIPT */
848
+ }, {
849
+ name: "xsBTC",
850
+ symbol: "xsBTC",
851
+ logo: "https://assets.strkfarm.com/integrations/tokens/xsbtc_solv.svg",
852
+ address: ContractAddr.from("0x580f3dc564a7b82f21d40d404b3842d490ae7205e6ac07b1b7af2b4a5183dc9"),
853
+ decimals: 18,
854
+ coingeckId: void 0,
855
+ displayDecimals: 6,
856
+ priceCheckAmount: 1e-4,
857
+ // 112000 * 0.0001 = $11.2
858
+ priceMethod: "Avnu",
859
+ indexingType: "lstScript" /* LST_SCRIPT */
860
+ }, {
861
+ name: "xtBTC",
862
+ symbol: "xtBTC",
863
+ logo: "https://assets.strkfarm.com/integrations/tokens/xtbtc.svg",
864
+ address: ContractAddr.from("0x43a35c1425a0125ef8c171f1a75c6f31ef8648edcc8324b55ce1917db3f9b91"),
865
+ decimals: 18,
866
+ coingeckId: void 0,
867
+ displayDecimals: 6,
868
+ priceCheckAmount: 1e-3,
869
+ // 112000 * 0.0001 = $110.2
870
+ priceMethod: "Avnu",
871
+ indexingType: "lstScript" /* LST_SCRIPT */
872
+ }, {
873
+ name: "xLBTC",
874
+ symbol: "xLBTC",
875
+ logo: "https://assets.strkfarm.com/integrations/tokens/xlbtc.svg",
876
+ address: ContractAddr.from("0x07dd3c80de9fcc5545f0cb83678826819c79619ed7992cc06ff81fc67cd2efe0"),
877
+ decimals: 8,
878
+ coingeckId: void 0,
879
+ displayDecimals: 6,
880
+ priceCheckAmount: 1e-4,
881
+ // 112000 * 0.0001 = $11.2
882
+ priceMethod: "Avnu",
883
+ indexingType: "lstScript" /* LST_SCRIPT */
884
+ }, {
885
+ name: "mRe7BTC",
886
+ symbol: "mRe7BTC",
887
+ logo: "https://imagedelivery.net/0xPAQaDtnQhBs8IzYRIlNg/3a62ecee-1e58-45d3-9862-3ce90dff1900/logo",
888
+ address: ContractAddr.from("0x4e4fb1a9ca7e84bae609b9dc0078ad7719e49187ae7e425bb47d131710eddac"),
889
+ decimals: 18,
890
+ coingeckId: void 0,
891
+ displayDecimals: 6,
892
+ priceCheckAmount: 1e-4,
893
+ // 112000 * 0.0001 = $11.2
894
+ dontPrice: true,
895
+ indexingType: "ignore" /* IGNORE */
896
+ }, {
897
+ name: "mRe7YIELD",
898
+ symbol: "mRe7YIELD",
899
+ logo: "https://midas.app/assets/mre7-BcOOHm7i.svg",
900
+ address: ContractAddr.from("0x4be8945e61dc3e19ebadd1579a6bd53b262f51ba89e6f8b0c4bc9a7e3c633fc"),
901
+ decimals: 18,
902
+ coingeckId: void 0,
903
+ displayDecimals: 2,
904
+ priceCheckAmount: 100,
905
+ dontPrice: true,
906
+ indexingType: "ignore" /* IGNORE */
907
+ }, {
908
+ name: "fyeWBTC",
909
+ symbol: "fyeWBTC",
910
+ logo: "https://assets.strkfarm.com/integrations/tokens/wbtc.svg",
911
+ address: ContractAddr.from("0x04dd39de0a588f5e1c7a8377e1bef2c49caaee49a11433429d2c48f587b3a492"),
912
+ decimals: 8,
913
+ coingeckId: void 0,
914
+ displayDecimals: 6,
915
+ priceCheckAmount: 1e-3,
916
+ // 112000 * 0.0001 = $110.2
917
+ dontPrice: true,
918
+ indexingType: "ignore" /* IGNORE */
919
+ }, {
920
+ name: "fyETH",
921
+ symbol: "fyETH",
922
+ logo: "https://assets.strkfarm.com/integrations/tokens/eth.svg",
923
+ address: ContractAddr.from("0x050707bC3b8730022F10530C2c6f6b9467644129C50C2868Ad0036c5e4E9e616"),
924
+ decimals: 18,
925
+ coingeckId: void 0,
926
+ displayDecimals: 4,
927
+ priceCheckAmount: 0.1,
928
+ dontPrice: true,
929
+ indexingType: "ignore" /* IGNORE */
930
+ }, {
931
+ name: "fyeUSDC",
932
+ symbol: "fyeUSDC",
933
+ logo: "https://assets.strkfarm.com/integrations/tokens/usdc.svg",
934
+ address: ContractAddr.from("0x07fdcec0cef01294c9c3d52415215949805c77bae8003702a7928fd6d2c36bc1"),
935
+ decimals: 6,
936
+ coingeckId: void 0,
937
+ displayDecimals: 2,
938
+ priceCheckAmount: 100,
939
+ dontPrice: true,
940
+ indexingType: "ignore" /* IGNORE */
941
+ }, {
942
+ name: "strkBTC",
943
+ symbol: "strkBTC",
944
+ logo: "https://assets.troves.fi/integrations/tokens/strkbtc.svg",
945
+ address: ContractAddr.from("0x0787150e306e6eae6e3f79dea881770e8bbff2c1b8eb490f969669ee945b3135"),
946
+ decimals: 8,
947
+ coingeckId: void 0,
948
+ displayDecimals: 6,
949
+ priceCheckAmount: 1e-3,
950
+ // 112000 * 0.0001 = $110.2
951
+ priceMethod: "Avnu",
952
+ priceProxySymbol: "WBTC",
953
+ indexingType: "pegged" /* PEGGED */
954
+ }, {
955
+ name: "xstrkBTC",
956
+ symbol: "xstrkBTC",
957
+ logo: "https://assets.troves.fi/integrations/tokens/xstrkbtc.svg",
958
+ address: ContractAddr.from("0x047751b3532fabca89b0f2e35ca1cb45e5a7b11d5e3d3663dfa1f4406b45fd88"),
959
+ decimals: 8,
960
+ coingeckId: void 0,
961
+ displayDecimals: 6,
962
+ priceCheckAmount: 1e-3,
963
+ priceMethod: "Avnu",
964
+ indexingType: "lstScript" /* LST_SCRIPT */
965
+ }];
740
966
  var tokens = defaultTokens;
741
967
  var _Global = class _Global {
742
968
  static fatalError(message, err) {
743
969
  logger.error(message);
744
970
  console.error(message, err);
745
- if (err) console.error(err);
971
+ if (err)
972
+ console.error(err);
746
973
  process.exit(1);
747
974
  }
748
975
  static httpError(url, err, message) {
@@ -754,9 +981,7 @@ var _Global = class _Global {
754
981
  }
755
982
  static async getTokens() {
756
983
  if (tokens.length) return tokens;
757
- const data = await axios.get(
758
- "https://assets.troves.fi/integrations/tokens.json"
759
- );
984
+ const data = await axios.get("https://assets.troves.fi/integrations/tokens.json");
760
985
  const tokensData = data.data.content;
761
986
  tokensData.forEach((token) => {
762
987
  if (!token.tags.includes("AVNU") || !token.tags.includes("Verified")) {
@@ -769,7 +994,8 @@ var _Global = class _Global {
769
994
  decimals: token.decimals,
770
995
  logo: token.logoUri,
771
996
  coingeckId: token.extensions.coingeckoId,
772
- displayDecimals: 2
997
+ displayDecimals: 2,
998
+ indexingType: "ignore" /* IGNORE */
773
999
  });
774
1000
  });
775
1001
  console.log(tokens);
@@ -780,25 +1006,25 @@ var _Global = class _Global {
780
1006
  throw new FatalError(message);
781
1007
  }
782
1008
  }
783
- static async getTokenInfoFromName(tokenName) {
1009
+ static async getTokenInfoFromAddr(addr) {
784
1010
  if (tokens.length == defaultTokens.length) {
785
1011
  await _Global.getTokens();
786
1012
  }
787
- const token = tokens.find(
788
- (token2) => token2.name.toLowerCase() === tokenName.toLowerCase()
789
- );
1013
+ const token = tokens.find((token2) => addr.eq(token2.address));
790
1014
  if (!token) {
791
- throw new FatalError(`Token not found: ${tokenName}`);
1015
+ throw new FatalError(`Token not found: ${addr.address}`);
792
1016
  }
793
1017
  return token;
794
1018
  }
795
- static async getTokenInfoFromAddr(addr) {
1019
+ static async getTokenInfoFromName(tokenName) {
796
1020
  if (tokens.length == defaultTokens.length) {
797
1021
  await _Global.getTokens();
798
1022
  }
799
- const token = tokens.find((token2) => addr.eq(token2.address));
1023
+ const token = tokens.find(
1024
+ (token2) => token2.name.toLowerCase() === tokenName.toLowerCase()
1025
+ );
800
1026
  if (!token) {
801
- throw new FatalError(`Token not found: ${addr.address}`);
1027
+ throw new FatalError(`Token not found: ${tokenName}`);
802
1028
  }
803
1029
  return token;
804
1030
  }
@@ -4047,21 +4273,14 @@ var Pricer = class extends PricerBase {
4047
4273
  }
4048
4274
  }
4049
4275
  async _getPrice(token) {
4050
- const pinned = this.methodToUse[token.symbol];
4051
- if (pinned) {
4052
- logger.verbose(`Fetching price of ${token.symbol} using pinned ${pinned}`);
4053
- try {
4054
- return await this._tryPriceMethod(token, pinned);
4055
- } catch (error) {
4056
- console.warn(`${pinned}: pinned price failed [${token.symbol}]: `, error.message);
4057
- delete this.methodToUse[token.symbol];
4058
- }
4059
- }
4060
- for (const method of PRICE_METHOD_PRIORITY) {
4276
+ const methodsToTry = this._getMethodsToTry(token);
4277
+ for (const method of methodsToTry) {
4061
4278
  logger.verbose(`Fetching price of ${token.symbol} using ${method}`);
4062
4279
  try {
4063
4280
  const result = await this._tryPriceMethod(token, method);
4064
- this.methodToUse[token.symbol] = method;
4281
+ if (!token.priceMethod) {
4282
+ this.methodToUse[token.symbol] = method;
4283
+ }
4065
4284
  return result;
4066
4285
  } catch (error) {
4067
4286
  console.warn(`${method}: price err [${token.symbol}]: `, error.message);
@@ -4069,6 +4288,22 @@ var Pricer = class extends PricerBase {
4069
4288
  }
4070
4289
  throw new FatalError(`Price not found for ${token.symbol}`);
4071
4290
  }
4291
+ _getMethodsToTry(token) {
4292
+ const methods = [];
4293
+ if (token.priceMethod) {
4294
+ methods.push(token.priceMethod);
4295
+ }
4296
+ const pinned = this.methodToUse[token.symbol];
4297
+ if (pinned && pinned !== token.priceMethod) {
4298
+ methods.push(pinned);
4299
+ }
4300
+ for (const method of PRICE_METHOD_PRIORITY) {
4301
+ if (!methods.includes(method)) {
4302
+ methods.push(method);
4303
+ }
4304
+ }
4305
+ return methods;
4306
+ }
4072
4307
  async _tryPriceMethod(token, method) {
4073
4308
  switch (method) {
4074
4309
  case "AvnuApi":
@@ -4284,35 +4519,6 @@ var Web3Number2 = class _Web3Number2 extends _Web3Number {
4284
4519
  }
4285
4520
  };
4286
4521
 
4287
- // src/interfaces/lending.ts
4288
- var MarginType = /* @__PURE__ */ ((MarginType2) => {
4289
- MarginType2["SHARED"] = "shared";
4290
- MarginType2["NONE"] = "none";
4291
- return MarginType2;
4292
- })(MarginType || {});
4293
- var ILending = class {
4294
- constructor(config, metadata) {
4295
- this.tokens = [];
4296
- this.initialised = false;
4297
- this.metadata = metadata;
4298
- this.config = config;
4299
- this.init();
4300
- }
4301
- /** Wait for initialisation */
4302
- waitForInitilisation() {
4303
- return new Promise((resolve, reject) => {
4304
- const interval = setInterval(() => {
4305
- logger.verbose(`Waiting for ${this.metadata.name} to initialise`);
4306
- if (this.initialised) {
4307
- logger.verbose(`${this.metadata.name} initialised`);
4308
- clearInterval(interval);
4309
- resolve();
4310
- }
4311
- }, 1e3);
4312
- });
4313
- }
4314
- };
4315
-
4316
4522
  // src/modules/zkLend.ts
4317
4523
  var _ZkLend = class _ZkLend extends ILending {
4318
4524
  constructor(config, pricer) {
@@ -4343,7 +4549,8 @@ var _ZkLend = class _ZkLend extends ILending {
4343
4549
  decimals: pool.token.decimals,
4344
4550
  borrowFactor: Web3Number2.fromWei(pool.borrow_factor.value, pool.borrow_factor.decimals),
4345
4551
  collareralFactor,
4346
- displayDecimals: 2
4552
+ displayDecimals: 2,
4553
+ indexingType: "ignore" /* IGNORE */
4347
4554
  };
4348
4555
  this.tokens.push(token);
4349
4556
  });
@@ -4745,7 +4952,8 @@ var EkuboPricer = class extends PricerBase {
4745
4952
  constructor(config, tokens2) {
4746
4953
  super(config, tokens2);
4747
4954
  this.EKUBO_PRICE_FETCHER_ADDRESS = "0x04946fb4ad5237d97bbb1256eba2080c4fe1de156da6a7f83e3b4823bb6d7da1";
4748
- this.USDC_ADDRESS = "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8";
4955
+ // Updating to new USDC_ADDRESS
4956
+ this.USDC_ADDRESS = "0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb";
4749
4957
  this.USDC_DECIMALS = 6;
4750
4958
  this.contract = new Contract3({
4751
4959
  abi: ekubo_price_fethcer_abi_default,
@@ -4753,8 +4961,8 @@ var EkuboPricer = class extends PricerBase {
4753
4961
  providerOrAccount: config.provider
4754
4962
  });
4755
4963
  }
4756
- div2Power128(num16) {
4757
- return Number(num16 * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
4964
+ div2Power128(num17) {
4965
+ return Number(num17 * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
4758
4966
  }
4759
4967
  async getPrice(tokenAddr, blockIdentifier = "latest") {
4760
4968
  if (!tokenAddr) {
@@ -6284,217 +6492,6 @@ var EkuboQuoter = class _EkuboQuoter {
6284
6492
  }
6285
6493
  };
6286
6494
 
6287
- // src/interfaces/common.tsx
6288
- import { BlockTag, RpcProvider as RpcProvider3 } from "starknet";
6289
- import { Fragment, jsx } from "react/jsx-runtime";
6290
- var RiskType = /* @__PURE__ */ ((RiskType2) => {
6291
- RiskType2["MARKET_RISK"] = "Market Risk";
6292
- RiskType2["IMPERMANENT_LOSS"] = "Impermanent Loss Risk";
6293
- RiskType2["LIQUIDATION_RISK"] = "Liquidation Risk";
6294
- RiskType2["LOW_LIQUIDITY_RISK"] = "Low Liquidity Risk";
6295
- RiskType2["SMART_CONTRACT_RISK"] = "Smart Contract Risk";
6296
- RiskType2["ORACLE_RISK"] = "Oracle Risk";
6297
- RiskType2["TECHNICAL_RISK"] = "Technical Risk";
6298
- RiskType2["COUNTERPARTY_RISK"] = "Counterparty Risk";
6299
- RiskType2["DEPEG_RISK"] = "Depeg Risk";
6300
- return RiskType2;
6301
- })(RiskType || {});
6302
- var Network = /* @__PURE__ */ ((Network2) => {
6303
- Network2["mainnet"] = "mainnet";
6304
- Network2["sepolia"] = "sepolia";
6305
- Network2["devnet"] = "devnet";
6306
- return Network2;
6307
- })(Network || {});
6308
- var StrategyTag = /* @__PURE__ */ ((StrategyTag3) => {
6309
- StrategyTag3["META_VAULT"] = "Meta Vaults";
6310
- StrategyTag3["LEVERED"] = "Maxx";
6311
- StrategyTag3["AUTOMATED_LP"] = "Ekubo";
6312
- StrategyTag3["BTC"] = "BTC";
6313
- return StrategyTag3;
6314
- })(StrategyTag || {});
6315
- var VaultType = /* @__PURE__ */ ((VaultType2) => {
6316
- VaultType2["LOOPING"] = "Looping";
6317
- VaultType2["META_VAULT"] = "Meta Vault";
6318
- VaultType2["DELTA_NEUTRAL"] = "Delta Neutral";
6319
- VaultType2["AUTOMATED_LP"] = "Automated LP";
6320
- VaultType2["TVA"] = "Troves Value Averaging";
6321
- return VaultType2;
6322
- })(VaultType || {});
6323
- var AuditStatus = /* @__PURE__ */ ((AuditStatus2) => {
6324
- AuditStatus2["AUDITED"] = "Audited";
6325
- AuditStatus2["NOT_AUDITED"] = "Not Audited";
6326
- return AuditStatus2;
6327
- })(AuditStatus || {});
6328
- var SourceCodeType = /* @__PURE__ */ ((SourceCodeType2) => {
6329
- SourceCodeType2["OPEN_SOURCE"] = "Open Source";
6330
- SourceCodeType2["CLOSED_SOURCE"] = "Closed Source";
6331
- return SourceCodeType2;
6332
- })(SourceCodeType || {});
6333
- var AccessControlType = /* @__PURE__ */ ((AccessControlType2) => {
6334
- AccessControlType2["MULTISIG_ACCOUNT"] = "Multisig Account";
6335
- AccessControlType2["STANDARD_ACCOUNT"] = "Standard Account";
6336
- AccessControlType2["ROLE_BASED_ACCESS"] = "Role Based Access";
6337
- return AccessControlType2;
6338
- })(AccessControlType || {});
6339
- var InstantWithdrawalVault = /* @__PURE__ */ ((InstantWithdrawalVault2) => {
6340
- InstantWithdrawalVault2["YES"] = "Yes";
6341
- InstantWithdrawalVault2["NO"] = "No";
6342
- return InstantWithdrawalVault2;
6343
- })(InstantWithdrawalVault || {});
6344
- var FlowChartColors = /* @__PURE__ */ ((FlowChartColors2) => {
6345
- FlowChartColors2["Green"] = "purple";
6346
- FlowChartColors2["Blue"] = "#35484f";
6347
- FlowChartColors2["Purple"] = "#6e53dc";
6348
- return FlowChartColors2;
6349
- })(FlowChartColors || {});
6350
- var StrategyLiveStatus = /* @__PURE__ */ ((StrategyLiveStatus2) => {
6351
- StrategyLiveStatus2["ACTIVE"] = "Active";
6352
- StrategyLiveStatus2["NEW"] = "New";
6353
- StrategyLiveStatus2["COMING_SOON"] = "Coming Soon";
6354
- StrategyLiveStatus2["DEPRECATED"] = "Deprecated";
6355
- StrategyLiveStatus2["RETIRED"] = "Retired";
6356
- StrategyLiveStatus2["HOT"] = "Hot & New \u{1F525}";
6357
- return StrategyLiveStatus2;
6358
- })(StrategyLiveStatus || {});
6359
- function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier = BlockTag.LATEST) {
6360
- return {
6361
- provider: new RpcProvider3({
6362
- nodeUrl: rpcUrl,
6363
- blockIdentifier
6364
- // specVersion
6365
- }),
6366
- stage: "production",
6367
- network: "mainnet" /* mainnet */
6368
- };
6369
- }
6370
- var getStrategyTagDesciption = (tag) => {
6371
- switch (tag) {
6372
- case "Meta Vaults" /* META_VAULT */:
6373
- return "A meta vault is a vault that auto allocates funds to multiple vaults based on optimal yield opportunities";
6374
- case "Maxx" /* LEVERED */:
6375
- return "Looping vaults on Endur LSTs with leveraged borrowing of STRK or BTC to increase yield (2-4x higher yield than simply staking)";
6376
- case "Ekubo" /* AUTOMATED_LP */:
6377
- return "Automated LP vaults on Ekubo that rebalance position automatically, ensuring you earn fees efficiently";
6378
- case "BTC" /* BTC */:
6379
- return "BTC linked vaults";
6380
- }
6381
- };
6382
- var getAllStrategyTags = () => {
6383
- return Object.values(StrategyTag);
6384
- };
6385
- var getRiskExplaination = (riskType) => {
6386
- switch (riskType) {
6387
- case "Market Risk" /* MARKET_RISK */:
6388
- return "The risk of the market moving against the position.";
6389
- case "Impermanent Loss Risk" /* IMPERMANENT_LOSS */:
6390
- return "The temporary loss of value experienced by liquidity providers in AMMs when asset prices diverge compared to simply holding them.";
6391
- case "Liquidation Risk" /* LIQUIDATION_RISK */:
6392
- return "The risk of losing funds due to the position being liquidated.";
6393
- case "Low Liquidity Risk" /* LOW_LIQUIDITY_RISK */:
6394
- return "The risk of low liquidity in the pool, which can lead to high slippages or reduced in-abilities to quickly exit the position.";
6395
- case "Oracle Risk" /* ORACLE_RISK */:
6396
- return "The risk of the oracle being manipulated or incorrect.";
6397
- case "Smart Contract Risk" /* SMART_CONTRACT_RISK */:
6398
- return "The risk of the smart contract being vulnerable to attacks.";
6399
- case "Technical Risk" /* TECHNICAL_RISK */:
6400
- return "The risk of technical issues e.g. backend failure.";
6401
- case "Counterparty Risk" /* COUNTERPARTY_RISK */:
6402
- return "The risk of the counterparty defaulting e.g. bad debt on lending platforms.";
6403
- case "Depeg Risk" /* DEPEG_RISK */:
6404
- return "The risk of a token losing its peg to the underlying asset, leading to potential losses for holders.";
6405
- }
6406
- };
6407
- var getRiskColor = (risk) => {
6408
- const value = risk.value;
6409
- if (value <= 2) return "light_green_2";
6410
- if (value < 3) return "yellow";
6411
- return "red";
6412
- };
6413
- var getNoRiskTags = (risks) => {
6414
- const noRisks1 = risks.filter((risk) => risk.value === 0).map((risk) => risk.type);
6415
- const noRisks2 = Object.values(RiskType).filter(
6416
- (risk) => !risks.map((risk2) => risk2.type).includes(risk)
6417
- );
6418
- const mergedUnique = [.../* @__PURE__ */ new Set([...noRisks1, ...noRisks2])];
6419
- return mergedUnique;
6420
- };
6421
- function highlightTextWithLinks(put, highlights) {
6422
- const escapeRegExp = (text) => text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
6423
- const pattern = new RegExp(
6424
- `(${highlights.map((m) => escapeRegExp(m.highlight)).join("|")})`,
6425
- "gi"
6426
- );
6427
- const parts = put.split(pattern);
6428
- return /* @__PURE__ */ jsx(Fragment, { children: parts.map((part, i) => {
6429
- const match = highlights.find((m) => m.highlight.toLowerCase() === part.toLowerCase());
6430
- return match ? /* @__PURE__ */ jsx("a", { href: match.link, target: "_blank", style: { color: "white", background: "rgba(255, 255, 255, 0.04)" }, children: part }, i) : /* @__PURE__ */ jsx("span", { children: part }, i);
6431
- }) });
6432
- }
6433
- var VesuProtocol = {
6434
- name: "Vesu",
6435
- logo: "https://static-assets-8zct.onrender.com/integrations/vesu/logo.png"
6436
- };
6437
- var AvnuProtocol = {
6438
- name: "Avnu",
6439
- logo: "https://static-assets-8zct.onrender.com/integrations/avnu/logo.png"
6440
- };
6441
- var EndurProtocol = {
6442
- name: "Endur",
6443
- logo: "http://endur.fi/logo.png"
6444
- };
6445
- var ExtendedProtocol = {
6446
- name: "Extended",
6447
- logo: "https://static-assets-8zct.onrender.com/integrations/extended/extended.svg"
6448
- };
6449
- var EkuboProtocol = {
6450
- name: "Ekubo",
6451
- logo: "https://app.ekubo.org/favicon.ico"
6452
- };
6453
- var NoneProtocol = {
6454
- name: "-",
6455
- logo: ""
6456
- };
6457
- var VaultProtocol = {
6458
- name: "Vault",
6459
- logo: ""
6460
- };
6461
- var TrovesProtocol = {
6462
- name: "Troves",
6463
- logo: "https://app.troves.fi/favicon.ico"
6464
- };
6465
- var Protocols = {
6466
- NONE: NoneProtocol,
6467
- VESU: VesuProtocol,
6468
- ENDUR: EndurProtocol,
6469
- EXTENDED: ExtendedProtocol,
6470
- EKUBO: EkuboProtocol,
6471
- AVNU: AvnuProtocol,
6472
- VAULT: VaultProtocol,
6473
- TROVES: TrovesProtocol
6474
- };
6475
- var UnwrapLabsCurator = {
6476
- name: "Unwrap Labs",
6477
- logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
6478
- };
6479
-
6480
- // src/interfaces/initializable.ts
6481
- var Initializable = class {
6482
- constructor() {
6483
- this.initialized = false;
6484
- }
6485
- async waitForInitilisation() {
6486
- return new Promise((resolve, reject) => {
6487
- const interval = setInterval(() => {
6488
- if (this.initialized) {
6489
- console.log("Initialised");
6490
- clearInterval(interval);
6491
- resolve();
6492
- }
6493
- }, 1e3);
6494
- });
6495
- }
6496
- };
6497
-
6498
6495
  // src/strategies/autoCompounderStrk.ts
6499
6496
  import { Contract as Contract6, uint256 as uint2569 } from "starknet";
6500
6497
  var AutoCompounderSTRK = class {
@@ -18031,6 +18028,73 @@ async function binarySearch(lowWei, highWei, callback) {
18031
18028
  }
18032
18029
  return null;
18033
18030
  }
18031
+ async function findMaxInputWithSlippage(options) {
18032
+ const {
18033
+ apiGetOutput,
18034
+ maxInput,
18035
+ maxSlippagePercent,
18036
+ tolerance,
18037
+ minInput = 0,
18038
+ referenceAmountMultiplier = 1e-3,
18039
+ referenceRate = 0
18040
+ } = options;
18041
+ let apiCalls = 0;
18042
+ if (!referenceRate && !referenceAmountMultiplier) {
18043
+ throw new Error("One of referenceRate or referenceAmountMultiplier must be provided");
18044
+ }
18045
+ let _referenceRate = referenceRate;
18046
+ if (!_referenceRate) {
18047
+ const smallAmount = maxInput * referenceAmountMultiplier;
18048
+ const referenceOutput = await apiGetOutput(smallAmount);
18049
+ apiCalls++;
18050
+ _referenceRate = referenceOutput / smallAmount;
18051
+ }
18052
+ async function checkSlippage(inputAmount) {
18053
+ const actualOutput = await apiGetOutput(inputAmount);
18054
+ apiCalls++;
18055
+ const expectedOutput = inputAmount * referenceRate;
18056
+ const slippage = (expectedOutput - actualOutput) / expectedOutput;
18057
+ logger.verbose(`findMaxInputWithSlippage::checkSlippage inputAmount: ${inputAmount}, actualOutput: ${actualOutput}, slippage: ${slippage}, maxSlippagePercent: ${maxSlippagePercent}`);
18058
+ return {
18059
+ acceptable: slippage <= maxSlippagePercent,
18060
+ slippage,
18061
+ output: actualOutput
18062
+ };
18063
+ }
18064
+ const maxCheck = await checkSlippage(maxInput);
18065
+ if (maxCheck.acceptable) {
18066
+ return {
18067
+ optimalInput: maxInput,
18068
+ actualOutput: maxCheck.output,
18069
+ actualSlippage: maxCheck.slippage,
18070
+ apiCallsUsed: apiCalls
18071
+ };
18072
+ }
18073
+ let left = minInput;
18074
+ let right = maxInput;
18075
+ let bestInput = minInput;
18076
+ let bestOutput = 0;
18077
+ let bestSlippage = 0;
18078
+ const convergenceThreshold = tolerance * maxInput;
18079
+ while (right - left > convergenceThreshold) {
18080
+ const mid = (left + right) / 2;
18081
+ const midCheck = await checkSlippage(mid);
18082
+ if (midCheck.acceptable) {
18083
+ bestInput = mid;
18084
+ bestOutput = midCheck.output;
18085
+ bestSlippage = midCheck.slippage;
18086
+ left = mid;
18087
+ } else {
18088
+ right = mid;
18089
+ }
18090
+ }
18091
+ return {
18092
+ optimalInput: bestInput,
18093
+ actualOutput: bestOutput,
18094
+ actualSlippage: bestSlippage,
18095
+ apiCallsUsed: apiCalls
18096
+ };
18097
+ }
18034
18098
 
18035
18099
  // src/strategies/ekubo-cl-vault.tsx
18036
18100
  import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
@@ -18636,8 +18700,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
18636
18700
  upperTick: _EkuboCLVault.i129ToNumber(result.bounds.upper)
18637
18701
  };
18638
18702
  }
18639
- static div2Power128(num16) {
18640
- return Number(BigInt(num16.toString()) * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
18703
+ static div2Power128(num17) {
18704
+ return Number(BigInt(num17.toString()) * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
18641
18705
  }
18642
18706
  static priceToTick(price, isRoundDown, tickSpacing) {
18643
18707
  const value = isRoundDown ? Math.floor(Math.log(price) / Math.log(1.000001)) : Math.ceil(Math.log(price) / Math.log(1.000001));
@@ -30264,7 +30328,8 @@ var vesuPrimeUSDC = {
30264
30328
  name: "Vesu Prime USDC",
30265
30329
  decimals: 18,
30266
30330
  logo: usdc.logo,
30267
- displayDecimals: 2
30331
+ displayDecimals: 2,
30332
+ indexingType: "ignore" /* IGNORE */
30268
30333
  };
30269
30334
  var strk = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
30270
30335
  function getYoloVaultErc4626Config(mainToken, secondaryToken) {
@@ -38273,7 +38338,7 @@ var UniversalStrategies = [
38273
38338
  ];
38274
38339
 
38275
38340
  // src/strategies/universal-lst-muliplier-strategy.tsx
38276
- import { Contract as Contract18, uint256 as uint25624 } from "starknet";
38341
+ import { Contract as Contract18, num as num14, uint256 as uint25624 } from "starknet";
38277
38342
 
38278
38343
  // src/strategies/universal-adapters/adapter-optimizer.ts
38279
38344
  var AdapterOptimizer = class {
@@ -38755,41 +38820,270 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
38755
38820
  }
38756
38821
  async netAPY() {
38757
38822
  const unusedBalance = await this.getUnusedBalance();
38758
- const maxDeposits = await this.maxNewDeposits({ isAPYComputation: true });
38759
- const lstAPY = await this.getLSTAPR(this.getLSTUnderlyingTokenInfo().address);
38760
- if (maxDeposits * 1.5 < unusedBalance.amount.toNumber()) {
38823
+ const maxNewDeposits = await this.maxNewDeposits({
38824
+ isAPYComputation: true
38825
+ });
38826
+ const lstAPY = await this.getLSTAPR(
38827
+ this.getLSTUnderlyingTokenInfo().address
38828
+ );
38829
+ if (maxNewDeposits * 1.5 < unusedBalance.amount.toNumber()) {
38761
38830
  logger.verbose(
38762
38831
  `${this.getTag()}::netAPY: unused balance is > max servicable from loan, lstAPY: ${lstAPY}`
38763
38832
  );
38764
- const output = await super.netAPY();
38833
+ const { positions, baseAPYs, rewardAPYs } = await this.getVesuAPYs();
38834
+ const unusedBalanceAPY = await this.getUnusedBalanceAPY();
38835
+ baseAPYs.push(...[unusedBalanceAPY.apy]);
38836
+ rewardAPYs.push(0);
38837
+ const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
38838
+ weights.push(unusedBalanceAPY.weight);
38839
+ const prevAUM = await this.getPrevAUM();
38840
+ const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
38841
+ const prevAUMUSD = prevAUM.multipliedBy(price.price);
38842
+ const output = await this.returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD);
38765
38843
  output.splits.push({ apy: lstAPY, id: "lst_apy" });
38766
38844
  return output;
38767
38845
  } else {
38768
38846
  logger.verbose(
38769
38847
  `${this.getTag()}::netAPY: we can take more deposits, use theoretical max APY`
38770
38848
  );
38771
- const output = await super.netAPY();
38849
+ const { positions, baseAPYs, rewardAPYs } = await this.getVesuAPYs();
38850
+ const weights = positions.map(
38851
+ (p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1)
38852
+ );
38853
+ const aum = weights.reduce((acc, curr) => acc + curr, 0);
38854
+ const output = await this.returnNetAPY(
38855
+ baseAPYs,
38856
+ rewardAPYs,
38857
+ weights,
38858
+ new Web3Number(
38859
+ aum.toFixed(9),
38860
+ this.getLSTUnderlyingTokenInfo().decimals
38861
+ )
38862
+ );
38772
38863
  output.splits.push({ apy: lstAPY, id: "lst_apy" });
38773
38864
  return output;
38774
38865
  }
38775
38866
  }
38776
- async maxNewDeposits(params = { isAPYComputation: false }) {
38777
- let numerator = 0;
38778
- for (let adapter of this.getVesuMultiplyAdapters()) {
38779
- const maxDepositInfo = await adapter.maxDeposit();
38780
- numerator += maxDepositInfo.amount.toNumber();
38867
+ async getVesuAPYs() {
38868
+ const vesuAdapters = this.getVesuAdapters();
38869
+ const allVesuPools = await VesuAdapter.getVesuPools();
38870
+ const pools = vesuAdapters.map((vesuAdapter) => {
38871
+ return allVesuPools.pools.find((p) => vesuAdapter.config.poolId.eqString(num14.getHexString(p.id)));
38872
+ });
38873
+ logger.verbose(`${this.metadata.name}::netAPY: vesu-pools: ${JSON.stringify(pools)}`);
38874
+ if (pools.some((p) => !p)) {
38875
+ throw new Error("Pool not found");
38876
+ }
38877
+ const positions = await this.getVesuPositions();
38878
+ logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
38879
+ const baseAPYs = [];
38880
+ const rewardAPYs = [];
38881
+ for (const [index, pool] of pools.entries()) {
38882
+ const vesuAdapter = vesuAdapters[index];
38883
+ const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
38884
+ const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
38885
+ const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
38886
+ const lstAPY = await this.getLSTAPR(vesuAdapter.config.collateral.address);
38887
+ logger.verbose(`${this.metadata.name}::netAPY: ${vesuAdapter.config.collateral.symbol} LST APR from Endur: ${lstAPY}`);
38888
+ baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
38889
+ rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
38890
+ }
38891
+ logger.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
38892
+ logger.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
38893
+ assert(baseAPYs.length == positions.length, "APYs and positions length mismatch");
38894
+ return {
38895
+ baseAPYs,
38896
+ rewardAPYs,
38897
+ positions
38898
+ };
38899
+ }
38900
+ async returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD) {
38901
+ if (weights.every((p) => p == 0)) {
38902
+ return {
38903
+ net: 0,
38904
+ splits: [{
38905
+ apy: 0,
38906
+ id: "base"
38907
+ }, {
38908
+ apy: 0,
38909
+ id: "defispring"
38910
+ }]
38911
+ };
38781
38912
  }
38782
- return numerator;
38913
+ const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
38914
+ const rewardAPY = this.computeAPY(rewardAPYs, weights, prevAUMUSD);
38915
+ const netAPY = baseAPY + rewardAPY;
38916
+ logger.verbose(`${this.metadata.name}::netAPY: net: ${netAPY}, baseAPY: ${baseAPY}, rewardAPY: ${rewardAPY}`);
38917
+ return {
38918
+ net: netAPY,
38919
+ splits: [{
38920
+ apy: baseAPY,
38921
+ id: "base"
38922
+ }, {
38923
+ apy: rewardAPY,
38924
+ id: "defispring"
38925
+ }]
38926
+ };
38783
38927
  }
38784
38928
  async getUnusedBalanceAPY() {
38785
38929
  const unusedBalance = await this.getUnusedBalance();
38786
- const underlying = this.getLSTUnderlyingTokenInfo();
38930
+ const vesuAdapter = this.getVesuSameTokenAdapter();
38931
+ const underlying = vesuAdapter.config.debt;
38787
38932
  const lstAPY = await this.getLSTAPR(underlying.address);
38788
38933
  return {
38789
38934
  apy: lstAPY,
38790
38935
  weight: unusedBalance.usdValue
38791
38936
  };
38792
38937
  }
38938
+ computeAPY(apys, weights, currentAUM) {
38939
+ assert(apys.length === weights.length, "APYs and weights length mismatch");
38940
+ const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
38941
+ logger.verbose(`${this.getTag()} computeAPY: apys: ${JSON.stringify(apys)}, weights: ${JSON.stringify(weights)}, weightedSum: ${weightedSum}, currentAUM: ${currentAUM}`);
38942
+ return weightedSum / currentAUM.toNumber();
38943
+ }
38944
+ getVesuAdapters() {
38945
+ const multiply = this.getVesuMultiplyAdapters();
38946
+ return multiply.map((m) => m._vesuAdapter);
38947
+ }
38948
+ async getVesuPositions(blockNumber = "latest") {
38949
+ const adapters = this.getVesuAdapters();
38950
+ const positions = [];
38951
+ for (const adapter of adapters) {
38952
+ positions.push(...await adapter.getPositions(this.config, blockNumber));
38953
+ }
38954
+ return positions;
38955
+ }
38956
+ async getUnusedBalance() {
38957
+ const balance = await new ERC20(this.config).balanceOf(this.asset().address, this.metadata.additionalInfo.vaultAllocator, this.asset().decimals);
38958
+ const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
38959
+ const usdValue = Number(balance.toFixed(6)) * price.price;
38960
+ return {
38961
+ tokenInfo: this.asset(),
38962
+ amount: balance,
38963
+ usdValue
38964
+ };
38965
+ }
38966
+ async maxNewDeposits(params = { isAPYComputation: false }) {
38967
+ const maxBorrowableAmounts = await this.getMaxBorrowableAmount(params);
38968
+ let numerator = 0;
38969
+ for (let adapter of this.getVesuAdapters()) {
38970
+ const maxBorrowableAmountInfo = maxBorrowableAmounts.maxBorrowables.find(
38971
+ (b) => b.borrowableAsset.address.eq(adapter.config.debt.address)
38972
+ );
38973
+ if (!maxBorrowableAmountInfo || !maxBorrowableAmountInfo?.amount) {
38974
+ throw new Error(
38975
+ `Max borrowable amount not found for adapter: ${adapter.config.debt.symbol}`
38976
+ );
38977
+ }
38978
+ numerator += this.metadata.additionalInfo.targetHealthFactor * maxBorrowableAmountInfo.amount.toNumber() / maxBorrowableAmountInfo.ltv;
38979
+ }
38980
+ return numerator - maxBorrowableAmounts.netMaxBorrowableAmount.toNumber();
38981
+ }
38982
+ async getMaxBorrowableAmount(params = { isAPYComputation: false }) {
38983
+ const vesuAdapters = this.getVesuAdapters();
38984
+ let netMaxBorrowableAmount = Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals);
38985
+ const maxBorrowables = [];
38986
+ for (const vesuAdapter of vesuAdapters) {
38987
+ const output = await this.getMaxBorrowableAmountByVesuAdapter(
38988
+ vesuAdapter,
38989
+ params.isAPYComputation
38990
+ );
38991
+ const ltv = await vesuAdapter.getLTVConfig(this.config);
38992
+ maxBorrowables.push({ ...output, ltv, poolId: vesuAdapter.config.poolId });
38993
+ }
38994
+ maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
38995
+ netMaxBorrowableAmount = maxBorrowables.reduce(
38996
+ (acc, curr) => acc.plus(curr.amount),
38997
+ Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals)
38998
+ );
38999
+ return { netMaxBorrowableAmount, maxBorrowables };
39000
+ }
39001
+ async getMaxSwappableWithMaxSlippage(fromToken, toToken, maxSlippage, maxAmount) {
39002
+ const output = await findMaxInputWithSlippage({
39003
+ apiGetOutput: async (inputAmount) => {
39004
+ const ekuboQuoter = new EkuboQuoter(this.config, this.pricer);
39005
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
39006
+ const quote = await ekuboQuoter.getQuoteExactInput(
39007
+ fromToken.address.address,
39008
+ toToken.address.address,
39009
+ new Web3Number(inputAmount.toFixed(9), fromToken.decimals)
39010
+ );
39011
+ return Web3Number.fromWei(
39012
+ quote.total_calculated.toString(),
39013
+ toToken.decimals
39014
+ ).toNumber();
39015
+ },
39016
+ maxInput: maxAmount.toNumber(),
39017
+ maxSlippagePercent: maxSlippage,
39018
+ tolerance: 1e-3,
39019
+ referenceRate: 1
39020
+ });
39021
+ return new Web3Number(output.optimalInput, fromToken.decimals);
39022
+ }
39023
+ async getMaxBorrowableAmountByVesuAdapter(vesuAdapter, isAPYComputation) {
39024
+ const lstAPY = await this.getLSTAPR(
39025
+ this.getLSTUnderlyingTokenInfo().address
39026
+ );
39027
+ const maxInterestRate = lstAPY * 0.8;
39028
+ const { maxDebtToHave: maxBorrowableAmount, currentDebt } = await vesuAdapter.getMaxBorrowableByInterestRate(
39029
+ this.config,
39030
+ vesuAdapter.config.debt,
39031
+ maxInterestRate
39032
+ );
39033
+ const debtCap = await vesuAdapter.getDebtCap(this.config);
39034
+ if (currentDebt.gte(debtCap)) {
39035
+ return {
39036
+ amount: Web3Number.fromWei("0", vesuAdapter.config.debt.decimals),
39037
+ dexSwappableAmount: Web3Number.fromWei(
39038
+ "0",
39039
+ vesuAdapter.config.debt.decimals
39040
+ ),
39041
+ maxBorrowableAmount: Web3Number.fromWei(
39042
+ "0",
39043
+ vesuAdapter.config.debt.decimals
39044
+ ),
39045
+ borrowableAsset: vesuAdapter.config.debt
39046
+ };
39047
+ }
39048
+ const availableToBorrow = debtCap.minus(currentDebt);
39049
+ const maxBorrowable = maxBorrowableAmount.minimum(availableToBorrow).multipliedBy(0.999);
39050
+ if (vesuAdapter.config.debt.address.eq(
39051
+ this.getLSTUnderlyingTokenInfo().address
39052
+ ) || isAPYComputation) {
39053
+ return {
39054
+ amount: maxBorrowable,
39055
+ dexSwappableAmount: maxBorrowable,
39056
+ maxBorrowableAmount: maxBorrowable,
39057
+ borrowableAsset: vesuAdapter.config.debt
39058
+ };
39059
+ }
39060
+ try {
39061
+ const maxSwappable = await this.getMaxSwappableWithMaxSlippage(
39062
+ vesuAdapter.config.debt,
39063
+ this.getLSTUnderlyingTokenInfo(),
39064
+ 2e-4,
39065
+ maxBorrowable
39066
+ );
39067
+ return {
39068
+ amount: maxBorrowable.minimum(maxSwappable),
39069
+ dexSwappableAmount: maxSwappable,
39070
+ maxBorrowableAmount: maxBorrowable,
39071
+ borrowableAsset: vesuAdapter.config.debt
39072
+ };
39073
+ } catch (error) {
39074
+ logger.warn(`${this.getTag()}: Failed to get max swappable: ${error}`);
39075
+ const maxSwappable = Web3Number.fromWei(
39076
+ "0",
39077
+ vesuAdapter.config.debt.decimals
39078
+ );
39079
+ return {
39080
+ amount: maxBorrowable.minimum(maxSwappable),
39081
+ dexSwappableAmount: maxSwappable,
39082
+ maxBorrowableAmount: maxBorrowable,
39083
+ borrowableAsset: vesuAdapter.config.debt
39084
+ };
39085
+ }
39086
+ }
38793
39087
  async getAUM(unrealizedAUM = false) {
38794
39088
  const underlying = this.asset();
38795
39089
  assert(underlying.symbol.startsWith("x"), "Underlying is not an LST of Endur");
@@ -39152,6 +39446,9 @@ var hyperxWBTC = {
39152
39446
  borrowable_assets: [{
39153
39447
  tokenInfo: Global.getDefaultTokens().find((token) => token.symbol === "WBTC"),
39154
39448
  poolId: VesuPools.Re7xBTC
39449
+ }, {
39450
+ tokenInfo: Global.getDefaultTokens().find((token) => token.symbol === "WBTC"),
39451
+ poolId: VesuPools.Prime
39155
39452
  }],
39156
39453
  underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "WBTC"),
39157
39454
  quoteAmountToFetchPrice: new Web3Number("0.001", Global.getDefaultTokens().find((token) => token.symbol === "WBTC").decimals),
@@ -39264,8 +39561,7 @@ var HYPER_LST_SECURITY = {
39264
39561
  },
39265
39562
  accessControl: {
39266
39563
  type: "Standard Account" /* STANDARD_ACCOUNT */,
39267
- addresses: [ContractAddr.from("0x0")],
39268
- timeLock: "2 Days"
39564
+ addresses: [ContractAddr.from("0x03495dd1e4838aa06666aac236036d86e81a6553e222fc02e70c2cbc0062e8d0")]
39269
39565
  }
39270
39566
  };
39271
39567
  var HYPER_LST_REDEMPTION_INFO = {
@@ -39342,7 +39638,7 @@ var HyperLSTStrategies = [
39342
39638
  ];
39343
39639
 
39344
39640
  // src/strategies/token-boosted-xstrk-carry-strategy.tsx
39345
- import { uint256 as uint25625, num as num14 } from "starknet";
39641
+ import { uint256 as uint25625, num as num15 } from "starknet";
39346
39642
  import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
39347
39643
  var BoostedxSTRKCarryStrategy = class _BoostedxSTRKCarryStrategy extends SVKStrategy {
39348
39644
  constructor(config, pricer, metadata) {
@@ -39606,7 +39902,7 @@ var BoostedxSTRKCarryStrategy = class _BoostedxSTRKCarryStrategy extends SVKStra
39606
39902
  );
39607
39903
  const allVesuPools = await VesuAdapter.getVesuPools();
39608
39904
  const pool = allVesuPools.pools.find(
39609
- (p) => vesuAdapter.config.poolId.eqString(num14.getHexString(p.id))
39905
+ (p) => vesuAdapter.config.poolId.eqString(num15.getHexString(p.id))
39610
39906
  );
39611
39907
  if (!pool) {
39612
39908
  throw new Error(
@@ -40793,7 +41089,7 @@ var PricerRedis = class extends Pricer {
40793
41089
 
40794
41090
  // src/node/deployer.ts
40795
41091
  import assert2 from "assert";
40796
- import { Deployer as SnDeployer, TransactionExecutionStatus, constants as constants3, extractContractHashes, json, num as num15 } from "starknet";
41092
+ import { Deployer as SnDeployer, TransactionExecutionStatus, constants as constants3, extractContractHashes, json, num as num16 } from "starknet";
40797
41093
  import { readFileSync as readFileSync2, existsSync, writeFileSync as writeFileSync2 } from "fs";
40798
41094
 
40799
41095
  // src/utils/store.ts
@@ -41075,7 +41371,7 @@ async function prepareMultiDeployContracts(contracts, config, acc) {
41075
41371
  }
41076
41372
  async function executeDeployCalls(contractsInfo, acc, provider2) {
41077
41373
  for (let contractInfo of contractsInfo) {
41078
- assert2(num15.toHexString(contractInfo.call.contractAddress) == num15.toHexString(constants3.UDC.ADDRESS), "Must be pointed at UDC address");
41374
+ assert2(num16.toHexString(contractInfo.call.contractAddress) == num16.toHexString(constants3.UDC.ADDRESS), "Must be pointed at UDC address");
41079
41375
  }
41080
41376
  const allCalls = contractsInfo.map((info) => info.call);
41081
41377
  await executeTransactions(allCalls, acc, provider2, `Deploying contracts: ${contractsInfo.map((info) => info.contract_name).join(", ")}`);
@@ -41215,6 +41511,7 @@ export {
41215
41511
  TRANSFER_SANITIZER,
41216
41512
  TelegramGroupNotif,
41217
41513
  TelegramNotif,
41514
+ TokenIndexingType,
41218
41515
  TokenMarketData,
41219
41516
  TokenTransferAdapter,
41220
41517
  UNIVERSAL_ADAPTER_IDS,