@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.
package/dist/index.mjs CHANGED
@@ -15345,7 +15345,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15345
15345
  };
15346
15346
  }
15347
15347
  static div2Power128(num5) {
15348
- return Number(BigInt(num5.toString()) * 1000000n / BigInt(2 ** 128)) / 1e6;
15348
+ return Number(BigInt(num5.toString()) * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
15349
15349
  }
15350
15350
  static priceToTick(price, isRoundDown, tickSpacing) {
15351
15351
  const value = isRoundDown ? Math.floor(Math.log(price) / Math.log(1.000001)) : Math.ceil(Math.log(price) / Math.log(1.000001));
@@ -15366,18 +15366,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15366
15366
  tick_spacing: result.pool_key.tick_spacing.toString(),
15367
15367
  extension: result.pool_key.extension.toString()
15368
15368
  };
15369
- const token0Info = await Global.getTokenInfoFromAddr(poolKey.token0);
15370
- const token1Info = await Global.getTokenInfoFromAddr(poolKey.token1);
15371
- assert(
15372
- token0Info.decimals == token1Info.decimals,
15373
- "Tested only for equal decimals"
15374
- );
15375
15369
  this.poolKey = poolKey;
15376
15370
  return poolKey;
15377
15371
  }
15378
15372
  async getNewBounds() {
15379
15373
  const poolKey = await this.getPoolKey();
15380
15374
  const currentPrice = await this._getCurrentPrice(poolKey);
15375
+ if (typeof this.metadata.additionalInfo.newBounds === "string") {
15376
+ throw new Error(`New bounds are managed known, to be set manually/externally`);
15377
+ }
15381
15378
  const newLower = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.lower) * Number(poolKey.tick_spacing);
15382
15379
  const newUpper = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.upper) * Number(poolKey.tick_spacing);
15383
15380
  return {
@@ -15392,8 +15389,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15392
15389
  * @param amount1: amount of token1
15393
15390
  * @returns {amount0, amount1}
15394
15391
  */
15395
- async _getExpectedAmountsForLiquidity(amount0, amount1, bounds, justUseInputAmount = true) {
15396
- assert(amount0.greaterThan(0) || amount1.greaterThan(0), "Amount is 0");
15392
+ async _getExpectedAmountsForLiquidity(inputAmount0, inputAmount1, bounds, justUseInputAmount = true) {
15393
+ assert(inputAmount0.greaterThan(0) || inputAmount1.greaterThan(0), "Amount is 0");
15397
15394
  const sampleLiq = 1e20;
15398
15395
  const { amount0: sampleAmount0, amount1: sampleAmount1 } = await this.getLiquidityToAmounts(
15399
15396
  Web3Number.fromWei(sampleLiq.toString(), 18),
@@ -15407,39 +15404,37 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15407
15404
  logger.verbose(
15408
15405
  `${_EkuboCLVault.name}: _getExpectedAmountsForLiquidity => price: ${price}`
15409
15406
  );
15410
- if (amount1.eq(0) && amount0.greaterThan(0)) {
15407
+ if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
15411
15408
  if (sampleAmount1.eq(0)) {
15412
15409
  return {
15413
- amount0,
15414
- amount1: Web3Number.fromWei("0", amount1.decimals),
15410
+ amount0: inputAmount0,
15411
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals),
15415
15412
  ratio: Infinity
15416
15413
  };
15417
15414
  } else if (sampleAmount0.eq(0)) {
15418
15415
  return {
15419
- amount0: Web3Number.fromWei("0", amount0.decimals),
15420
- amount1: amount0.multipliedBy(price),
15416
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals),
15417
+ // to ensure decimal consistency, we start with 0
15418
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals).plus(inputAmount0.toString()).multipliedBy(price),
15421
15419
  ratio: 0
15422
15420
  };
15423
15421
  }
15424
- } else if (amount0.eq(0) && amount1.greaterThan(0)) {
15422
+ } else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
15425
15423
  if (sampleAmount0.eq(0)) {
15426
15424
  return {
15427
- amount0: Web3Number.fromWei("0", amount0.decimals),
15428
- amount1,
15425
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals),
15426
+ amount1: inputAmount1,
15429
15427
  ratio: 0
15430
15428
  };
15431
15429
  } else if (sampleAmount1.eq(0)) {
15432
15430
  return {
15433
- amount0: amount1.dividedBy(price),
15434
- amount1: Web3Number.fromWei("0", amount1.decimals),
15431
+ // to ensure decimal consistency, we start with 0
15432
+ amount0: Web3Number.fromWei("0", inputAmount0.decimals).plus(inputAmount1.toString()).dividedBy(price),
15433
+ amount1: Web3Number.fromWei("0", inputAmount1.decimals),
15435
15434
  ratio: Infinity
15436
15435
  };
15437
15436
  }
