@strkfarm/sdk 1.0.51 → 1.0.52

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.
@@ -51731,7 +51731,7 @@ var strkfarm_risk_engine = (() => {
51731
51731
  }
51732
51732
  };
51733
51733
  }
51734
- async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null) {
51734
+ async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20) {
51735
51735
  const poolKey = await this.getPoolKey();
51736
51736
  const unusedBalances = await this.unusedBalances(poolKey);
51737
51737
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -51768,10 +51768,11 @@ var strkfarm_risk_engine = (() => {
51768
51768
  poolKey,
51769
51769
  token0Bal,
51770
51770
  token1Bal,
51771
- ekuboBounds
51771
+ ekuboBounds,
51772
+ maxIterations
51772
51773
  );
51773
51774
  }
51774
- async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds) {
51775
+ async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20) {
51775
51776
  logger.verbose(
51776
51777
  `${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
51777
51778
  );
@@ -51784,7 +51785,7 @@ var strkfarm_risk_engine = (() => {
51784
51785
  `${_EkuboCLVault.name}: getSwapInfoToHandleUnused => expectedAmounts2: ${expectedAmounts.amount0.toString()}, ${expectedAmounts.amount1.toString()}`
51785
51786
  );
51786
51787
  let retry = 0;
51787
- const maxRetry = 10;
51788
+ const maxRetry = maxIterations;
51788
51789
  function assertValidAmounts(expectedAmounts2, token0Bal2, token1Bal2) {
51789
51790
  if (expectedAmounts2.amount0.lessThan(token0Bal2) && expectedAmounts2.amount1.lessThan(token1Bal2)) {
51790
51791
  throw new Error("Both tokens are decreased, something is wrong");
@@ -51894,8 +51895,7 @@ var strkfarm_risk_engine = (() => {
51894
51895
  * @returns Array of contract calls needed for rebalancing
51895
51896
  * @throws Error if max retries reached without successful rebalance
51896
51897
  */
51897
- async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n) {
51898
- const MAX_RETRIES = 40;
51898
+ async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40) {
51899
51899
  logger.verbose(
51900
51900
  `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}`
51901
51901
  );
@@ -52048,7 +52048,7 @@ var strkfarm_risk_engine = (() => {
52048
52048
  amount1
52049
52049
  };
52050
52050
  }
52051
- async harvest(acc) {
52051
+ async harvest(acc, maxIterations = 20) {
52052
52052
  const ekuboHarvests = new EkuboHarvests(this.config);
52053
52053
  const unClaimedRewards = await ekuboHarvests.getUnHarvestedRewards(
52054
52054
  this.address
@@ -52077,7 +52077,8 @@ var strkfarm_risk_engine = (() => {
52077
52077
  poolKey,
52078
52078
  token0Amt,
52079
52079
  token1Amt,
52080
- bounds
52080
+ bounds,
52081
+ maxIterations
52081
52082
  );
52082
52083
  swapInfo.token_to_address = token0Info.address.address;
52083
52084
  logger.verbose(
@@ -15524,7 +15524,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15524
15524
  }
15525
15525
  };
15526
15526
  }
15527
- async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null) {
15527
+ async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20) {
15528
15528
  const poolKey = await this.getPoolKey();
15529
15529
  const unusedBalances = await this.unusedBalances(poolKey);
15530
15530
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -15561,10 +15561,11 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15561
15561
  poolKey,
15562
15562
  token0Bal,
15563
15563
  token1Bal,
15564
- ekuboBounds
15564
+ ekuboBounds,
15565
+ maxIterations
15565
15566
  );
15566
15567
  }
15567
- async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds) {
15568
+ async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20) {
15568
15569
  logger.verbose(
15569
15570
  `${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
15570
15571
  );
@@ -15577,7 +15578,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15577
15578
  `${_EkuboCLVault.name}: getSwapInfoToHandleUnused => expectedAmounts2: ${expectedAmounts.amount0.toString()}, ${expectedAmounts.amount1.toString()}`
15578
15579
  );
15579
15580
  let retry = 0;
