@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.
@@ -200,6 +200,7 @@ var defaultTokens = [{
200
200
  address: ContractAddr.from("0x0593e034dda23eea82d2ba9a30960ed42cf4a01502cc2351dc9b9881f9931a68"),
201
201
  decimals: 18,
202
202
  coingeckId: void 0,
203
+ priceProxySymbol: "WBTC",
203
204
  displayDecimals: 6,
204
205
  priceCheckAmount: 1e-4
205
206
  // 112000 * 0.0001 = $11.2
@@ -211,6 +212,40 @@ var defaultTokens = [{
211
212
  decimals: 8,
212
213
  coingeckId: void 0,
213
214
  displayDecimals: 6,
215
+ priceProxySymbol: "WBTC",
216
+ priceCheckAmount: 1e-4
217
+ // 112000 * 0.0001 = $11.2
218
+ }, {
219
+ name: "xWBTC",
220
+ symbol: "xWBTC",
221
+ logo: "https://assets.strkfarm.com/integrations/tokens/xwbtc.svg",
222
+ address: ContractAddr.from("0x6a567e68c805323525fe1649adb80b03cddf92c23d2629a6779f54192dffc13"),
223
+ decimals: 8,
224
+ coingeckId: void 0,
225
+ displayDecimals: 6,
226
+ priceProxySymbol: "WBTC",
227
+ priceCheckAmount: 1e-4
228
+ // 112000 * 0.0001 = $11.2
229
+ }, {
230
+ name: "xsBTC",
231
+ symbol: "xsBTC",
232
+ logo: "https://assets.strkfarm.com/integrations/tokens/xsbtc_solv.svg",
233
+ address: ContractAddr.from("0x580f3dc564a7b82f21d40d404b3842d490ae7205e6ac07b1b7af2b4a5183dc9"),
234
+ decimals: 18,
235
+ coingeckId: void 0,
236
+ displayDecimals: 6,
237
+ priceProxySymbol: "WBTC",
238
+ priceCheckAmount: 1e-4
239
+ // 112000 * 0.0001 = $11.2
240
+ }, {
241
+ name: "xtBTC",
242
+ symbol: "xtBTC",
243
+ logo: "https://assets.strkfarm.com/integrations/tokens/xtbtc.svg",
244
+ address: ContractAddr.from("0x43a35c1425a0125ef8c171f1a75c6f31ef8648edcc8324b55ce1917db3f9b91"),
245
+ decimals: 8,
246
+ coingeckId: void 0,
247
+ displayDecimals: 6,
248
+ priceProxySymbol: "WBTC",
214
249
  priceCheckAmount: 1e-4
215
250
  // 112000 * 0.0001 = $11.2
216
251
  }];
@@ -300,9 +335,11 @@ var PricerBase = class {
300
335
  // src/modules/pricer.ts
301
336
  var Pricer = class extends PricerBase {
302
337
  // e.g. ETH/USDC
303
- constructor(config, tokens2) {
338
+ constructor(config, tokens2, refreshInterval = 3e4, staleTime = 6e4) {
304
339
  super(config, tokens2);
305
340
  this.prices = {};
341
+ this.refreshInterval = 3e4;
342
+ this.staleTime = 6e4;
306
343
  // code populates this map during runtime to determine which method to use for a given token
307
344
  // The method set will be the first one to try after first attempt
308
345
  this.methodToUse = {};
@@ -311,6 +348,8 @@ var Pricer = class extends PricerBase {
311
348
  */
312
349
  this.PRICE_API = `https://api.coinbase.com/v2/prices/{{PRICER_KEY}}/buy`;
313
350
  this.EKUBO_API = "https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_ADDRESS}}/0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8";
351
+ this.refreshInterval = refreshInterval;
352
+ this.staleTime = staleTime;
314
353
  }
315
354
  isReady() {
316
355
  const allPricesExist = Object.keys(this.prices).length === this.tokens.length;
@@ -343,10 +382,10 @@ var Pricer = class extends PricerBase {
343
382
  this._loadPrices();
344
383
  setInterval(() => {
345
384
  this._loadPrices();
346
- }, 3e4);
385
+ }, this.refreshInterval);
347
386
  }
348
387
  isStale(timestamp, tokenName) {
349
- const STALE_TIME = 6e4;
388
+ const STALE_TIME = this.staleTime;
350
389
  return (/* @__PURE__ */ new Date()).getTime() - timestamp.getTime() > STALE_TIME;
351
390
  }
352
391
  assertNotStale(timestamp, tokenName) {
@@ -372,13 +411,25 @@ var Pricer = class extends PricerBase {
372
411
  onUpdate(token.symbol);
373
412
  return;
374
413
  }
375
- const price = await this._getPrice(token);
376
- this.prices[token.symbol] = {
377
- price,
378
- timestamp: /* @__PURE__ */ new Date()
379
- };
414
+ if (token.priceProxySymbol) {
415
+ const proxyToken = this.tokens.find((t) => t.symbol === token.priceProxySymbol);
416
+ if (!proxyToken) {
417
+ throw new FatalError(`Price proxy token ${token.priceProxySymbol} not found`);
418
+ }
419
+ const price = await this._getPrice(proxyToken);
420
+ this.prices[token.symbol] = {
421
+ price,
422
+ timestamp: /* @__PURE__ */ new Date()
423
+ };
424
+ } else {
425
+ const price = await this._getPrice(token);
426
+ this.prices[token.symbol] = {
427
+ price,
428
+ timestamp: /* @__PURE__ */ new Date()
429
+ };
430
+ }
380
431
  onUpdate(token.symbol);
381
- logger.verbose(`Fetched price of ${token.name} as ${price}`);
432
+ logger.verbose(`Fetched price of ${token.name} as ${this.prices[token.symbol].price}`);
382
433
  break;
383
434
  } catch (error) {
384
435
  if (retry < MAX_RETRIES) {
@@ -3810,6 +3861,18 @@ async function getAPIUsingHeadlessBrowser(url) {
3810
3861
 
3811
3862
  // src/modules/harvests.ts
3812
3863
  import { Contract as Contract4, num as num3 } from "starknet";
3864
+
3865
+ // src/strategies/constants.ts
3866
+ var COMMON_CONTRACTS = [{
3867
+ address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
3868
+ name: "Access Controller",
3869
+ sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
3870
+ }];
3871
+ var ENDPOINTS = {
3872
+ VESU_BASE: "https://cache-server-t2me.onrender.com/vesu"
3873
+ };
3874
+
3875
+ // src/modules/harvests.ts
3813
3876
  var Harvests = class _Harvests {
3814
3877
  constructor(config) {
3815
3878
  this.config = config;
@@ -3869,7 +3932,7 @@ var EkuboHarvests = class extends Harvests {
3869
3932
  var VESU_REWARDS_CONTRACT = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
3870
3933
  var VesuHarvests = class _VesuHarvests extends Harvests {
3871
3934
  async getHarvests(addr) {
3872
- const result = await fetch(`https://api.vesu.xyz/users/${addr.address}/strk-rewards/calldata`);
3935
+ const result = await fetch(`${ENDPOINTS.VESU_BASE}/users/${addr.address}/strk-rewards/calldata`);
3873
3936
  const data = await result.json();
3874
3937
  const rewardsContract = VESU_REWARDS_CONTRACT;
3875
3938
  const cls = await this.config.provider.getClassAt(rewardsContract.address);
@@ -9347,13 +9410,6 @@ var vesu_pools_default = {
9347
9410
  ]
9348
9411
  };
9349
9412
 
9350
- // src/strategies/constants.ts
9351
- var COMMON_CONTRACTS = [{
9352
- address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
9353
- name: "Access Controller",
9354
- sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
9355
- }];
9356
-
9357
9413
  // src/strategies/vesu-rebalance.tsx
9358
9414
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
9359
9415
  var VesuRebalance = class _VesuRebalance extends BaseStrategy {
@@ -9482,7 +9538,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
9482
9538
  };
9483
9539
  }
9484
9540
  static async getAllPossibleVerifiedPools(asset) {
9485
- const data = await getAPIUsingHeadlessBrowser("https://api.vesu.xyz/pools");
9541
+ const data = await getAPIUsingHeadlessBrowser(`${ENDPOINTS.VESU_BASE}/pools`);
9486
9542
  const verifiedPools = data.data.filter((d) => d.isVerified);
9487
9543
  const pools = verifiedPools.map((p) => {
9488
9544
  const hasMyAsset = p.assets.find((a) => asset.eqString(a.address));
@@ -9659,7 +9715,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
9659
9715
  let pools = [];
9660
9716
  try {
9661
9717
  const data = await getAPIUsingHeadlessBrowser(
9662
- "https://api.vesu.xyz/pools"
9718
+ `${ENDPOINTS.VESU_BASE}/pools`
9663
9719
  );
9664
9720
  pools = data.data;
9665
9721
  for (const pool of vesu_pools_default.data) {
@@ -15259,7 +15315,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15259
15315
  * Calculates assets before and now in a given token of TVL per share to observe growth
15260
15316
  * @returns {Promise<number>} The weighted average APY across all pools
15261
15317
  */
15262
- async netAPY(blockIdentifier = "latest", sinceBlocks = 2e4) {
15318
+ async netAPY(blockIdentifier = "latest", sinceBlocks = 6e5) {
15263
15319
  const tvlNow = await this._getTVL(blockIdentifier);
15264
15320
  const supplyNow = await this.totalSupply(blockIdentifier);
15265
15321
  const priceNow = await this.getCurrentPrice(blockIdentifier);
@@ -16296,6 +16352,15 @@ var faqs2 = [
16296
16352
  ] })
16297
16353
  }
16298
16354
  ];
16355
+ function getLSTFAQs(lstSymbol) {
16356
+ return [
16357
+ ...faqs2,
16358
+ {
16359
+ question: "Why might I see a negative APY?",
16360
+ 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.`
16361
+ }
16362
+ ];
16363
+ }
16299
16364
  var xSTRKSTRK = {
16300
16365
  name: "Ekubo xSTRK/STRK",
16301
16366
  description: /* @__PURE__ */ jsx3(Fragment2, {}),
@@ -16317,7 +16382,7 @@ var xSTRKSTRK = {
16317
16382
  netRisk: _corelatedPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _corelatedPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
16318
16383
  notARisks: getNoRiskTags(_corelatedPoolRiskFactors)
16319
16384
  },
16320
- apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
16385
+ apyMethodology: "APY based on 30-day historical performance, including fees and rewards.",
16321
16386
  additionalInfo: {
16322
16387
  newBounds: {
16323
16388
  lower: -1,
@@ -16334,13 +16399,7 @@ var xSTRKSTRK = {
16334
16399
  },
16335
16400
  quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "STRK")
16336
16401
  },
16337
- faqs: [
16338
- ...faqs2,
16339
- {
16340
- question: "Why might I see a negative APY?",
16341
- 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."
16342
- }
16343
- ],
16402
+ faqs: getLSTFAQs("xSTRK"),
16344
16403
  points: [{
16345
16404
  multiplier: 1,
16346
16405
  logo: "https://endur.fi/favicon.ico",
@@ -16349,6 +16408,78 @@ var xSTRKSTRK = {
16349
16408
  contractDetails: [],
16350
16409
  investmentSteps: []
16351
16410
  };
16411
+ var lstStrategies = [
16412
+ xSTRKSTRK,
16413
+ {
16414
+ ...xSTRKSTRK,
16415
+ name: "Ekubo xWBTC/WBTC",
16416
+ description: /* @__PURE__ */ jsx3(Fragment2, {}),
16417
+ address: ContractAddr.from(
16418
+ "0x2ea99b4971d3c277fa4a9b4beb7d4d7d169e683393a29eef263d5d57b4380a"
16419
+ ),
16420
+ launchBlock: 2338309,
16421
+ // must be same order as poolKey token0 and token1
16422
+ depositTokens: [
16423
+ Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
16424
+ Global.getDefaultTokens().find((t) => t.symbol === "xWBTC")
16425
+ ],
16426
+ additionalInfo: {
16427
+ ...xSTRKSTRK.additionalInfo,
16428
+ quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
16429
+ lstContract: Global.getDefaultTokens().find((t) => t.symbol === "xWBTC").address
16430
+ },
16431
+ faqs: getLSTFAQs("xWBTC"),
16432
+ points: [],
16433
+ contractDetails: [],
16434
+ investmentSteps: []
16435
+ },
16436
+ {
16437
+ ...xSTRKSTRK,
16438
+ name: "Ekubo xtBTC/tBTC",
16439
+ description: /* @__PURE__ */ jsx3(Fragment2, {}),
16440
+ address: ContractAddr.from(
16441
+ "0x785dc3dfc4e80ef2690a99512481e3ed3a5266180adda5a47e856245d68a4af"
16442
+ ),
16443
+ launchBlock: 2344809,
16444
+ // must be same order as poolKey token0 and token1
16445
+ depositTokens: [
16446
+ Global.getDefaultTokens().find((t) => t.symbol === "xtBTC"),
16447
+ Global.getDefaultTokens().find((t) => t.symbol === "tBTC")
16448
+ ],
16449
+ additionalInfo: {
16450
+ ...xSTRKSTRK.additionalInfo,
16451
+ quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "tBTC"),
16452
+ lstContract: Global.getDefaultTokens().find((t) => t.symbol === "xtBTC").address
16453
+ },
16454
+ faqs: getLSTFAQs("xtBTC"),
16455
+ points: [],
16456
+ contractDetails: [],
16457
+ investmentSteps: []
16458
+ },
16459
+ {
16460
+ ...xSTRKSTRK,
16461
+ name: "Ekubo xsBTC/solvBTC",
16462
+ description: /* @__PURE__ */ jsx3(Fragment2, {}),
16463
+ address: ContractAddr.from(
16464
+ "0x3af1c7faa7c464cf2c494e988972ad1939f1103dbfb6e47e9bf0c47e49b14ef"
16465
+ ),
16466
+ launchBlock: 2344809,
16467
+ // must be same order as poolKey token0 and token1
16468
+ depositTokens: [
16469
+ Global.getDefaultTokens().find((t) => t.symbol === "xsBTC"),
16470
+ Global.getDefaultTokens().find((t) => t.symbol === "solvBTC")
16471
+ ],
16472
+ additionalInfo: {
16473
+ ...xSTRKSTRK.additionalInfo,
16474
+ quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "solvBTC"),
16475
+ lstContract: Global.getDefaultTokens().find((t) => t.symbol === "xsBTC").address
16476
+ },
16477
+ faqs: getLSTFAQs("xsBTC"),
16478
+ points: [],
16479
+ contractDetails: [],
16480
+ investmentSteps: []
16481
+ }
16482
+ ];
16352
16483
  var ETHUSDCRe7Strategy = {
16353
16484
  ...xSTRKSTRK,
16354
16485
  name: "Ekubo ETH/USDC",
@@ -16356,12 +16487,13 @@ var ETHUSDCRe7Strategy = {
16356
16487
  address: ContractAddr.from(
16357
16488
  "0x160d8fa4569ef6a12e6bf47cb943d7b5ebba8a41a69a14c1d943050ba5ff947"
16358
16489
  ),
16359
- launchBlock: 1501761,
16490
+ launchBlock: 1504232,
16360
16491
  // must be same order as poolKey token0 and token1
16361
16492
  depositTokens: [
16362
16493
  Global.getDefaultTokens().find((t) => t.symbol === "ETH"),
16363
16494
  Global.getDefaultTokens().find((t) => t.symbol === "USDC")
16364
16495
  ],
16496
+ apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
16365
16497
  additionalInfo: {
16366
16498
  newBounds: "Managed by Re7",
16367
16499
  truePrice: 1,
@@ -16397,7 +16529,7 @@ var RE7Strategies = [
16397
16529
  address: ContractAddr.from(
16398
16530
  "0x3a4f8debaf12af97bb911099bc011d63d6c208d4c5ba8e15d7f437785b0aaa2"
16399
16531
  ),
16400
- launchBlock: 1501761,
16532
+ launchBlock: 1506139,
16401
16533
  // must be same order as poolKey token0 and token1
16402
16534
  depositTokens: [
16403
16535
  Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
@@ -16412,7 +16544,7 @@ var RE7Strategies = [
16412
16544
  address: ContractAddr.from(
16413
16545
  "0x351b36d0d9d8b40010658825adeeddb1397436cd41acd0ff6c6e23aaa8b5b30"
16414
16546
  ),
16415
- launchBlock: 1501762,
16547
+ launchBlock: 1504079,
16416
16548
  // must be same order as poolKey token0 and token1
16417
16549
  depositTokens: [
16418
16550
  Global.getDefaultTokens().find((t) => t.symbol === "STRK"),
@@ -16427,7 +16559,7 @@ var RE7Strategies = [
16427
16559
  address: ContractAddr.from(
16428
16560
  "0x4ce3024b0ee879009112d7b0e073f8a87153dd35b029347d4247ffe48d28f51"
16429
16561
  ),
16430
- launchBlock: 1501763,
16562
+ launchBlock: 1504149,
16431
16563
  // must be same order as poolKey token0 and token1
16432
16564
  depositTokens: [
16433
16565
  Global.getDefaultTokens().find((t) => t.symbol === "STRK"),
@@ -16442,7 +16574,7 @@ var RE7Strategies = [
16442
16574
  address: ContractAddr.from(
16443
16575
  "0x2bcaef2eb7706875a5fdc6853dd961a0590f850bc3a031c59887189b5e84ba1"
16444
16576
  ),
16445
- launchBlock: 1501764,
16577
+ launchBlock: 1506144,
16446
16578
  // must be same order as poolKey token0 and token1
16447
16579
  depositTokens: [
16448
16580
  Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
@@ -16472,7 +16604,7 @@ var RE7Strategies = [
16472
16604
  address: ContractAddr.from(
16473
16605
  "0x1c9232b8186d9317652f05055615f18a120c2ad9e5ee96c39e031c257fb945b"
16474
16606
  ),
16475
- launchBlock: 1501765,
16607
+ launchBlock: 1506145,
16476
16608
  // must be same order as poolKey token0 and token1
16477
16609
  depositTokens: [
16478
16610
  Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
@@ -16487,7 +16619,7 @@ var RE7Strategies = [
16487
16619
  address: ContractAddr.from(
16488
16620
  "0x1248e385c23a929a015ec298a26560fa7745bbd6e41a886550e337b02714b1b"
16489
16621
  ),
16490
- launchBlock: 1501766,
16622
+ launchBlock: 1506147,
16491
16623
  // must be same order as poolKey token0 and token1
16492
16624
  depositTokens: [
16493
16625
  Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
@@ -16497,7 +16629,7 @@ var RE7Strategies = [
16497
16629
  }
16498
16630
  ];
16499
16631
  var EkuboCLVaultStrategies = [
16500
- xSTRKSTRK,
16632
+ ...[lstStrategies[0]],
16501
16633
  ...RE7Strategies
16502
16634
  ];
16503
16635
  EkuboCLVaultStrategies.forEach((s) => {
@@ -16528,7 +16660,11 @@ EkuboCLVaultStrategies.forEach((s) => {
16528
16660
  /* @__PURE__ */ jsx3("h4", { style: { fontWeight: "bold" }, children: "Key points to note:" }),
16529
16661
  /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "10px", color: "var(--chakra-colors-text_secondary)" }, children: [
16530
16662
  /* @__PURE__ */ jsx3("p", { style: {}, children: "1. During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." }),
16531
- s.name.includes("xSTRK/STRK") && /* @__PURE__ */ jsx3("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." })
16663
+ s.additionalInfo.lstContract && /* @__PURE__ */ jsxs2("p", { style: {}, children: [
16664
+ "2. Sometimes you might see a negative APY \u2014 this is usually not a big deal. It happens when ",
16665
+ s.name.split(" ")[1].split("/")[0],
16666
+ "'s price drops on DEXes, but things typically bounce back within a few days or a week."
16667
+ ] })
16532
16668
  ] })
16533
16669
  ] })
16534
16670
  ] });
@@ -21310,7 +21446,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
21310
21446
  let pools = [];
21311
21447
  try {
21312
21448
  const data = await getAPIUsingHeadlessBrowser(
21313
- "https://api.vesu.xyz/pools"
21449
+ `${ENDPOINTS.VESU_BASE}/pools`
21314
21450
  );
21315
21451
  pools = data.data;
21316
21452
  for (const pool of vesu_pools_default.data) {
package/dist/index.d.ts CHANGED
@@ -73,6 +73,7 @@ interface TokenInfo {
73
73
  logo: string;
74
74
  coingeckId?: string;
75
75
  displayDecimals: number;
76
+ priceProxySymbol?: string;
76
77
  priceCheckAmount?: number;
77
78
  }
78
79
  declare enum Network {
@@ -236,13 +237,15 @@ declare class Pricer extends PricerBase {
236
237
  protected prices: {
237
238
  [key: string]: PriceInfo;
238
239
  };
240
+ refreshInterval: number;
241
+ staleTime: number;
239
242
  private methodToUse;
240
243
  /**
241
244
  * TOKENA and TOKENB are the two token names to get price of TokenA in terms of TokenB
242
245
  */
243
246
  protected PRICE_API: string;
244
247
  protected EKUBO_API: string;
245
- constructor(config: IConfig, tokens: TokenInfo[]);
248
+ constructor(config: IConfig, tokens: TokenInfo[], refreshInterval?: number, staleTime?: number);
246
249
  isReady(): boolean;
247
250
  waitTillReady(): Promise<void>;
248
251
  start(): void;