@strkfarm/sdk 2.0.0-dev.49 → 2.0.0-dev.50

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.
@@ -96442,7 +96442,7 @@ spurious results.`);
96442
96442
  async depositCall(amountInfo, receiver) {
96443
96443
  throw new Error("Not implemented");
96444
96444
  }
96445
- async withdrawCall(amountInfo, receiver, owner) {
96445
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
96446
96446
  throw new Error("Not implemented");
96447
96447
  }
96448
96448
  async getVaultPositions() {
@@ -102158,7 +102158,7 @@ spurious results.`);
102158
102158
  * @param owner - Address that owns the strategy tokens
102159
102159
  * @returns Populated contract call for withdrawal
102160
102160
  */
102161
- async withdrawCall(amountInfo, receiver, owner) {
102161
+ async withdrawCall(amountInfo, receiver, owner, _isMaxWithdraw = false) {
102162
102162
  return [
102163
102163
  this.contract.populate("withdraw", [
102164
102164
  uint256_exports.bnToUint256(amountInfo.amount.toWei()),
@@ -106571,8 +106571,8 @@ spurious results.`);
106571
106571
  ]);
106572
106572
  return Web3Number.fromWei(shares.toString(), 18);
106573
106573
  }
106574
- async withdrawCall(amountInfo, receiver, owner) {
106575
- const shares = await this.tokensToShares(amountInfo);
106574
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
106575
+ const shares = isMaxWithdraw ? await this.balanceOf(receiver) : await this.tokensToShares(amountInfo);
106576
106576
  logger2.verbose(
106577
106577
  `${_EkuboCLVault.name}: withdrawCall: shares=${shares.toString()}`
106578
106578
  );
@@ -107625,7 +107625,7 @@ spurious results.`);
107625
107625
  }
107626
107626
  }
107627
107627
  static priceToSqrtRatio(price) {
107628
- return BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128) / BigInt(1e9);
107628
+ return BigInt(Math.sqrt(price) * 2 ** 128);
107629
107629
  }
107630
107630
  static i129ToNumber(i129) {
107631
107631
  if (i129.sign == 0 || i129.sign == 1) {
@@ -117700,7 +117700,7 @@ spurious results.`);
117700
117700
  const calls = [call1, call2];
117701
117701
  return calls;
117702
117702
  }
117703
- async withdrawCall(amountInfo, receiver, owner) {
117703
+ async withdrawCall(amountInfo, receiver, owner, _isMaxWithdraw = false) {
117704
117704
  const call = this.contract.populate("withdraw", [
117705
117705
  uint256_exports.bnToUint256(amountInfo.amount.toWei()),
117706
117706
  receiver.address,
@@ -118429,7 +118429,7 @@ spurious results.`);
118429
118429
  }
118430
118430
  };
118431
118431
  }
118432
- async withdrawCall(amountInfo, receiver, owner) {
118432
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
118433
118433
  try {
118434
118434
  let {
118435
118435
  shares: userShares,
@@ -118438,15 +118438,20 @@ spurious results.`);
118438
118438
  } = await this.getNormalizedUserInfo(receiver);
118439
118439
  redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
118440
118440
  redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
118441
- const withdrawRequest = this.resolveWithdrawRequest(
118442
- amountInfo,
118443
- redeemableBaseTokenAmount,
118444
- redeemableSecondaryTokenAmount
118445
- );
118446
- if (!withdrawRequest) {
118447
- throw new Error("Invalid amount info");
118441
+ let requiredShares;
118442
+ if (isMaxWithdraw) {
118443
+ requiredShares = userShares;
118444
+ } else {
118445
+ const withdrawRequest = this.resolveWithdrawRequest(
118446
+ amountInfo,
118447
+ redeemableBaseTokenAmount,
118448
+ redeemableSecondaryTokenAmount
118449
+ );
118450
+ if (!withdrawRequest) {
118451
+ throw new Error("Invalid amount info");
118452
+ }
118453
+ requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
118448
118454
  }
118449
- const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
118450
118455
  const redeemFn = this.erc4626.isBaseERC4626 ? "redeem_combined" : "redeem";
118451
118456
  const vault = await this.contract;
118452
118457
  let withdrawCall = vault.populate(redeemFn, [
@@ -125302,12 +125307,12 @@ spurious results.`);
125302
125307
  ]);
125303
125308
  return [call1, call2];
