@strkfarm/sdk 1.1.5 → 1.1.7

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.js CHANGED
@@ -328,6 +328,7 @@ var defaultTokens = [{
328
328
  address: ContractAddr.from("0x0593e034dda23eea82d2ba9a30960ed42cf4a01502cc2351dc9b9881f9931a68"),
329
329
  decimals: 18,
330
330
  coingeckId: void 0,
331
+ priceProxySymbol: "WBTC",
331
332
  displayDecimals: 6,
332
333
  priceCheckAmount: 1e-4
333
334
  // 112000 * 0.0001 = $11.2
@@ -339,6 +340,40 @@ var defaultTokens = [{
339
340
  decimals: 8,
340
341
  coingeckId: void 0,
341
342
  displayDecimals: 6,
343
+ priceProxySymbol: "WBTC",
344
+ priceCheckAmount: 1e-4
345
+ // 112000 * 0.0001 = $11.2
346
+ }, {
347
+ name: "xWBTC",
348
+ symbol: "xWBTC",
349
+ logo: "https://assets.strkfarm.com/integrations/tokens/xwbtc.svg",
350
+ address: ContractAddr.from("0x6a567e68c805323525fe1649adb80b03cddf92c23d2629a6779f54192dffc13"),
351
+ decimals: 8,
352
+ coingeckId: void 0,
353
+ displayDecimals: 6,
354
+ priceProxySymbol: "WBTC",
355
+ priceCheckAmount: 1e-4
356
+ // 112000 * 0.0001 = $11.2
357
+ }, {
358
+ name: "xsBTC",
359
+ symbol: "xsBTC",
360
+ logo: "https://assets.strkfarm.com/integrations/tokens/xsbtc_solv.svg",
361
+ address: ContractAddr.from("0x580f3dc564a7b82f21d40d404b3842d490ae7205e6ac07b1b7af2b4a5183dc9"),
362
+ decimals: 18,
363
+ coingeckId: void 0,
364
+ displayDecimals: 6,
365
+ priceProxySymbol: "WBTC",
366
+ priceCheckAmount: 1e-4
367
+ // 112000 * 0.0001 = $11.2
368
+ }, {
369
+ name: "xtBTC",
370
+ symbol: "xtBTC",
371
+ logo: "https://assets.strkfarm.com/integrations/tokens/xtbtc.svg",
372
+ address: ContractAddr.from("0x43a35c1425a0125ef8c171f1a75c6f31ef8648edcc8324b55ce1917db3f9b91"),
373
+ decimals: 8,
374
+ coingeckId: void 0,
375
+ displayDecimals: 6,
376
+ priceProxySymbol: "WBTC",
342
377
  priceCheckAmount: 1e-4
343
378
  // 112000 * 0.0001 = $11.2
344
379
  }];
@@ -428,9 +463,11 @@ var PricerBase = class {
428
463
  // src/modules/pricer.ts
429
464
  var Pricer = class extends PricerBase {
430
465
  // e.g. ETH/USDC
431
- constructor(config, tokens2) {
466
+ constructor(config, tokens2, refreshInterval = 3e4, staleTime = 6e4) {
432
467
  super(config, tokens2);
433
468
  this.prices = {};
469
+ this.refreshInterval = 3e4;
470
+ this.staleTime = 6e4;
434
471
  // code populates this map during runtime to determine which method to use for a given token
435
472
  // The method set will be the first one to try after first attempt
436
473
  this.methodToUse = {};
@@ -439,6 +476,8 @@ var Pricer = class extends PricerBase {
439
476
  */
440
477
  this.PRICE_API = `https://api.coinbase.com/v2/prices/{{PRICER_KEY}}/buy`;
441
478
  this.EKUBO_API = "https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_ADDRESS}}/0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8";
479
+ this.refreshInterval = refreshInterval;
480
+ this.staleTime = staleTime;
442
481
  }
443
482
  isReady() {
444
483
  const allPricesExist = Object.keys(this.prices).length === this.tokens.length;
@@ -471,10 +510,10 @@ var Pricer = class extends PricerBase {
471
510
  this._loadPrices();
472
511
  setInterval(() => {
473
512
  this._loadPrices();
474
- }, 3e4);
513
+ }, this.refreshInterval);
475
514
  }
476
515
  isStale(timestamp, tokenName) {
477
- const STALE_TIME = 6e4;
516
+ const STALE_TIME = this.staleTime;
478
517
  return (/* @__PURE__ */ new Date()).getTime() - timestamp.getTime() > STALE_TIME;
479
518
  }
480
519
  assertNotStale(timestamp, tokenName) {
@@ -500,13 +539,25 @@ var Pricer = class extends PricerBase {
500
539
  onUpdate(token.symbol);
501
540
  return;
502
541
  }
503
- const price = await this._getPrice(token);
504
- this.prices[token.symbol] = {
505
- price,
506
- timestamp: /* @__PURE__ */ new Date()
507
- };
542
+ if (token.priceProxySymbol) {
543
+ const proxyToken = this.tokens.find((t) => t.symbol === token.priceProxySymbol);
544
+ if (!proxyToken) {
545
+ throw new FatalError(`Price proxy token ${token.priceProxySymbol} not found`);
546
+ }
547
+ const price = await this._getPrice(proxyToken);
548
+ this.prices[token.symbol] = {
549
+ price,
550
+ timestamp: /* @__PURE__ */ new Date()
551
+ };
552
+ } else {
553
+ const price = await this._getPrice(token);
554
+ this.prices[token.symbol] = {
555
+ price,
556
+ timestamp: /* @__PURE__ */ new Date()
557
+ };
558
+ }
508
559
  onUpdate(token.symbol);
509
- logger.verbose(`Fetched price of ${token.name} as ${price}`);
560
+ logger.verbose(`Fetched price of ${token.name} as ${this.prices[token.symbol].price}`);
510
561
  break;
511
562
  } catch (error) {
512
563
  if (retry < MAX_RETRIES) {
@@ -3946,6 +3997,18 @@ async function getAPIUsingHeadlessBrowser(url) {
3946
3997
 
3947
3998
  // src/modules/harvests.ts
3948
3999
  var import_starknet9 = require("starknet");
4000
+
4001
+ // src/strategies/constants.ts
4002
+ var COMMON_CONTRACTS = [{
4003
+ address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
4004
+ name: "Access Controller",
4005
+ sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
4006
+ }];
4007
+ var ENDPOINTS = {
4008
+ VESU_BASE: "https://cache-server-t2me.onrender.com/vesu"
4009
+ };
4010
+
4011
+ // src/modules/harvests.ts
3949
4012
  var Harvests = class _Harvests {
3950
4013
  constructor(config) {
3951
4014
  this.config = config;
@@ -4005,7 +4068,7 @@ var EkuboHarvests = class extends Harvests {
4005
4068
  var VESU_REWARDS_CONTRACT = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
4006
4069
  var VesuHarvests = class _VesuHarvests extends Harvests {
4007
4070
  async getHarvests(addr) {
4008
- const result = await fetch(`https://api.vesu.xyz/users/${addr.address}/strk-rewards/calldata`);
4071
+ const result = await fetch(`${ENDPOINTS.VESU_BASE}/users/${addr.address}/strk-rewards/calldata`);
4009
4072
  const data = await result.json();
4010
4073
  const rewardsContract = VESU_REWARDS_CONTRACT;
4011
4074
  const cls = await this.config.provider.getClassAt(rewardsContract.address);
@@ -9483,13 +9546,6 @@ var vesu_pools_default = {
9483
9546
  ]
9484
9547
  };
9485
9548
 
9486
- // src/strategies/constants.ts
9487
- var COMMON_CONTRACTS = [{
9488
- address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
9489
- name: "Access Controller",
9490
- sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
9491
- }];
9492
-
9493
9549
  // src/strategies/vesu-rebalance.tsx
9494
9550
  var import_jsx_runtime2 = require("react/jsx-runtime");
9495
9551
  var VesuRebalance = class _VesuRebalance extends BaseStrategy {
@@ -9618,7 +9674,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
9618
9674
  };
9619
9675
  }
9620
9676
  static async getAllPossibleVerifiedPools(asset) {
9621
- const data = await getAPIUsingHeadlessBrowser("https://api.vesu.xyz/pools");
9677
+ const data = await getAPIUsingHeadlessBrowser(`${ENDPOINTS.VESU_BASE}/pools`);
9622
9678
  const verifiedPools = data.data.filter((d) => d.isVerified);
9623
9679
  const pools = verifiedPools.map((p) => {
9624
9680
  const hasMyAsset = p.assets.find((a) => asset.eqString(a.address));
@@ -9795,7 +9851,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
9795
9851
  let pools = [];
9796
9852
  try {
9797
9853
  const data = await getAPIUsingHeadlessBrowser(
9798
- "https://api.vesu.xyz/pools"
9854
+ `${ENDPOINTS.VESU_BASE}/pools`
9799
9855
  );
9800
9856
  pools = data.data;
9801
9857
  for (const pool of vesu_pools_default.data) {
@@ -15391,7 +15447,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15391
15447
  * Calculates assets before and now in a given token of TVL per share to observe growth
15392
15448
  * @returns {Promise<number>} The weighted average APY across all pools
15393
15449
  */
15394
- async netAPY(blockIdentifier = "latest", sinceBlocks = 2e4) {
15450
+ async netAPY(blockIdentifier = "latest", sinceBlocks = 6e5) {
15395
15451
  const tvlNow = await this._getTVL(blockIdentifier);
15396
15452
  const supplyNow = await this.totalSupply(blockIdentifier);
15397
15453
  const priceNow = await this.getCurrentPrice(blockIdentifier);
@@ -16428,6 +16484,15 @@ var faqs2 = [
16428
16484
  ] })
16429
16485
  }
16430
16486
  ];
16487
+ function getLSTFAQs(lstSymbol) {
16488
+ return [
16489
+ ...faqs2,
16490
+ {
16491
+ question: "Why might I see a negative APY?",
16492
+ answer: `A negative APY can occur when ${lstSymbol}'s price drops on DEXes. This is usually temporary and tends to recover within a few days or a week.`
16493
+ }
16494
+ ];
16495
+ }
16431
16496
  var xSTRKSTRK = {
16432
16497
  name: "Ekubo xSTRK/STRK",
16433
16498
  description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
@@ -16449,7 +16514,7 @@ var xSTRKSTRK = {
16449
16514
  netRisk: _corelatedPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _corelatedPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
16450
16515
  notARisks: getNoRiskTags(_corelatedPoolRiskFactors)
16451
16516
  },
16452
- apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
16517
+ apyMethodology: "APY based on 30-day historical performance, including fees and rewards.",
16453
16518
  additionalInfo: {
16454
16519
  newBounds: {
16455
16520
  lower: -1,
@@ -16466,13 +16531,7 @@ var xSTRKSTRK = {
16466
16531
  },
16467
16532
  quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "STRK")
16468
16533
  },
16469
- faqs: [
16470
- ...faqs2,
16471
- {
16472
- question: "Why might I see a negative APY?",
16473
- answer: "A negative APY can occur when xSTRK's price drops on DEXes. This is usually temporary and tends to recover within a few days or a week."
16474
- }
16475
- ],
16534
+ faqs: getLSTFAQs("xSTRK"),
16476
16535
  points: [{
16477
16536
  multiplier: 1,
16478
16537
  logo: "https://endur.fi/favicon.ico",
@@ -16481,6 +16540,78 @@ var xSTRKSTRK = {
16481
16540
  contractDetails: [],
16482
16541
  investmentSteps: []
16483
16542
  };
16543
+ var lstStrategies = [
16544
+ xSTRKSTRK,
16545
+ {
16546
+ ...xSTRKSTRK,
16547
+ name: "Ekubo xWBTC/WBTC",
16548
+ description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
16549
+ address: ContractAddr.from(
16550
+ "0x2ea99b4971d3c277fa4a9b4beb7d4d7d169e683393a29eef263d5d57b4380a"
16551
+ ),
16552
+ launchBlock: 2338309,
16553
+ // must be same order as poolKey token0 and token1
16554
+ depositTokens: [
16555
+ Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
16556
+ Global.getDefaultTokens().find((t) => t.symbol === "xWBTC")
16557
+ ],
16558
+ additionalInfo: {
16559
+ ...xSTRKSTRK.additionalInfo,
16560
+ quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
16561
+ lstContract: Global.getDefaultTokens().find((t) => t.symbol === "xWBTC").address
16562
+ },
16563
+ faqs: getLSTFAQs("xWBTC"),
16564
+ points: [],
16565
+ contractDetails: [],
16566
+ investmentSteps: []
16567
+ },
16568
+ {
16569
+ ...xSTRKSTRK,
16570
+ name: "Ekubo xtBTC/tBTC",
16571
+ description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
16572
+ address: ContractAddr.from(
16573
+ "0x785dc3dfc4e80ef2690a99512481e3ed3a5266180adda5a47e856245d68a4af"
16574
+ ),
16575
+ launchBlock: 2344809,
16576
+ // must be same order as poolKey token0 and token1
16577
+ depositTokens: [
16578
+ Global.getDefaultTokens().find((t) => t.symbol === "xtBTC"),
16579
+ Global.getDefaultTokens().find((t) => t.symbol === "tBTC")
16580
+ ],
16581
+ additionalInfo: {
16582
+ ...xSTRKSTRK.additionalInfo,
16583
+ quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "tBTC"),
16584
+ lstContract: Global.getDefaultTokens().find((t) => t.symbol === "xtBTC").address
16585
+ },
16586
+ faqs: getLSTFAQs("xtBTC"),
16587
+ points: [],
16588
+ contractDetails: [],
16589
+ investmentSteps: []
16590
+ },
16591
+ {
16592
+ ...xSTRKSTRK,
16593
+ name: "Ekubo xsBTC/solvBTC",
16594
+ description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
16595
+ address: ContractAddr.from(
16596
+ "0x3af1c7faa7c464cf2c494e988972ad1939f1103dbfb6e47e9bf0c47e49b14ef"
16597
+ ),
16598
+ launchBlock: 2344809,
16599
+ // must be same order as poolKey token0 and token1
16600
+ depositTokens: [
16601
+ Global.getDefaultTokens().find((t) => t.symbol === "xsBTC"),
16602
+ Global.getDefaultTokens().find((t) => t.symbol === "solvBTC")
16603
+ ],
16604
+ additionalInfo: {
16605
+ ...xSTRKSTRK.additionalInfo,
16606
+ quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "solvBTC"),
16607
+ lstContract: Global.getDefaultTokens().find((t) => t.symbol === "xsBTC").address
16608
+ },
16609
+ faqs: getLSTFAQs("xsBTC"),
16610
+ points: [],
16611
+ contractDetails: [],
16612
+ investmentSteps: []
16613
+ }
16614
+ ];
16484
16615
  var ETHUSDCRe7Strategy = {
16485
16616
  ...xSTRKSTRK,
16486
16617
  name: "Ekubo ETH/USDC",
@@ -16488,12 +16619,13 @@ var ETHUSDCRe7Strategy = {
16488
16619
  address: ContractAddr.from(
16489
16620
  "0x160d8fa4569ef6a12e6bf47cb943d7b5ebba8a41a69a14c1d943050ba5ff947"
16490
16621
  ),
16491
- launchBlock: 1501761,
16622
+ launchBlock: 1504232,
16492
16623
  // must be same order as poolKey token0 and token1
16493
16624
  depositTokens: [
16494
16625
  Global.getDefaultTokens().find((t) => t.symbol === "ETH"),
16495
16626
  Global.getDefaultTokens().find((t) => t.symbol === "USDC")
16496
16627
  ],
16628
+ apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
16497
16629
  additionalInfo: {
16498
16630
  newBounds: "Managed by Re7",
16499
16631
  truePrice: 1,
@@ -16529,7 +16661,7 @@ var RE7Strategies = [
16529
16661
  address: ContractAddr.from(
16530
16662
  "0x3a4f8debaf12af97bb911099bc011d63d6c208d4c5ba8e15d7f437785b0aaa2"
16531
16663
  ),
16532
- launchBlock: 1501761,
16664
+ launchBlock: 1506139,
16533
16665
  // must be same order as poolKey token0 and token1
16534
16666
  depositTokens: [
16535
16667
  Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
@@ -16544,7 +16676,7 @@ var RE7Strategies = [
16544
16676
  address: ContractAddr.from(
16545
16677
  "0x351b36d0d9d8b40010658825adeeddb1397436cd41acd0ff6c6e23aaa8b5b30"
16546
16678
  ),
16547
- launchBlock: 1501762,
16679
+ launchBlock: 1504079,
16548
16680
  // must be same order as poolKey token0 and token1
16549
16681
  depositTokens: [
16550
16682
  Global.getDefaultTokens().find((t) => t.symbol === "STRK"),
@@ -16559,7 +16691,7 @@ var RE7Strategies = [
16559
16691
  address: ContractAddr.from(
16560
16692
  "0x4ce3024b0ee879009112d7b0e073f8a87153dd35b029347d4247ffe48d28f51"
16561
16693
  ),
16562
- launchBlock: 1501763,
16694
+ launchBlock: 1504149,
16563
16695
  // must be same order as poolKey token0 and token1
16564
16696
  depositTokens: [
16565
16697
  Global.getDefaultTokens().find((t) => t.symbol === "STRK"),
@@ -16574,7 +16706,7 @@ var RE7Strategies = [
16574
16706
  address: ContractAddr.from(
16575
16707
  "0x2bcaef2eb7706875a5fdc6853dd961a0590f850bc3a031c59887189b5e84ba1"
16576
16708
  ),
16577
- launchBlock: 1501764,
16709
+ launchBlock: 1506144,
16578
16710
  // must be same order as poolKey token0 and token1
16579
16711
  depositTokens: [
16580
16712
  Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
@@ -16604,7 +16736,7 @@ var RE7Strategies = [
16604
16736
  address: ContractAddr.from(
16605
16737
  "0x1c9232b8186d9317652f05055615f18a120c2ad9e5ee96c39e031c257fb945b"
16606
16738
  ),
16607
- launchBlock: 1501765,
16739
+ launchBlock: 1506145,
16608
16740
  // must be same order as poolKey token0 and token1
16609
16741
  depositTokens: [
16610
16742
  Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
@@ -16619,7 +16751,7 @@ var RE7Strategies = [
16619
16751
  address: ContractAddr.from(
16620
16752
  "0x1248e385c23a929a015ec298a26560fa7745bbd6e41a886550e337b02714b1b"
16621
16753
  ),
16622
- launchBlock: 1501766,
16754
+ launchBlock: 1506147,
16623
16755
  // must be same order as poolKey token0 and token1
16624
16756
  depositTokens: [
16625
16757
  Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
@@ -16629,7 +16761,7 @@ var RE7Strategies = [
16629
16761
  }
16630
16762
  ];
16631
16763
  var EkuboCLVaultStrategies = [
16632
- xSTRKSTRK,
16764
+ ...[lstStrategies[0]],
16633
16765
  ...RE7Strategies
16634
16766
  ];
16635
16767
  EkuboCLVaultStrategies.forEach((s) => {
@@ -16660,7 +16792,11 @@ EkuboCLVaultStrategies.forEach((s) => {
16660
16792
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h4", { style: { fontWeight: "bold" }, children: "Key points to note:" }),
16661
16793
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "10px", color: "var(--chakra-colors-text_secondary)" }, children: [
16662
16794
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { style: {}, children: "1. During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." }),
16663
- s.name.includes("xSTRK/STRK") && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { style: {}, children: "2. Sometimes you might see a negative APY \u2014 this is usually not a big deal. It happens when xSTRK's price drops on DEXes, but things typically bounce back within a few days or a week." })
16795
+ s.additionalInfo.lstContract && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { style: {}, children: [
16796
+ "2. Sometimes you might see a negative APY \u2014 this is usually not a big deal. It happens when ",
16797
+ s.name.split(" ")[1].split("/")[0],
16798
+ "'s price drops on DEXes, but things typically bounce back within a few days or a week."
16799
+ ] })
16664
16800
  ] })
16665
16801
  ] })
16666
16802
  ] });
@@ -21442,7 +21578,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
21442
21578
  let pools = [];
21443
21579
  try {
21444
21580
  const data = await getAPIUsingHeadlessBrowser(
21445
- "https://api.vesu.xyz/pools"
21581
+ `${ENDPOINTS.VESU_BASE}/pools`
21446
21582
  );
21447
21583
  pools = data.data;
21448
21584
  for (const pool of vesu_pools_default.data) {