@strkfarm/sdk 1.0.45 → 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.
package/dist/index.js CHANGED
@@ -15410,7 +15410,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15410
15410
  };
15411
15411
  }
15412
15412
  static div2Power128(num5) {
15413
- return Number(BigInt(num5.toString()) * 1000000n / BigInt(2 ** 128)) / 1e6;
15413
+ return Number(BigInt(num5.toString()) * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
15414
15414
  }
15415
15415
  static priceToTick(price, isRoundDown, tickSpacing) {
15416
15416
  const value = isRoundDown ? Math.floor(Math.log(price) / Math.log(1.000001)) : Math.ceil(Math.log(price) / Math.log(1.000001));
@@ -15431,18 +15431,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15431
15431
  tick_spacing: result.pool_key.tick_spacing.toString(),
15432
15432
  extension: result.pool_key.extension.toString()
15433
15433
  };
15434
- const token0Info = await Global.getTokenInfoFromAddr(poolKey.token0);
15435
- const token1Info = await Global.getTokenInfoFromAddr(poolKey.token1);
15436
- assert(
15437
- token0Info.decimals == token1Info.decimals,
15438
- "Tested only for equal decimals"
15439
- );
15440
15434
  this.poolKey = poolKey;
15441
15435
  return poolKey;
15442
15436
  }
15443
15437
  async getNewBounds() {
15444
15438
  const poolKey = await this.getPoolKey();
15445
15439
  const currentPrice = await this._getCurrentPrice(poolKey);
15440
+ if (typeof this.metadata.additionalInfo.newBounds === "string") {
15441
+ throw new Error(`New bounds are managed known, to be set manually/externally`);
15442
+ }
15446
15443
  const newLower = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.lower) * Number(poolKey.tick_spacing);
15447
15444
  const newUpper = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.upper) * Number(poolKey.tick_spacing);
15448
15445
  return {
@@ -15457,8 +15454,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15457
15454
  * @param amount1: amount of token1
15458
15455
  * @returns {amount0, amount1}
15459
15456
  */
15460
- async _getExpectedAmountsForLiquidity(amount0, amount1, bounds, justUseInputAmount = true) {
15461
- assert(amount0.greaterThan(0) || amount1.greaterThan(0), "Amount is 0");
15457
+ async _getExpectedAmountsForLiquidity(inputAmount0, inputAmount1, bounds, justUseInputAmount = true) {
15458
+ assert(inputAmount0.greaterThan(0) || inputAmount1.greaterThan(0), "Amount is 0");
15462
15459
  const sampleLiq = 1e20;
15463
15460
  const { amount0: sampleAmount0, amount1: sampleAmount1 } = await this.getLiquidityToAmounts(
15464
15461
  Web3Number.fromWei(sampleLiq.toString(), 18),
@@ -15472,39 +15469,37 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15472
15469
  logger.verbose(
15473
15470
  `${_EkuboCLVault.name}: _getExpectedAmountsForLiquidity => price: ${price}`
15474
15471
  );
15475
- if (amount1.eq(0) && amount0.greaterThan(0)) {
15472
+ if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
15476
15473
  if (sampleAmount1.eq(0)) {
15477
15474
  return {
15478
- amount0,
15479
- amount1: Web3Number.fromWei("0", amount1.decimals),
15475
+ amount0: inputAmount0,
15476
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals),
15480
15477
  ratio: Infinity
15481
15478
  };
15482
15479
  } else if (sampleAmount0.eq(0)) {
15483
15480
  return {
15484
- amount0: Web3Number.fromWei("0", amount0.decimals),
15485
- amount1: amount0.multipliedBy(price),
15481
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals),
15482
+ // to ensure decimal consistency, we start with 0
15483
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals).plus(inputAmount0.toString()).multipliedBy(price),
15486
15484
  ratio: 0
15487
15485
  };
15488
15486
  }
15489
- } else if (amount0.eq(0) && amount1.greaterThan(0)) {
15487
+ } else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
15490
15488
  if (sampleAmount0.eq(0)) {
15491
15489
  return {
15492
- amount0: Web3Number.fromWei("0", amount0.decimals),
15493
- amount1,
15490
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals),
15491
+ amount1: inputAmount1,
15494
15492
  ratio: 0
15495
15493
  };
15496
15494
  } else if (sampleAmount1.eq(0)) {
15497
15495
  return {
15498
- amount0: amount1.dividedBy(price),
15499
- amount1: Web3Number.fromWei("0", amount1.decimals),
15496
+ // to ensure decimal consistency, we start with 0
15497
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals).plus(inputAmount1.toString()).dividedBy(price),
15498
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals),
15500
15499
  ratio: Infinity
15501
15500
  };
15502
15501
  }
15503
15502
  }
15504
- assert(
15505
- sampleAmount0.decimals == sampleAmount1.decimals,
15506
- "Sample amounts have different decimals"
15507
- );
15508
15503
  const ratioWeb3Number = sampleAmount0.multipliedBy(1e18).dividedBy(sampleAmount1.toString()).dividedBy(1e18);
15509
15504
  const ratio = Number(ratioWeb3Number.toFixed(18));
