@strkfarm/sdk 1.0.44 → 1.0.46

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.
@@ -51502,7 +51502,7 @@ var strkfarm_risk_engine = (() => {
51502
51502
  };
51503
51503
  }
51504
51504
  static div2Power128(num) {
51505
- return Number(BigInt(num.toString()) * 1000000n / BigInt(2 ** 128)) / 1e6;
51505
+ return Number(BigInt(num.toString()) * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
51506
51506
  }
51507
51507
  static priceToTick(price, isRoundDown, tickSpacing) {
51508
51508
  const value = isRoundDown ? Math.floor(Math.log(price) / Math.log(1.000001)) : Math.ceil(Math.log(price) / Math.log(1.000001));
@@ -51523,18 +51523,15 @@ var strkfarm_risk_engine = (() => {
51523
51523
  tick_spacing: result.pool_key.tick_spacing.toString(),
51524
51524
  extension: result.pool_key.extension.toString()
51525
51525
  };
51526
- const token0Info = await Global.getTokenInfoFromAddr(poolKey.token0);
51527
- const token1Info = await Global.getTokenInfoFromAddr(poolKey.token1);
51528
- assert3(
51529
- token0Info.decimals == token1Info.decimals,
51530
- "Tested only for equal decimals"
51531
- );
51532
51526
  this.poolKey = poolKey;
51533
51527
  return poolKey;
51534
51528
  }
51535
51529
  async getNewBounds() {
51536
51530
  const poolKey = await this.getPoolKey();
51537
51531
  const currentPrice = await this._getCurrentPrice(poolKey);
51532
+ if (typeof this.metadata.additionalInfo.newBounds === "string") {
51533
+ throw new Error(`New bounds are managed known, to be set manually/externally`);
51534
+ }
51538
51535
  const newLower = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.lower) * Number(poolKey.tick_spacing);
51539
51536
  const newUpper = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.upper) * Number(poolKey.tick_spacing);
51540
51537
  return {
@@ -51549,8 +51546,8 @@ var strkfarm_risk_engine = (() => {
51549
51546
  * @param amount1: amount of token1
51550
51547
  * @returns {amount0, amount1}
51551
51548
  */
51552
- async _getExpectedAmountsForLiquidity(amount0, amount1, bounds, justUseInputAmount = true) {
51553
- assert3(amount0.greaterThan(0) || amount1.greaterThan(0), "Amount is 0");
51549
+ async _getExpectedAmountsForLiquidity(inputAmount0, inputAmount1, bounds, justUseInputAmount = true) {
51550
+ assert3(inputAmount0.greaterThan(0) || inputAmount1.greaterThan(0), "Amount is 0");
51554
51551
  const sampleLiq = 1e20;
51555
51552
  const { amount0: sampleAmount0, amount1: sampleAmount1 } = await this.getLiquidityToAmounts(
51556
51553
  Web3Number.fromWei(sampleLiq.toString(), 18),
@@ -51564,39 +51561,37 @@ var strkfarm_risk_engine = (() => {
51564
51561
  logger.verbose(
51565
51562
  `${_EkuboCLVault.name}: _getExpectedAmountsForLiquidity => price: ${price}`
51566
51563
  );
51567
- if (amount1.eq(0) && amount0.greaterThan(0)) {
51564
+ if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
51568
51565
  if (sampleAmount1.eq(0)) {
51569
51566
  return {
51570
- amount0,
51571
- amount1: Web3Number.fromWei("0", amount1.decimals),
51567
+ amount0: inputAmount0,
51568
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals),
51572
51569
  ratio: Infinity
51573
51570
  };
51574
51571
  } else if (sampleAmount0.eq(0)) {
51575
51572
  return {
51576
- amount0: Web3Number.fromWei("0", amount0.decimals),
51577
- amount1: amount0.multipliedBy(price),
51573
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals),
51574
+ // to ensure decimal consistency, we start with 0
51575
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals).plus(inputAmount0.toString()).multipliedBy(price),
51578
51576
  ratio: 0
51579
51577
  };
51580
51578
  }
51581
- } else if (amount0.eq(0) && amount1.greaterThan(0)) {
51579
+ } else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
51582
51580
  if (sampleAmount0.eq(0)) {
51583
51581
  return {
51584
- amount0: Web3Number.fromWei("0", amount0.decimals),
51585
- amount1,
51582
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals),
51583
+ amount1: inputAmount1,
51586
51584
  ratio: 0
51587
51585
  };
51588
51586
  } else if (sampleAmount1.eq(0)) {
51589
51587
  return {
51590
- amount0: amount1.dividedBy(price),
51591
- amount1: Web3Number.fromWei("0", amount1.decimals),
51588
+ // to ensure decimal consistency, we start with 0
51589
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals).plus(inputAmount1.toString()).dividedBy(price),
51590
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals),
51592
51591
  ratio: Infinity
51593
51592
  };
51594
51593
  }
51595
51594
  }
51596
- assert3(
51597
- sampleAmount0.decimals == sampleAmount1.decimals,
51598
- "Sample amounts have different decimals"
51599
- );
51600
51595
  const ratioWeb3Number = sampleAmount0.multipliedBy(1e18).dividedBy(sampleAmount1.toString()).dividedBy(1e18);
51601
51596
  const ratio = Number(ratioWeb3Number.toFixed(18));
51602
51597
  logger.verbose(
@@ -51604,23 +51599,23 @@ var strkfarm_risk_engine = (() => {
51604
51599
  );
51605
51600
  if (justUseInputAmount)
51606
51601
  return this._solveExpectedAmountsEq(
51607
- amount0,
51608
- amount1,
51602
+ inputAmount0,
51603
+ inputAmount1,
51609
51604
  ratioWeb3Number,
51610
51605
  price
51611
51606
  );
51612
- if (amount1.eq(0) && amount0.greaterThan(0)) {
51613
- const _amount1 = amount0.dividedBy(ratioWeb3Number);
51607
+ if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
51608
+ const _amount1 = new Web3Number(inputAmount0.toString(), inputAmount1.decimals).dividedBy(ratioWeb3Number);
51614
51609
  return {
51615
- amount0,
51610
+ amount0: inputAmount0,
51616
51611
  amount1: _amount1,
51617
51612
  ratio
51618
51613
  };
51619
- } else if (amount0.eq(0) && amount1.greaterThan(0)) {
51620
- const _amount0 = amount1.multipliedBy(ratio);
51614
+ } else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
51615
+ const _amount0 = new Web3Number(inputAmount1.toString(), inputAmount0.decimals).multipliedBy(ratio);
51621
51616
  return {
51622
51617
  amount0: _amount0,
51623
- amount1,
51618
+ amount1: inputAmount1,
51624
51619
  ratio
51625
51620
  };
51626
51621
  } else {
@@ -51683,7 +51678,7 @@ var strkfarm_risk_engine = (() => {
51683
51678
  }
51684
51679
  };
51685
51680
  }
51686
- async getSwapInfoToHandleUnused(considerRebalance = true) {
51681
+ async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null) {
51687
51682
  const poolKey = await this.getPoolKey();
51688
51683
  const unusedBalances = await this.unusedBalances(poolKey);
51689
51684
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -51706,7 +51701,9 @@ var strkfarm_risk_engine = (() => {
51706
51701
  `${_EkuboCLVault.name}: getSwapInfoToHandleUnused => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
51707
51702
  );
51708
51703
  let ekuboBounds;
51709
- if (considerRebalance) {
51704
+ if (newBounds) {
51705
+ ekuboBounds = newBounds;
51706
+ } else if (considerRebalance) {
51710
51707
  ekuboBounds = await this.getNewBounds();
51711
51708
  } else {
51712
51709
  ekuboBounds = await this.getCurrentBounds();
@@ -51947,6 +51944,10 @@ var strkfarm_risk_engine = (() => {
51947
51944
  return BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128) / BigInt(1e9);
51948
51945
  }
51949
51946
  static i129ToNumber(i129) {
51947
+ if (i129.sign == 0 || i129.sign == 1) {
51948
+ return _EkuboCLVault.i129ToNumber({ mag: i129.mag, sign: i129.sign == 1 ? "true" : "false" });
51949
+ }
51950
+ assert3(i129.sign.toString() == "false" || i129.sign.toString() == "true", "Invalid sign value");
51950
51951
  return i129.mag * (i129.sign.toString() == "false" ? 1n : -1n);
51951
51952
  }
51952
51953
  static tickToPrice(tick) {
@@ -52125,7 +52126,7 @@ var strkfarm_risk_engine = (() => {
52125
52126
  subItems: [
52126
52127
  {
52127
52128
  key: "Range selection",
52128
- value: `${this.metadata.additionalInfo.newBounds.lower * Number(poolKey.tick_spacing)} to ${this.metadata.additionalInfo.newBounds.upper * Number(poolKey.tick_spacing)} ticks`
52129
+ value: typeof this.metadata.additionalInfo.newBounds == "string" ? this.metadata.additionalInfo.newBounds : `${this.metadata.additionalInfo.newBounds.lower * Number(poolKey.tick_spacing)} to ${this.metadata.additionalInfo.newBounds.upper * Number(poolKey.tick_spacing)} ticks`
52129
52130
  }
52130
52131
  ],
52131
52132
  linkedFlows: [linkedFlow],
@@ -52177,12 +52178,79 @@ var strkfarm_risk_engine = (() => {
52177
52178
  ] })
52178
52179
  }
52179
52180
  ];
52181
+ var xSTRKSTRK = {
52182
+ name: "Ekubo xSTRK/STRK",
52183
+ description: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
52184
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: _description2.replace("{{POOL_NAME}}", "xSTRK/STRK") }),
52185
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
52186
+ "ul",
52187
+ {
52188
+ style: {
52189
+ marginLeft: "20px",
52190
+ listStyle: "circle",
52191
+ fontSize: "12px"
52192
+ },
52193
+ children: [
52194
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." }),
52195
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { style: { marginTop: "10px" }, children: "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." })
52196
+ ]
52197
+ }
52198
+ )
52199
+ ] }),
52200
+ address: ContractAddr.from(
52201
+ "0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
52202
+ ),
52203
+ launchBlock: 1209881,
52204
+ type: "Other",
52205
+ // must be same order as poolKey token0 and token1
52206
+ depositTokens: [
52207
+ Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
52208
+ Global.getDefaultTokens().find((t) => t.symbol === "STRK")
52209
+ ],
52210
+ protocols: [_protocol2],
52211
+ auditUrl: AUDIT_URL2,
52212
+ maxTVL: Web3Number.fromWei("0", 18),
52213
+ risk: {
52214
+ riskFactor: _riskFactor2,
52215
+ netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
52216
+ notARisks: getNoRiskTags(_riskFactor2)
52217
+ },
52218
+ apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
52219
+ additionalInfo: {
52220
+ newBounds: {
52221
+ lower: -1,
52222
+ upper: 1
52223
+ },
52224
+ lstContract: ContractAddr.from(
52225
+ "0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
52226
+ ),
52227
+ feeBps: 1e3,
52228
+ rebalanceConditions: {
52229
+ customShouldRebalance: async (currentPrice) => true,
52230
+ minWaitHours: 24,
52231
+ direction: "uponly"
52232
+ }
52233
+ },
52234
+ faqs: [
52235
+ ...faqs2,
52236
+ {
52237
+ question: "Why might I see a negative APY?",
52238
+ 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."
52239
+ }
52240
+ ],
52241
+ points: [{
52242
+ multiplier: 1,
52243
+ logo: "https://endur.fi/favicon.ico",
52244
+ toolTip: "This strategy holds xSTRK and STRK tokens. Earn 1x Endur points on your xSTRK portion of Liquidity. STRK portion will earn Endur's DEX Bonus points. Points can be found on endur.fi."
52245
+ }]
52246
+ };
52180
52247
  var EkuboCLVaultStrategies = [
52248
+ xSTRKSTRK,
52181
52249
  {
52182
- name: "Ekubo xSTRK/STRK",
52250
+ name: "Ekubo USDC/USDT",
52183
52251
  description: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
52184
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: _description2.replace("{{POOL_NAME}}", "xSTRK/STRK") }),
52185
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
52252
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: _description2.replace("{{POOL_NAME}}", "USDC/USDT") }),
52253
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
52186
52254
  "ul",
52187
52255
  {
52188
52256
  style: {
@@ -52190,30 +52258,30 @@ var strkfarm_risk_engine = (() => {
52190
52258
  listStyle: "circle",
52191
52259
  fontSize: "12px"
52192
52260
  },
52193
- children: [
52194
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." }),
52195
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { style: { marginTop: "10px" }, children: "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." })
52196
- ]
52261
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." })
52197
52262
  }
52198
52263
  )
52199
52264
  ] }),
52200
52265
  address: ContractAddr.from(
52201
- "0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
52266
+ "0xd647ed735f0db52f2a5502b6e06ed21dc4284a43a36af4b60d3c80fbc56c91"
52202
52267
  ),
52203
- launchBlock: 1209881,
52268
+ launchBlock: 1385576,
52204
52269
  type: "Other",
52205
52270
  // must be same order as poolKey token0 and token1
52206
52271
  depositTokens: [
52207
- Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
52208
- Global.getDefaultTokens().find((t) => t.symbol === "STRK")
52272
+ Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
52273
+ Global.getDefaultTokens().find((t) => t.symbol === "USDT")
52209
52274
  ],
52210
52275
  protocols: [_protocol2],
52211
52276
  auditUrl: AUDIT_URL2,
52212
- maxTVL: Web3Number.fromWei("0", 18),
52277
+ maxTVL: Web3Number.fromWei("0", 6),
52213
52278
  risk: {
52214
- riskFactor: _riskFactor2,
52215
- netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
52216
- notARisks: getNoRiskTags(_riskFactor2)
52279
+ riskFactor: _riskFactorStable,
52280
+ netRisk: _riskFactorStable.reduce(
52281
+ (acc, curr) => acc + curr.value * curr.weight,
52282
+ 0
52283
+ ) / _riskFactorStable.reduce((acc, curr) => acc + curr.weight, 0),
52284
+ notARisks: getNoRiskTags(_riskFactorStable)
52217
52285
  },
52218
52286
  apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
52219
52287
  additionalInfo: {
@@ -52221,29 +52289,22 @@ var strkfarm_risk_engine = (() => {
52221
52289
  lower: -1,
52222
52290
  upper: 1
52223
52291
  },
52224
- lstContract: ContractAddr.from(
52225
- "0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
52226
- ),
52292
+ truePrice: 1,
52227
52293
  feeBps: 1e3,
52228
52294
  rebalanceConditions: {
52229
- customShouldRebalance: async (currentPrice) => true,
52230
- minWaitHours: 24,
52231
- direction: "uponly"
52295
+ customShouldRebalance: async (currentPrice) => currentPrice > 0.99 && currentPrice < 1.01,
52296
+ minWaitHours: 6,
52297
+ direction: "any"
52232
52298
  }
52233
52299
  },
52234
- faqs: [
52235
- ...faqs2,
52236
- {
52237
- question: "Why might I see a negative APY?",
52238
- 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."
52239
- }
52240
- ]
52300
+ faqs: [...faqs2]
52241
52301
  }
52242
52302
  // {
52243
- // name: "Ekubo USDC/USDT",
52303
+ // ...xSTRKSTRK,
52304
+ // name: "Ekubo STRK/USDC",
52244
52305
  // description: (
52245
52306
  // <div>
52246
- // <p>{_description.replace("{{POOL_NAME}}", "USDC/USDT")}</p>
52307
+ // <p>{_description.replace("{{POOL_NAME}}", "STRK/USDC")}</p>
52247
52308
  // <ul
52248
52309
  // style={{
52249
52310
  // marginLeft: "20px",
@@ -52259,44 +52320,25 @@ var strkfarm_risk_engine = (() => {
52259
52320
  // </div>
52260
52321
  // ),
52261
52322
  // address: ContractAddr.from(
52262
- // "0xd647ed735f0db52f2a5502b6e06ed21dc4284a43a36af4b60d3c80fbc56c91"
52323
+ // "0xb7bd37121041261446d8eedec618955a4490641034942da688e8cbddea7b23"
52263
52324
  // ),
52264
- // launchBlock: 1385576,
52265
- // type: "Other",
52325
+ // launchBlock: 1492136,
52266
52326
  // // must be same order as poolKey token0 and token1
52267
52327
  // depositTokens: [
52328
+ // Global.getDefaultTokens().find((t) => t.symbol === "STRK")!,
52268
52329
  // Global.getDefaultTokens().find((t) => t.symbol === "USDC")!,
52269
- // Global.getDefaultTokens().find((t) => t.symbol === "USDT")!,
52270
52330
  // ],
52271
- // protocols: [_protocol],
52272
- // auditUrl: AUDIT_URL,
52273
52331
  // maxTVL: Web3Number.fromWei("0", 6),
52274
- // risk: {
52275
- // riskFactor: _riskFactorStable,
52276
- // netRisk:
52277
- // _riskFactorStable.reduce(
52278
- // (acc, curr) => acc + curr.value * curr.weight,
52279
- // 0
52280
- // ) / _riskFactorStable.reduce((acc, curr) => acc + curr.weight, 0),
52281
- // notARisks: getNoRiskTags(_riskFactorStable),
52282
- // },
52283
- // apyMethodology:
52284
- // "APY based on 7-day historical performance, including fees and rewards.",
52285
52332
  // additionalInfo: {
52286
- // newBounds: {
52287
- // lower: -1,
52288
- // upper: 1,
52289
- // },
52290
- // truePrice: 1,
52333
+ // newBounds: "Managed by Re7",
52291
52334
  // feeBps: 1000,
52292
52335
  // rebalanceConditions: {
52293
52336
  // customShouldRebalance: async (currentPrice: number) =>
52294
- // currentPrice > 0.99 && currentPrice < 1.01,
52337
+ // true,
52295
52338
  // minWaitHours: 6,
52296
52339
  // direction: "any",
52297
52340
  // },
52298
52341
  // },
52299
- // faqs: [...faqs],
52300
52342
  // },
52301
52343
  ];
52302
52344
  return __toCommonJS(index_browser_exports);