@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.
@@ -15296,7 +15296,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15296
15296
  };
15297
15297
  }
15298
15298
  static div2Power128(num5) {
15299
- return Number(BigInt(num5.toString()) * 1000000n / BigInt(2 ** 128)) / 1e6;
15299
+ return Number(BigInt(num5.toString()) * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
15300
15300
  }
15301
15301
  static priceToTick(price, isRoundDown, tickSpacing) {
15302
15302
  const value = isRoundDown ? Math.floor(Math.log(price) / Math.log(1.000001)) : Math.ceil(Math.log(price) / Math.log(1.000001));
@@ -15317,18 +15317,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15317
15317
  tick_spacing: result.pool_key.tick_spacing.toString(),
15318
15318
  extension: result.pool_key.extension.toString()
15319
15319
  };
15320
- const token0Info = await Global.getTokenInfoFromAddr(poolKey.token0);
15321
- const token1Info = await Global.getTokenInfoFromAddr(poolKey.token1);
15322
- assert(
15323
- token0Info.decimals == token1Info.decimals,
15324
- "Tested only for equal decimals"
15325
- );
15326
15320
  this.poolKey = poolKey;
15327
15321
  return poolKey;
15328
15322
  }
15329
15323
  async getNewBounds() {
15330
15324
  const poolKey = await this.getPoolKey();
15331
15325
  const currentPrice = await this._getCurrentPrice(poolKey);
15326
+ if (typeof this.metadata.additionalInfo.newBounds === "string") {
15327
+ throw new Error(`New bounds are managed known, to be set manually/externally`);
15328
+ }
15332
15329
  const newLower = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.lower) * Number(poolKey.tick_spacing);
15333
15330
  const newUpper = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.upper) * Number(poolKey.tick_spacing);
15334
15331
  return {
@@ -15343,8 +15340,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15343
15340
  * @param amount1: amount of token1
15344
15341
  * @returns {amount0, amount1}
15345
15342
  */
15346
- async _getExpectedAmountsForLiquidity(amount0, amount1, bounds, justUseInputAmount = true) {
15347
- assert(amount0.greaterThan(0) || amount1.greaterThan(0), "Amount is 0");
15343
+ async _getExpectedAmountsForLiquidity(inputAmount0, inputAmount1, bounds, justUseInputAmount = true) {
15344
+ assert(inputAmount0.greaterThan(0) || inputAmount1.greaterThan(0), "Amount is 0");
15348
15345
  const sampleLiq = 1e20;
15349
15346
  const { amount0: sampleAmount0, amount1: sampleAmount1 } = await this.getLiquidityToAmounts(
15350
15347
  Web3Number.fromWei(sampleLiq.toString(), 18),
@@ -15358,39 +15355,37 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15358
15355
  logger.verbose(
15359
15356
  `${_EkuboCLVault.name}: _getExpectedAmountsForLiquidity => price: ${price}`
15360
15357
  );
15361
- if (amount1.eq(0) && amount0.greaterThan(0)) {
15358
+ if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
15362
15359
  if (sampleAmount1.eq(0)) {
15363
15360
  return {
15364
- amount0,
15365
- amount1: Web3Number.fromWei("0", amount1.decimals),
15361
+ amount0: inputAmount0,
15362
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals),
15366
15363
  ratio: Infinity
15367
15364
  };
15368
15365
  } else if (sampleAmount0.eq(0)) {
15369
15366
  return {
15370
- amount0: Web3Number.fromWei("0", amount0.decimals),
15371
- amount1: amount0.multipliedBy(price),
15367
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals),
15368
+ // to ensure decimal consistency, we start with 0
15369
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals).plus(inputAmount0.toString()).multipliedBy(price),
15372
15370
  ratio: 0
15373
15371
  };
15374
15372
  }
15375
- } else if (amount0.eq(0) && amount1.greaterThan(0)) {
15373
+ } else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
15376
15374
  if (sampleAmount0.eq(0)) {
15377
15375
  return {
15378
- amount0: Web3Number.fromWei("0", amount0.decimals),
15379
- amount1,
15376
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals),
15377
+ amount1: inputAmount1,
15380
15378
  ratio: 0
15381
15379
  };
15382
15380
  } else if (sampleAmount1.eq(0)) {
15383
15381
  return {
15384
- amount0: amount1.dividedBy(price),
15385
- amount1: Web3Number.fromWei("0", amount1.decimals),
15382
+ // to ensure decimal consistency, we start with 0
15383
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals).plus(inputAmount1.toString()).dividedBy(price),
15384
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals),
15386
15385
  ratio: Infinity