15438
15437
  }
15439
- assert(
15440
- sampleAmount0.decimals == sampleAmount1.decimals,
15441
- "Sample amounts have different decimals"
15442
- );
15443
15438
  const ratioWeb3Number = sampleAmount0.multipliedBy(1e18).dividedBy(sampleAmount1.toString()).dividedBy(1e18);
15444
15439
  const ratio = Number(ratioWeb3Number.toFixed(18));
15445
15440
  logger.verbose(
@@ -15447,23 +15442,23 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15447
15442
  );
15448
15443
  if (justUseInputAmount)
15449
15444
  return this._solveExpectedAmountsEq(
15450
- amount0,
15451
- amount1,
15445
+ inputAmount0,
15446
+ inputAmount1,
15452
15447
  ratioWeb3Number,
15453
15448
  price
15454
15449
  );
15455
- if (amount1.eq(0) && amount0.greaterThan(0)) {
15456
- const _amount1 = amount0.dividedBy(ratioWeb3Number);
15450
+ if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
15451
+ const _amount1 = new Web3Number(inputAmount0.toString(), inputAmount1.decimals).dividedBy(ratioWeb3Number);
15457
15452
  return {
15458
- amount0,
15453
+ amount0: inputAmount0,
15459
15454
  amount1: _amount1,
15460
15455
  ratio
15461
15456
  };
15462
- } else if (amount0.eq(0) && amount1.greaterThan(0)) {
15463
- const _amount0 = amount1.multipliedBy(ratio);
15457
+ } else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
15458
+ const _amount0 = new Web3Number(inputAmount1.toString(), inputAmount0.decimals).multipliedBy(ratio);
15464
15459
  return {
15465
15460
  amount0: _amount0,
15466
- amount1,
15461
+ amount1: inputAmount1,
15467
15462
  ratio
15468
15463
  };
15469
15464
  } else {
@@ -15526,7 +15521,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15526
15521
  }
15527
15522
  };
15528
15523
  }
15529
- async getSwapInfoToHandleUnused(considerRebalance = true) {
15524
+ async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null) {
15530
15525
  const poolKey = await this.getPoolKey();
15531
15526
  const unusedBalances = await this.unusedBalances(poolKey);
15532
15527
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -15549,7 +15544,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15549
15544
  `${_EkuboCLVault.name}: getSwapInfoToHandleUnused => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
15550
15545
  );
15551
15546
  let ekuboBounds;
15552
- if (considerRebalance) {
15547
+ if (newBounds) {
15548
+ ekuboBounds = newBounds;
15549
+ } else if (considerRebalance) {
15553
15550
  ekuboBounds = await this.getNewBounds();
15554
15551
  } else {
15555
15552
  ekuboBounds = await this.getCurrentBounds();
@@ -15790,6 +15787,10 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15790
15787
  return BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128) / BigInt(1e9);
15791
15788
  }
15792
15789
  static i129ToNumber(i129) {
15790
+ if (i129.sign == 0 || i129.sign == 1) {
15791
+ return _EkuboCLVault.i129ToNumber({ mag: i129.mag, sign: i129.sign == 1 ? "true" : "false" });
15792
+ }
15793
+ assert(i129.sign.toString() == "false" || i129.sign.toString() == "true", "Invalid sign value");
15793
15794
  return i129.mag * (i129.sign.toString() == "false" ? 1n : -1n);
15794
15795
  }
15795
15796
  static tickToPrice(tick) {
@@ -15968,7 +15969,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15968
15969
  subItems: [
15969
15970
  {
15970
15971
  key: "Range selection",
15971
- value: `${this.metadata.additionalInfo.newBounds.lower * Number(poolKey.tick_spacing)} to ${this.metadata.additionalInfo.newBounds.upper * Number(poolKey.tick_spacing)} ticks`
15972
+ 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`
15972
15973
  }
15973
15974
  ],
15974
15975
  linkedFlows: [linkedFlow],
@@ -16020,12 +16021,79 @@ var faqs2 = [
16020
16021
  ] })
16021
16022
  }
16022
16023
  ];