15510
15505
  logger.verbose(
@@ -15512,23 +15507,23 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15512
15507
  );
15513
15508
  if (justUseInputAmount)
15514
15509
  return this._solveExpectedAmountsEq(
15515
- amount0,
15516
- amount1,
15510
+ inputAmount0,
15511
+ inputAmount1,
15517
15512
  ratioWeb3Number,
15518
15513
  price
15519
15514
  );
15520
- if (amount1.eq(0) && amount0.greaterThan(0)) {
15521
- const _amount1 = amount0.dividedBy(ratioWeb3Number);
15515
+ if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
15516
+ const _amount1 = new Web3Number(inputAmount0.toString(), inputAmount1.decimals).dividedBy(ratioWeb3Number);
15522
15517
  return {
15523
- amount0,
15518
+ amount0: inputAmount0,
15524
15519
  amount1: _amount1,
15525
15520
  ratio
15526
15521
  };
15527
- } else if (amount0.eq(0) && amount1.greaterThan(0)) {
15528
- const _amount0 = amount1.multipliedBy(ratio);
15522
+ } else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
15523
+ const _amount0 = new Web3Number(inputAmount1.toString(), inputAmount0.decimals).multipliedBy(ratio);
15529
15524
  return {
15530
15525
  amount0: _amount0,
15531
- amount1,
15526
+ amount1: inputAmount1,
15532
15527
  ratio
15533
15528
  };
15534
15529
  } else {
@@ -15591,7 +15586,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15591
15586
  }
15592
15587
  };
15593
15588
  }
15594
- async getSwapInfoToHandleUnused(considerRebalance = true) {
15589
+ async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null) {
15595
15590
  const poolKey = await this.getPoolKey();
15596
15591
  const unusedBalances = await this.unusedBalances(poolKey);
15597
15592
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -15614,7 +15609,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15614
15609
  `${_EkuboCLVault.name}: getSwapInfoToHandleUnused => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
15615
15610
  );
15616
15611
  let ekuboBounds;
15617
- if (considerRebalance) {
15612
+ if (newBounds) {
15613
+ ekuboBounds = newBounds;
15614
+ } else if (considerRebalance) {
15618
15615
  ekuboBounds = await this.getNewBounds();
15619
15616
  } else {
15620
15617
  ekuboBounds = await this.getCurrentBounds();
@@ -15855,6 +15852,10 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15855
15852
  return BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128) / BigInt(1e9);
15856
15853
  }
15857
15854
  static i129ToNumber(i129) {
15855
+ if (i129.sign == 0 || i129.sign == 1) {
15856
+ return _EkuboCLVault.i129ToNumber({ mag: i129.mag, sign: i129.sign == 1 ? "true" : "false" });
15857
+ }
15858
+ assert(i129.sign.toString() == "false" || i129.sign.toString() == "true", "Invalid sign value");
15858
15859
  return i129.mag * (i129.sign.toString() == "false" ? 1n : -1n);
15859
15860
  }
15860
15861
  static tickToPrice(tick) {
@@ -16033,7 +16034,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16033
16034
  subItems: [
16034
16035
  {
16035
16036
  key: "Range selection",
16036
- value: `${this.metadata.additionalInfo.newBounds.lower * Number(poolKey.tick_spacing)} to ${this.metadata.additionalInfo.newBounds.upper * Number(poolKey.tick_spacing)} ticks`
16037
+ 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`
16037
16038
  }
16038
16039
  ],
16039
16040
  linkedFlows: [linkedFlow],
@@ -16085,73 +16086,74 @@ var faqs2 = [
16085
16086
  ] })
16086
16087
  }
16087
16088
  ];