15387
15386
  };
15388
15387
  }
15389
15388
  }
15390
- assert(
15391
- sampleAmount0.decimals == sampleAmount1.decimals,
15392
- "Sample amounts have different decimals"
15393
- );
15394
15389
  const ratioWeb3Number = sampleAmount0.multipliedBy(1e18).dividedBy(sampleAmount1.toString()).dividedBy(1e18);
15395
15390
  const ratio = Number(ratioWeb3Number.toFixed(18));
15396
15391
  logger.verbose(
@@ -15398,23 +15393,23 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15398
15393
  );
15399
15394
  if (justUseInputAmount)
15400
15395
  return this._solveExpectedAmountsEq(
15401
- amount0,
15402
- amount1,
15396
+ inputAmount0,
15397
+ inputAmount1,
15403
15398
  ratioWeb3Number,
15404
15399
  price
15405
15400
  );
15406
- if (amount1.eq(0) && amount0.greaterThan(0)) {
15407
- const _amount1 = amount0.dividedBy(ratioWeb3Number);
15401
+ if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
15402
+ const _amount1 = new Web3Number(inputAmount0.toString(), inputAmount1.decimals).dividedBy(ratioWeb3Number);
15408
15403
  return {
15409
- amount0,
15404
+ amount0: inputAmount0,
15410
15405
  amount1: _amount1,
15411
15406
  ratio
15412
15407
  };
15413
- } else if (amount0.eq(0) && amount1.greaterThan(0)) {
15414
- const _amount0 = amount1.multipliedBy(ratio);
15408
+ } else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
15409
+ const _amount0 = new Web3Number(inputAmount1.toString(), inputAmount0.decimals).multipliedBy(ratio);
15415
15410
  return {
15416
15411
  amount0: _amount0,
15417
- amount1,
15412
+ amount1: inputAmount1,
15418
15413
  ratio
15419
15414
  };
15420
15415
  } else {
@@ -15477,7 +15472,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15477
15472
  }
15478
15473
  };
15479
15474
  }
15480
- async getSwapInfoToHandleUnused(considerRebalance = true) {
15475
+ async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null) {
15481
15476
  const poolKey = await this.getPoolKey();
15482
15477
  const unusedBalances = await this.unusedBalances(poolKey);
15483
15478
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -15500,7 +15495,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15500
15495
  `${_EkuboCLVault.name}: getSwapInfoToHandleUnused => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
15501
15496
  );
15502
15497
  let ekuboBounds;
15503
- if (considerRebalance) {
15498
+ if (newBounds) {
15499
+ ekuboBounds = newBounds;
15500
+ } else if (considerRebalance) {
15504
15501
  ekuboBounds = await this.getNewBounds();
15505
15502
  } else {
15506
15503
  ekuboBounds = await this.getCurrentBounds();
@@ -15741,6 +15738,10 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15741
15738
  return BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128) / BigInt(1e9);
15742
15739
  }
15743
15740
  static i129ToNumber(i129) {
15741
+ if (i129.sign == 0 || i129.sign == 1) {
15742
+ return _EkuboCLVault.i129ToNumber({ mag: i129.mag, sign: i129.sign == 1 ? "true" : "false" });
15743
+ }
15744
+ assert(i129.sign.toString() == "false" || i129.sign.toString() == "true", "Invalid sign value");
15744
15745
  return i129.mag * (i129.sign.toString() == "false" ? 1n : -1n);
15745
15746
  }
15746
15747
  static tickToPrice(tick) {
@@ -15919,7 +15920,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15919
15920
  subItems: [
15920
15921
  {
15921
15922
  key: "Range selection",
15922
- value: `${this.metadata.additionalInfo.newBounds.lower * Number(poolKey.tick_spacing)} to ${this.metadata.additionalInfo.newBounds.upper * Number(poolKey.tick_spacing)} ticks`
15923
+ 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`
15923
15924
  }