16024
+ var xSTRKSTRK = {
16025
+ name: "Ekubo xSTRK/STRK",
16026
+ description: /* @__PURE__ */ jsxs2("div", { children: [
16027
+ /* @__PURE__ */ jsx2("p", { children: _description2.replace("{{POOL_NAME}}", "xSTRK/STRK") }),
16028
+ /* @__PURE__ */ jsxs2(
16029
+ "ul",
16030
+ {
16031
+ style: {
16032
+ marginLeft: "20px",
16033
+ listStyle: "circle",
16034
+ fontSize: "12px"
16035
+ },
16036
+ children: [
16037
+ /* @__PURE__ */ jsx2("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." }),
16038
+ /* @__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." })
16039
+ ]
16040
+ }
16041
+ )
16042
+ ] }),
16043
+ address: ContractAddr.from(
16044
+ "0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
16045
+ ),
16046
+ launchBlock: 1209881,
16047
+ type: "Other",
16048
+ // must be same order as poolKey token0 and token1
16049
+ depositTokens: [
16050
+ Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
16051
+ Global.getDefaultTokens().find((t) => t.symbol === "STRK")
16052
+ ],
16053
+ protocols: [_protocol2],
16054
+ auditUrl: AUDIT_URL2,
16055
+ maxTVL: Web3Number.fromWei("0", 18),
16056
+ risk: {
16057
+ riskFactor: _riskFactor2,
16058
+ netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
16059
+ notARisks: getNoRiskTags(_riskFactor2)
16060
+ },
16061
+ apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
16062
+ additionalInfo: {
16063
+ newBounds: {
16064
+ lower: -1,
16065
+ upper: 1
16066
+ },
16067
+ lstContract: ContractAddr.from(
16068
+ "0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
16069
+ ),
16070
+ feeBps: 1e3,
16071
+ rebalanceConditions: {
16072
+ customShouldRebalance: async (currentPrice) => true,
16073
+ minWaitHours: 24,
16074
+ direction: "uponly"
16075
+ }
16076
+ },
16077
+ faqs: [
16078
+ ...faqs2,
16079
+ {
16080
+ question: "Why might I see a negative APY?",
16081
+ 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."
16082
+ }
16083
+ ],
16084
+ points: [{
16085
+ multiplier: 1,
16086
+ logo: "https://endur.fi/favicon.ico",
16087
+ 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."
16088
+ }]
16089
+ };
16023
16090
  var EkuboCLVaultStrategies = [
16091
+ xSTRKSTRK,
16024
16092
  {
16025
- name: "Ekubo xSTRK/STRK",
16093
+ name: "Ekubo USDC/USDT",
16026
16094
  description: /* @__PURE__ */ jsxs2("div", { children: [
16027
- /* @__PURE__ */ jsx2("p", { children: _description2.replace("{{POOL_NAME}}", "xSTRK/STRK") }),
16028
- /* @__PURE__ */ jsxs2(
16095
+ /* @__PURE__ */ jsx2("p", { children: _description2.replace("{{POOL_NAME}}", "USDC/USDT") }),
16096
+ /* @__PURE__ */ jsx2(
16029
16097
  "ul",
16030
16098
  {
16031
16099
  style: {
@@ -16033,30 +16101,30 @@ var EkuboCLVaultStrategies = [
16033
16101
  listStyle: "circle",
16034
16102
  fontSize: "12px"
16035
16103
  },
16036
- children: [
16037
- /* @__PURE__ */ jsx2("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." }),
16038
- /* @__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." })
16039
- ]
16104
+ children: /* @__PURE__ */ jsx2("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." })
16040
16105
  }
16041
16106
  )
16042
16107
  ] }),
16043
16108
  address: ContractAddr.from(
16044
- "0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
16109
+ "0xd647ed735f0db52f2a5502b6e06ed21dc4284a43a36af4b60d3c80fbc56c91"
16045
16110
  ),
16046
- launchBlock: 1209881,
16111
+ launchBlock: 1385576,
16047
16112
  type: "Other",
16048
16113
  // must be same order as poolKey token0 and token1
16049
16114
  depositTokens: [
16050
- Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
16051
- Global.getDefaultTokens().find((t) => t.symbol === "STRK")
16115
+ Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
16116
+ Global.getDefaultTokens().find((t) => t.symbol === "USDT")
16052
16117
  ],
16053
16118
  protocols: [_protocol2],
16054
16119
  auditUrl: AUDIT_URL2,
16055
- maxTVL: Web3Number.fromWei("0", 18),
16120
+ maxTVL: Web3Number.fromWei("0", 6),
16056
16121
  risk: {
16057
- riskFactor: _riskFactor2,
16058
- netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
16059
- notARisks: getNoRiskTags(_riskFactor2)
16122
+ riskFactor: _riskFactorStable,
16123
+ netRisk: _riskFactorStable.reduce(
16124
+ (acc, curr) => acc + curr.value * curr.weight,
16125
+ 0
16126
+ ) / _riskFactorStable.reduce((acc, curr) => acc + curr.weight, 0),
16127
+ notARisks: getNoRiskTags(_riskFactorStable)
16060
16128
  },
16061
16129
  apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
16062
16130
  additionalInfo: {
@@ -16064,29 +16132,22 @@ var EkuboCLVaultStrategies = [
16064
16132
  lower: -1,
16065
16133
  upper: 1
16066
16134
  },
16067
- lstContract: ContractAddr.from(
16068
- "0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
16069
- ),
16135
+ truePrice: 1,
16070
16136
  feeBps: 1e3,
16071
16137
  rebalanceConditions: {
16072
- customShouldRebalance: async (currentPrice) => true,
16073
- minWaitHours: 24,
16074
- direction: "uponly"
16138
+ customShouldRebalance: async (currentPrice) => currentPrice > 0.99 && currentPrice < 1.01,
16139
+ minWaitHours: 6,
16140
+ direction: "any"
16075
16141
  }
16076
16142
  },
16077
- faqs: [
16078
- ...faqs2,
16079
- {
16080
- question: "Why might I see a negative APY?",
16081
- 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."
16082
- }
16083
- ]
16143
+ faqs: [...faqs2]
16084
16144
  }
16085
16145
  // {
16086
- // name: "Ekubo USDC/USDT",
16146
+ // ...xSTRKSTRK,
16147
+ // name: "Ekubo STRK/USDC",
16087
16148
  // description: (
16088
16149
  // <div>
16089
- // <p>{_description.replace("{{POOL_NAME}}", "USDC/USDT")}</p>
16150
+ // <p>{_description.replace("{{POOL_NAME}}", "STRK/USDC")}</p>
16090
16151
  // <ul
16091
16152
  // style={{
16092
16153
  // marginLeft: "20px",
@@ -16102,44 +16163,25 @@ var EkuboCLVaultStrategies = [
16102
16163
  // </div>
16103
16164
  // ),
16104
16165
  // address: ContractAddr.from(
16105
- // "0xd647ed735f0db52f2a5502b6e06ed21dc4284a43a36af4b60d3c80fbc56c91"
16166
+ // "0xb7bd37121041261446d8eedec618955a4490641034942da688e8cbddea7b23"
16106
16167
  // ),
16107
- // launchBlock: 1385576,
16108
- // type: "Other",
16168
+ // launchBlock: 1492136,
16109
16169
  // // must be same order as poolKey token0 and token1
16110
16170
  // depositTokens: [
16171
+ // Global.getDefaultTokens().find((t) => t.symbol === "STRK")!,
16111
16172
  // Global.getDefaultTokens().find((t) => t.symbol === "USDC")!,
16112
- // Global.getDefaultTokens().find((t) => t.symbol === "USDT")!,
16113
16173
  // ],
16114
- // protocols: [_protocol],
16115
- // auditUrl: AUDIT_URL,
16116
16174
  // maxTVL: Web3Number.fromWei("0", 6),
16117
- // risk: {
16118
- // riskFactor: _riskFactorStable,
16119
- // netRisk:
16120
- // _riskFactorStable.reduce(
16121
- // (acc, curr) => acc + curr.value * curr.weight,
16122
- // 0
16123
- // ) / _riskFactorStable.reduce((acc, curr) => acc + curr.weight, 0),
16124
- // notARisks: getNoRiskTags(_riskFactorStable),
16125
- // },
16126
- // apyMethodology:
16127
- // "APY based on 7-day historical performance, including fees and rewards.",
16128
16175
  // additionalInfo: {
16129
- // newBounds: {
16130
- // lower: -1,
16131
- // upper: 1,
16132
- // },
16133
- // truePrice: 1,
16176
+ // newBounds: "Managed by Re7",
16134
16177
  // feeBps: 1000,
16135
16178
  // rebalanceConditions: {
16136
16179
  // customShouldRebalance: async (currentPrice: number) =>
16137
- // currentPrice > 0.99 && currentPrice < 1.01,
16180
+ // true,
16138
16181
  // minWaitHours: 6,
16139
16182
  // direction: "any",
16140
16183
  // },
16141
16184
  // },
16142
- // faqs: [...faqs],
16143
16185
  // },
16144
16186
  ];
16145
16187
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "description": "STRKFarm TS SDK (Meant for our internal use, but feel free to use it)",
5
5
  "typings": "dist/index.d.ts",
6
6
  "types": "dist/index.d.ts",
@@ -84,6 +84,7 @@ export interface IStrategyMetadata<T> {
84
84
  apyMethodology?: string;
85
85
  additionalInfo: T;
86
86
  faqs: FAQ[];
87
+ points?: {multiplier: number, logo: string, toolTip?: string}[];
87
88
  }
88
89
 
89
90
  export interface IInvestmentFlow {