16088
- var EkuboCLVaultStrategies = [
16089
- {
16090
- name: "Ekubo xSTRK/STRK",
16091
- description: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
16092
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: _description2.replace("{{POOL_NAME}}", "xSTRK/STRK") }),
16093
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
16094
- "ul",
16095
- {
16096
- style: {
16097
- marginLeft: "20px",
16098
- listStyle: "circle",
16099
- fontSize: "12px"
16100
- },
16101
- children: [
16102
- /* @__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." }),
16103
- /* @__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." })
16104
- ]
16105
- }
16106
- )
16107
- ] }),
16108
- address: ContractAddr.from(
16109
- "0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
16110
- ),
16111
- launchBlock: 1209881,
16112
- type: "Other",
16113
- // must be same order as poolKey token0 and token1
16114
- depositTokens: [
16115
- Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
16116
- Global.getDefaultTokens().find((t) => t.symbol === "STRK")
16117
- ],
16118
- protocols: [_protocol2],
16119
- auditUrl: AUDIT_URL2,
16120
- maxTVL: Web3Number.fromWei("0", 18),
16121
- risk: {
16122
- riskFactor: _riskFactor2,
16123
- netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
16124
- notARisks: getNoRiskTags(_riskFactor2)
16125
- },
16126
- apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
16127
- additionalInfo: {
16128
- newBounds: {
16129
- lower: -1,
16130
- upper: 1
16131
- },
16132
- lstContract: ContractAddr.from(
16133
- "0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
16134
- ),
16135
- feeBps: 1e3,
16136
- rebalanceConditions: {
16137
- customShouldRebalance: async (currentPrice) => true,
16138
- minWaitHours: 24,
16139
- direction: "uponly"
16089
+ var xSTRKSTRK = {
16090
+ name: "Ekubo xSTRK/STRK",
16091
+ description: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
16092
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: _description2.replace("{{POOL_NAME}}", "xSTRK/STRK") }),
16093
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
16094
+ "ul",
16095
+ {
16096
+ style: {
16097
+ marginLeft: "20px",
16098
+ listStyle: "circle",
16099
+ fontSize: "12px"
16100
+ },
16101
+ children: [
16102
+ /* @__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." }),
16103
+ /* @__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." })
16104
+ ]
16140
16105
  }
16106
+ )
16107
+ ] }),
16108
+ address: ContractAddr.from(
16109
+ "0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
16110
+ ),
16111
+ launchBlock: 1209881,
16112
+ type: "Other",
16113
+ // must be same order as poolKey token0 and token1
16114
+ depositTokens: [
16115
+ Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
16116
+ Global.getDefaultTokens().find((t) => t.symbol === "STRK")
16117
+ ],
16118
+ protocols: [_protocol2],
16119
+ auditUrl: AUDIT_URL2,
16120
+ maxTVL: Web3Number.fromWei("0", 18),
16121
+ risk: {
16122
+ riskFactor: _riskFactor2,
16123
+ netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
16124
+ notARisks: getNoRiskTags(_riskFactor2)
16125
+ },
16126
+ apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
16127
+ additionalInfo: {
16128
+ newBounds: {
16129
+ lower: -1,
16130
+ upper: 1
16141
16131
  },
16142
- faqs: [
16143
- ...faqs2,
16144
- {
16145
- question: "Why might I see a negative APY?",
16146
- 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."
16147
- }
16148
- ],
16149
- points: [{
16150
- multiplier: 1,
16151
- logo: "https://endur.fi/favicon.ico",
16152
- 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."
16153
- }]
16132
+ lstContract: ContractAddr.from(
16133
+ "0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
16134
+ ),
16135
+ feeBps: 1e3,
16136
+ rebalanceConditions: {
16137
+ customShouldRebalance: async (currentPrice) => true,
16138
+ minWaitHours: 24,
16139
+ direction: "uponly"
16140
+ }
16154
16141
  },
16142
+ faqs: [
16143
+ ...faqs2,
16144
+ {
16145
+ question: "Why might I see a negative APY?",
16146
+ 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."
16147
+ }
16148
+ ],
16149
+ points: [{
16150
+ multiplier: 1,
16151
+ logo: "https://endur.fi/favicon.ico",
16152
+ 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."
16153
+ }]
16154
+ };
16155
+ var EkuboCLVaultStrategies = [
16156
+ xSTRKSTRK,
16155
16157
  {
16156
16158
  name: "Ekubo USDC/USDT",
16157
16159
  description: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
@@ -16205,6 +16207,47 @@ var EkuboCLVaultStrategies = [
16205
16207
  },
16206
16208
  faqs: [...faqs2]
16207
16209
  }
16210
+ // {
16211
+ // ...xSTRKSTRK,
16212
+ // name: "Ekubo STRK/USDC",
16213
+ // description: (
16214
+ // <div>
16215
+ // <p>{_description.replace("{{POOL_NAME}}", "STRK/USDC")}</p>
16216
+ // <ul
16217
+ // style={{
16218
+ // marginLeft: "20px",
16219
+ // listStyle: "circle",
16220
+ // fontSize: "12px",
16221
+ // }}
16222
+ // >
16223
+ // <li style={{ marginTop: "10px" }}>
16224
+ // During withdrawal, you may receive either or both tokens depending
16225
+ // on market conditions and prevailing prices.
16226
+ // </li>
16227
+ // </ul>
16228
+ // </div>
16229
+ // ),
16230
+ // address: ContractAddr.from(
16231
+ // "0xb7bd37121041261446d8eedec618955a4490641034942da688e8cbddea7b23"
16232
+ // ),
16233
+ // launchBlock: 1492136,
16234
+ // // must be same order as poolKey token0 and token1
16235
+ // depositTokens: [
16236
+ // Global.getDefaultTokens().find((t) => t.symbol === "STRK")!,
16237
+ // Global.getDefaultTokens().find((t) => t.symbol === "USDC")!,
16238
+ // ],
16239
+ // maxTVL: Web3Number.fromWei("0", 6),
16240
+ // additionalInfo: {
16241
+ // newBounds: "Managed by Re7",
16242
+ // feeBps: 1000,
16243
+ // rebalanceConditions: {
16244
+ // customShouldRebalance: async (currentPrice: number) =>
16245
+ // true,
16246
+ // minWaitHours: 6,
16247
+ // direction: "any",
16248
+ // },
16249
+ // },
16250
+ // },
16208
16251
  ];
16209
16252
 
16210
16253
  // src/notifs/telegram.ts