15924
15925
  ],
15925
15926
  linkedFlows: [linkedFlow],
@@ -15971,12 +15972,79 @@ var faqs2 = [
15971
15972
  ] })
15972
15973
  }
15973
15974
  ];
15975
+ var xSTRKSTRK = {
15976
+ name: "Ekubo xSTRK/STRK",
15977
+ description: /* @__PURE__ */ jsxs2("div", { children: [
15978
+ /* @__PURE__ */ jsx2("p", { children: _description2.replace("{{POOL_NAME}}", "xSTRK/STRK") }),
15979
+ /* @__PURE__ */ jsxs2(
15980
+ "ul",
15981
+ {
15982
+ style: {
15983
+ marginLeft: "20px",
15984
+ listStyle: "circle",
15985
+ fontSize: "12px"
15986
+ },
15987
+ children: [
15988
+ /* @__PURE__ */ jsx2("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." }),
15989
+ /* @__PURE__ */ jsx2("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." })
15990
+ ]
15991
+ }
15992
+ )
15993
+ ] }),
15994
+ address: ContractAddr.from(
15995
+ "0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
15996
+ ),
15997
+ launchBlock: 1209881,
15998
+ type: "Other",
15999
+ // must be same order as poolKey token0 and token1
16000
+ depositTokens: [
16001
+ Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
16002
+ Global.getDefaultTokens().find((t) => t.symbol === "STRK")
16003
+ ],
16004
+ protocols: [_protocol2],
16005
+ auditUrl: AUDIT_URL2,
16006
+ maxTVL: Web3Number.fromWei("0", 18),
16007
+ risk: {
16008
+ riskFactor: _riskFactor2,
16009
+ netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
16010
+ notARisks: getNoRiskTags(_riskFactor2)
16011
+ },
16012
+ apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
16013
+ additionalInfo: {
16014
+ newBounds: {
16015
+ lower: -1,
16016
+ upper: 1
16017
+ },
16018
+ lstContract: ContractAddr.from(
16019
+ "0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
16020
+ ),
16021
+ feeBps: 1e3,
16022
+ rebalanceConditions: {
16023
+ customShouldRebalance: async (currentPrice) => true,
16024
+ minWaitHours: 24,
16025
+ direction: "uponly"
16026
+ }
16027
+ },
16028
+ faqs: [
16029
+ ...faqs2,
16030
+ {
16031
+ question: "Why might I see a negative APY?",
16032
+ 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."
16033
+ }
16034
+ ],
16035
+ points: [{
16036
+ multiplier: 1,
16037
+ logo: "https://endur.fi/favicon.ico",
16038
+ 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."
16039
+ }]
16040
+ };
15974
16041
  var EkuboCLVaultStrategies = [
16042
+ xSTRKSTRK,
15975
16043
  {
15976
- name: "Ekubo xSTRK/STRK",
16044
+ name: "Ekubo USDC/USDT",
15977
16045
  description: /* @__PURE__ */ jsxs2("div", { children: [
15978
- /* @__PURE__ */ jsx2("p", { children: _description2.replace("{{POOL_NAME}}", "xSTRK/STRK") }),
15979
- /* @__PURE__ */ jsxs2(
16046
+ /* @__PURE__ */ jsx2("p", { children: _description2.replace("{{POOL_NAME}}", "USDC/USDT") }),
16047
+ /* @__PURE__ */ jsx2(
15980
16048
  "ul",
15981
16049
  {
15982
16050
  style: {
@@ -15984,30 +16052,30 @@ var EkuboCLVaultStrategies = [
15984
16052
  listStyle: "circle",
15985
16053
  fontSize: "12px"
15986
16054
  },
15987
- children: [
15988
- /* @__PURE__ */ jsx2("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." }),
15989
- /* @__PURE__ */ jsx2("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." })
15990
- ]
16055
+ children: /* @__PURE__ */ jsx2("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." })
15991
16056
  }
15992
16057
  )
15993
16058
  ] }),
15994
16059
  address: ContractAddr.from(
15995
- "0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
16060
+ "0xd647ed735f0db52f2a5502b6e06ed21dc4284a43a36af4b60d3c80fbc56c91"
15996
16061
  ),
15997
- launchBlock: 1209881,
16062
+ launchBlock: 1385576,
15998
16063
  type: "Other",
15999
16064
  // must be same order as poolKey token0 and token1
16000
16065
  depositTokens: [
16001
- Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
16002
- Global.getDefaultTokens().find((t) => t.symbol === "STRK")
16066
+ Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
16067
+ Global.getDefaultTokens().find((t) => t.symbol === "USDT")
16003
16068
  ],
16004
16069
  protocols: [_protocol2],
16005
16070
  auditUrl: AUDIT_URL2,
16006
- maxTVL: Web3Number.fromWei("0", 18),
16071
+ maxTVL: Web3Number.fromWei("0", 6),
16007
16072
  risk: {
16008
- riskFactor: _riskFactor2,
16009
- netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
16010
- notARisks: getNoRiskTags(_riskFactor2)
16073
+ riskFactor: _riskFactorStable,
16074
+ netRisk: _riskFactorStable.reduce(
16075
+ (acc, curr) => acc + curr.value * curr.weight,
16076
+ 0
16077
+ ) / _riskFactorStable.reduce((acc, curr) => acc + curr.weight, 0),
16078
+ notARisks: getNoRiskTags(_riskFactorStable)
16011
16079
  },
16012
16080
  apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
16013
16081
  additionalInfo: {
@@ -16015,29 +16083,22 @@ var EkuboCLVaultStrategies = [
16015
16083
  lower: -1,
16016
16084
  upper: 1
16017
16085
  },
16018
- lstContract: ContractAddr.from(
16019
- "0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
16020
- ),
16086
+ truePrice: 1,
16021
16087
  feeBps: 1e3,
16022
16088
  rebalanceConditions: {
16023
- customShouldRebalance: async (currentPrice) => true,
16024
- minWaitHours: 24,
16025
- direction: "uponly"
16089
+ customShouldRebalance: async (currentPrice) => currentPrice > 0.99 && currentPrice < 1.01,
16090
+ minWaitHours: 6,
16091
+ direction: "any"
16026
16092
  }
16027
16093
  },
16028
- faqs: [
16029
- ...faqs2,
16030
- {
16031
- question: "Why might I see a negative APY?",
16032
- 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."
16033
- }
16034
- ]
16094
+ faqs: [...faqs2]
16035
16095
  }