15580
- const maxRetry = 10;
15581
+ const maxRetry = maxIterations;
15581
15582
  function assertValidAmounts(expectedAmounts2, token0Bal2, token1Bal2) {
15582
15583
  if (expectedAmounts2.amount0.lessThan(token0Bal2) && expectedAmounts2.amount1.lessThan(token1Bal2)) {
15583
15584
  throw new Error("Both tokens are decreased, something is wrong");
@@ -15687,8 +15688,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15687
15688
  * @returns Array of contract calls needed for rebalancing
15688
15689
  * @throws Error if max retries reached without successful rebalance
15689
15690
  */
15690
- async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n) {
15691
- const MAX_RETRIES = 40;
15691
+ async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40) {
15692
15692
  logger.verbose(
15693
15693
  `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}`
15694
15694
  );
@@ -15841,7 +15841,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15841
15841
  amount1
15842
15842
  };
15843
15843
  }
15844
- async harvest(acc) {
15844
+ async harvest(acc, maxIterations = 20) {
15845
15845
  const ekuboHarvests = new EkuboHarvests(this.config);
15846
15846
  const unClaimedRewards = await ekuboHarvests.getUnHarvestedRewards(
15847
15847
  this.address
@@ -15870,7 +15870,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15870
15870
  poolKey,
15871
15871
  token0Amt,
15872
15872
  token1Amt,
15873
- bounds
15873
+ bounds,
15874
+ maxIterations
15874
15875
  );
15875
15876
  swapInfo.token_to_address = token0Info.address.address;
15876
15877
  logger.verbose(
package/dist/index.d.ts CHANGED
@@ -712,8 +712,8 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
712
712
  usdValue: number;
713
713
  };
714
714
  }>;
715
- getSwapInfoToHandleUnused(considerRebalance?: boolean, newBounds?: EkuboBounds | null): Promise<SwapInfo>;
716
- getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds): Promise<SwapInfo>;
715
+ getSwapInfoToHandleUnused(considerRebalance?: boolean, newBounds?: EkuboBounds | null, maxIterations?: number): Promise<SwapInfo>;
716
+ getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds, maxIterations?: number): Promise<SwapInfo>;
717
717
  /**
718
718
  * Attempts to rebalance the vault by iteratively adjusting swap amounts if initial attempt fails.
719
719
  * Uses binary search approach to find optimal swap amount.
@@ -727,7 +727,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
727
727
  * @returns Array of contract calls needed for rebalancing
728
728
  * @throws Error if max retries reached without successful rebalance
729
729
  */
730
- rebalanceIter(swapInfo: SwapInfo, acc: Account, estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>, isSellTokenToken0?: boolean, retry?: number, lowerLimit?: bigint, upperLimit?: bigint): Promise<Call[]>;
730
+ rebalanceIter(swapInfo: SwapInfo, acc: Account, estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>, isSellTokenToken0?: boolean, retry?: number, lowerLimit?: bigint, upperLimit?: bigint, MAX_RETRIES?: number): Promise<Call[]>;
731
731
  static tickToi129(tick: number): {
732
732
  mag: number;
733
733
  sign: number;
@@ -746,7 +746,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
746
746
  amount0: Web3Number;
747
747
  amount1: Web3Number;
748
748
  }>;
749
- harvest(acc: Account): Promise<Call[]>;
749
+ harvest(acc: Account, maxIterations?: number): Promise<Call[]>;
750
750
  getInvestmentFlows(): Promise<IInvestmentFlow[]>;
751
751
  }