125304
125309
  }
125305
- async withdrawCall(amountInfo, receiver, owner) {
125310
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
125306
125311
  assert3(
125307
125312
  amountInfo.tokenInfo.address.eq(this.asset().address),
125308
125313
  "Withdraw token mismatch"
125309
125314
  );
125310
- const shares = await this.contract.call("convert_to_shares", [uint256_exports.bnToUint256(amountInfo.amount.toWei())]);
125315
+ const shares = isMaxWithdraw ? await this.contract.call("balanceOf", [receiver.address]) : await this.contract.call("convert_to_shares", [uint256_exports.bnToUint256(amountInfo.amount.toWei())]);
125311
125316
  const call = this.contract.populate("request_redeem", [
125312
125317
  uint256_exports.bnToUint256(shares.toString()),
125313
125318
  receiver.address,
@@ -125729,12 +125734,12 @@ spurious results.`);
125729
125734
  ]);
125730
125735
  return [call1, call2];
125731
125736
  }
125732
- async withdrawCall(amountInfo, receiver, owner) {
125737
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
125733
125738
  assert3(
125734
125739
  amountInfo.tokenInfo.address.eq(this.asset().address),
125735
125740
  "Withdraw token mismatch"
125736
125741
  );
125737
- const shares = await this.contract.call("convert_to_shares", [uint256_exports.bnToUint256(amountInfo.amount.toWei())]);
125742
+ const shares = isMaxWithdraw ? await this.contract.call("balanceOf", [receiver.address]) : await this.contract.call("convert_to_shares", [uint256_exports.bnToUint256(amountInfo.amount.toWei())]);
125738
125743
  const call = this.contract.populate("request_redeem", [
125739
125744
  uint256_exports.bnToUint256(shares.toString()),
125740
125745
  receiver.address,
@@ -7918,7 +7918,7 @@ var BaseStrategy = class extends CacheClass {
7918
7918
  async depositCall(amountInfo, receiver) {
7919
7919
  throw new Error("Not implemented");
7920
7920
  }
7921
- async withdrawCall(amountInfo, receiver, owner) {
7921
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
7922
7922
  throw new Error("Not implemented");
7923
7923
  }
7924
7924
  async getVaultPositions() {
@@ -13636,7 +13636,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
13636
13636
  * @param owner - Address that owns the strategy tokens
13637
13637
  * @returns Populated contract call for withdrawal
13638
13638
  */
13639
- async withdrawCall(amountInfo, receiver, owner) {
13639
+ async withdrawCall(amountInfo, receiver, owner, _isMaxWithdraw = false) {
13640
13640
  return [
13641
13641
  this.contract.populate("withdraw", [
13642
13642
  uint2569.bnToUint256(amountInfo.amount.toWei()),
@@ -18060,8 +18060,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
18060
18060
  ]);
18061
18061
  return Web3Number.fromWei(shares.toString(), 18);
18062
18062
  }
18063
- async withdrawCall(amountInfo, receiver, owner) {
18064
- const shares = await this.tokensToShares(amountInfo);
18063
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
18064
+ const shares = isMaxWithdraw ? await this.balanceOf(receiver) : await this.tokensToShares(amountInfo);
18065
18065
  logger.verbose(
18066
18066
  `${_EkuboCLVault.name}: withdrawCall: shares=${shares.toString()}`
18067
18067
  );
@@ -19114,7 +19114,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
19114
19114
  }
19115
19115
  }
19116
19116
  static priceToSqrtRatio(price) {
19117
- return BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128) / BigInt(1e9);
19117
+ return BigInt(Math.sqrt(price) * 2 ** 128);
19118
19118
  }
19119
19119
  static i129ToNumber(i129) {
19120
19120
  if (i129.sign == 0 || i129.sign == 1) {
@@ -29195,7 +29195,7 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
29195
29195
  const calls = [call1, call2];
29196
29196
  return calls;
29197
29197
  }
29198
- async withdrawCall(amountInfo, receiver, owner) {
29198
+ async withdrawCall(amountInfo, receiver, owner, _isMaxWithdraw = false) {
29199
29199
  const call = this.contract.populate("withdraw", [
29200
29200
  uint25612.bnToUint256(amountInfo.amount.toWei()),
29201
29201
  receiver.address,
@@ -29926,7 +29926,7 @@ var YoLoVault = class extends BaseStrategy {
29926
29926
  }
29927
29927
  };
29928
29928
  }
29929
- async withdrawCall(amountInfo, receiver, owner) {
29929
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
29930
29930
  try {
29931
29931
  let {
29932
29932
  shares: userShares,
@@ -29935,15 +29935,20 @@ var YoLoVault = class extends BaseStrategy {
29935
29935
  } = await this.getNormalizedUserInfo(receiver);
29936
29936
  redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
29937
29937
  redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
29938
- const withdrawRequest = this.resolveWithdrawRequest(
29939
- amountInfo,
29940
- redeemableBaseTokenAmount,
29941
- redeemableSecondaryTokenAmount
29942
- );
29943
- if (!withdrawRequest) {
29944
- throw new Error("Invalid amount info");
29938
+ let requiredShares;
29939
+ if (isMaxWithdraw) {
29940
+ requiredShares = userShares;
29941
+ } else {
29942
+ const withdrawRequest = this.resolveWithdrawRequest(
29943
+ amountInfo,
29944
+ redeemableBaseTokenAmount,
29945
+ redeemableSecondaryTokenAmount
29946
+ );
29947
+ if (!withdrawRequest) {
29948
+ throw new Error("Invalid amount info");
29949
+ }
29950
+ requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
29945
29951
  }
29946
- const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
29947
29952
  const redeemFn = this.erc4626.isBaseERC4626 ? "redeem_combined" : "redeem";
29948
29953
  const vault = await this.contract;
29949
29954
  let withdrawCall = vault.populate(redeemFn, [
@@ -36819,12 +36824,12 @@ var SVKStrategy = class extends BaseStrategy {
36819
36824
  ]);
36820
36825
  return [call1, call2];
36821
36826
  }
36822
- async withdrawCall(amountInfo, receiver, owner) {
36827
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
36823
36828
  assert(
36824
36829
  amountInfo.tokenInfo.address.eq(this.asset().address),
36825
36830
  "Withdraw token mismatch"
36826
36831
  );
36827
- const shares = await this.contract.call("convert_to_shares", [uint25621.bnToUint256(amountInfo.amount.toWei())]);
36832
+ const shares = isMaxWithdraw ? await this.contract.call("balanceOf", [receiver.address]) : await this.contract.call("convert_to_shares", [uint25621.bnToUint256(amountInfo.amount.toWei())]);
36828
36833
  const call = this.contract.populate("request_redeem", [
36829
36834
  uint25621.bnToUint256(shares.toString()),
36830
36835
  receiver.address,
@@ -37246,12 +37251,12 @@ var UniversalStrategy = class _UniversalStrategy extends SVKStrategy {
37246
37251
  ]);
37247
37252
  return [call1, call2];
37248
37253
  }
37249
- async withdrawCall(amountInfo, receiver, owner) {
37254
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
37250
37255
  assert(
37251
37256
  amountInfo.tokenInfo.address.eq(this.asset().address),
37252
37257
  "Withdraw token mismatch"
37253
37258
  );
37254
- const shares = await this.contract.call("convert_to_shares", [uint25622.bnToUint256(amountInfo.amount.toWei())]);
37259
+ const shares = isMaxWithdraw ? await this.contract.call("balanceOf", [receiver.address]) : await this.contract.call("convert_to_shares", [uint25622.bnToUint256(amountInfo.amount.toWei())]);
37255
37260
  const call = this.contract.populate("request_redeem", [
37256
37261
  uint25622.bnToUint256(shares.toString()),
37257
37262
  receiver.address,
package/dist/index.d.ts CHANGED
@@ -607,7 +607,7 @@ declare class BaseStrategy<TVLInfo, DepositActionInfo, WithdrawActionInfo = Depo
607
607
  getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<TVLInfo>;
608
608
  getTVL(): Promise<TVLInfo>;
609
609
  depositCall(amountInfo: DepositActionInfo, receiver: ContractAddr): Promise<Call[]>;
610
- withdrawCall(amountInfo: WithdrawActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
610
+ withdrawCall(amountInfo: WithdrawActionInfo, receiver: ContractAddr, owner: ContractAddr, isMaxWithdraw?: boolean): Promise<Call[]>;
611
611
  getVaultPositions(): Promise<VaultPosition[]>;
612
612
  netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: "24h" | "7d" | "30d" | "3m"): Promise<number | string | NetAPYDetails>;
613
613
  getPendingRewards(): Promise<HarvestInfo[]>;
@@ -886,7 +886,7 @@ declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAm
886
886
  * @param owner - Address that owns the strategy tokens
887
887
  * @returns Populated contract call for withdrawal
888
888
  */
889
- withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<starknet.Call[]>;
889
+ withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr, _isMaxWithdraw?: boolean): Promise<starknet.Call[]>;
890
890
  /**
891
891
  * Returns the underlying asset token of the strategy.
892
892
  * @returns The deposit token supported by this strategy
@@ -1098,7 +1098,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
1098
1098
  getMinDepositAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
1099
1099
  depositCall(amountInfo: DualActionAmount, receiver: ContractAddr): Promise<Call[]>;
1100
1100
  tokensToShares(amountInfo: DualActionAmount): Promise<Web3Number>;
1101
- withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
1101
+ withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr, isMaxWithdraw?: boolean): Promise<Call[]>;
1102
1102
  rebalanceCall(newBounds: EkuboBounds, swapParams: SwapInfo): Call[];
1103
1103
  handleUnusedCall(swapParams: SwapInfo): Call[];
1104
1104
  handleFeesCall(): Call[];
@@ -1311,7 +1311,7 @@ declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmou
1311
1311
  getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<SingleTokenInfo>;
1312
1312
  getTVL(): Promise<SingleTokenInfo>;
1313
1313
  depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
1314
- withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
1314
+ withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr, _isMaxWithdraw?: boolean): Promise<Call[]>;
1315
1315
  getPositionInfo(): Promise<{
1316
1316
  collateralXSTRK: Web3Number;
1317
1317
  collateralUSDValue: Web3Number;
@@ -1425,7 +1425,7 @@ declare class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount,
1425
1425
  depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
1426
1426
  getVaultStatus(): Promise<YoloVaultStatus>;
1427
1427
  matchInputAmounts(amountInfo: DualActionAmount, user: ContractAddr): Promise<DualActionAmount>;
1428
- withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
1428
+ withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr, isMaxWithdraw?: boolean): Promise<Call[]>;
1429
1429
  netAPY(): Promise<number | string | NetAPYDetails>;
1430
1430
  getSwapAmounts(spendUnits: Web3Number): Promise<{
1431
1431
  grossSpend: Web3Number;
@@ -2401,7 +2401,7 @@ declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends
2401
2401
  */
2402
2402
  asset(): TokenInfo;
2403
2403
  depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
2404
- withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
2404
+ withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr, isMaxWithdraw?: boolean): Promise<Call[]>;
2405
2405
  getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<SingleTokenInfo>;
2406
2406
  /**
2407
2407
  * Returns the unused balance in the vault allocator.
@@ -2519,7 +2519,7 @@ declare class UniversalStrategy<S extends UniversalStrategySettings> extends SVK
2519
2519
  getAdapter(id: string): BaseAdapter<any, any>;
2520
2520
  asset(): TokenInfo;
2521
2521
  depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
2522
- withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
2522
+ withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr, isMaxWithdraw?: boolean): Promise<Call[]>;
2523
2523
  getVesuAPYs(): Promise<{
2524
2524
  baseAPYs: number[];
2525
2525
  rewardAPYs: number[];
package/dist/index.js CHANGED
@@ -8255,7 +8255,7 @@ var BaseStrategy = class extends CacheClass {
8255
8255
  async depositCall(amountInfo, receiver) {
8256
8256
  throw new Error("Not implemented");
8257
8257
  }
8258
- async withdrawCall(amountInfo, receiver, owner) {
8258
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
8259
8259
  throw new Error("Not implemented");
8260
8260
  }
8261
8261
  async getVaultPositions() {
@@ -13973,7 +13973,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
13973
13973
  * @param owner - Address that owns the strategy tokens
13974
13974
  * @returns Populated contract call for withdrawal
13975
13975
  */
13976
- async withdrawCall(amountInfo, receiver, owner) {
13976
+ async withdrawCall(amountInfo, receiver, owner, _isMaxWithdraw = false) {
13977
13977
  return [
13978
13978
  this.contract.populate("withdraw", [
13979
13979
  import_starknet19.uint256.bnToUint256(amountInfo.amount.toWei()),
@@ -18393,8 +18393,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
18393
18393
  ]);
18394
18394
  return Web3Number.fromWei(shares.toString(), 18);
18395
18395
  }
18396
- async withdrawCall(amountInfo, receiver, owner) {
18397
- const shares = await this.tokensToShares(amountInfo);
18396
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
18397
+ const shares = isMaxWithdraw ? await this.balanceOf(receiver) : await this.tokensToShares(amountInfo);
18398
18398
  logger.verbose(
18399
18399
  `${_EkuboCLVault.name}: withdrawCall: shares=${shares.toString()}`
18400
18400
  );
@@ -19447,7 +19447,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
19447
19447
  }
19448
19448
  }
19449
19449
  static priceToSqrtRatio(price) {
19450
- return BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128) / BigInt(1e9);
19450
+ return BigInt(Math.sqrt(price) * 2 ** 128);
19451
19451
  }
19452
19452
  static i129ToNumber(i129) {
19453
19453
  if (i129.sign == 0 || i129.sign == 1) {
@@ -29528,7 +29528,7 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
29528
29528
  const calls = [call1, call2];
29529
29529
  return calls;
29530
29530
  }
29531
- async withdrawCall(amountInfo, receiver, owner) {
29531
+ async withdrawCall(amountInfo, receiver, owner, _isMaxWithdraw = false) {
29532
29532
  const call = this.contract.populate("withdraw", [
29533
29533
  import_starknet22.uint256.bnToUint256(amountInfo.amount.toWei()),
29534
29534
  receiver.address,
@@ -30259,7 +30259,7 @@ var YoLoVault = class extends BaseStrategy {
30259
30259
  }
30260
30260
  };
30261
30261
  }
30262
- async withdrawCall(amountInfo, receiver, owner) {
30262
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
30263
30263
  try {
30264
30264
  let {
30265
30265
  shares: userShares,
@@ -30268,15 +30268,20 @@ var YoLoVault = class extends BaseStrategy {
30268
30268
  } = await this.getNormalizedUserInfo(receiver);
30269
30269
  redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
30270
30270
  redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
30271
- const withdrawRequest = this.resolveWithdrawRequest(
30272
- amountInfo,
30273
- redeemableBaseTokenAmount,
30274
- redeemableSecondaryTokenAmount
30275
- );
30276
- if (!withdrawRequest) {
30277
- throw new Error("Invalid amount info");
30271
+ let requiredShares;
30272
+ if (isMaxWithdraw) {
30273
+ requiredShares = userShares;
30274
+ } else {
30275
+ const withdrawRequest = this.resolveWithdrawRequest(
30276
+ amountInfo,
30277
+ redeemableBaseTokenAmount,
30278
+ redeemableSecondaryTokenAmount
30279
+ );
30280
+ if (!withdrawRequest) {
30281
+ throw new Error("Invalid amount info");
30282
+ }
30283
+ requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
30278
30284
  }
30279
- const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
30280
30285
  const redeemFn = this.erc4626.isBaseERC4626 ? "redeem_combined" : "redeem";
30281
30286
  const vault = await this.contract;
30282
30287
  let withdrawCall = vault.populate(redeemFn, [
@@ -37152,12 +37157,12 @@ var SVKStrategy = class extends BaseStrategy {
37152
37157
  ]);
37153
37158
  return [call1, call2];
37154
37159
  }
37155
- async withdrawCall(amountInfo, receiver, owner) {
37160
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
37156
37161
  assert(
37157
37162
  amountInfo.tokenInfo.address.eq(this.asset().address),
37158
37163
  "Withdraw token mismatch"
37159
37164
  );
37160
- const shares = await this.contract.call("convert_to_shares", [import_starknet34.uint256.bnToUint256(amountInfo.amount.toWei())]);
37165
+ const shares = isMaxWithdraw ? await this.contract.call("balanceOf", [receiver.address]) : await this.contract.call("convert_to_shares", [import_starknet34.uint256.bnToUint256(amountInfo.amount.toWei())]);
37161
37166
  const call = this.contract.populate("request_redeem", [
37162
37167
  import_starknet34.uint256.bnToUint256(shares.toString()),
37163
37168
  receiver.address,
@@ -37579,12 +37584,12 @@ var UniversalStrategy = class _UniversalStrategy extends SVKStrategy {
37579
37584
  ]);
37580
37585
  return [call1, call2];
37581
37586
  }
37582
- async withdrawCall(amountInfo, receiver, owner) {
37587
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
37583
37588
  assert(
37584
37589
  amountInfo.tokenInfo.address.eq(this.asset().address),
37585
37590
  "Withdraw token mismatch"
37586
37591
  );
37587
- const shares = await this.contract.call("convert_to_shares", [import_starknet35.uint256.bnToUint256(amountInfo.amount.toWei())]);
37592
+ const shares = isMaxWithdraw ? await this.contract.call("balanceOf", [receiver.address]) : await this.contract.call("convert_to_shares", [import_starknet35.uint256.bnToUint256(amountInfo.amount.toWei())]);
37588
37593
  const call = this.contract.populate("request_redeem", [
37589
37594
  import_starknet35.uint256.bnToUint256(shares.toString()),
37590
37595
  receiver.address,
package/dist/index.mjs CHANGED
@@ -8085,7 +8085,7 @@ var BaseStrategy = class extends CacheClass {
8085
8085
  async depositCall(amountInfo, receiver) {
8086
8086
  throw new Error("Not implemented");
8087
8087
  }
8088
- async withdrawCall(amountInfo, receiver, owner) {
8088
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
8089
8089
  throw new Error("Not implemented");
8090
8090
  }
8091
8091
  async getVaultPositions() {
@@ -13803,7 +13803,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
13803
13803
  * @param owner - Address that owns the strategy tokens
13804
13804
  * @returns Populated contract call for withdrawal
13805
13805
  */
13806
- async withdrawCall(amountInfo, receiver, owner) {
13806
+ async withdrawCall(amountInfo, receiver, owner, _isMaxWithdraw = false) {
13807
13807
  return [
13808
13808
  this.contract.populate("withdraw", [
13809
13809
  uint25610.bnToUint256(amountInfo.amount.toWei()),
@@ -18227,8 +18227,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
18227
18227
  ]);
18228
18228
  return Web3Number.fromWei(shares.toString(), 18);
18229
18229
  }
18230
- async withdrawCall(amountInfo, receiver, owner) {
18231
- const shares = await this.tokensToShares(amountInfo);
18230
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
18231
+ const shares = isMaxWithdraw ? await this.balanceOf(receiver) : await this.tokensToShares(amountInfo);
18232
18232
  logger.verbose(
18233
18233
  `${_EkuboCLVault.name}: withdrawCall: shares=${shares.toString()}`
18234
18234
  );
@@ -19281,7 +19281,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
19281
19281
  }
19282
19282
  }
19283
19283
  static priceToSqrtRatio(price) {
19284
- return BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128) / BigInt(1e9);
19284
+ return BigInt(Math.sqrt(price) * 2 ** 128);
19285
19285
  }
19286
19286
  static i129ToNumber(i129) {
19287
19287
  if (i129.sign == 0 || i129.sign == 1) {
@@ -29362,7 +29362,7 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
29362
29362
  const calls = [call1, call2];
29363
29363
  return calls;
29364
29364
  }
29365
- async withdrawCall(amountInfo, receiver, owner) {
29365
+ async withdrawCall(amountInfo, receiver, owner, _isMaxWithdraw = false) {
29366
29366
  const call = this.contract.populate("withdraw", [
29367
29367
  uint25613.bnToUint256(amountInfo.amount.toWei()),
29368
29368
  receiver.address,
@@ -30093,7 +30093,7 @@ var YoLoVault = class extends BaseStrategy {
30093
30093
  }
30094
30094
  };
30095
30095
  }
30096
- async withdrawCall(amountInfo, receiver, owner) {
30096
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
30097
30097
  try {
30098
30098
  let {
30099
30099
  shares: userShares,
@@ -30102,15 +30102,20 @@ var YoLoVault = class extends BaseStrategy {
30102
30102
  } = await this.getNormalizedUserInfo(receiver);
30103
30103
  redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
30104
30104
  redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
30105
- const withdrawRequest = this.resolveWithdrawRequest(
30106
- amountInfo,
30107
- redeemableBaseTokenAmount,
30108
- redeemableSecondaryTokenAmount
30109
- );
30110
- if (!withdrawRequest) {
30111
- throw new Error("Invalid amount info");
30105
+ let requiredShares;
30106
+ if (isMaxWithdraw) {
30107
+ requiredShares = userShares;
30108
+ } else {
30109
+ const withdrawRequest = this.resolveWithdrawRequest(
30110
+ amountInfo,
30111
+ redeemableBaseTokenAmount,
30112
+ redeemableSecondaryTokenAmount
30113
+ );
30114
+ if (!withdrawRequest) {
30115
+ throw new Error("Invalid amount info");
30116
+ }
30117
+ requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
30112
30118
  }
30113
- const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
30114
30119
  const redeemFn = this.erc4626.isBaseERC4626 ? "redeem_combined" : "redeem";
30115
30120
  const vault = await this.contract;
30116
30121
  let withdrawCall = vault.populate(redeemFn, [
@@ -36986,12 +36991,12 @@ var SVKStrategy = class extends BaseStrategy {
36986
36991
  ]);
36987
36992
  return [call1, call2];
36988
36993
  }
36989
- async withdrawCall(amountInfo, receiver, owner) {
36994
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
36990
36995
  assert(
36991
36996
  amountInfo.tokenInfo.address.eq(this.asset().address),
36992
36997
  "Withdraw token mismatch"
36993
36998
  );
36994
- const shares = await this.contract.call("convert_to_shares", [uint25622.bnToUint256(amountInfo.amount.toWei())]);
36999
+ const shares = isMaxWithdraw ? await this.contract.call("balanceOf", [receiver.address]) : await this.contract.call("convert_to_shares", [uint25622.bnToUint256(amountInfo.amount.toWei())]);
36995
37000
  const call = this.contract.populate("request_redeem", [
36996
37001
  uint25622.bnToUint256(shares.toString()),
36997
37002
  receiver.address,
@@ -37413,12 +37418,12 @@ var UniversalStrategy = class _UniversalStrategy extends SVKStrategy {
37413
37418
  ]);
37414
37419
  return [call1, call2];
37415
37420
  }
37416
- async withdrawCall(amountInfo, receiver, owner) {
37421
+ async withdrawCall(amountInfo, receiver, owner, isMaxWithdraw = false) {
37417
37422
  assert(
37418
37423
  amountInfo.tokenInfo.address.eq(this.asset().address),
37419
37424
  "Withdraw token mismatch"
37420
37425
  );
37421
- const shares = await this.contract.call("convert_to_shares", [uint25623.bnToUint256(amountInfo.amount.toWei())]);
37426
+ const shares = isMaxWithdraw ? await this.contract.call("balanceOf", [receiver.address]) : await this.contract.call("convert_to_shares", [uint25623.bnToUint256(amountInfo.amount.toWei())]);
37422
37427
  const call = this.contract.populate("request_redeem", [
37423
37428
  uint25623.bnToUint256(shares.toString()),
37424
37429
  receiver.address,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "2.0.0-dev.49",
3
+ "version": "2.0.0-dev.50",
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",
@@ -109,7 +109,7 @@ export class BaseStrategy<
109
109
  throw new Error("Not implemented");
110
110
  }
111
111
 
112
- async withdrawCall(amountInfo: WithdrawActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]> {
112
+ async withdrawCall(amountInfo: WithdrawActionInfo, receiver: ContractAddr, owner: ContractAddr, isMaxWithdraw: boolean = false): Promise<Call[]> {
113
113
  throw new Error("Not implemented");
114
114
  }
115
115
 
@@ -280,9 +280,12 @@ export class EkuboCLVault extends BaseStrategy<
280
280
  async withdrawCall(
281
281
  amountInfo: DualActionAmount,
282
282
  receiver: ContractAddr,
283
- owner: ContractAddr
283
+ owner: ContractAddr,
284
+ isMaxWithdraw: boolean = false
284
285
  ): Promise<Call[]> {
285
- const shares = await this.tokensToShares(amountInfo);
286
+ const shares = isMaxWithdraw
287
+ ? await this.balanceOf(receiver)
288
+ : await this.tokensToShares(amountInfo);
286
289
  logger.verbose(
287
290
  `${EkuboCLVault.name}: withdrawCall: shares=${shares.toString()}`
288
291
  );
@@ -1836,8 +1839,7 @@ export class EkuboCLVault extends BaseStrategy<
1836
1839
 
1837
1840
  static priceToSqrtRatio(price: number) {
1838
1841
  return (
1839
- (BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128)) /
1840
- BigInt(1e9)
1842
+ (BigInt(Math.sqrt(price) * 2 ** 128))
1841
1843
  );
1842
1844
  }
1843
1845
 
@@ -128,7 +128,7 @@ export class SenseiVault extends BaseStrategy<
128
128
  return calls;
129
129
  }
130
130
 
131
- async withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]> {
131
+ async withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr, _isMaxWithdraw: boolean = false): Promise<Call[]> {
132
132
  const call = this.contract.populate('withdraw', [
133
133
  uint256.bnToUint256(amountInfo.amount.toWei()),
134
134
  receiver.address,
@@ -80,12 +80,14 @@ export abstract class SVKStrategy<S extends UniversalStrategySettings>
80
80
  return [call1, call2];
81
81
  }
82
82
 
83
- async withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]> {
83
+ async withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr, isMaxWithdraw: boolean = false): Promise<Call[]> {
84
84
  assert(
85
85
  amountInfo.tokenInfo.address.eq(this.asset().address),
86
86
  "Withdraw token mismatch"
87
87
  );
88
- const shares = await this.contract.call('convert_to_shares', [uint256.bnToUint256(amountInfo.amount.toWei())]);
88
+ const shares = isMaxWithdraw
89
+ ? await this.contract.call("balanceOf", [receiver.address])
90
+ : await this.contract.call('convert_to_shares', [uint256.bnToUint256(amountInfo.amount.toWei())]);
89
91
  const call = this.contract.populate("request_redeem", [
90
92
  uint256.bnToUint256(shares.toString()),
91
93
  receiver.address,
@@ -141,12 +141,14 @@ export class UniversalStrategy<
141
141
  return [call1, call2];
142
142
  }
143
143
 
144
- async withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]> {
144
+ async withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr, isMaxWithdraw: boolean = false): Promise<Call[]> {
145
145
  assert(
146
146
  amountInfo.tokenInfo.address.eq(this.asset().address),
147
147
  "Withdraw token mismatch"
148
148
  );
149
- const shares = await this.contract.call('convert_to_shares', [uint256.bnToUint256(amountInfo.amount.toWei())]);
149
+ const shares = isMaxWithdraw
150
+ ? await this.contract.call("balanceOf", [receiver.address])
151
+ : await this.contract.call('convert_to_shares', [uint256.bnToUint256(amountInfo.amount.toWei())]);
150
152
  const call = this.contract.populate("request_redeem", [
151
153
  uint256.bnToUint256(shares.toString()),
152
154
  receiver.address,
@@ -159,7 +159,8 @@ export class VesuRebalance extends BaseStrategy<
159
159
  async withdrawCall(
160
160
  amountInfo: SingleActionAmount,
161
161
  receiver: ContractAddr,
162
- owner: ContractAddr
162
+ owner: ContractAddr,
163
+ _isMaxWithdraw: boolean = false
163
164
  ) {
164
165
  return [
165
166
  this.contract.populate("withdraw", [
@@ -608,6 +608,7 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
608
608
  amountInfo: DualActionAmount,
609
609
  receiver: ContractAddr,
610
610
  owner: ContractAddr,
611
+ isMaxWithdraw: boolean = false,
611
612
  ): Promise<Call[]> {
612
613
  try{
613
614
  let {
@@ -617,16 +618,22 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
617
618
  } = await this.getNormalizedUserInfo(receiver);
618
619
  redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
619
620
  redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
620
- const withdrawRequest = this.resolveWithdrawRequest(
621
- amountInfo,
622
- redeemableBaseTokenAmount,
623
- redeemableSecondaryTokenAmount,
624
- );
625
-
626
- if (!withdrawRequest) {
627
- throw new Error("Invalid amount info");
621
+
622
+ let requiredShares;
623
+ if (isMaxWithdraw) {
624
+ requiredShares = userShares;
625
+ } else {
626
+ const withdrawRequest = this.resolveWithdrawRequest(
627
+ amountInfo,
628
+ redeemableBaseTokenAmount,
629
+ redeemableSecondaryTokenAmount,
630
+ );
631
+
632
+ if (!withdrawRequest) {
633
+ throw new Error("Invalid amount info");
634
+ }
635
+ requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
628
636
  }
629
- const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
630
637
  const redeemFn = this.erc4626.isBaseERC4626 ? "redeem_combined" : "redeem";
631
638
  const vault = await this.contract;
632
639
  let withdrawCall = vault.populate(redeemFn, [