16036
16096
  // {
16037
- // name: "Ekubo USDC/USDT",
16097
+ // ...xSTRKSTRK,
16098
+ // name: "Ekubo STRK/USDC",
16038
16099
  // description: (
16039
16100
  // <div>
16040
- // <p>{_description.replace("{{POOL_NAME}}", "USDC/USDT")}</p>
16101
+ // <p>{_description.replace("{{POOL_NAME}}", "STRK/USDC")}</p>
16041
16102
  // <ul
16042
16103
  // style={{
16043
16104
  // marginLeft: "20px",
@@ -16053,44 +16114,25 @@ var EkuboCLVaultStrategies = [
16053
16114
  // </div>
16054
16115
  // ),
16055
16116
  // address: ContractAddr.from(
16056
- // "0xd647ed735f0db52f2a5502b6e06ed21dc4284a43a36af4b60d3c80fbc56c91"
16117
+ // "0xb7bd37121041261446d8eedec618955a4490641034942da688e8cbddea7b23"
16057
16118
  // ),
16058
- // launchBlock: 1385576,
16059
- // type: "Other",
16119
+ // launchBlock: 1492136,
16060
16120
  // // must be same order as poolKey token0 and token1
16061
16121
  // depositTokens: [
16122
+ // Global.getDefaultTokens().find((t) => t.symbol === "STRK")!,
16062
16123
  // Global.getDefaultTokens().find((t) => t.symbol === "USDC")!,
16063
- // Global.getDefaultTokens().find((t) => t.symbol === "USDT")!,
16064
16124
  // ],
16065
- // protocols: [_protocol],
16066
- // auditUrl: AUDIT_URL,
16067
16125
  // maxTVL: Web3Number.fromWei("0", 6),
16068
- // risk: {
16069
- // riskFactor: _riskFactorStable,
16070
- // netRisk:
16071
- // _riskFactorStable.reduce(
16072
- // (acc, curr) => acc + curr.value * curr.weight,
16073
- // 0
16074
- // ) / _riskFactorStable.reduce((acc, curr) => acc + curr.weight, 0),
16075
- // notARisks: getNoRiskTags(_riskFactorStable),
16076
- // },
16077
- // apyMethodology:
16078
- // "APY based on 7-day historical performance, including fees and rewards.",
16079
16126
  // additionalInfo: {
16080
- // newBounds: {
16081
- // lower: -1,
16082
- // upper: 1,
16083
- // },
16084
- // truePrice: 1,
16127
+ // newBounds: "Managed by Re7",
16085
16128
  // feeBps: 1000,
16086
16129
  // rebalanceConditions: {
16087
16130
  // customShouldRebalance: async (currentPrice: number) =>
16088
- // currentPrice > 0.99 && currentPrice < 1.01,
16131
+ // true,
16089
16132
  // minWaitHours: 6,
16090
16133
  // direction: "any",
16091
16134
  // },
16092
16135
  // },
16093
- // faqs: [...faqs],
16094
16136
  // },
16095
16137
  ];