752
752
  /**
package/dist/index.js CHANGED
@@ -15639,7 +15639,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15639
15639
  }
15640
15640
  };
15641
15641
  }
15642
- async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null) {
15642
+ async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20) {
15643
15643
  const poolKey = await this.getPoolKey();
15644
15644
  const unusedBalances = await this.unusedBalances(poolKey);
15645
15645
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -15676,10 +15676,11 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15676
15676
  poolKey,
15677
15677
  token0Bal,
15678
15678
  token1Bal,
15679
- ekuboBounds
15679
+ ekuboBounds,
15680
+ maxIterations
15680
15681
  );
15681
15682
  }
15682
- async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds) {
15683
+ async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20) {
15683
15684
  logger.verbose(
15684
15685
  `${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
15685
15686
  );
@@ -15692,7 +15693,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15692
15693
  `${_EkuboCLVault.name}: getSwapInfoToHandleUnused => expectedAmounts2: ${expectedAmounts.amount0.toString()}, ${expectedAmounts.amount1.toString()}`
15693
15694
  );
15694
15695
  let retry = 0;
15695
- const maxRetry = 10;
15696
+ const maxRetry = maxIterations;
15696
15697
  function assertValidAmounts(expectedAmounts2, token0Bal2, token1Bal2) {
15697
15698
  if (expectedAmounts2.amount0.lessThan(token0Bal2) && expectedAmounts2.amount1.lessThan(token1Bal2)) {
15698
15699
  throw new Error("Both tokens are decreased, something is wrong");
@@ -15802,8 +15803,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15802
15803
  * @returns Array of contract calls needed for rebalancing
15803
15804
  * @throws Error if max retries reached without successful rebalance
15804
15805
  */
15805
- async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n) {
15806
- const MAX_RETRIES = 40;
15806
+ async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40) {
15807
15807
  logger.verbose(
15808
15808
  `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}`
15809
15809
  );
@@ -15956,7 +15956,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15956
15956
  amount1
15957
15957
  };
15958
15958
  }
15959
- async harvest(acc) {
15959
+ async harvest(acc, maxIterations = 20) {
15960
15960
  const ekuboHarvests = new EkuboHarvests(this.config);
15961
15961
  const unClaimedRewards = await ekuboHarvests.getUnHarvestedRewards(
15962
15962
  this.address
@@ -15985,7 +15985,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15985
15985
  poolKey,
15986
15986
  token0Amt,
15987
15987
  token1Amt,
15988
- bounds
15988
+ bounds,
15989
+ maxIterations
15989
15990
  );
15990
15991
  swapInfo.token_to_address = token0Info.address.address;
15991
15992
  logger.verbose(
package/dist/index.mjs CHANGED
@@ -15573,7 +15573,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15573
15573
  }
15574
15574
  };
15575
15575
  }
15576
- async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null) {
15576
+ async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20) {
15577
15577
  const poolKey = await this.getPoolKey();
15578
15578
  const unusedBalances = await this.unusedBalances(poolKey);
15579
15579
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -15610,10 +15610,11 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15610
15610
  poolKey,
15611
15611
  token0Bal,
15612
15612
  token1Bal,
15613
- ekuboBounds
15613
+ ekuboBounds,
15614
+ maxIterations
15614
15615
  );
15615
15616
  }
15616
- async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds) {
15617
+ async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20) {
15617
15618
  logger.verbose(
15618
15619
  `${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
15619
15620
  );
@@ -15626,7 +15627,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15626
15627
  `${_EkuboCLVault.name}: getSwapInfoToHandleUnused => expectedAmounts2: ${expectedAmounts.amount0.toString()}, ${expectedAmounts.amount1.toString()}`
15627
15628
  );
15628
15629
  let retry = 0;
15629
- const maxRetry = 10;
15630
+ const maxRetry = maxIterations;
15630
15631
  function assertValidAmounts(expectedAmounts2, token0Bal2, token1Bal2) {
15631
15632
  if (expectedAmounts2.amount0.lessThan(token0Bal2) && expectedAmounts2.amount1.lessThan(token1Bal2)) {
15632
15633
  throw new Error("Both tokens are decreased, something is wrong");
@@ -15736,8 +15737,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15736
15737
  * @returns Array of contract calls needed for rebalancing
15737
15738
  * @throws Error if max retries reached without successful rebalance
15738
15739
  */
15739
- async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n) {
15740
- const MAX_RETRIES = 40;
15740
+ async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40) {
15741
15741
  logger.verbose(
15742
15742
  `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}`
15743
15743
  );
@@ -15890,7 +15890,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15890
15890
  amount1
15891
15891
  };
15892
15892
  }
15893
- async harvest(acc) {
15893
+ async harvest(acc, maxIterations = 20) {
15894
15894
  const ekuboHarvests = new EkuboHarvests(this.config);
15895
15895
  const unClaimedRewards = await ekuboHarvests.getUnHarvestedRewards(
15896
15896
  this.address
@@ -15919,7 +15919,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
15919
15919
  poolKey,
15920
15920
  token0Amt,
15921
15921
  token1Amt,
15922
- bounds
15922
+ bounds,
15923
+ maxIterations
15923
15924
  );
15924
15925
  swapInfo.token_to_address = token0Info.address.address;
15925
15926
  logger.verbose(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.0.51",
3
+ "version": "1.0.52",
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",
@@ -872,7 +872,7 @@ export class EkuboCLVault extends BaseStrategy<
872
872
  };
873
873
  }
874
874
 
875
- async getSwapInfoToHandleUnused(considerRebalance: boolean = true, newBounds: EkuboBounds | null = null): Promise<SwapInfo> {
875
+ async getSwapInfoToHandleUnused(considerRebalance: boolean = true, newBounds: EkuboBounds | null = null, maxIterations = 20): Promise<SwapInfo> {
876
876
  const poolKey = await this.getPoolKey();
877
877
 
878
878
  // fetch current unused balances of vault
@@ -932,7 +932,8 @@ export class EkuboCLVault extends BaseStrategy<
932
932
  poolKey,
933
933
  token0Bal,
934
934
  token1Bal,
935
- ekuboBounds
935
+ ekuboBounds,
936
+ maxIterations
936
937
  );
937
938
  }
938
939
 
@@ -940,7 +941,8 @@ export class EkuboCLVault extends BaseStrategy<
940
941
  poolKey: EkuboPoolKey,
941
942
  token0Bal: Web3Number,
942
943
  token1Bal: Web3Number,
943
- bounds: EkuboBounds
944
+ bounds: EkuboBounds,
945
+ maxIterations: number = 20
944
946
  ): Promise<SwapInfo> {
945
947
  logger.verbose(
946
948
  `${
@@ -961,7 +963,7 @@ export class EkuboCLVault extends BaseStrategy<
961
963
  );
962
964
 
963
965
  let retry = 0;
964
- const maxRetry = 10;
966
+ const maxRetry = maxIterations;
965
967
 
966
968
  // Helper to check for invalid states:
967
969
  // Throws if both tokens are decreased or both are increased, which is not expected
@@ -1146,9 +1148,9 @@ export class EkuboCLVault extends BaseStrategy<
1146
1148
  isSellTokenToken0 = true,
1147
1149
  retry = 0,
1148
1150
  lowerLimit = 0n,
1149
- upperLimit = 0n
1151
+ upperLimit = 0n,
1152
+ MAX_RETRIES = 40
1150
1153
  ): Promise<Call[]> {
1151
- const MAX_RETRIES = 40;
1152
1154
 
1153
1155
  logger.verbose(
1154
1156
  `Rebalancing ${this.metadata.name}: ` +
@@ -1334,7 +1336,7 @@ export class EkuboCLVault extends BaseStrategy<
1334
1336
  };
1335
1337
  }
1336
1338
 
1337
- async harvest(acc: Account) {
1339
+ async harvest(acc: Account, maxIterations = 20): Promise<Call[]> {
1338
1340
  const ekuboHarvests = new EkuboHarvests(this.config);
1339
1341
  const unClaimedRewards = await ekuboHarvests.getUnHarvestedRewards(
1340
1342
  this.address
@@ -1377,7 +1379,8 @@ export class EkuboCLVault extends BaseStrategy<
1377
1379
  poolKey,
1378
1380
  token0Amt,
1379
1381
  token1Amt,
1380
- bounds
1382
+ bounds,
1383
+ maxIterations
1381
1384
  );
1382
1385
  swapInfo.token_to_address = token0Info.address.address;
1383
1386
  logger.verbose(