16096
16138
  export {
package/dist/index.d.ts CHANGED
@@ -110,6 +110,11 @@ interface IStrategyMetadata<T> {
110
110
  apyMethodology?: string;
111
111
  additionalInfo: T;
112
112
  faqs: FAQ[];
113
+ points?: {
114
+ multiplier: number;
115
+ logo: string;
116
+ toolTip?: string;
117
+ }[];
113
118
  }
114
119
  interface IInvestmentFlow {
115
120
  id?: string;
@@ -595,7 +600,7 @@ interface CLVaultStrategySettings {
595
600
  newBounds: {
596
601
  lower: number;
597
602
  upper: number;
598
- };
603
+ } | string;
599
604
  lstContract?: ContractAddr;
600
605
  truePrice?: number;
601
606
  feeBps: number;
@@ -690,7 +695,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
690
695
  usdValue: number;
691
696
  };
692
697
  }>;
693
- getSwapInfoToHandleUnused(considerRebalance?: boolean): Promise<SwapInfo>;
698
+ getSwapInfoToHandleUnused(considerRebalance?: boolean, newBounds?: EkuboBounds | null): Promise<SwapInfo>;
694
699
  getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds): Promise<SwapInfo>;
695
700
  /**
696
701
  * Attempts to rebalance the vault by iteratively adjusting swap amounts if initial attempt fails.
@@ -713,7 +718,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
713
718
  static priceToSqrtRatio(price: number): bigint;
714
719
  static i129ToNumber(i129: {
715
720
  mag: bigint;
716
- sign: number;
721
+ sign: 0 | 1 | "true" | "false";
717
722
  }): bigint;
718
723
  static tickToPrice(tick: bigint): number;
719
724
  getLiquidityToAmounts(liquidity: Web3Number, bounds: EkuboBounds, blockIdentifier?: BlockIdentifier, _poolKey?: EkuboPoolKey | null, _currentPrice?: {